Commit Graph

12522 Commits

Author SHA1 Message Date
Saleem Abdulrasool
547701f7f3 build: repair the windows cross-compilation
The SIMDOperators module was being added prior to SwiftOnoneSupport, which
resulted in the import library target for Windows not being setup prior to use.
As a result, we would link against the DLL rather than the import library which
is not supported (except as a MinGW hack in the binutils linker).  Re-order the
registration to ensure that the target is setup already.
2018-12-06 10:04:33 -08:00
Michael Ilseman
8863a5514c Merge pull request #21024 from milseman/fass_and_smol
[String] In-register comparison of small ASCII strings
2018-12-06 09:01:37 -08:00
Michael Ilseman
4394ce1a23 Merge pull request #21072 from milseman/i_dem_potent
[String] String-from-whole-Substring fast-path.
2018-12-06 09:01:12 -08:00
Doug Gregor
00d2acd809 Merge pull request #21037 from DougGregor/flatten-abs
[ABI] [stdlib] Remove magnitude-based overload of abs(_:).
2018-12-06 08:36:24 -08:00
Mike Ash
6f7143bfaf [Runtime] Allow casts from AnyHashable to a Hashable enum to succeed.
rdar://problem/46472361
2018-12-06 10:33:35 -05:00
Karoy Lorentey
549926337c Merge pull request #20967 from lorentey/aump-read
[stdlib] AutoreleasingUnsafeMutablePointer: Switch subscripts to _read accessors
2018-12-06 15:13:09 +00:00
sarveshtamba
7dbda7847d Updating Change 'isValidPointerForNativeRetain' check for PowerPC(ppc64le) 2018-12-06 11:43:25 +00:00
Doug Gregor
ab75577079 [stdlib] Teach abs(_:) to use magnitude when it can.
Within the (single) implementation of abs(_:), dynamically check whether
the numeric type and its `Magnitude` are of the same type and, if so,
return the result of `magnitude`. This ensures that we do the right thing
with respect to (e.g.) floating point values like -0.0, without resorting
to overloading of abs(_:).
2018-12-05 21:05:52 -08:00
Jon Shier
2bc4cbbfdd Update for revised proposal. 2018-12-05 23:17:35 -05:00
Michael Ilseman
255c17aeb6 [String] String-from-whole-Substring fast-path.
Add in a fast-path for Strings created from Substring which covers the
entire String. Put String-from-Substring behind a non-inlinable
resilience barrier for future flexibility.
2018-12-05 18:22:47 -08:00
Michael Ilseman
b08d94d6ba [String] In-register smol ASCII string compare
Compare small strings in-register when they store ASCII (and thus NFC)
contents.
2018-12-05 18:16:46 -08:00
Karoy Lorentey
1485404532 [stdlib] Document that hashValue is deprecated 2018-12-05 19:00:35 +00:00
adrian-prantl
bf2a4712ec Merge pull request #21017 from adrian-prantl/debrief
Remove \brief commands from doxygen comments.
2018-12-05 10:40:53 -08:00
Karoy Lorentey
ce96f1e528 [stdlib] _modify: Use defer to ensure invariants are restored when yield throws
_modify mustn’t leave Collection storage in an inconsistent state when the code to which we’re yielding happens to throw. In practice this means that any cleanup code must happen in defer blocks before the yield.

Fix Dictionary to do just that and add tests to cover this functionality (as well as some other aspects of _modify).
2018-12-05 17:35:24 +00:00
sarveshtamba
2fbdf74df2 Change 'isValidPointerForNativeRetain' check for PowerPC(ppc64le) 2018-12-05 07:22:03 +00:00
Doug Gregor
85d488d461 [stdlib] Remove magnitude-based overload of abs(_:).
The standard library has two versions of the `abs(_:)` function:

```
func abs<T : SignedNumeric>(_ x: T) -> T where T.Magnitude == T
func abs<T : SignedNumeric & Comparable>(_ x: T) -> T
```

The first is more specialized than the second because `T.Magnitude` is
known to conform to `Comparable`. Indeed, it’s a more specialized
implementation that returns `magnitude`.

However, this overload behaves oddly: in the expression `abs(-8)`, the type
checker will pick the first overload because it is more specialized. That’s
a general guiding principle for overloading: pick the most specialized
overload that works.

However, to select that overload, it needs to pick a type for the literal
“8” for which that overload works, and it chooses `Double`. The “obvious”
answer, `Int`, doesn’t work because `Int.Magnitude == UInt`.

