Commit Graph

13406 Commits

Author SHA1 Message Date
Arnold Schwaighofer
93f871e5e3 Get rid of some control flow for precondition checks
We can use cond_fail instead of control flow and int_trap. This should help
avoid some control flow in release builds.

Swift SVN r18940
2014-06-16 23:44:30 +00:00
Joe Groff
aeaa23470c stdlib: Add a ConstUnsafePointer type.
Like UnsafePointer, without the mutation accessors. gybify UnsafePointer.swift so we can generate both types from the same skeleton.

Swift SVN r18937
2014-06-16 20:35:30 +00:00
Doug Gregor
2ccbcccc0a Rename Dictionary downcast entry points to include "Conditional".
s/_dictionaryCheckedDownCast/_dictionaryDownCastConditional/g
s/_dictionaryBridgeFromObjectiveC/_dictionaryBridgeFromObjectiveCConditional/g


Swift SVN r18931
2014-06-16 15:35:18 +00:00
Doug Gregor
c19b92e4b3 Rename array downcast entry points to have "conditional" in the name.
s/_arrayCheckedDownCast/_arrayDownCastConditional/g
s/_arrayBridgeFromObjectiveC/_arrayBridgeFromObjectiveCConditional/g



Swift SVN r18930
2014-06-16 15:06:04 +00:00
Dave Abrahams
e310fd7f0b [stdlib] Shed Array's vestigial copy and unshare
Swift SVN r18927
2014-06-16 14:11:37 +00:00
Dave Abrahams
c5c17e2615 [stdlib] Sort Arrays using bulk mutation backdoor
This results in a a massive speedup and could in principle be applied to
other bulk array mutations.

Swift SVN r18926
2014-06-16 14:04:54 +00:00
Dave Abrahams
9603472490 [stdlib] Add Array.withMutableStorage
This is our backdoor for efficient bulk in-place mutation of arrays
until uniqueness-check hoisting is available.

Swift SVN r18925
2014-06-16 14:04:53 +00:00
Dave Abrahams
bf10db2834 [stdlib] Add an UnsafeMutableArray
Will be useful in optimizing bulk array mutations such as sort()

Also stopped making UnsafeArray a generator; in general making a
collection a generator seems somewhat muddled and dangerous, especially
when it comes to adapters that may have reference semantics.

Swift SVN r18924
2014-06-16 14:04:53 +00:00
Dave Abrahams
85533dd7d3 [stdlib] Restore Array value semantics
'nuff said.

Swift SVN r18923
2014-06-16 13:56:15 +00:00
Dave Abrahams
acc2c3be40 [stdlib] Prepare array sort for value semantics
Sorting was a bit of a mess; we had sort functions doing in-place
mutation /and/ returing the value, and people were confused by the
asymmetry of Array's sort() method with other higher-level methods.

Fixes <rdar://problem/17185815> sort([]T, f) mutates the original array
<rdar://problem/17225190> The Array.sort() method should return a sorted array

Swift SVN r18922
2014-06-16 13:48:43 +00:00
Chris Lattner
f923013047 implement the last bits of <rdar://problem/16879701> Should be able to pattern match 'nil' against optionals
We enable pattern matching against nil even if the T of an option type isn't comparable by implementing
a crazy new ~= operator.  This approach would work to enable comparisons against nil as well, but I can't
make it happen without introducing ambiguities.


Swift SVN r18919
2014-06-15 23:29:48 +00:00
Chris Lattner
60fc0e6cd2 Implement <rdar://problem/16951729> nil should be a literal type
This is all goodness, and eliminates a major source of implicit conversions.
One thing this regresses on though, is that we now reject "x == nil" where
x is an option type and the element of the optional is not Equtatable.  If
this is important, there are ways to enable this, but directly testing it as
a logic value is more straight-forward.

This does not include support for pattern matching against nil, that will be
a follow on patch.



Swift SVN r18918
2014-06-15 22:59:03 +00:00
Chris Lattner
371efa74d7 r18747 (which changed how we import macros that expand to nil) regressed on some GCD macros that are widely
used.  Fix this by adding them to the GCD overlay.  A more general solution is tracked in rdar://17245039,
but that isn't on the critical path right now.


Swift SVN r18916
2014-06-15 20:44:57 +00:00
Chris Lattner
b5cec06c12 remove an extraneous space.
Swift SVN r18911
2014-06-15 19:59:15 +00:00
Chris Lattner
ab3100230e restore DaveZ's r18786, which adds a .bytesSwapped property. Not all byte
swapping is about endianness.  This resolves rdar://17319884.


