Commit Graph

4494 Commits

Author SHA1 Message Date
eeckstein
2335396b5e Merge pull request #16358 from eeckstein/stdlib-string-no-inlinable
stdlib: remove some @inlineables from String API functions.
2018-05-04 10:56:48 -07:00
swift-ci
55f1c866c0 Merge remote-tracking branch 'origin/master' into master-next 2018-05-03 19:09:31 -07:00
Michael Ilseman
cd32463fa2 Merge pull request #16320 from milseman/identity_crisis
[string] Only bridge tagged NSStrings to small string form.
2018-05-03 19:06:33 -07:00
swift-ci
98343b57ac Merge remote-tracking branch 'origin/master' into master-next 2018-05-03 17:49:33 -07:00
Michael Ilseman
c25188bafd Merge pull request #16140 from milseman/never_inlin
[stdlib] Drop @inlinable if @inline(never).
2018-05-03 17:43:24 -07:00
Erik Eckstein
9a961208ec stdlib: remove some @inlineables from String API functions.
Beside the general goal to remove inlinable functions, this reduces code size and also improves performance for several benchmarks.
The performance problem was that by inlining top-level String API functions into client code (like String.count) it ended up calling non-inlinable internal String functions eventually.
This is much slower than to make a single call at the top-level API boundary into the library. Inside the library all the internal String functions can be specialized and inlined.

rdar://problem/39921548
2018-05-03 14:37:11 -07:00
Nathan Lanza
9815368788 Configure the swiftImageInspectionShared to generate arch & sdk specific libraries
Previously, swiftImageInspectionShared generated one specific library at
`lib/libswiftImageInspectionShared.a` for only the main arch and sdk.
Generic cross compilation and various changes to the build system to get
cross compilation to work will require swiftImageInspectionShared to
generate libraries at the proper subdirectory. Change the outputs to
agree with paths such as `lib/swift/linux/x86_64`
2018-05-03 12:33:45 -07:00
Michael Ilseman
5f1ba83e8d [String] Only bridge tagged NSStrings to small string form.
Non-tagged NSStrings carry identity separate from their
value. Continue to bridge them lazily, even if they could fit in small
form, to respect this and avoid potential information loss.

