Commit Graph

5263 Commits

Author SHA1 Message Date
swift-ci
33164b1493 Merge remote-tracking branch 'origin/master' into master-next 2018-04-29 06:48:57 -07:00
Michael Ilseman
c00a460ea3 [string] Drop StringStorage.create inlinability annotation.
StringStorage.create is the primary means of allocating storage for a
string, so drop inlinability to allow for future evolution.

StringStorage also exposes some .appendInPlace methods, which we
currently need to keep inlinable for benchmark performance. We'd
really like to drop inlinability for these for evolution purposes
(e.g. imagine a future version that adjusts nul-termination or changes
in coordination with create). These are flagged with:

` // TODO(inlinability): @usableFromInline - P3`

Where "P3" reflects urgency on a scale from 1 (stop the presses) to 5
(whatevs).
2018-04-28 15:36:12 -07:00
Michael Ilseman
715003c206 [gardening] Internalize many non-API String interfaces 2018-04-28 15:36:05 -07:00
swift-ci
63f81ddb82 Merge remote-tracking branch 'origin/master' into master-next 2018-04-27 14:09:08 -07:00
Ben Cohen
8f27db3433 underscore inlineable to inlinnable 2018-04-27 10:23:16 -07:00
Ben Cohen
fc60c6c4e0 Delete rogue where: label holdover 2018-04-27 10:09:14 -07:00
Ben Cohen
d6444f5f27 Add Sequence.allSatisfy 2018-04-27 08:53:35 -07:00
swift-ci
b0a762505f Merge remote-tracking branch 'origin/master' into master-next 2018-04-26 15:49:13 -07:00
Mox Soini
d4511da4f8 Make _fastEnumerationStorageMutationsPtr internal
...and make Foundation use it's own fileprivate _fastEnumerationStorageMutationsPtr
2018-04-27 00:00:26 +03:00
Karoy Lorentey
5d259cf082 [SE-0206] Update Hashable docs for hash(into:)
Also, repeat warning about hash values not being stable in the docs of Hasher.finalize().
2018-04-26 16:38:03 +01:00
Michael Ilseman
4267d4d526 [stdlib] Restore @inlinable for _getElementSlowPath
Done to address benchmark regressions.
2018-04-26 07:24:28 -07:00
Michael Ilseman
e4c65d1127 [stdlib] Restore some @inlinable for performance.
Dropping many of Array's @inlinable annotations caused some
performance regressions. Restore them temporarily while we figure out
how to better annotate these decls.
2018-04-25 20:45:01 -07:00
Michael Ilseman
e907d11dbc [stdlib] Drop @inlinable if @inline(never).
Aggressively remove all `@inlinable` from any function that's
`@inline(never)` to see the impact.

`@inlinable @inline(never)` is a potential code smell. While it might
expose some optimization and specialization opportunities to the
optimizer, it's most commonly a sign that more thought is needed.
2018-04-25 18:30:33 -07:00
swift-ci
8127c05972 Merge remote-tracking branch 'origin/master' into master-next 2018-04-24 22:49:21 -07:00
Slava Pestov
28ce9204fe stdlib: More SE-0193 updates 2018-04-24 21:21:22 -07:00
swift-ci
c02f08330a Merge remote-tracking branch 'origin/master' into master-next 2018-04-24 16:09:15 -07:00
Karoy Lorentey
1e1f6b8d92 [stdlib] Remove obsolete hashing interfaces 2018-04-24 17:55:35 +01:00
Karoy Lorentey
23c1b24e6a [SE-0206][Sema] Update Hashable synthesizer to support hash(into:)
This removes the default implementation of hash(into:), and replaces it with automatic synthesis built into the compiler. Hashable can now be implemented by defining either hashValue or hash(into:) -- the compiler supplies the missing half automatically, in all cases.

