Commit Graph

10155 Commits

Author SHA1 Message Date
Michael Ilseman
8d5d3815a1 Merge pull request #30180 from benrimmington/se-0263-test
[SE-0263] Add test, rename API, update docs
2020-03-06 08:54:24 -08:00
Michael Ilseman
fd468d068e [stdlib] Disable assertion tripping up ASAN
We have (and important!) assertion that our claimed allocation is
complete and the breadcrumbs are falling where we expect them
to. Something about ASAN changes the allocation behavior. Temporarily
disable this assertion until I can figure how to work with ASAN here.
2020-03-06 08:43:25 -08:00
Valeriy Van
f49f6a99ba Fixes variable name 2020-03-06 06:32:53 +01:00
Michael Ilseman
79bac4e6a3 Merge pull request #30244 from milseman/string_shrink
[string] Shrink storage class sizes
2020-03-05 19:57:40 -08:00
Michael Ilseman
89f0a1280f [gardening] Remove dead comments and code 2020-03-05 16:45:04 -08:00
swift-ci
55782b2f73 Merge pull request #29436 from amartini51/master 2020-03-05 16:24:10 -08:00
Michael Ilseman
d8f25be9fa [string] Skip unnecessary self UTF-16 length in isEqual
For isEqual bridging comparisons, skip checking our own UTF-16 length when the
string we're comparing against is known to be ASCII.
2020-03-05 16:13:15 -08:00
Michael Ilseman
7ff3ecf2e5 [string] Skip unnecessary self UTF-16 length in isEqual
For isEqual bridging comparisons, skip checking our own UTF-16 length when the
string we're comparing against is known to be ASCII.
2020-03-05 16:13:15 -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
Saleem Abdulrasool
23c536940f Merge pull request #30145 from 3405691582/OpenBSD_Port_Stdlib_Prelim
Preliminary support for OpenBSD in the stdlib.
2020-03-05 15:15:58 -08:00
Michael Ilseman
ebe8aac848 Merge pull request #30132 from valeriyvan/RemoveRedundantZeroingStringGraphemeBreaking
Removes redundant buffer zeroing in StringGraphemeBreaking.swift by using `init(unsafeUninitializedCapacity:initializingWith:)
2020-03-05 12:22:23 -08:00
Michael Ilseman
1255e10b62 [stdlib] [gardening] Remove whitespace, document growth issue 2020-03-05 12:16:26 -08:00
Alex Martini
011a115d85 Group operators explicitly.
The '+' operator binds tighter than the '...' operator.

Fixes rdar://problem/59833804
2020-03-05 11:18:03 -08:00
Alex Martini
bc5f0153fa Match docs to current behavior.
Confirmed this change on using the swift-5.2-DEVELOPMENT-SNAPSHOT-2020-01-22-a
toolchain, Apple Swift version 5.2-dev (Swift d3f0448a4c).

Fixes rdar://problem/58717942
2020-03-05 11:17:55 -08:00
Alex Martini
c0e2f08818 Add missing backtick.
Fixes rdar://problem/58855960
2020-03-05 11:17:50 -08:00
Ben Rimmington
b11856a93c [SE-0263] Update documentation
Co-Authored-By: Nate Cook <natecook@apple.com>
2020-03-05 14:51:48 +00:00
Ben Rimmington
cf8988455f [SE-0263] Rename internal API 2020-03-05 14:51:10 +00:00
Valeriy Van
190b8a73db Changes implementation of _persistCString from _StringGuts to be in sync with implementation from stdlib 2020-03-05 15:25:45 +01:00
Mike Ash
c1faaa5267 Merge pull request #30207 from mikeash/fix-objc-name-suffixes
[Runtime] Reject suffixes on ObjC mangled class names.
2020-03-04 17:05:16 -05:00
Michael Ilseman
7876eab91b Merge pull request #30131 from valeriyvan/RemoveRedundantZeroingStringGuts
Removes redundant buffer zeroing in StringGuts.swift by using `init(unsafeUninitializedCapacity:initializingWith:)
2020-03-04 11:04:08 -08:00
Kuba (Brecka) Mracek
0d400ca310 Merge branch 'master' into mracek/arm64e 2020-03-04 09:36:25 -08:00
Mike Ash
614f4becef [Runtime] Reject suffixes on ObjC mangled class names.
The demangler tolerates arbitrary suffixes on mangled names, and parses them as a Suffix node. When looking up a class by an ObjC mangled name, we don't want such demanglings to succeed, because this will result in false positives. It's expected that NSClassFromString(someClassName + "some suffix") will fail, unless something has actually created a class with that suffix.

rdar://problem/60012296
2020-03-04 12:05:35 -05:00
swift-ci
db10388b3c Merge pull request #30194 from xwu/floating-point-conversion-oops 2020-03-03 21:35:53 -08:00
3405691582
73bd558925 [stdlib] Modulemap for libc on OpenBSD.
Provide a separate modulemap for OpenBSD's libc, rather than try to
continue to overload the modulemap for glibc, since glibc has its own
idiosyncracies.
2020-03-03 20:23:32 -05:00
Ben Rimmington
f5fe8e376d [stdlib] StaticString documentation and tests
Co-Authored-By: Nate Cook <natecook@apple.com>
2020-03-04 00:15:07 +00:00
Xiaodi Wu
03903ae1ea [stdlib] Fix generic floating-point conversion when two representable values are equally close 2020-03-03 18:22:47 -05:00
Kuba (Brecka) Mracek
5d918e5ee1 Merge branch 'master' into mracek/arm64e 2020-03-03 08:28:01 -08:00
David Smith
eb74e71903 Merge pull request #30106 from Catfish-Man/going-public
Make String(unsafeUninitializedCapacity:initializingUTF8With:) public
2020-03-02 18:08:37 -08:00
David Smith
b9ddaa6e90 Make String(unsafeUninitializedCapacity:,initializingUTF8With:) public 2020-03-02 14:25:14 -08:00
3405691582
5847726f51 Preliminary support for OpenBSD in the stdlib.
These should hopefully all be uncontroversial, minimal changes to deal
with progressing the build to completion on OpenBSD or addressing minor
portability issues. This is not the full set of changes to get a
successful build; other portability issues will be addressed in future
commits.

