Commit Graph

5263 Commits

Author SHA1 Message Date
Mike Ash
b05c9e95cf [Stdlib] Make the !_runtime(_ObjC) version of _bridgeAnythingToObjectiveC non-inlinable as it calls an internal function. 2018-10-04 16:27:56 -04:00
Arnold Schwaighofer
0463ba3f88 Add the Swift equivalent of the llvm.assume intrinsic
rdar://44947459
2018-10-04 13:08:26 -07:00
swift-ci
dfed2796ae Merge pull request #19706 from airspeedswift/further-pwnage 2018-10-04 11:40:11 -07:00
Mike Ash
fa4178c5e8 [IRGen][Runtime] Adjust the ObjC reserved bits on x86-64 to exactly match what the target uses.
Previously we had a single mask for all x86-64 targets which included both the top and bottom bits. This accommodated simulators, which use the top bit, while macOS uses the bottom bit, but reserved one bit more than necessary on each. This change breaks out x86-64 simulators from non-simulators and reserves only the one bit used on each.

rdar://problem/34805348 rdar://problem/29765919
2018-10-04 12:34:08 -04:00
Mark Lacey
1dcb06bdb4 Merge pull request #19698 from rudkx/designated-protocols
[ConstraintSystem] Use operator designated protocols to speed type checking.
2018-10-04 08:39:25 -07:00
Ben Cohen
ed64e7bdfc reorder a __consuming func 2018-10-04 06:38:58 -07:00
Karoy Lorentey
a2e21667eb Merge pull request #19694 from lorentey/values-isnt-really-a-mutablecollection
[stdlib] Allow native dictionaries to advance Cocoa indices
2018-10-04 11:45:22 +01:00
Ben Cohen
9ce2143335 Additional ownership annotations 2018-10-03 19:10:22 -07:00
Harlan
3f470b074a [stdlib] Break infinite recursion false positive in _fatalErrorMessage (#19693)
Introduce an inner function that breaks the infinite recursion check, silencing this warning:

```
swift/stdlib/public/core/AssertCommon.swift:166:15: warning: all paths through this function will call itself
internal func _fatalErrorMessage(
              ^
```
2018-10-03 15:49:53 -07:00
Karoy Lorentey
6e671b6631 [stdlib] Allow native dictionaries to advance Cocoa indices 2018-10-03 21:05:46 +01:00
Ben Cohen
6cc6f4f182 Underscore @usableFromInlinable symbols (#19686) 2018-10-03 12:01:28 -07:00
Mark Lacey
9b7f9b2ec2 [stdlib] Update Policy.swift to use designated protocols for operators.
Also enable the parsing of these with
-enable-operator-designated-protocols in the stdlib build.

The constraint solver support to make use of these is not yet in-tree.
and will probably land with a different command-line option to enable
it, so that we can continue to have parsing support enabled in-tree
while the constraint solver support is iteratively improved.
2018-10-03 10:24:12 -07:00
Karoy Lorentey
20bb815b62 Merge pull request #19683 from lorentey/inline-customization-points
[stdlib] Force-inline some Sequence/Collection customization points
2018-10-03 15:43:53 +01:00
Karoy Lorentey
6b2d65e815 Merge pull request #19684 from lorentey/force-inline-native-iterators
[stdlib] Set, Dictionary: force-inline native iterators
2018-10-03 15:38:35 +01:00
Mike Ash
c4d5db404b [Stdlib] Change _swift_stdlib_random SPI to swift_stdlib_random API. 2018-10-03 09:55:34 -04:00
Mike Ash
e18e03171f [Stdlib] Change SWIFT_RUNTIME_STDLIB_INTERNAL to not export the symbol.
The functions in LibcShims are used externally, some directly and some through @inlineable functions. These are changed to SWIFT_RUNTIME_STDLIB_SPI to better match their actual usage. Their names are also changed to add "_swift" to the front to match our naming conventions.

Three functions from SwiftObject.mm are changed to SPI and get a _swift prefix.

A few other support functions are also changed to SPI. They already had a prefix and look like they were meant to be SPI anyway. It was just hard to notice any mixup when they were #defined to the same thing.

rdar://problem/35863717
2018-10-03 09:55:33 -04:00
Karoy Lorentey
89aa80679b [stdlib] Force-inline native Set iterators 2018-10-03 13:25:51 +01:00
Karoy Lorentey
6cb546534e [stdlib] Dictionary: Force-inline native iterators 2018-10-03 13:23:47 +01:00
Karoy Lorentey
4615e18366 [stdlib] Force-inline trivial default implementations for hidden Sequence/Collection customization points
This is usually a code size pessimization, but in this case the bodies are trivial, so inlining them eliminates a call + a conditional branch.
2018-10-03 13:18:16 +01:00
Karoy Lorentey
2f0f43a869 [stdlib] Dictionary, Set: Force-inline hidden Sequence/Collection customization points
This should eliminate a branch, which should probably lead to a tiny overall code size improvement, as well as a tiny performance boost.
2018-10-03 13:14:48 +01:00
Karoy Lorentey
267b80fe07 [stdlib] _Bitset: Use &* for join and capacity
We know it won’t overflow, because the result will not exceed the capacity, which is guaranteed to fit in an integer.
2018-10-03 12:01:38 +01:00
Karoy Lorentey
18c56540d5 [stdlib] _Bitset: Revert to using division/multiplication
However, convert input values to UInts before dividing them.
2018-10-03 12:01:38 +01:00
Karoy Lorentey
a6f7af161d [stdlib] Bitset: Use explicit left/right shifts instead of multiplication/division by powers-of-two
The divisions don’t get eliminated in -Osize builds.
2018-10-03 12:01:38 +01:00
Karoy Lorentey
2b1b68fed4 Merge pull request #19666 from lorentey/dictionary-remove-is-slow
[stdlib] Mark _NativeDictionary._delete(at:) non-releasing
2018-10-03 11:46:24 +01:00
Karoy Lorentey
f3006226f3 [stdlib] Mark _NativeSet._delete as non-releasing
Following a previous change that did this for Dictionary.
2018-10-02 20:40:38 +01:00
Karoy Lorentey
4887fcfc83 Merge pull request #19663 from lorentey/default-subscript-is-slow
[stdlib] Force-inline Dictionary.subscript(_:, default:)._modify
2018-10-02 17:10:27 +01:00
Karoy Lorentey
d6e31a80f1 [stdlib] Mark _NativeDictionary._delete(at:) non-releasing
This eliminates a retain/release pair around calls to it when it doesn’t get inlined.

_delete is responsible for restoring hash table invariants after a removal. It moves around elements in complicated patterns, but it doesn’t release them.
2018-10-02 15:38:39 +01:00
Karoy Lorentey
08e0ad66e3 [stdlib] Set, Dictionary: Enable per-instance hash seeds
The performance of operations merging two similar-sized sets or dictionaries is currently quadratic. Enabling per-instance seeds makes most of these linear, which is what most people expect.

This affects Set.union, Set.symmetricDifference and similar operations, including the for-loop based forms that people write manually.

The only remaining quadratic cases are when two sets/dictionaries are merged that are mutated copy-on-write copies of the same original instance. (We can’t change the hash seed without a full rehash,
2018-10-02 14:52:53 +01:00
Karoy Lorentey
5c04ebf6ae [stdlib] Force-inline Dictionary.subscript(_:, default:)._modify
Otherwise the autoclosure argument gets allocated on the heap, which leads to a 2x slowdown.
2018-10-02 14:34:57 +01:00
Ben Cohen
5e2c815edf Mark reversed as consuming (#19617) 2018-10-01 19:31:22 -07:00
Joe Groff
b824f288af Merge pull request #19600 from Kaiede/32bitBuiltinWordFix
Add sextOrBitCast to conversions of Builtin.Word
2018-10-01 14:22:50 -07:00
Stephen Canon
c34358d258 Remove an overly fragile test for armv7k (#19646)
We're not actually sure what this test is trying to validate, but it's quite fragile and probably not the best way to test it. Remove it rather than continuing to blindly update it.

Also minor improvements for the generic converts on 32b platforms; there's still more to be done with these, but this keeps us on the HW path for the common case.
2018-10-01 16:52:41 -04:00
Ben Cohen
615ed9d8a6 Inline for various builtins (almost all inline-always) (#19610) 2018-10-01 12:38:16 -07:00
Karoy Lorentey
2b7ef24990 [stdlib] Dictionary.merge: Don’t leave storage in an inconsistent state when closure throws 2018-10-01 15:40:14 +01:00
Stephen Canon
0707ca6dac Remove concrete floating-point inits from integer types (#19624)
Also removes .gyb from FloatingPoint.swift, since we barely are using it after this change.

Rework Self._convert from integer, by making it require RawSignificand: FixedWidthInteger. This requirement should have always been there, and the existing implementaiton wouldn't have actually worked correctly without it. Making it explcit makes the implementation quite a bit simpler, which is nice.

Additionally add a  fast-path conversion that will catch all concrete integer types without needing to be a concrete implementation itself. Room for further improvement, but good start. See RandomDouble performance improvements, for example.
2018-09-30 11:57:49 -04:00
Karoy Lorentey
df73981f31 [stdlib] Set, Dictionary: Remove bad @_effects attribute 2018-09-29 02:30:48 +01:00
Karoy Lorentey
1529d37301 [stdlib] Implement formIndex(after:) in all hashed collections 2018-09-29 02:30:08 +01:00
Karoy Lorentey
526162f706 [stdlib] Set, Dictionary: Fix uniqueness checking for Cocoa indices 2018-09-29 02:29:32 +01:00
Karoy Lorentey
15f4b91762 [stdlib] Set, Dictionary: Hide Cocoa index storage classes
Replace the single typed storage reference with two _BridgeObjects; this should give us plenty of space to play around with alternative representations.
2018-09-28 20:59:14 +01:00
Karoy Lorentey
41bedbe42b [stdlib] Set, Dictionary: Remove inappropriate @_effects from Index hashing 2018-09-28 20:15:55 +01:00
Karoy Lorentey
bb36ddfc17 Merge pull request #19599 from lorentey/opaque-cocoa-indices
[stdlib] Set, Dictionary: Make Cocoa indices resilient for now
2018-09-28 19:53:45 +01:00
Karoy Lorentey
900c930b4b [stdlib] Turn _CocoaDictionary.Index into a COW value type with opaque storage 2018-09-28 18:25:16 +01:00
Karoy Lorentey
eb69682f77 [stdlib] Turn _CocoaSet.Index into a COW value type with opaque storage
This enables making the struct @_fixed_layout, which should win us back some of the performance lost by hiding Cocoa indexing internals.
2018-09-28 17:57:20 +01:00
Adam Thayer
7288f2650f Add sextOrBitCast to conversions of Builtin.Word
An error was hit when attempting to build Swift on a 32-bit Linux host. It was asserting when attempting to run ‘RedunantLoadElim” during the optimizer. The reason why is a bit messy.

First, Builtin.Word is always considered to be 64-bit when it is a SILType. This means the optimizer, when working with a Builtin.Word, will create 64-bit APInts when converting from other types.

Second, the SIL being output for a particular literal looked like this:
Int2048 (integer_literal) : Int32 (Signed Truncation) : Word (zextOrBitCast)

The constant fold behavior would convert this into an integer_literal of the Builtin.Word type. But because of the zext cast, if the original literal was -1, it would become +4 billion during folding.

This normally isn’t a problem **except** when SIL is still attempting to optimize. (See First)

Third, The Redundant Load Elimination pass was attempting to make sense of an index_addr instruction which was indexing at -1. This happens when you perform “-= 1” on an UnsafePointer. Because SIL was interpreting Word’s size incorrectly, it caused the RLE pass to ask “what is the ProjectionKind at ptr[4billion]?” Since there’s no feasible answer for such a question, the answer was “nothing” when the Projection’s kind() was checked, which tripped the assert.

This fix uses sign extension when converting “upward” and the Integer type is signed, otherwise it will still use zero extension.
2018-09-28 09:22:36 -07:00
Karoy Lorentey
cceb389718 [stdlib] Set, Dictionary: Make more Cocoa indexy things non-inlinable 2018-09-28 15:18:15 +01:00
Karoy Lorentey
d477420ee4 [stdlib] Set, Dictionary: Make Cocoa indices resilient for now 2018-09-28 15:18:15 +01:00
Ben Cohen
3268b9d7de fishy-inlining (#19597) 2018-09-28 05:49:26 -07:00
Karoy Lorentey
ee4ad7a014 Merge pull request #19589 from lorentey/prepare-for-per-instance-seeds
[stdlib] Set, Dictionary: Prepare for per-instance hash seeds
2018-09-28 11:38:02 +01:00
Karoy Lorentey
7a8b34a499 [stdlib] Set, Dictionary: Make reserveCapacity non-inlinable
This allows us to record the reserved capacity in storage later, which will enable removals to resize the hash table.
2018-09-28 04:59:33 +01:00
Karoy Lorentey
e080bab5e5 Merge pull request #19602 from lorentey/dict-iterators
[stdlib] Dictionary.Keys, .Values: Implement custom iterators
2018-09-28 04:18:15 +01:00