To determine which hash(into:) implementation to generate, the synthesizer resolves hashValue -- if it finds a synthesized definition for it, then the generated hash(into:) body implements hashing from scratch, feeding components into the hasher. Otherwise, the body implements hash(into:) in terms of hashValue.
2018-04-24 17:42:42 +01:00
Karoy Lorentey
0fb3e88110 [SE-0206][stdlib] De-underscore Hashable.hash(into:) 2018-04-24 17:42:42 +01:00
Karoy Lorentey
08d8804da9 [SE-0206][stdlib] Clarify Hasher.finalize() documentation 2018-04-24 17:42:42 +01:00
Karoy Lorentey
97ec2967e0 [SE-0206][stdlib] Hasher, SipHash: Make non-public declarations internal
Newly internal declarations include Hasher._seed and the integer overloads of Hasher._combine(_:), as well as _SipHash13 and _SipHash24.

Unify the interfaces of these SipHash testing structs with Hasher. Update SipHash test to cover Hasher, too.

Add @usableFromInline to all newly internal stuff. In addition to its normal use, it also enables white box testing; compile tests that need to use these declarations with -disable-access-control.
2018-04-24 17:42:42 +01:00
Karoy Lorentey
87685aaef9 [SE-0206][stdlib] Make Hasher.finalize() nonmutating but __consuming
As noted in the proposal’s revision, this allows us to get rid of finalization checks, improves API robustness, and paves the way for making Hasher move-only in the future.
2018-04-24 17:42:42 +01:00
Karoy Lorentey
de66338475 [SE-0206][stdlib] Document Hasher 2018-04-24 17:42:42 +01:00
Karoy Lorentey
45cb8b7123 [SE-0206][stdlib] De-underscore Hasher 2018-04-24 17:42:42 +01:00
swift-ci
32544ba2d3 Merge remote-tracking branch 'origin/master' into master-next 2018-04-24 09:29:23 -07:00
Michael Ilseman
8ef98b8dd2 Merge pull request #16119 from milseman/unicode_mistake
[string] Comparison bug fix: Kelvin
2018-04-24 09:18:15 -07:00
swift-ci
40ee7cbbcf Merge remote-tracking branch 'origin/master' into master-next 2018-04-23 18:49:14 -07:00
Nate Cook
b1ab7d89db [stdlib] Implement sequence/collection methods for searching from the end (#13337)
This implements the new last(where:), and lastIndex(of/where:) methods as
extensions on `BidirectionalCollection`, which partially implements SE-204.
The protocol requirements for `Sequence` and `Collection` as described
in the proposal need to wait until there's a solution for picking up the
specialized versions in types that conditionally conform to `BidirectionalCollection`.
2018-04-23 20:47:26 -05:00
Michael Ilseman
ebbfd8c639 [string] Comparison bug fix: Kelvin
Unicode Kelvin sign normalizes to ASCII 'K', but our comparison logic
didn't handle this situation when the other side was single-byte all
ASCII. Fall back to the slow comparison path if the point of
difference between an all-ASCII string and a UTF-16 string falls on
such a non-ASCII-yet-normalizes-to-ASCII scalar (rare).
2018-04-23 17:45:04 -07:00
swift-ci
2f8a7bb581 Merge remote-tracking branch 'origin/master' into master-next 2018-04-23 08:27:18 -07:00
Vijaya Prakash Kandel
a912a12805 Update ErrorType.swift documentation on IntParsingError (#16092)
Update ErrorType.swift

Example on IntParsingError should have Character as associated value type not String.
Also updated sample code to use c rather than s
2018-04-23 10:16:15 -05:00
Tony Allevato
54f4c77ce7 [stdlib] Revert hasNormalizationBoundaryBefore
This property is too specific in that it forces a particular normalization; let's not expose it this way, but instead in the future with a full normalization API.
2018-04-22 12:01:03 -07:00
swift-ci
09fc62ef2f Merge remote-tracking branch 'origin/master' into master-next 2018-04-21 17:47:48 -07:00
Nate Cook
58933d88c5 [stdlib] Rename index(...) methods to firstIndex(...)
A la SE-204.
2018-04-21 18:07:25 -05:00
swift-ci
1dbf8d5840 Merge remote-tracking branch 'origin/master' into master-next 2018-04-21 08:29:36 -07:00
Timm Preetz
46d36c8136 [gardening] Correct comment 2018-04-21 11:34:02 +02:00
swift-ci
2d269b33ca Merge remote-tracking branch 'origin/master' into master-next 2018-04-20 15:29:38 -07:00
Jordan Rose
f6b67f33fe Declare some FloatingPointSign members explicitly for @inlinable (#16043)
The compiler can synthesize these, but it doesn't mark them
@inlinable, since in the general case they're just a "default"
implementation and not "the only implementation forever". But for a
two-element enum that's based on a part of IEEE 754, it's probably
safe to assume this is the only implementation forever, and that
can be important for performance.

https://bugs.swift.org/browse/SR-7094
2018-04-20 15:28:53 -07:00
swift-ci
44b4be86f4 Merge remote-tracking branch 'origin/master' into master-next 2018-04-20 08:27:12 -07:00
Andrew Trick
abab49e54c Support exclusivity enforcement of KeyPath read-only access.
Use begin_unpaired_access [no_nested_conflict] for
Builtin.performInstantaneousReadAccess. This can't be optimized away
and is the proper marker to use when the access scope is unknown.

Drop the requirement that
_semantics("optimize.sil.preserve_exclusivity") be @inline(never). We
actually want theses inlined into user code. Verify that the
@_semantic functions are not inlined or otherwise tampered with prior
to serialization.

Make *no* change to propagate @inline(__always) into LLVM. This no longer has
any relationship to this PR and can be investigated seperately.
2018-04-19 22:46:10 -07:00
Devin Coughlin
ef4a89c479 [Exclusivity] Enforce exclusive access for class offsets in KeyPaths
Add dynamic enforcement of exclusive access when a KeyPath directly accesses a final
stored property on an instance of a class. For read-only projections, this begins and ends
the access immediately. For mutable projections, this uses the ClassHolder to perform
a long-term access that lasts as long as the lifetime of the ClassHolder.

rdar://problem/31972680
2018-04-19 21:37:12 -07:00
swift-ci
631977be80 Merge remote-tracking branch 'origin/master' into master-next 2018-04-19 17:08:59 -07:00
swift-ci
f45a9c8052 Merge pull request #16030 from lorentey/array-hash-encoding 2018-04-19 16:59:02 -07:00
Karoy Lorentey
882462ff8a [stdlib] Array._hash(into:): Include the count as a discriminator value
This makes the hash encoding unambiguous when arrays are hashed in sequence.
2018-04-19 20:05:29 +01:00
swift-ci
474160e84f Merge remote-tracking branch 'origin/master' into master-next 2018-04-19 10:28:27 -07:00
Karoy Lorentey
ebf290a598 [stdlib] Optimize ASCII String hashing
- String hashing is not inlinable, so it can use _Hasher._core operations directly. Remove custom buffering.
- Speed up ASCII hashing by as much as 5.5x by feeding the storage buffer directly into hasher in a single go.
- For other strings, just feed the UTF-8 encoding of the normalized string to the hasher; don't switch to UTF-16 at the first non-ASCII scalar. (Doing that would make the hash encoding of some string sequences ambiguous, leading to artificial collisions.)
- Add a single unconditional terminator byte, 0xFF. It's not a valid UTF-8 code unit, so it won't ever occur within a normalized string encoding.
2018-04-19 11:49:51 +01:00
swift-ci
7bf7526738 Merge remote-tracking branch 'origin/master' into master-next 2018-04-19 02:08:39 -07:00
Karoy Lorentey
7ed7354003 Merge pull request #16009 from lorentey/brand-new-combine-harvester2
[SE-0206][stdlib] Implement Hasher API (underscored)
2018-04-19 09:59:10 +01:00
swift-ci
e334846746 Merge remote-tracking branch 'origin/master' into master-next 2018-04-18 13:47:12 -07:00
Karoy Lorentey
7e66a38af8 [stdlib] De-gyb SipHash; implement full Hasher API 2018-04-18 17:33:24 +01:00