Commit Graph

2342 Commits

Author SHA1 Message Date
Erik Eckstein
f83bd2885d tests: fix the timeout.py script and move it to a more central place
A string->float conversion for the command line argument was missing
2020-04-10 20:10:24 +02:00
tbkka
110e5136c1 Float16 optimal formatting (#30862)
Extend SwiftDtoa to provide optimal formatting for Float16 and use that for `Float16.description` and `Float16.debugDescription`.

Notes on signaling NaNs: LLVM's Float16 support passes Float16s on x86
by legalizing to Float32.  This works well for most purposes but incidentally
loses the signaling marker from any NaN (because it's a conversion as far
as the hardware is concerned), with a side effect that the print code never
actually sees a true sNaN.  This is similar to what happens with Float and
Double on i386 backends.  The earlier code here tried to detect sNaN in a
different way, but that approach isn't guaranteed to work so we decided to
make this code use the correct detection logic -- sNaN printing will just be
broken until we can get a better argument passing convention.

Resolves rdar://61414101
2020-04-09 09:37:38 -04:00
Saleem Abdulrasool
1471d52662 test: mark stdlib/StringSwitch as executable_test
This is a runtime test, ensure that is marked as an execution test.
2020-04-07 20:36:59 -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
Xi Ge
faf91d5cf6 test: disable stdlib/TestData.swift due to rdar://61347106 2020-04-06 10:13:37 -07: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
swift-ci
e5110d7953 Merge pull request #30146 from benrimmington/static-string-documentation 2020-03-27 16:36:13 -07:00
Ravi Kandhadai
b7e8f76108 [stdlib/private][os log] Simplify the OSLogPrototype stdlib-private
module to contain only code necessary for testing the compiler
optimizations and diagnostics. This commit comprises the following changes:

1. Rename the OSLogPrototype module to OSLogTestHelper and rename the files.
2. Make the private module: OSLogTestHelper independent of os overlay.
3. Simplify the os log test suites and make them not perform logging.
4. Enable the os log test suites on all platforms.

<rdar://problem/60542172>
2020-03-27 01:18:04 -07:00
Mishal Shah
88b093e9d7 Merge pull request #30615 from apple/post-back-master-xcode-11.4
Update master to build with Xcode 11.4
2020-03-24 17:19:37 -07:00
Mishal Shah
e7cd5ab17f Update master to build with Xcode 11.4 2020-03-24 11:30:45 -07:00
3405691582
4a36a4b6c5 [test] Setup testing for OpenBSD.
This commit focuses the basics: setting up the relevant stanzas in
lit.cfg and adding platform conditionals for importing Glibc. Future
commits will deal with other portability fixes.
2020-03-23 20:47:31 -04:00
Hamish Knight
b62c9b6b01 [CS] Use getParameterType for KeyPath as function
Previously we were using `getPlainType` to match
the parameter type against the key path's base
type. This gave us the external parameter type,
which would be the element type for a variadic
parameter.  However the code we generate expects
the internal parameter type, which is provided by
`getParameterType`.

Resolves rdar://problem/59445486.
2020-03-11 17:21:28 -07:00
Kuba (Brecka) Mracek
b2edf20a81 Merge pull request #30112 from apple/mracek/arm64e
Add arm64e and pointer authentication support for Swift
2020-03-07 20:38:36 -08:00
John McCall
ceff414820 Distinguish invocation and pattern substitutions on SILFunctionType.
In order to allow this, I've had to rework the syntax of substituted function types; what was previously spelled `<T> in () -> T for <X>` is now spelled `@substituted <T> () -> T for <X>`.  I think this is a nice improvement for readability, but it did require me to churn a lot of test cases.

Distinguishing the substitutions has two chief advantages over the existing representation.  First, the semantics seem quite a bit clearer at use points; the `implicit` bit was very subtle and not always obvious how to use.  More importantly, it allows the expression of generic function types that must satisfy a particular generic abstraction pattern, which was otherwise impossible to express.

As an example of the latter, consider the following protocol conformance:

```
protocol P { func foo() }
struct A<T> : P { func foo() {} }
```

The lowered signature of `P.foo` is `<Self: P> (@in_guaranteed Self) -> ()`.  Without this change, the lowered signature of `A.foo`'s witness would be `<T> (@in_guaranteed A<T>) -> ()`, which does not preserve information about the conformance substitution in any useful way.  With this change, the lowered signature of this witness could be `<T> @substituted <Self: P> (@in_guaranteed Self) -> () for <A<T>>`, which nicely preserves the exact substitutions which relate the witness to the requirement.

When we adopt this, it will both obviate the need for the special witness-table conformance field in SILFunctionType and make it far simpler for the SILOptimizer to devirtualize witness methods.  This patch does not actually take that step, however; it merely makes it possible to do so.

As another piece of unfinished business, while `SILFunctionType::substGenericArgs()` conceptually ought to simply set the given substitutions as the invocation substitutions, that would disturb a number of places that expect that method to produce an unsubstituted type.  This patch only set invocation arguments when the generic type is a substituted type, which we currently never produce in type-lowering.

My plan is to start by producing substituted function types for accessors.  Accessors are an important case because the coroutine continuation function is essentially an implicit component of the function type which the current substitution rules simply erase the intended abstraction of.  They're also used in narrower ways that should exercise less of the optimizer.
2020-03-07 16:25:59 -05:00
Kuba (Brecka) Mracek
ab6533a40f Merge branch 'master' into mracek/arm64e 2020-03-06 15:07:01 -08: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
c4f1b83a5a Merge pull request #30259 from milseman/backspective
[test] Disable introspective test in back deployment
2020-03-06 09:16:56 -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
633d46ff26 [test] Disable introspective test in back deployment 2020-03-06 07:19:08 -08: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
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
Ben Rimmington
557e5662e4 [SE-0263] Add test for public API 2020-03-05 14:51:10 +00: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
Xiaodi Wu
6e46135965 [stdlib] Update tests for generic floating-point conversion 2020-03-03 18:35:27 -05: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
Kuba Mracek
1bd425da67 [arm64e] Test changes to support arm64e 2020-02-27 16:10:48 -08:00
Michael Gottesman
48939898f6 Merge pull request #30064 from gottesmm/pr-f768cd12b2b9ed81d02c7df2f86e47aa07ef8cbe
[stdlib] Mark Unmanaged._withUnsafeGuaranteedRef as _transparent and add a test/comments as requested in the original PR where this landed.
2020-02-25 19:32:26 -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
Ravi Kandhadai
7c9ddca1d4 [os log][stdlib/private] Enable precision and alignment values to be dynamic.
The format specifier constructed by the os log implementation uses '*' for
width and precision, and passes those values to the os_log ABIs as additional
arguments of the message. (The precision/alignment arguments have the
type: count).

Update tests to handle this change.
2020-02-25 15:11: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
Saleem Abdulrasool
e9aaef4bea test: move RangeSet test into validation-test
The RangeSet test depends on the StdlibCollectionUnittest, which is part
of the validation tests.  This should repair the tests.
2020-02-22 17:26:43 -08: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
Mike Ash
495554f270 [Test] Don't run EmptyCollectionSingletonRealization on older runtimes that aren't fixed.
rdar://problem/59590614
2020-02-19 11:30:29 -05:00
Slava Pestov
092fb33ab0 Merge pull request #29901 from slavapestov/reflection-zero-edition
IRGen: Fix reflection metadata for zero-sized enum cases
2020-02-19 11:08:11 -05:00
Slava Pestov
5b6a050e80 IRGen: Fix reflection metadata for zero-sized enum cases
If an enum has a payload case with zero size, we treat it as an empty case
for ABI purposes. Unfortunately, this meant that reflection metadata was
incomplete for such cases, with a Mirror reporting that the enum value
had zero children.

Tweak the field type metadata emission slightly to preserve the payload
type for such enum cases.

Fixes <https://bugs.swift.org/browse/SR-12044> / <rdar://problem/58861157>.
2020-02-18 14:16:58 -05:00
Mike Ash
2763e13a9a [Stdlib] Fix an overrelease in -[__SwiftNativeNSError description].
getDescription takes its argument at +1, but the implementation was passing the value directly. This caused the contained error value to be destroyed.

rdar://problem/59512630
2020-02-18 11:30:03 -05:00
swift-ci
bb20a87b2b Merge pull request #29871 from swiftwasm/swiftwasm-stdlib-tests 2020-02-18 04:19:33 -08:00
Max Desiatov
88ad780419 Fix a few tests for WASI 2020-02-16 21:16:01 +00:00
Mike Ash
440d2799f7 [Stdlib] Eagerly realize EmptyDictionarySingleton and EmptySetSingleton.
These objects can escape into ObjC without their class being realized first, which can cause a crash if the unrealized class gets passed into the ObjC runtime.

rdar://problem/59295395
2020-02-14 11:57:52 -05:00
Ravi Kandhadai
3c7f6d88e2 [stdlib/private][OSLog] Add basic support for interpolating floating-point
types without formatting options, add an auto-inferred privacy mode and
make it the default privacy mode, add support for aligning string
arguments.
2020-02-12 18:46:50 -08:00
swift-ci
518509dcf1 Merge pull request #29653 from owenv/test-fix 2020-02-11 09:43:53 -08:00
Ravi Kandhadai
ec9844b2d9 [SIL Optimization] Add a new mandatory pass for unrolling forEach
calls over arrays created from array literals. This enables optimizing
further the output of the OSLogOptimization pass, and results in
highly-compact and optimized IR for calls to the new os log API.

<rdar://58928427>
2020-02-07 20:06:29 -08:00
swift-ci
eed603d980 Merge pull request #29518 from ravikandhadai/oslog-string-formatting 2020-02-07 19:55:43 -08:00
Ravi Kandhadai
4f2a55bdd4 [stdlib/private][OSLog] Support expressive, fprintf-style formatting
options for integers passed to os log string interpolation.
2020-02-07 17:36:06 -08:00