Commit Graph

21492 Commits

Author SHA1 Message Date
Dmitri Hrybenko
2103b1d995 stdlib/Unicode: fix UTF-16 decoder not to crash on invalid code unit sequences
Also implemented U+FFFD insertion in UTF-16 decoder according to Unicode
reccomendation.


Swift SVN r19091
2014-06-23 14:52:24 +00:00
Joe Groff
1a1683e813 stdlib: Add internal entry points that can be used by intrinsic pointer conversions.
Swift SVN r19084
2014-06-22 20:10:19 +00:00
John McCall
d0dc196e8b Fix a metatype casting bug in the new casting runtime.
Swift SVN r19078
2014-06-22 09:53:34 +00:00
Greg Parker
6493bee517 Remove now-unnecessary extra retain during heap object destruction.
RC_DEALLOCATING_BIT prevents re-entrance into the destructor 
due to balanced retain/release during destruction.


Swift SVN r19060
2014-06-21 00:36:44 +00:00
Dmitri Hrybenko
aa7d6d690d Work around SIL optimizer bug to allow stdlib to be built with
optimizations

Swift SVN r19050
2014-06-20 20:03:47 +00:00
Doug Gregor
e47b0c220f Address Dmitri's review comments
Swift SVN r19047
2014-06-20 13:57:00 +00:00
Doug Gregor
22dc55058e Make bridgeFromObjectiveC return non-optional.
Now that we use bridgeFromObjectiveCConditional to perform conditional
bridging, make bridgeFromObjectiveC handle forced bridging. For the
latter, deferred checking is acceptable.

Almost all of <rdar://problem/17319154>.


Swift SVN r19046
2014-06-20 13:15:41 +00:00
Dmitri Hrybenko
f370ca0746 stdlib: fix a bunch of various Unicode issues, primarily in UTF-8 decoding
In UTF-8 decoder:
- implement U+FFFD insertion according to the recommendation given in the
  Unicode spec.  This required changing the decoder to become stateful, which
  significantly increased complexity due to the need to maintain an internal
  buffer.
- reject invalid code unit sequences properly instead of crashing rdar://16767868
- reject overlong sequences rdar://16767911

In stdlib:
- change APIs that assume that UTF decoding can never fail to account for
  possibility of errors
- fix a bug in UnicodeScalarView that could cause a crash during backward
  iteration if U+8000 is present in the string
- allow noncharacters in UnicodeScalar.  They are explicitly allowed in the
  definition of "Unicode scalar" in the specification.  Disallowing noncharacters
  in UnicodeScalar prevents actually using these scalar values as internal
  special values during string processing, which is exactly the reason why they
  are reserved in the first place.
- fix a crash in String.fromCString() that could happen if it was passed a null
  pointer

In Lexer:
- allow noncharacters in string literals.  These Unicode scalar values are not
  allowed to be exchanged externally, but it is totally reasonable to have them
  in literals as long as they don't escape the program.  For example, using
  U+FFFF as a delimiter and then calling str.split("\uffff") is completely
  reasonable.

This is a lot of changes in a single commit; the primary reason why they are
lumped together is the need to change stdlib APIs to account for the
possibility of UTF decoding failure, and this has long-reaching effects
throughout stdlib where these APIs are used.


Swift SVN r19045
2014-06-20 13:07:40 +00:00
John McCall
47427ccc5a Ensure that we deallocate opaque existential containers
if we dynamic-cast out of them as a take.

Swift SVN r19043
2014-06-20 07:47:01 +00:00
Doug Gregor
fd62de4373 Use bridgeFromObjectiveCConditional where we want conditional bridging.
More of <rdar://problem/17319154>.


Swift SVN r19038
2014-06-20 07:41:50 +00:00
Michael Gottesman
e269523e48 Reintroduce discriminator bit stripping in the runtime that was reverted
when I undid the array enum change in r19026.

Swift SVN r19028
2014-06-20 02:40:57 +00:00
Michael Gottesman
8de060ff3f Revert "[stdlib] mask unused bits in uniqueness checks"
Revert "[stdlib] Use an enum for ArrayBuffer storage"

This reverts commit r18996.
This reverts commit r18954.

The optimizer is not ready yet to handle this change especially given
the time until Beta 3. After speaking with DaveA, we agreed to revert
this and take such large changes onto private branches until we are sure
that the optimizer is ready to handle them rather than risking
performance regressions due to hitting the "optimization cliff".

Swift SVN r19026
2014-06-20 01:41:04 +00:00
Dmitri Hrybenko
c4fd1c4092 stdlib: explain the trick used to achieve @noinline without @noinline
Swift SVN r19018
2014-06-19 23:53:09 +00:00
Chris Hanson
7d1cf3d107 Remove XCTest overlay
The XCTest support for Swift is now built as part of XCTest.framework
itself, so the overlay is no longer necessary.

Addresses <rdar://problem/17383462>.

