Commit Graph

7767 Commits

Author SHA1 Message Date
Doug Gregor
c9ebcc592e [Runtime] Generalize dynamic casting between tuple types.
This allows dynamic casting to succeed between tuple types with
different element types, converting each element in turn. Fixes
rdar://problem/19892202.
2016-09-21 09:00:23 -07:00
Doug Gregor
fcacd089d6 [Mirrors] Use tuple labels when forming a mirror for a tuple type.
Fixes rdar://problem/22191852.
2016-09-21 09:00:22 -07:00
Doug Gregor
cccfe7ab1f [Printing] Print tuple labels when available.
When printing a tuple via print(...), print tuple labels when they are
available. This is possible now that the runtime metadata properly
stores tuple labels. Fixes rdar://problem/23130016.
2016-09-21 09:00:22 -07:00
Nicholas Maccharoli
384b2e3b83 [gardening] fix enum value spacing 2016-09-21 18:03:22 +09:00
swift-ci
81ee414f7a Merge pull request #4894 from DougGregor/tuple-casting 2016-09-20 21:04:34 -07:00
Doug Gregor
87908c8a1b [Runtime] Handle tuple/tuple dynamic casts that add/remove labels.
Introduce narrow support for tuple/tuple dynamic casts that merely add
or remove labels, but require the element types to match exactly. This
gets us back to allowing the same correct dynamic casts as in Swift
3.0, when labels were completely ignored.
2016-09-20 17:05:07 -07:00
Erik Eckstein
a006d3ca83 stdlib: improve comments 2016-09-20 16:34:51 -07:00
Erik Eckstein
5922aa8b14 stdlib: always inline the Set/Dictionary's _bucket function
If the Key is a class, then FunctionSignatureOpts cannot convert it to a @guaranteed parameter.
Using the new EpilogueARCAnalysis in FunctionSignatureOpts should fix that.
2016-09-20 16:34:51 -07:00
Erik Eckstein
8b1184708e stdlib: replace _squeezeHashValue with a specialized version for power-of-2 ranges.
This function is only used for Set and Dictionary and there the range (which is the capacity) is always a power of 2.
2016-09-20 16:34:51 -07:00
Erik Eckstein
36ef0e6cd7 stdlib: specify to the optimizer that the capacity value of Dictionary/Set is never negative.
This removes some runtime checks.
2016-09-20 16:34:51 -07:00
Erik Eckstein
504361ff66 stdlib: Replace some _preconditions with _sanityChecks.
Those conditions should not fail with any user code. They just check the internal implementation of the stdlib.
This removes some runtime checks in the generated code with the optimized library.
2016-09-20 16:34:51 -07:00
Joe Groff
2bfe9214ed Merge pull request #4869 from jckarter/optional-bridging
(take 2) SR-0140: Bridge Optionals to nonnull ObjC objects by bridging their payload, or using a sentinel.
2016-09-20 14:35:13 -07:00
Doug Gregor
1a8189814a [Runtime] Include tuple labels when printing the runtime name of a type.
When we started recording labels within the metadata for a tuple type,
we failed to print those labels when rendering the type name from
metadata.
2016-09-20 13:47:34 -07:00
Joe Groff
1a52e3f2c2 SR-0140: Bridge Optionals to nonnull ObjC objects by bridging their payload, or using a sentinel.
id-as-Any lets you pass Optional to an ObjC API that takes `nonnull id`, and also lets you bridge containers of `Optional` to `NSArray` etc. When this occurs, we can unwrap the value and bridge it so that inhabited optionals still pass into ObjC in the expected way, but we need something to represent `none` other than the `nil` pointer. Cocoa provides `NSNull` as the canonical "null for containers" object, which is the least bad of many possible answers. If we happen to have the rare nested optional `T??`, there is no precedented analog for these in Cocoa, so just generate a unique sentinel object to preserve the `nil`-ness depth so we at least don't lose information round-tripping across the ObjC-Swift bridge.

Making Optional conform to _ObjectiveCBridgeable is more or less enough to make this all work, though there are a few additional edge case things that need to be fixed up. We don't want to accept `AnyObject??` as an @objc-compatible type, so special-case Optional in `getForeignRepresentable`.

