Commit Graph

5543 Commits

Author SHA1 Message Date
Saleem Abdulrasool
d0048ccc61 stdlib: android does not support FP80
Correct the maximal floating point width.  Although technically, Android
could support FP128 on AArch64, Swift does not currently support FP128.
For now, ensure that we use FP64 on Android.
2020-04-13 12:23:26 -07:00
Robert Widmann
763875aea7 Merge pull request #15108 from darquro/fast-path-ad-hoc-printing-of-strings
[stdlib][SR-7136] Fast-path ad-hoc printing of Strings
2020-04-12 09:30:52 -07:00
Saleem Abdulrasool
b7654f158b Merge pull request #30885 from compnerd/android-fp80
stdlib: android does not support fp80
2020-04-11 10:13:52 -07:00
Michael Ilseman
38fce16254 [string] Convert IR tests to SIL tests 2020-04-10 11:39:22 -07:00
Michael Ilseman
d02f5bc509 [string] Move wCSIA check higher than _HasContiguousBytes 2020-04-10 11:39:03 -07:00
Michael Ilseman
ae224cacdb [string] Restore _HasContiguousBytes for untyped storage
UnsafeRawBufferPointer cannot implement
withContiguousStorageIfAvailable because doing so would potentially
create a typed pointer from untyped data.
2020-04-09 13:38:28 -07:00
Michael Ilseman
e536ad2342 [string] Outline cold path from initializer
Outline the cold, non-contiguous UTF-8 path from String(decoding:as:),
saving ~40 bytes (33%) of code size (x86_64 and arm64) from every call
site where the contiguity check cannot be constant folded away.
2020-04-09 13:38:28 -07:00
Michael Ilseman
c2631004d7 [string] _HasContiguousBytes -> withContiguousStorageIfAvailable
Switch String(decoding:as) and other entry points to call
withContiguousStorageIfAvailable rather than use _HasContiguousBytes.
2020-04-09 13:38:28 -07:00
Michael Ilseman
19b332c8e2 [gardening] Delete Trailing Whitespace 2020-04-09 13:38:27 -07:00
Saleem Abdulrasool
3fe5b1531c stdlib: android does not support fp80
Like Windows, Android does not support FP80.  Ensure that we do not emit
these even on x86 and x86_64.
2020-04-08 10:07:50 -07:00
Dario Rexin
999b93bfdb Merge pull request #30815 from ktoso/wip-mangledTypeName
Improve usability of _mangledTypeName with Any.Type arguments
2020-04-06 20:49:13 -07:00
Stephen Canon
248c554524 Add Float16 to stdlib (#30130)
Add Float16 (IEEE 754 binary16) to the standard library, plus assorted runtime support operations.

Swift Evolution thread: https://forums.swift.org/t/se-0277-float16/33546
2020-04-06 17:57:44 -04:00
Konrad `ktoso` Malawski
5faf82c553 Improve usability of _mangledTypeName with Any.Type arguments 2020-04-05 12:27:50 +09:00
Michael Ilseman
5815468ebb Merge pull request #30719 from milseman/tilde_equality
[String] Concrete String/Substring overloads for ~=
2020-04-03 11:12:32 -07:00
Michael Ilseman
30c92574ed [String] Concrete String/Substring overloads for ~=
Add concrete overloads for ~= for String/Substring
combinations. SR-12457 tracks making this generic after we understand
the expression type checker impact.
2020-04-02 10:37:30 -07:00
Ben Rimmington
682c1672b6 [stdlib] Update file headers of de-gybbed files 2020-04-01 22:14:03 +01:00
Joe Groff
026b8b31c9 Merge pull request #30318 from ktoso/wip-mangledTypeName
Add _mangledTypeName to allow round trips T->mangledName->T
2020-03-30 18:13:56 -07:00
swift-ci
e5110d7953 Merge pull request #30146 from benrimmington/static-string-documentation 2020-03-27 16:36:13 -07:00
Mishal Shah
e7cd5ab17f Update master to build with Xcode 11.4 2020-03-24 11:30:45 -07:00
Konrad `ktoso` Malawski
34b6e4fe58 Add precondition that no repairs were made to _mangledTypeName string 2020-03-18 11:51:28 +09:00
Xiaodi Wu
90c6c491d9 [gardening] Silence a warning about unused value 2020-03-14 10:33:45 -04:00
swift-ci
cc4bfe82da Merge pull request #30398 from milseman/palloc_size 2020-03-13 17:57:59 -07:00
Michael Ilseman
d98a022924 [stdlib] Re-enable assertions on malloc size
Round up our malloc requests and assert that breadcrumbs are aligned
and where we think they should be. This is necessary because ASAN
doesn't give us pointer-rounded sizes.
2020-03-13 15:50:40 -07:00
Konrad `ktoso` Malawski
ea6b69eabc Add missing @available marker on _getMangledTypeName 2020-03-10 14:04:47 +09:00
Konrad `ktoso` Malawski
33444489e5 Add _mangledTypeName to allow round trips T->mangledName->T 2020-03-10 12:20:08 +09:00
Michael Ilseman
4715d68890 Merge pull request #30237 from valeriyvan/RemoveRedundantZeroingStringGuts
Changes implementation of _persistCString from _StringGuts
2020-03-09 14:36:05 -07:00
Kuba (Brecka) Mracek
ab6533a40f Merge branch 'master' into mracek/arm64e 2020-03-06 15:07:01 -08:00
Rintaro Ishizaki
3f69d6b9dd Merge pull request #30260 from milseman/assert_san
[stdlib] Disable assertion tripping up ASAN
2020-03-06 09:32:31 -08:00
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
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
swift-ci
db10388b3c Merge pull request #30194 from xwu/floating-point-conversion-oops 2020-03-03 21:35:53 -08: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