Most of this is just adding the relevant clauses to the ifdefs, but of
note in this commit:

* StdlibUnittest.swift: the default conditional in _getOSVersion assumes
  an Apple platform, therefore the explicit conditional and the relevant
  enums need filling out. The default conditional should be #error, but
  we'll fix this in a different commit.

* tgmath.swift.gyb: inexplicably, OpenBSD is missing just lgammal_r.
  Tests are updated correspondingly.

* ThreadLocalStorage.h: we use the pthread implementation, so it
  seems we should typedef __swift_thread_key_t as pthread_key_t.
  However, that's also a tweak for another commit.
2020-03-01 12:50:06 -05:00
Valeriy Van
78fb0f7774 Removes redundant buffer zeroing 2020-02-28 23:32:05 +01:00
Valeriy Van
47acd72a6b Removes redundand buffer zeroing 2020-02-28 23:23:49 +01:00
Kuba Mracek
84c4864911 [arm64e] Add Swift compiler support for arm64e pointer authentication 2020-02-27 16:10:31 -08:00
Michael Gottesman
59823811b5 [stdlib] Mark Unmanaged._withUnsafeGuaranteedRef as _transparent and add a test/comments as requested in the original PR where this landed.
rdar://59735604
2020-02-25 15:46:19 -08:00
Michael Gottesman
9e8d65fbf8 Merge pull request #30033 from gottesmm/pr-89ff0d5130b608cdfae1e68dfc8c4b10de0f78cd
[stdlib] Change _withUnsafeGuaranteedRef to use Builtin.convertUnownedUnsafeToGuaranteed.
2020-02-25 14:25:48 -08:00
Daniel Rodríguez Troitiño
073e44d6e8 Merge pull request #29296 from buttaface/droid
[android] Get build scripts working natively, fix tests and install
2020-02-24 21:05:47 -08:00
Michael Gottesman
7820ddc7c7 [stdlib] Change _withUnsafeGuaranteedRef to use Builtin.convertUnownedUnsafeToGuaranteed.
This builtin (which lowers to raw SIL that doesn't use an actual builtin
instruction) allows us to access an unmanaged value at +0 with a language
guarantee rather than relying on the optimizer.

Previously, we did not do this directly since without OSSA, we were scared that
the frontend/optimizer would not be able to safely emit this code. Now that we
have ownership ssa, we are able to ensure that the frontend always copies the +0
value passed into the closure if the value +0 escapes from the closure (either
via a return, storing into memory, or by passing off as a +1 parameter to a
function).

rdar://59735604
2020-02-24 12:49:45 -08:00
Xiaodi Wu
1d7ec4c129 [NFC][Foundation] Remove or replace unnecessary uses of 'fileprivate' 2020-02-23 13:45:13 -05:00
Xiaodi Wu
ae423c5bcd [NFC] Replace two uses of 'fileprivate' with 'private' 2020-02-23 12:05:39 -05:00
Nate Cook
c6183ee71b Add RangeSet and discontiguous collection operations (#28161)
This adds the RangeSet and DiscontiguousSlice types, as well as collection
operations for working with discontiguous ranges of elements. This also adds
a COWLoggingArray type to the test suite to verify that mutable collection
algorithms don't perform unexpected copy-on-write operations when mutating
slices mid-operation.
2020-02-22 15:33:03 -06:00
Slava Pestov
20048bdc0d Runtime: Bounds check method override descriptors 2020-02-21 02:05:47 -05:00
Slava Pestov
dd94d57504 Merge pull request #29972 from slavapestov/clean-up-metadata-relative-pointers
ABI: Clean up context and method descriptor pointers
2020-02-20 22:22:41 -05:00
David Smith
428a08d498 Merge pull request #29978 from Catfish-Man/get-in-the-zone
Cache the default malloc zone
2020-02-20 18:25:46 -08:00
David Smith
71b8d03990 Cache the default malloc zone 2020-02-20 16:43:58 -08:00
Slava Pestov
a98f446f5f ABI: Clean up context and method descriptor pointers 2020-02-20 17:20:19 -05:00
Slava Pestov
2ae049121f Reflection: Fix a compiler warning 2020-02-20 17:19:21 -05:00
Michael Ilseman
2897daa434 Merge pull request #22616 from karwa/substring_inline
[stdlib] Make some trivial Substring methods inlinable
2020-02-20 09:25:38 -08:00
Alexis Laferrière
814491af50 Merge pull request #29942 from xymus/spitdlib
[stdlib] Update one String initializer and client to use @_spi
2020-02-19 19:43:39 -08:00
David Smith
3fe6b65899 Merge pull request #24303 from Catfish-Man/uninitialized-initialize
Add the new uninitialized buffer String initializer privately and use it to fix a perf TODO in append
2020-02-19 16:42:25 -08:00
Alexis Laferrière
4055c94d6d [stdlib] Update one String initializer and client to use @_spi 2020-02-19 16:38:51 -08:00