Swift SVN r18910
2014-06-15 19:57:37 +00:00
Doug Gregor
b039880a01 Revert r18906 "Make Dictionary bridgeFromObjectiveC return nil if bridging fails" while we discuss it.
Swift SVN r18908
2014-06-15 16:59:25 +00:00
Doug Gregor
dd8c668aa8 Import NSDictionary as Dictionary<NSObject, AnyObject>
Fixes <rdar://problem/16870626>.


Swift SVN r18907
2014-06-15 10:44:23 +00:00
Doug Gregor
d3d2092ac0 Make Dictionary bridgeFromObjectiveC return nil if bridging fails.
This allows conditional downcasting (e.g., via as? or is) to fail
without trapping. Noticed by inspection.


Swift SVN r18906
2014-06-15 08:53:22 +00:00
Doug Gregor
7acecc5457 Add a library entry point for Dictionary downcasting for bridged keys & values.
This is an inefficient, copying implementation of
_dictionaryBridgeToObjectiveC to aid progress on wiring up dictionary
downcasting <rdar://problem/16847470>. Making this implementation
efficient is tracked by <rdar://problem/16852016>.



Swift SVN r18897
2014-06-14 16:55:53 +00:00
Doug Gregor
2d4148796b Add a library entry point for Dictionary upcasting for object keys & values.
This is an inefficient, copying implementation of
_dictionaryCheckedDownCast to aid progress on wiring up dictionary
downcasting <rdar://problem/16847470>.  Making this implementation
efficient is tracked by <rdar://problem/16852016>.


Swift SVN r18896
2014-06-14 16:25:08 +00:00
Doug Gregor
47fbf0d166 Extend dictionary upcast support for handle mixed bridging/upcasting.
This allows dictionary upcasting where the key is bridged and the
value is not, or vice-versa. Finishes <rdar://problem/17289296>.


Swift SVN r18895
2014-06-14 15:48:12 +00:00
Doug Gregor
47748ba9aa Add stub implementations of the dictionary upcast entry points.
This introduces _dictionaryUpCast and _dictionaryBridgeToObjectiveC,
which will be used for upcasting for non-bridged and bridged key/value
types, respectively. _dictionaryUpCast is a horrible copying O(n)
implementation where we should be able to provide an O(1)
implementation, and _dictionaryBridgeToObjectiveC is similarly
awful. Hence, this is not for <rdar://problem/16852016>, but is merely
a stub to let us make progress on upcasting in the frontend
(<rdar://problem/17289296>).

Swift SVN r18867
2014-06-13 16:32:49 +00:00
Ted Kremenek
23d3ca2648 Fix 'charater' typo in documentation comment. <rdar://problem/17249044>
Swift SVN r18856
2014-06-13 05:43:05 +00:00
Doug Gregor
5ca3882b06 Rename array upcast/bridge expressions to "collection".
This is staging for dictionary bridging upcasts.


Swift SVN r18840
2014-06-12 21:41:55 +00:00
Jordan Rose
5f4db71fc5 Remove KVOContext from the Foundation overlay.
We're recommending people just go with a global variable.

<rdar://problem/17272837>

Swift SVN r18837
2014-06-12 19:55:45 +00:00
Greg Parker
6aa83e9d01 Improve the error message when a nil Optional is unwrapped.
Swift SVN r18822
2014-06-12 03:34:07 +00:00
Greg Parker
fc3794d7e9 <rdar://16978397> Overlay most of the rest of math.h.
Swift SVN r18821
2014-06-12 01:48:00 +00:00
John McCall
9890d8bca0 Add swift_dynamicCast.
This is the most general dynamic cast operation, permitting
arbitary source and destination types and handling arbitrary
changes in representation.  A value of the destination type
is constructed in an address provided by the caller; flags
control the behavior w.r.t. the source value.

Not yet used; probably buggy in various particulars.

Swift SVN r18815
2014-06-12 00:13:13 +00:00
John McCall
a581511069 Permit LLVM's cast operators to be used on Metadata
instances, and add ExistentialTypeMetadata::isClassBounded().

Swift SVN r18814
2014-06-12 00:13:08 +00:00
Greg Parker
8548760762 <rdar://16978397> Add overlays for most of tgmath.h.
Swift SVN r18808
2014-06-11 21:56:25 +00:00
Dmitri Hrybenko
363dfbee9b stdlib: add doc comments
Swift SVN r18794
2014-06-10 23:59:24 +00:00
Dave Zarzycki
152627896e stdlib: more byte swap feedback
Swift SVN r18790
2014-06-10 23:23:56 +00:00
Dave Zarzycki
59368b5711 stdlib: byte swap feedback
We only care about little-endian hosts at it shows. ;-)

