Commit Graph

34 Commits

Author SHA1 Message Date
Josh Soref
624a54b9cf Spelling stdlib (#42544)
* spelling: abcdefghijklmnopqrstuvwxyz

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: clazz

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: collection

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: compressible

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: constituent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: contiguous

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: convertibility

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: element

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: enforce

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exhaustive

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exhausts

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: existential

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: facilitate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: ignored

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: incorporated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: intersection

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: laziness

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: misaligned

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overhaul

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: preamble

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: precondition

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: replacement

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: trailing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unambiguous

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: uncompressible

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: world

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-22 19:18:38 -07:00
Evan Wilde
4040ad3680 Disable storage3 check in NewStringAppending
The other instances had been disabled in commit 5236224eb1.
FileCheck was recently updated so that it complains about undefined
variables, which is why no one noticed until now. storage3 wasn't
defined because the place where it got defined was disabled. Disabling
that instance now.
2021-08-18 16:25:36 -07:00
Kuba (Brecka) Mracek
d7dfa3e942 Bring up tests + validation tests for the 'freestanding' build and the standalone_minimal preset (#34386) 2020-10-26 16:32:36 -07:00
Michael Ilseman
9cabe077f4 Merge pull request #30263 from milseman/malloc_san
[test] Disable allocator-specific test portion
2020-03-06 11:47:27 -08:00
Michael Ilseman
5236224eb1 [test] Disable allocator-specific test portion
Disagble a portion of a test with hard-coded assumptions about the
result of malloc_size.
2020-03-06 09:37:55 -08:00
Michael Ilseman
633d46ff26 [test] Disable introspective test in back deployment 2020-03-06 07:19:08 -08:00
Michael Ilseman
0ca42e9ef7 [string] Shrink storage class sizes.
* Don't allocate breadrumbs pointer if under threshold
* Increase breadrumbs threshold
* Linear 16-byte bucketing until 128 bytes, malloc_size after
* Allow cap less than _SmallString.capacity (bridging non-ASCII)

This change decreases the amount of heap usage for moderate-length
strings (< 64 UTF-8 code units in length) and increases the amount of
spare code unit capacity available (less growth needed).

Average improvements for moderate-length strings:

* 64-bit: on average, 8 bytes saved and 4 bytes of extra capacity
* 32-bit: on average, 4 bytes saved and 6 bytes of extra capacity

Additionally, on 32-bit, large-length strings also gain an average of
6 bytes of extra spare capacity.

Details:

On 64-bit, half of moderate-length allocations will save 16 bytes
while the other half get an extra 8 bytes of spare capacity.

On 32-bit, a quarter of moderate-length allocations will save 16
bytes, and the rest get an extra 4 bytes of spare
capacity. Additionally, 32-bit string's storage class now claims its
full allocation, which is its birthright. Prior to this change, we'd
have on average 1.5 bytes of spare capacity, and now we have 7.5 bytes
of spare capacity.

Breadcrumbs threshold is increased from the super-conservative 32 to
the pretty-conservative 64. Some speed improvements are incorporated
in this change, but more are in flight. Even without those eventual
improvements, this is a worthwhile change (ASCII is still fast-pathed
and irrelevant to breadcrumbing).

For a complex real-world workload, this amounts to around a 5%
improvement to transient heap usage due to all strings and a 4%
improvement to peak heap usage due to all strings. For moderate-length
strings specifically, this gives around 11% improvement to both.
2020-03-05 16:10:23 -08:00
Slava Pestov
94b1a28011 Fix remaining tests that pass -swift-version 3
Fixes <rdar://problem/45749460>.
2018-11-08 15:48:26 -05:00
Michael Ilseman
e6582c37ee [test] Adjust String tests for UTF-8 representation.
Adjust tests for the UTF-8 representation, in preparation for 32-bit
support. Includes UTF-8 literal update.
2018-11-04 10:42:41 -08:00
Michael Ilseman
ba6158d74e [test] Internalize _StringGuts; Add shared testing struct; NFC
Create a _StringRepresentation struct to standardize internal testing
on. Internalize much of _StringGuts, except for some SPI hacks, and
update tests to use _StringRepresentation.
2018-08-01 14:23:56 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Michael Ilseman
1fe5fb717d [string] Skip allocation in reserveCapacity if smol
If the requested capacity is small enough to fit in our small string
representation, don't allocate a UTF-16 buffer, instead just return
early.
2018-05-18 21:26:59 -07:00
Karoy Lorentey
5cf9fd7414 Remove _StringBuffer 🎉🎉🎉 2018-01-21 12:35:15 -08:00
Michael Ilseman
3be2faf5d3 [String] Initial implementation of 64-bit StringGuts.
Include the initial implementation of _StringGuts, a 2-word
replacement for _LegacyStringCore. 64-bit Darwin supported, 32-bit and
Linux support in subsequent commits.
2018-01-21 12:32:26 -08:00
Michael Ilseman
75463e30f3 [stdlib] Rename _StringCore to _LegacyStringCore. NFC.
In grand LLVM tradition, the first step to redesigning _StringCore is
to first rename it to _LegacyStringCore. Subsequent commits will
introduce the replacement, and eventually all uses of the old one will
be moved to the new one.

NFC.
2018-01-21 12:28:56 -08:00
Dave Abrahams
b2e4bd5d09 [stdlib] Replace _HeapBuffer with a thin wrapper
...over ManagedBufferPointer
2017-06-01 04:40:52 -07:00
Dave Abrahams
fd30b72ee1 [stdlib] Fix a race
Lock-free programming is almost always a bug.
Fixes <rdar://25398370> Data Race in StringBuffer.append (found by TSan)
2017-05-18 16:29:59 -07:00
Max Moiseev
9fc37efee4 [test] renaming test/1_stdlib to just test/stdlib 2016-09-01 16:51:43 -07:00
Jordan Rose
e83c117c30 [test] Hack: run stdlib tests first to start long-running tests earlier.
This decreases total testing time by over a minute on my old Mac Pro.
It probably has much less effect on systems with fewer cores, but shouldn't
be any worse there.

Swift SVN r22745
2014-10-15 01:30:51 +00:00
Dave Abrahams
3f36a4d5e7 Use %target-run-stdlib-swift in more tests
Now that it disables access control, this lit definition applies to many
more tests, where we used to use %target-run-stdlib-swift before access
control came online.

Also, drop -Xfrontend -disable-access-control from a bunch of tests that
don't need it.

Swift SVN r22634
2014-10-09 20:53:07 +00:00
Dave Abrahams
6c07fb4ad1 [stdlib] Revert UnsafePointer casting change
The syntax being reverted added busywork and noise to the common case
where you want to say "I have the right address, but the wrong type,"
without adding any real safety.

Also it eliminated the ability to write UnsafePointer<T>(otherPointer),
without adding ".self" to T.  Overall, it was not a win.

This reverts commits r21324 and r21342

Swift SVN r21424
2014-08-22 21:53:12 +00:00
Dave Abrahams
1fb0f889d7 [stdlib] Make UnsafePointer conversions explicit
Previously, it was possible to write Unsafe[Mutable]Pointer(x) and have
Swift deduce the pointee type based on context.  Since reinterpreting
memory is a fundamentally type-unsafe operation, it's better to be
explicit about conversions from Unsafe[Mutable]Pointer<T> to
Unsafe[Mutable]Pointer<U>.  This change is consistent with the move from
reinterpretCast(x) to unsafeBitCast(x, T.self).

Also, we've encoded the operations of explicitly adding or removing
mutability as properties, so that adding mutability can be separated
from wild reinterpretCast'ing, a much more severe form of unsafety.

Swift SVN r21324
2014-08-20 23:15:56 +00:00
Dmitri Hrybenko
6e3a9e93e7 NewStringAppending: attempt to fix this test under ASan by making it
independent of memory allocator implementation


Swift SVN r21005
2014-08-04 11:03:37 +00:00
Greg Parker
fe8618a3d2 Scrap the custom allocator until we have time to fix it.
The allocator's crimes include:
* It uses OS SPI that must not be used by non-OS apps.
* It does not play well with memory debugging tools like Instruments.
* It does not return memory to the OS in response to memory pressure.
* It is less tested than we would like because many configurations 
  inadvertently turn it off (such as running from Xcode).
* Its per-thread magazine implementation does not actually work.
* Its "try alloc" flag is incompletely implemented and never used.
* Its "zero fill" flag is unimplemented and inconsistently used.



Swift SVN r20757
2014-07-30 14:11:40 +00:00
Dave Abrahams
d00e888d95 [stdlib] Rename reinterpretCast => unsafeBitCast
Also give unsafeBitCast an explicit type parameter.  So

  let x: T = reinterpretCast(y)

becomes

  let x = unsafeBitCast(y, T.self)

Swift SVN r20487
2014-07-24 13:17:36 +00:00
Dmitri Hrybenko
766c9816de stdlib: underscore-prefix String.core
Swift SVN r20411
2014-07-23 16:28:57 +00:00
Dave Abrahams
21669b3aee [stdlib] Add "Mutable" to [Autoreleasing]UnsafePointer
UnsafePointer becomes UnsafeMutablePointer
AutoreleasingUnsafePointer becomes AutoreleasingUnsafeMutablePointer

Swift SVN r20316
2014-07-22 16:56:23 +00:00
Jordan Rose
bdd1ec3116 Update stdlib and tests for accessibility, again.
I'll be turning on access control early next week.

Swift SVN r19551
2014-07-04 01:53:53 +00:00
Jordan Rose
5557c3972b Update tests for accessibility.
In most cases this means adding @public to things that get serialized;
in a few cases it means using a modern public stdlib API instead of
a legacy thing I was trying to keep @internal.

Swift SVN r19350
2014-06-30 18:50:40 +00:00
Kuba Brecka
2da733d672 test/stdlib/NewStringAppending.swift has XFAIL: asan, but the test actually passes on ASanSwift buildbot. Let's just remove the XFAIL, although it still depends on the implementation of ASan's memory allocator. This means the test may start failing again in the future, but this is also true for non-ASan builds.
Swift SVN r19100
2014-06-23 20:23:33 +00:00
Doug Gregor
67ca1c9ea1 Implement the new casting syntaxes "as" and "as?".
There's a bit of a reshuffle of the ExplicitCastExpr subclasses:
  - The existing ConditionalCheckedCastExpr expression node now represents
"as?". 
  - A new ForcedCheckedCastExpr node represents "as" when it is a
  downcast.
  - CoerceExpr represents "as" when it is a coercion.
  - A new UnresolvedCheckedCastExpr node describes "as" before it has
  been type-checked down to ForcedCheckedCastExpr or CoerceExpr. This
  wasn't a strictly necessary change, but it helps us detangle what's
  going on.

There are a few new diagnostics to help users avoid getting bitten by
as/as? mistakes:
  - Custom errors when a forced downcast (as) is used as the operand
  of postfix '!' or '?', with Fix-Its to remove the '!' or make the
  downcast conditional (with as?), respectively.
  - A warning when a forced downcast is injected into an optional,
  with a suggestion to use a conditional downcast.
  - A new error when the postfix '!' is used for a contextual
  downcast, with a Fix-It to replace it with "as T" with the
  contextual type T.

Lots of test updates, none of which felt like regressions. The new
tests are in test/expr/cast/optionals.swift. 

Addresses <rdar://problem/17000058>


Swift SVN r18556
2014-05-22 06:15:29 +00:00
Dmitri Hrybenko
2cc8fe40d4 stdlib/printing: replace four printing systems with one new one
The old ones were:

- print/println
- printAny
- printf
- Console

The new printing story is just print/println.  Every object can be printed.
You can customize the way it is printed by adopting Printable protocol.  Full
details in comments inside stdlib/core/OutputStream.swift.

Printing is not completely finished yet.  We still have ReplPrintable, which
should be removed, string interpolation still uses String constructors, and
printing objects that don't conform to Printable will result in printing
mangled names.


Swift SVN r18001
2014-05-13 13:07:59 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Greg Parker
d63772a7e7 [test] Move arch-specific string appending test to NewStringAppending.swift.
NewString.swift may now be asan-safe too, but I didn't try it.


Swift SVN r14385
2014-02-26 07:28:15 +00:00