There is a conflict between the two rules, here: we prefer more-specialized
overloads (but we’ll fall back to less-specialized if those don’t work) and we prefer to use `Int` for integer literals (but we’ll fall back to `Double` if it doesn’t work). We have a few options from a type-checker
perspective:

1. Consider the more-specialized-function rule to be more important
2. Consider the integer-literals-prefer-`Int` rule to be more important
3. Call the result ambiguous and make the user annotate it

The type checker currently does #1, although at some point in the past it
did #2. Moving forward, #1 is a better choice because it prunes the number
of overloads that need to be considered: if the more-specialized overload
succeeds its type-check, the others need not be considered. It’s also
easier to reason about than the literal-scoring approach, because there can
be a direct definition for “more specialized than” that can be reasoned
about.

I think we should dodge the issue by removing the more-specialized version
of `abs(_:)`. Its use of `magnitude` seems unlikely to provide a
significant performance benefit, and the presence of overloading either
forces us to consider both overloads always (which is bad for type checker
performance) or accept the regression that `abs(-8)` is `Double`. Better
to eliminate the overloading and, if needed in the future, find a better
way to introduce the more-specialized implementation without it being a
separate signature.

Fixes rdar://problem/42345366.
2018-12-04 23:10:04 -08:00
Ben Cohen
fc7830a4ed Remove Swift 3-only Compatibility Shims (#21019) 2018-12-04 18:22:27 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Bob Wilson
8e38173884 Merge pull request #21008 from mikeash/keypath-allocation-overflow-fix
[Stdlib] Ensure key paths allocate space for the terminating NUL.
2018-12-04 15:01:37 -08:00
Michael Ilseman
3e8b015afe Merge pull request #20983 from milseman/comparison_reform
[String] Comparison Speedups
2018-12-04 14:53:45 -08:00
John McCall
9379e19748 Merge pull request #21000 from rjmccall/arm64-tbi-future-proofing
Future-proof the ARM64 ABI by not reserving the entire top byte
2018-12-04 16:24:54 -05:00
Mike Ash
01b840a488 [Stdlib] Ensure key paths allocate space for the terminating NUL.
rdar://problem/46457346 SR-9404
2018-12-04 14:53:03 -05:00
Michael Ilseman
8530a2c940 [String] Hand-increment loop variable for perf.
Hand-incrementing the loop variable allows us to skip overflow
detection, and will permit more vectorization improvements in the
future. For now, it gives us perf improvements in nano-benchmarks.
2018-12-04 11:51:21 -08:00
Doug Gregor
2c5ecb477a Merge pull request #20858 from DougGregor/mangled-base-protocol-witnesses
[ABI] Use mangled names for base protocol witnesses.
2018-12-04 11:28:27 -08:00
Saleem Abdulrasool
16e9bab7f0 Platform: add setjmp module for VisualC
Add the setjmp module which was missing.  The roughly equivalent
function is `_setjmp`.  Unfortunately, it is not marked as
`__attribute__((__returns_twice__))`.
2018-12-04 09:55:33 -08:00
Saleem Abdulrasool
322a585714 Merge pull request #20994 from compnerd/calling-extension-o
Driver: correct the registrar extension
2018-12-04 08:28:58 -08:00
John McCall
d44851304b Future-proof the ARM64 ABI by not reserving the entire top byte.
Targets that want to use armv8.5a memory tagging will need this.
Hopefully nobody comes up with a brilliant reason they need to use
anything else.
2018-12-04 01:43:08 -05:00
Doug Gregor
f2dd852f94 [ABI] Optimize out the witness table pattern for resilient conformances.
Resilient conformances now put all witnesses into the resilient witness
table, so optimize away the witness table pattern for such cases. Teach
the runtime to fill in the protocol conformance descriptor, because that’s
the only bit of real information that would be in the pattern.

This is a minor optimization enabled by rdar://problem/46282080.
2018-12-03 20:16:18 -08:00
Saleem Abdulrasool
c931d9530e Driver: correct the registrar extension
The object file extension on Windows is `.obj` rather than `.o`.  Ensure
that we get the extension correct when compiling for Windows.
Furthermore, ensure that we install with the correct extension when
installing a cross-compiled image.  As we may be using the homegrown
cross-compilation system, we must explicitly handle the extension
ourselves.  This allows nearly a 100 additional tests to pass on
Windows.
2018-12-03 19:17:06 -08:00
Jon Shier
7fb5905f5f Updates for review comments. 2018-12-03 21:52:21 -05:00
Slava Pestov
60e3373636 Merge pull request #20987 from slavapestov/backward-deployment
Backward deployment fixes and tests
2018-12-03 21:49:00 -05:00
Slava Pestov
f871b0e661 Merge pull request #20948 from Azoy/remove-_getBool
[SILGen][stdlib] Remove _getBool
2018-12-03 21:00:31 -05:00
Slava Pestov
213d089c28 Runtime: Don't crash when overriding a weak-imported method that's not available 2018-12-03 20:36:03 -05:00
Doug Gregor
c0519c7185 [ABI] Put mangled inherited protocol witnesses into the resilient witness table
Emit mangled inherited protocol witnesses into the resilient witness table,
and realize them when we instantiate the resilient witness table. Don’t
put mangled inherited protocol witnesses into non-resilient witness tables:
there is no efficient way to make sure they are realized, so keep the
previous instantiation-function approach.

Implements the rest of rdar://problem/46282080.
2018-12-03 17:29:33 -08:00
Michael Ilseman
c0c530aef8 [String] Speed up constant factors on comparison.
Include some tuning and tweaking to reduce the constant factors
involved in string comparison. This yields considerable improvement on
our micro-benchmarks, and allows us to make less inlinable code and
have a smaller ABI surface area.

Adds more extensive testing of corner cases in our existing
fast-paths.
2018-12-03 15:49:38 -08:00
Michael Ilseman
1706d4c02d [String] Refactor and fast-path normalization
Refactor some normalization queries into StringNormalization.swift,
and add more latiny (<0x300) fast-paths.
2018-12-03 13:22:57 -08:00
Michael Ilseman
8d2af454e4 [String] Normalization-boundary-before UTF-8 fast path.
All latiny (<0x300) scalars have normalization boundaries before them,
so when asking if memory containing a scalar encoded in valid UTF-8
has a boundary before it, check if the leading byte definitely encodes
a scalar less than 0x300.
2018-12-03 13:20:39 -08:00
Karoy Lorentey
bb81b24248 Merge pull request #20918 from lorentey/dictionary-modify-layering
[stdlib] Refactor Dictionary.subscript._modify for better layering
2018-12-03 20:57:55 +00:00
Michael Ilseman
94942c5b3b [String] Fix corner case in comparison fast-path. (#20937)
When in a post-binary-prefix-scan fast-path, we need to make sure we
are comparing a full-segment scalar, otherwise we miss situations
where a combining end-of-segment scalar would be reordered with a
prior combining scalar in the same segment under normalization in one
string but not the other.

This was hidden by the fact that many combining scalars are not
NFC_QC=maybe, but those which are not present in any precomposed form
have NFC_QC=yes. Added tests.
2018-12-03 10:41:45 -08:00
swift-ci
3376f9fbe8 Merge pull request #20952 from xwu/stdlib-style-fixes 2018-12-03 09:03:37 -08:00
Karoy Lorentey
04586e3916 [stdlib] AutoreleasingUnsafeMutablePointer: Switch subscripts to _read accessors 2018-12-03 16:22:33 +00:00
Dale Buckley
6ef7cca298 Added decodable error handling and changed from operator constructors to uncheckedBounds constructor 2018-12-03 08:44:04 +00:00
Jon Shier
33dcfc462f Add update Result type to standard library. 2018-12-02 22:15:02 -05:00
Xiaodi Wu
9fe28c6e55 [gardening] Fix header comments [NFC] 2018-12-02 15:38:41 -05:00
Xiaodi Wu
f9e8b6363e [gardening] Make edits for stdlib style [NFC] 2018-12-02 15:26:35 -05:00
Azoy
a2dafc3d26 Remove _getBool 2018-12-01 18:51:25 -06:00
Saleem Abdulrasool
98d71ff38f SwiftPrivateThreadExtras: clean up using WinSDK SDK overlay
Use the constants rather than hardcoding values.
2018-12-01 11:04:13 -08:00
swift-ci
19eed120ee Merge pull request #20906 from compnerd/sdk-overlay 2018-12-01 10:27:33 -08:00
Michael Ilseman
b01ee7267a [String] Custom iterator for UTF16View (#20929)
Defining a custom iterator for the UTF16View avoid some redundant
computation over the indexing model. This speeds up iteration by
around 40% on non-ASCII strings.
2018-12-01 09:35:27 -08:00
Saleem Abdulrasool
84e94f563c SDK: add SDK overlay for Windows
Introduce a WinSDK overlay for Windows.  This allows us to define some
shared constants that are not correctly imported right now.  This cleans
up the logic in the swift side of things and aids in the bring up.

Now that we have a SDK overlay for Windows, we should structure the tree
according to the OS family.
2018-11-30 16:55:42 -08:00