Commit Graph

4494 Commits

Author SHA1 Message Date
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
Joe Groff
62771a0c9d stdlib: Add withUnsafeBytes(of:) and withUnsafePointer(to:) for immutable arguments.
Since the functions produce pointers with tightly-scoped lifetimes there's no formal reason these have to only work on `inout` things.  Now that arguments can be +0, we can even do this without copying values that we already have at +0.
2018-04-18 09:13:45 -07:00
Karoy Lorentey
ccdc218cbd [stdlib] _Hasher: append => combine 2018-04-18 14:18:44 +01:00
swift-ci
563d33a207 Merge remote-tracking branch 'origin/master' into master-next 2018-04-17 15:49:54 -07:00
Ben Cohen
ca7aea02e9 [stdlib] Add compatibility typealias for CountablePartialRangeFrom (#15989)
* Add compatibility typealias for CountablePartialRangeFrom
2018-04-17 15:48:54 -07:00
swift-ci
51d049d9bd Merge remote-tracking branch 'origin/master' into master-next 2018-04-17 15:09:51 -07:00
Karoy Lorentey
6c5a6a6a16 [stdlib] Make sure _SwiftNewtypeWrapper hashes the same way as its RawValue
_SwiftNewtypeWrapper forwarded hashValue to its rawValue, but it failed to do the same for _hash(into:), which resulted in the wrapper struct having subtly different hashing than the raw value.

This violated an implicit invariant when dictionaries/sets of such types were bridged to Objective-C through AnyHashable, leading to nondeterministic but frequent crashes.

rdar://problem/39398060
2018-04-17 22:04:55 +01:00
swift-ci
1261e6b6dd Merge remote-tracking branch 'origin/master' into master-next 2018-04-12 15:20:06 -07:00
Max Moiseev
02aef12281 Merge pull request #15815 from Moximillian/SR-7266-avoid-nesting-reversed
SR-7266: Avoid nesting of ReversedCollection
2018-04-12 15:05:54 -07:00
swift-ci
ba62fe78a1 Merge remote-tracking branch 'origin/master' into master-next 2018-04-11 13:32:51 -07:00
Michael Gottesman
f5ed323b7d Merge pull request #15865 from gottesmm/pr-64a51a9306ab1faab72f4e6bb58d6d062f984dcf
Add build-script flag --enable-exclusivity-checking to enable exclusi…
2018-04-11 13:15:09 -07:00
Nate Cook
69ce965881 Merge pull request #15794 from natecook1000/nc-fixes-83-1
[stdlib] Documentation revisions
2018-04-11 15:07:04 -05:00
swift-ci
09541e4da8 Merge remote-tracking branch 'origin/master' into master-next 2018-04-11 13:06:58 -07:00
Nate Cook
61c79f33c0 [stdlib] Address feedback from @airspeedswift and @CodaFi 2018-04-11 13:03:36 -05:00
Nate Cook
a63f5bf788 [stdlib] Revise masking shift and unsafe operation docs 2018-04-11 11:34:59 -05:00
Nate Cook
b6a0d9ed26 [stdlib] Documentation revisions
- Make RawRepresentable Codable abstracts distinguishable
- Make the UnboundedRange example a little more user friendly
- Correct the RangeReplaceableCollection example description
- Revise CaseIterable discussion
2018-04-11 11:34:51 -05:00
Michael Gottesman
e071e46068 Add build-script flag --enable-exclusivity-checking to enable exclusivity checking always when we compile stdlibCore.
It is off by default.

rdar://39335800
2018-04-11 09:23:06 -07:00
swift-ci
533c77156e Merge remote-tracking branch 'origin/master' into master-next 2018-04-11 08:07:02 -07:00
Karoy Lorentey
cff4eb77ef [stdlib] {Set,Dictionary}.init(minimumCapacity:) Update docs
Avoid describing the exact algorithm that these collections use to allocate storage. (It is a private implementation detail that we want to be able to change.)

rdar://problem/36619317
2018-04-11 12:25:51 +01:00
swift-ci
e0ef0a8300 Merge remote-tracking branch 'origin/master' into master-next 2018-04-10 13:12:33 -07:00