Swift SVN r18787
2014-06-10 23:03:56 +00:00
Dave Zarzycki
9bdf3f6f6e stdlib: add .byteSwapped to integer types
This fixes: <rdar://problem/17085624>

Swift SVN r18786
2014-06-10 22:41:27 +00:00
Dave Zarzycki
588b91f982 Runtime: Swift is public, we can now stop hiding crash reports
This fixes: <rdar://problem/15489050>

Swift SVN r18784
2014-06-10 22:12:45 +00:00
Joe Groff
ac903bf943 IRGen: Make our use of spare bits in heap objects tagged-pointer-safe.
Don't use spare bits on platforms that use ObjC tagged pointers when an enum payload involves a class-constrained existential, archetype, or ObjC-defined class type. If a payload is of a Swift-defined class type, we can still assume it's a real pointer and use its spare bits. Add an @unsafe_no_objc_tagged_pointer attribute that can be applied to protocols to denote that existentials bounded by that protocol can use spare bits; this is necessary to preserve the layout of bridged Array and Dictionary types, which should not be bound to tagged pointer types in practice (fingers crossed). Fixes <rdar://problem/16270219>.

Swift SVN r18781
2014-06-10 17:07:47 +00:00
John McCall
0f0874bb4b Add variants of the checked-cast instructions that
put the result in a different place.

WIP: no IRGen support yet.

This will eventually be the required form when casting
to an address-only type; the existing instructions will
have only scalar outputs.

Swift SVN r18780
2014-06-10 07:43:22 +00:00
Greg Parker
50404f6210 Fix build break in UIViewControllerAdditions.
Swift SVN r18779
2014-06-10 06:16:00 +00:00
Greg Parker
4f467b72f5 Fix build break in XCTest.
Swift SVN r18778
2014-06-10 05:36:31 +00:00
Greg Parker
4880bceda2 <rdar://17086151> Add overlays for open(), openat(), and struct stat.
Swift SVN r18777
2014-06-10 02:43:26 +00:00
John McCall
5e1c15df93 Rationalize the class-instance dynamicCast runtime functions.
dynamicCastClass assumes that the destination type is a
Swift class type.

dynamicCastObjCClass assumes that the destination type is
an ObjC class type (represented as ObjC metadata, not type
metadata).

dynamicCastUnknownClass assumes only that the destination
type is some kind of class.

Swift SVN r18776
2014-06-10 02:11:24 +00:00
Manman Ren
e3517e8792 [stdlib] add two-operand version of min.
This corresponds to the change on max at r18767.


Swift SVN r18769
2014-06-10 00:57:08 +00:00
Manman Ren
4c284e48bd [stdlib] add two-operand version of max.
This helps array append's performance by ~ 2x. The generic max with a variadic
argument takes at least 3 arguments, it creates a temporary array then iterates
over the array.

This is an updated version of r18764.
rdar://17140639 rdar://17073827


Swift SVN r18767
2014-06-10 00:33:46 +00:00
Greg Parker
dc5f3c2090 <rdar://16878510> Add definitions of stdin/stdout/stderr to the Darwin overlay.
Swift SVN r18766
2014-06-10 00:33:02 +00:00
Manman Ren
aec78d0693 [stdlib] revert r18764.
Swift SVN r18765
2014-06-10 00:13:41 +00:00
Manman Ren
cc90c81239 [stdlib] add two-operand version of max and use max2 in stdlib when appropriate.
This helps array append's performance by ~ 2x. The generic max with a variadic
argument creates a temporary array then iterates over the array.

rdar://17140639 rdar://17073827


Swift SVN r18764
2014-06-09 23:56:40 +00:00
Joe Groff
cf20524271 Fix typo.
Swift SVN r18761
2014-06-09 22:19:12 +00:00
John McCall
1f5fa04724 Move the rest of the dynamic-cast code over to Casting.cpp.
Swift SVN r18759
2014-06-09 21:42:30 +00:00
John McCall
fd9778165b Split the dynamic-cast code out into its own file.
Swift SVN r18756
2014-06-09 21:16:09 +00:00
Doug Gregor
fa71c0d0bb Teach _dynamicCastToExistential to check conformance to Objective-C protocols.
Narrowly address the problem of downcasting an array to an array of
Objective-C existentials by checking conformance for Objective-C
protocols. Addresses <rdar://problem/17165071>, but this area still
needs a lot of work.


Swift SVN r18745
2014-06-09 15:13:58 +00:00