Temporarily disable invariant that all natives strings that could be
small, are.
2018-05-03 10:45:19 -07:00
Lance Parker
851274df30 [stdlib] Restore @inlinable on _arrayOutOfPlaceReplace (#22)
Temporarily for https://bugs.swift.org/browse/SR-7588
2018-05-02 14:00:58 -07:00
Yuta Koshizawa
2da85ecc16 [stdlib] Make dictionary.keys.contains(key) O(1) even when wrapping a NSDictionary 2018-05-03 01:22:31 +09:00
swift-ci
2b9a333674 Merge remote-tracking branch 'origin/master' into master-next 2018-05-02 05:29:47 -07:00
Karoy Lorentey
b1a64e8303 Merge pull request #16177 from lorentey/hashable-docs
[SE-0206] Update Hashable docs for hash(into:)
2018-05-02 13:19:29 +01:00
swift-ci
b0428cef66 Merge remote-tracking branch 'origin/master' into master-next 2018-05-01 10:49:10 -07:00
eeckstein
c2cc3ee6cf stdlib: replace an obsolete initialize function in UnsafeBufferPointer.swapAt with the new one. (#16270)
This brings back performance on stdlib sort because the obsoleted function in UnsafePointer is not inlinable.
2018-05-01 10:48:32 -07:00
swift-ci
d9213aa780 Merge remote-tracking branch 'origin/master' into master-next 2018-05-01 10:29:52 -07:00
Michael Ilseman
17b0ed4708 [String] Define _copyContents for UTF8View
Define _copyContents on String.UTF8View, which allows it to
efficiently memcpy bytes when the String is already in UTF-8 (or
ASCII).
2018-04-30 17:08:12 -07:00
swift-ci
b80f58cbcf Merge remote-tracking branch 'origin/master' into master-next 2018-04-30 13:29:16 -07:00
Michael Gottesman
0d1f98a4ef Merge pull request #16259 from gottesmm/pr-aab473d24268b0934ac216bf2683f0a2c8e3be0f
[+0-all-args] Make _bridgeAnythingNonVerbatimToObjectiveC() take its …
2018-04-30 13:14:46 -07:00
swift-ci
9d81e603c3 Merge remote-tracking branch 'origin/master' into master-next 2018-04-30 12:29:27 -07:00
Michael Gottesman
161ffdaa77 Merge pull request #16257 from gottesmm/pr-a2ac5bea56b734ec3f97b29f6069bda20ffa3a15
[+0-all-args] Change _swift_stdlib_bridgeErrorToNSError to take its p…
2018-04-30 12:21:30 -07:00
Michael Gottesman
c31033c525 [+0-all-args] Make _bridgeAnythingNonVerbatimToObjectiveC() take its parameter at +1.
This hoists out the retain into Swift code from the casting runtime and along a
few paths in the runtime allows us to eliminate a dynamic retain release.

rdar://38196046
rdar://38771331
2018-04-30 11:05:00 -07:00
swift-ci
11c5a6b220 Merge remote-tracking branch 'origin/master' into master-next 2018-04-30 10:29:45 -07:00
Michael Gottesman
87681375e2 [+0-all-args] Change _swift_stdlib_bridgeErrorToNSError to take its parameter at +1.
This is truly a consuming operation. This can be seen since we always would need
to retain the argument here. This makes guaranteed -> owned less transformation
effective. Instead represent it taking a +1 argument so that the retain happens
outside the builtin instead of inside the builtin.

This also allows me to remove an extra copy from dynamicCastValueToNSError

rdar://38771331
2018-04-30 10:16:41 -07:00
Karoy Lorentey
5b80cf1d59 [stdlib]: Set,Dictionary: Fix subtle cross-collection hash collision issue
When Set/Dictionary is nested in another Set, the boundaries of the nested collections weren’t correctly delineated in commutative hashing.

For example, these Sets all hashed the same:

[[1, 2], [3, 4]]
[[1, 3], [2, 4]]
[[1, 4], [2, 3]]

Hash collisions could thus be systematically generated.

To fix this, remove collection-level support for one-shot hashing and revert to the previous method of generating hash values. (Set is still able to support one-shot hashing for its members, though.)
2018-04-30 15:40:16 +01:00
Karoy Lorentey
a274a0c92a [stdlib] Implement top-level hashing for stdlib types 2018-04-30 15:40:16 +01:00
Karoy Lorentey
3a162d225a [stdlib] Hashable, Hasher: Add non-public top-level hashing interface
The new _rawHashValue(seed:) requirement allows stdlib types to specialize their hashing when they’re hashed on their own (i.e., not as a component of some composite type).

This makes it possible to get rid of discriminator/terminator values and to eliminate most of Hasher’s resiliency overhead, leading to a measurable speedup, especially for tiny keys.
2018-04-30 15:16:47 +01:00
swift-ci
6e4b355297 Merge remote-tracking branch 'origin/master' into master-next 2018-04-30 04:49:57 -07:00
swift-ci
5f9bf115b3 Merge pull request #16154 from lorentey/hash-into-everywhere 2018-04-30 04:40:19 -07:00
Karoy Lorentey
bae6f529e1 [stdlib] Make Character.hash(into:) explicitly not inlinable
The @inlinable attribute was left off by accident, but this turned out to be a measurable performance boost for Character hashing.

Also add @effects(releasenone), for good measure.
2018-04-30 10:17:09 +01:00
Karoy Lorentey
0342ce3b96 [SE-0206][stdlib] Remove obsolete hashValue implementations
These are now synthesized by the compiler.
(Inlinability will be different, but that seems fine.)
2018-04-30 10:17:09 +01:00
Karoy Lorentey
239c2c91dd [SE-0206][stdlib] Add missing hash(into:) declarations 2018-04-30 10:17:09 +01:00
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