Implements SR-0140 (rdar://problem/27905315).
2016-09-20 13:04:09 -07:00
swift-ci
7a11b2d6fa Merge pull request #4888 from amartini51/seealso 2016-09-20 10:40:11 -07:00
Grzegorz Miłoś
f96b655a89 Merge remote-tracking branch 'upstream/master' into SR-755-linux-fatal-stacktrace-symbolication 2016-09-20 18:24:04 +01:00
Maxim Moiseev
46b860b5f8 [stdlib] returning false in case where comparison cannot succeed in SwiftValue (#4813) 2016-09-20 10:01:00 -07:00
Greg Parker
9666d8d39a [test] Add a timeout to runRaceTest(). Use it to limit test AtomicInt.swift. (#4815)
[test] Add a timeout to runRaceTest(). Use it to limit test AtomicInt.swift.

This cuts AtomicInt.swift's execution time from several hours to
about ten minutes on slow hardware and slow build configurations.
2016-09-19 21:46:25 -07:00
K Staring
7c50ccde5e fix cut/paste typo 'CMAKE_SDK != "FreeBSD"' to 'CMAKE_SDK in ["FreeBSD"]' (assuming some time more kqueue-supported platforms will want to support Swift) 2016-09-20 03:53:36 +02:00
K Staring
98a8b58957 add //FIXME for FreeBSD outcommented code, add sys/event.h for kqueue (untested) 2016-09-20 03:46:35 +02:00
airspeedswift
ed5231b47c Numbered all FIXME(ABI) entries for tracking purposes. (#4868) 2016-09-19 16:41:41 -07:00
Alex Martini
99dce85a6b Correct see-also markup in doc comments. 2016-09-19 13:48:36 -07:00
Joe Groff
b318763bb7 Add a builtin to generate the ObjC @encode string for a type.
We need the encode string to be able to construct NSValues using the core valueWithBytes:objCType: API. This builtin only works with concrete, @objc-representable types for now, which should be sufficient for a stdlib-internal API.
2016-09-19 11:14:01 -07:00
Brian Gesiak
4e552479b4 [stubs] Remove empty CMake variable
`swift_stubs_link_libraries` was removed in d227aeb64d. Remove the
`LINK_LIBRARIES` parameter, since its argument will always be empty.
2016-09-19 13:15:39 -04:00
practicalswift
2ee3c45b5b Merge pull request #4852 from practicalswift/optionals-set-to-nil
[gardening] Remove redundant nil-initialization of optional variables
2016-09-19 11:14:31 +02:00
K Staring
b267fda3c8 Merge branch 'master' of https://github.com/apple/swift 2016-09-18 13:09:34 +02:00
practicalswift
fa7fbdb8b0 [gardening] Remove redundant nil-initialization of optional variable
From the Swift documentation:

"If you define an optional variable without providing a default value,
 the variable is automatically set to nil for you."
2016-09-18 07:40:07 +02:00
Dmitri Gribenko
25378def9d stdlib: make RangeReplaceableCollection.SubSequence a RangeReplaceableCollection
Fixes rdar://problem/28330668.
2016-09-18 03:57:08 +03:00
Dmitri Gribenko
75fb1747d1 Foundation: change Data.Indices to be a CountableRange<Int>, that is much faster than the default 2016-09-18 03:57:07 +03:00
Dmitri Gribenko
573ed96ba2 Set Foundation.Data.SubSequence to be RangeReplaceable
RangeReplaceableCollection.SubSequence should be a
RangeReplaceableCollection.  Data implements RangeReplaceableCollection,
but sets SubSequence to MutableRandomAccessSlice that is not a
RangeReplaceableCollection.

This commit changes Foundation.Data.SubSequence to
MutableRangeReplaceableRandomAccessSlice.

Fixes rdar://problem/28330713.
2016-09-18 03:57:07 +03:00
swift-ci
16ff6ab227 Merge pull request #4847 from practicalswift/code-style-ii 2016-09-17 06:04:52 -07:00
practicalswift
710d8416f1 [gardening] Fix minor spacing issue in Data.swift 2016-09-17 13:28:34 +02:00
practicalswift
8d6251de66 [gardening] Fix accidental uses of \t 2016-09-17 13:15:26 +02:00
practicalswift
3a4ee89034 [gardening] Use consistent formatting. 2016-09-17 12:12:49 +02:00
practicalswift
89276cc07e [gardening] Replace "a NSFoo" with "an NSFoo". 2016-09-16 21:49:18 +02:00
practicalswift
2e9b699f48 Merge pull request #4837 from practicalswift/typo-fixes-20160916b
[gardening] Fix recently introduced typos
2016-09-16 21:21:53 +02:00
K Staring
7e51593508 Merge branch 'master' of https://github.com/apple/swift 2016-09-16 21:16:55 +02:00
swift-ci
3a72c9a68d Merge pull request #4836 from eeckstein/tail-alloc2 2016-09-16 12:04:30 -07:00
K Staring
4dbf4de036 don't try to link "dl" on FreeBSD 2016-09-16 20:49:22 +02:00
Nicholas Maccharoli
82713c033b [stdlib] fix unwrapped variable name (#4830) 2016-09-16 11:38:56 -07:00
practicalswift
7c63623ffc [gardening] Fix 13 recently introduced typos. 2016-09-16 20:30:57 +02:00
Erik Eckstein
312b0d8521 fix coding style 2016-09-16 11:14:36 -07:00
practicalswift
f250a2349b [gardening] Remove duplicate words. 2016-09-16 20:09:34 +02:00
Erik Eckstein
bd0d2bfed4 Remove the LLVM stack promotion pass and related SIL optimization logic.
It's not needed anymore because array buffers are now allocated with alloc_ref instead of a swift_bufferAllocate runtime call.
2016-09-16 11:02:19 -07:00
Erik Eckstein
b67959a6c1 stdlib: Use builtin tail-allocated arrays instead of ManagedBuffer to allocate Set and Dictionary buffers
This reduces the amount of SIL generated for Set/Dictionary operations significantly.
The generated code should be mostly the same (modulo different inlining decisions).
2016-09-16 11:02:19 -07:00
Erik Eckstein
266a5f90bd stdlib: Use builtin tail-allocated arrays instead of ManagedBuffer to allocate contiguous array buffers.
This reduces the amount of SIL generated for array operations significantly.
The generated code should be mostly the same (modulo different inlining decisions).
2016-09-16 11:02:19 -07:00
Erik Eckstein
d89a21460e Add builtins to generate instructions for tail-allocated arrays in SIL.
Those builtins are: allocWithTailElems_<n>, getTailAddr and projectTailElems
Also rename the "gep" builtin, which indexes raw bytes, to "gepRaw" and add a new "gep" builtin to index in a typed array.
2016-09-16 11:02:19 -07:00
Dmitri Gribenko
9a2bbc2d3d Merge pull request #4828 from apple/stdlib-improve-range-checking-for-strideable-indices
stdlib: Improve range checking in default implementations for strideable indices
2016-09-16 09:08:51 -07:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
Dmitri Gribenko
db945d5110 stdlib: Improve range checking in default implementations for strideable indices 2016-09-15 22:10:54 -07:00