Swift SVN r19016
2014-06-19 22:08:52 +00:00
Jordan Rose
f60213e4e6 Update Joe's UnsafePointer changes to account for Chris's ..< changes.
Swift SVN r19010
2014-06-19 18:09:55 +00:00
Jordan Rose
fe5c879a1a Work around single-expression closure not returning Void.
Swift SVN r19009
2014-06-19 18:04:21 +00:00
Chris Lattner
63e34d727c fix doc comment.
Swift SVN r19007
2014-06-19 18:02:31 +00:00
Chris Lattner
444d835d00 implement <rdar://problem/17054014> map method should exist on ranges
Swift SVN r19006
2014-06-19 18:01:05 +00:00
Kuba Brecka
1da7379ff2 Changing putchar's prototype to match the C version (missing return type).
Swift SVN r19005
2014-06-19 17:32:30 +00:00
Chris Lattner
aa722e4100 mark .. as unavailable and add the operator change to the release notes. I filed
rdar://17380298 to track removing .. entirely for GM.

This finishes <rdar://problem/17203527> Swift range operators too easy to mis-type: change .. to ..<


Swift SVN r19004
2014-06-19 17:22:01 +00:00
Kuba Brecka
7f69d6d27d strcmp has a wrong prototype, the return type in C is 'int' which doesn't map to Swift Int.
Swift SVN r19002
2014-06-19 17:16:43 +00:00
Doug Gregor
2e3863b211 Introduce _ConditionallyBridgedToObjectiveC.bridgeFromObjectiveCConditional.
This entry point is used in conditional downcasts (as?) to attempt to
bridge from an Objective-C class down to a specific native type (e.g.,
array, dictionary), bridging all elements eagerly so that it can
produce nil if the bridging would fail.

This is the scaffolding for <rdar://problem/17319154>, and makes the
example there work, but there is much more cleanup and optimization to
do.



Swift SVN r18999
2014-06-19 14:48:00 +00:00
Chris Lattner
62cad3dce8 add a "..<" operator, which is an alias for ".." and switch the stdlib to use it.
Until I have a chance to update the testsuite, we'll accept both.



Swift SVN r18998
2014-06-19 05:42:29 +00:00
Dave Abrahams
2b82e8988f [stdlib] mask unused bits in uniqueness checks
Also update ArrayBuffer to take advantage of it.

This change allows us to pass a word-sized enum with a native object
reference payload directly to the runtime, without switching on the enum
to unwrap the contents.  Even though that unwrapping was semantically
equivalent to bit masking, it was causing fits in the optimizer.

Swift SVN r18996
2014-06-19 02:32:07 +00:00
John McCall
7effec113c Change ImplicitlyUnwrappedOptional to be an enum type itself,
not a struct wrapping an Optional.

Among other things, this means you can now pattern-match on
an IUO.  It also makes it more convenient to build and destroy
them.

SILGen's type lowering should probably canonicalize one kind
of optional to the other so that we don't get silly abstraction
costs from conversion.

Swift SVN r18991
2014-06-18 23:27:08 +00:00
Dave Abrahams
89fb9c8bea [stdlib] Factor out Array growth calculation
This enables testing of other growth factors, per
<rdar://problem/17230502>.  See the radar for basic performance test
results confirming (to the degree practical) that 2x growth is better
than 1.5x in our current system.

Swift SVN r18990
2014-06-18 23:17:06 +00:00
Enrico Granata
da4044a4b0 I have a theory that the logger is getting malformed strings in some cases because this table of metadatakind to string is incomplete, and as such sometimes garbled data ends up being logged. Even though MagicMirror should only be generated in a few controlled cases, it seems possible that there are more such cases than I initially envisioned - hence the issue. This is my attempt at a fix here
Swift SVN r18986
2014-06-18 22:57:21 +00:00
Jordan Rose
94072c5379 Replace two uses of asmname with LLVM intrinsics.
Swift SVN r18971
2014-06-18 02:36:30 +00:00
Enrico Granata
a59e139988 UInt needs a Mirror of its own, it was simply forgotten when writing the gyb file
Fixes rdar://17181909



Swift SVN r18969
2014-06-18 01:41:41 +00:00
Pete Cooper
653a9d2d99 Create builtin's for math functions exposed as LLVM intrinsics. Use these builtin's in the wrappers for functions such as sqrt(Float) and cos(Double). rdar://problem/16709244
Swift SVN r18968
2014-06-18 00:27:13 +00:00
Dmitri Hrybenko
4fd936efab Add a comment blurb at the top of StdlibUnittest.swift.gyb
Swift SVN r18961
2014-06-17 21:13:34 +00:00
Dmitri Hrybenko
4904685f8f Extract some unit testing helpers from NSStringAPI into a module
Swift SVN r18956
2014-06-17 16:25:37 +00:00
Dave Abrahams
a4c232bab8 [stdlib] Use an enum for ArrayBuffer storage
instead of reinterpretCasting all over the place.  This should make it
easier on the ARC optimizer.

Addresses <rdar://problem/17312221>

Swift SVN r18954
2014-06-17 11:22:34 +00:00
Doug Gregor
ff8fe8b150 Add forced downcasting entry points for dictionary, _dictionaryDownCast and _dictionaryBridgeFromObjectiveC.
Swift SVN r18953
2014-06-17 10:10:57 +00:00
Doug Gregor
b9485466ff Add array forced downcast operations _arrayDownCast and _arrayBridgeFromObjectiveC.
Swift SVN r18952
2014-06-17 10:10:21 +00:00
Ted Kremenek
7d5a8aa5cc Use 'NSColor' instead of 'AnyObject' in argument to 'init' with 'colorsAndLocations'.
Swift SVN r18950
2014-06-17 07:01:17 +00:00
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