Commit Graph

21803 Commits

Author SHA1 Message Date
Doug Gregor
61ee5f7529 Allow dynamic casts between foreign classes and other classes.
These casts always succeed, because we don't have any way to check
them (yet). Part of <rdar://problem/18088474>.

Swift SVN r21386
2014-08-21 22:54:10 +00:00
Enrico Granata
4a45129d45 Remove the workaround for the malformed fieldNames field in JITed code. Now that the JIT is doing the right thing again, we can restore full reflection support. Fixes rdar://18007839
Swift SVN r21374
2014-08-21 21:32:48 +00:00
Dave Abrahams
4b2ccff3a4 [stdlib] Replace assert(false) with compile error
Unsupported architectures will cause a failure to compile rather than
some kind of runtime trap.  In particular, assert() should never be used
in the standard library; we have _sanityCheck for that purpose.

Swift SVN r21373
2014-08-21 21:06:20 +00:00
Dmitri Hrybenko
18bbf0dfef stdlib/Dictionary: implement fast enumartion for NSEnumerator of
bridged Swift.Dictionary; this allows us to autorelease less.

rdar://17944094


Swift SVN r21372
2014-08-21 20:28:28 +00:00
Doug Gregor
dde9485f08 Fix embarrassing bug in -_cfTypeID. Thanks, Joe
Swift SVN r21369
2014-08-21 18:13:48 +00:00
Dmitri Hrybenko
9404f1c055 Dictionary: in fast enumeration, don't autorelease objects that Dictionary has
a strong reference to.

rdar://17944094


Swift SVN r21368
2014-08-21 18:05:06 +00:00
Doug Gregor
0f3d1062aa Implement -_cfTypeID on SwiftObject.
This allows us to use CFGetTypeID() on a Swift-native class. This is
the simplest part of <rdar://problem/18088474>.

Swift SVN r21367
2014-08-21 17:59:31 +00:00
Dmitri Hrybenko
f1c3d879ef StdlibUnittest: add setUp and tearDown functions, which are executed before and
after every test


Swift SVN r21362
2014-08-21 16:56:49 +00:00
Doug Gregor
d603db43f2 Make factory methods unavailable when there is already a corresponding initializer.
Depending on visitation order, we would occasionally leave the factory
method available if we had completely imported the initializer
first. Fixes <rdar://problem/17261609>.

Swift SVN r21361
2014-08-21 16:45:17 +00:00
Doug Gregor
d1c76de9e0 Unbreak iOS build after r21324.
Swift SVN r21342
2014-08-21 05:07:07 +00:00
Arnold Schwaighofer
16e41ada77 Make Builtin.canBeClass return a tri-state
Replace the true/maybe state that Builtin.canBeClass was returning by a
tri-state (yes, no, maybe) allowing the optimizer to use the definite no
answer.  This removes the need of the sizeof check that we had in
isClassOrObjCExistential. It also removes the need to CSE this function since
in most cases we will be able to instantiate canBeClass to yes or no (vs maybe)
at compile time.

benchmark``````````````,``baserun0``,``optrun2``,``delta,``speedup
ClassArrayGetter```````,``988.00````,``337.00```,``644.00``,````````191.7%
DeltaBlue``````````````,``2429.00```,``1927.00``,``460.00``,````````23.9%
Dictionary`````````````,``1374.00```,``1231.00``,``129.00``,````````10.9%
Havlak`````````````````,``1079.00```,``911.00```,``124.00``,````````13.7%
Rectangles`````````````,``924.00````,``541.00```,``379.00``,````````70.1%

radar://16823238

Swift SVN r21331
2014-08-21 00:55:40 +00:00
Arnold Schwaighofer
411ad98fba Add @effects(readnone) to _swift_isClassOrObjCExistential
rdar://17961249

Swift SVN r21330
2014-08-21 00:55:36 +00:00
Dave Abrahams
1fb0f889d7 [stdlib] Make UnsafePointer conversions explicit
Previously, it was possible to write Unsafe[Mutable]Pointer(x) and have
Swift deduce the pointee type based on context.  Since reinterpreting
memory is a fundamentally type-unsafe operation, it's better to be
explicit about conversions from Unsafe[Mutable]Pointer<T> to
Unsafe[Mutable]Pointer<U>.  This change is consistent with the move from
reinterpretCast(x) to unsafeBitCast(x, T.self).

Also, we've encoded the operations of explicitly adding or removing
mutability as properties, so that adding mutability can be separated
from wild reinterpretCast'ing, a much more severe form of unsafety.

Swift SVN r21324
2014-08-20 23:15:56 +00:00
Doug Gregor
ebf4c1e5ca Allow "return nil" in a failable initializer to initiate failure.
Basic semantic analysis only; AST to follow.

Swift SVN r21309
2014-08-20 17:22:34 +00:00
Arnold Schwaighofer
f1ffbf0e0e Revert "stdlib: Add a _isClassOrObjCExistentialAndSizeofAnyObject function"
This reverts commit r21287.

Discussions ongoing.

Swift SVN r21288
2014-08-19 18:15:24 +00:00
Arnold Schwaighofer
87fe2bf736 stdlib: Add a _isClassOrObjCExistentialAndSizeofAnyObject function
The function _isClassOrObjCExistentialAndSizeofAnyObject encapsulates the
"sizeof(x) == sizeof(AnyObject)" check and the call to
swift_isClassOrObjCExistential. The sizeof(x) check cannot be eliminated at the
SIL level and creates extra control flow such that the call to
swift_isClassOrObjCExistential does not dominate. Encapsulating both checks
results in one function call that does dominate allowing us to CSE calls when we
add the attributes inline(late) and effects(readnone).

benchmark``````````````,``baserun0``,``optrun2``,``delta,``speedup
ClassArrayGetter```````,``977.00````,``571.00```,``409.00``,````````72.0%
DeltaBlue``````````````,``2594.00```,``2086.00``,``311.00``,````````14.9%
Rectangles`````````````,``921.00````,``605.00```,``314.00``,````````52.0%

rdar://17961249

Swift SVN r21287
2014-08-19 18:05:44 +00:00
Mikhail Zolotukhin
4027d140d1 stdlib: Replace quicksort with introsort.
Also, unite predicated and unpredicated versions of all functions via
GYB.

Swift SVN r21280
2014-08-19 13:41:04 +00:00
Dmitri Hrybenko
670c5989e1 stdlib: remove ImplicitlyUnwrappedOptional.hasBool, IUO is not a
BooleanType

rdar://18054470

Swift SVN r21275
2014-08-19 08:31:30 +00:00
Dmitri Hrybenko
9fb350761a stdlib: use unchecked arithmetic in _floorLog2 because it can never
overflow

Also improves comments and _sanityCheck messages.

Swift SVN r21259
2014-08-18 19:44:29 +00:00
Dmitri Hrybenko
cdc876f04d stdlib: remove 'public' from some internal bit twiddling functions
Swift SVN r21254
2014-08-18 15:10:49 +00:00
Mikhail Zolotukhin
fd50a501b1 stdlib: Add floorLog2 function.
Swift SVN r21252
2014-08-18 14:26:02 +00:00
Dmitri Hrybenko
58083094d8 stdlib: port Assert.swift test to StdlibUnittest
Swift SVN r21251
2014-08-18 14:07:56 +00:00
Dmitri Hrybenko
cae11e1e41 stdlib/Assert: add overloads for assertionFailure(), preconditionFailure(),
fatalError() that accept string interpolation

rdar://18043533


Swift SVN r21250
2014-08-18 10:48:52 +00:00
Dmitri Hrybenko
16604871b3 stdlib: disallow concatenating Characters with "+"
rdar://18026160


Swift SVN r21249
2014-08-18 10:13:36 +00:00
Dmitri Hrybenko
532ca776ca stdlib/String: fix a memory safety issue with using foreign indexes
(indexes obtained from a different object)

rdar://18037790

Swift SVN r21244
2014-08-15 23:56:30 +00:00
Dave Abrahams
980ccb7788 [stdlib] Fix reserve when extending String
I wish I knew how to code a regression test for this, but sadly I don't.

The only performance differences with magnitude > 7% show up in
-Ounchecked, and most of these look suspiciously like noise due to the
irrelevance of generic string append.  The only one I'd be remotely
concerned about is StrToInt, but it doesn't make any sense that it
should have gotten slower, so I think that's noise too.

Ackermann: -14.3%
Fibonacci: 33.3%
ImageProc: 9.0%
Phonebook: -7.1%
QuickSort: 15.6%
StrToInt: -14.3%

Swift SVN r21236
2014-08-15 16:44:10 +00:00
Dmitri Hrybenko
a64dceed58 stdlib: remove a stale FIXME, '!= nil' is now required to test Optionals for
the presence of a value


Swift SVN r21230
2014-08-15 10:19:54 +00:00
Dmitri Hrybenko
61f9b11e5f StdlibUnittest: add expectEqualUnicodeScalars() assertion function for precise
String comparison


Swift SVN r21229
2014-08-15 10:11:31 +00:00
Dmitri Hrybenko
823291e735 StdlibUnittest: add a compatibility typealias to allow PlaygroundLogger to
transition to the new APIs


Swift SVN r21225
2014-08-15 08:11:36 +00:00
Dmitri Hrybenko
8cca039e62 StdlibUnittest: rename TestCase to TestSuite since it contains multiple tests
Thanks, Ben!


Swift SVN r21222
2014-08-15 00:09:58 +00:00
Arnold Schwaighofer
dc001d3ece stdlib: Don't check overflow on UnsafePointers they are unsafe
This also reverts the commit "stdlib: Don't check for overflow in subscript accesses to
ContigousArrayBuffer" as removing the overflow check on all unsafe pointers has
the same effect.

Swift SVN r21220
2014-08-14 23:16:20 +00:00
Arnold Schwaighofer
70caa2e83e stdlib: Don't check for overflow in subscript accesses to ContigousArrayBuffer
We overflow checked the mulitplication in "a + sizeof(T) * i". This is not
necessary for ContingousArrayBuffer because this overflow check has happened
when we compute the size of the array during allocation of a native swift array
or a NSArray.

benchmark``````````````,``baserun0``,``optrun2``,``delta,``speedup
Memset`````````````````,``1184.00```,``487.00```,``698.00``,````````143.9%
QuickSort``````````````,``1299.00```,``1458.00``,``178.00``,````````-12.2%
SelectionSort``````````,``1027.00```,``814.00```,``213.00``,````````26.2%
StdlibSort`````````````,``1718.00```,``1587.00``,``127.00``,````````8.0%
Walsh``````````````````,``1160.00```,``1076.00``,``86.00```,````````8.1%
XorLoop````````````````,``1248.00```,``884.00```,``369.00``,````````42.0%

The  regression in quicksort is noise - i looked at the LLVM IR and the only
thing different in the graph is that we have removed the mulitplication with
overflow check (that is - we should be running faster). Same thing looking at
the assembly.

XorLoop and Memset speed up because we are now able to vectorize those loops.

Swift SVN r21218
2014-08-14 21:49:34 +00:00
Dmitri Hrybenko
9977f78393 stdlib: unbreak build with INTERNAL_CHECKS_ENABLED=NO
Swift SVN r21207
2014-08-14 17:44:56 +00:00
Dave Abrahams
35d9fc22fa [stdlib] Doc comment reduce algorithm
Swift SVN r21206
2014-08-14 17:36:49 +00:00
Dmitri Hrybenko
84abad0be4 stdlib: clarify a trap error message
Swift SVN r21205
2014-08-14 17:36:27 +00:00
Dave Abrahams
1eba71e4e6 [stdlib] Doc comments and parameter naming, NFC
Fixes <rdar://problem/17998481>

Swift SVN r21204
2014-08-14 17:31:54 +00:00
Doug Gregor
7a80e1249e Minor standard library cleanups. NFC
Swift SVN r21203
2014-08-14 17:27:43 +00:00
Doug Gregor
15b1790245 Fix generic definitions of &= and ^= for bitwise types <rdar://problem/18018525>.
Swift SVN r21202
2014-08-14 17:27:42 +00:00
Dmitri Hrybenko
938e7c2676 stdlib: introduce UnicodeScalarLiteralConvertible protocol
This allows UnicodeScalars to be constructed from an integer, rather
then from a string.  Not only this avoids an unnecessary memory
allocation (!) when creating a UnicodeScalar, this also allows the
compiler to statically check that the string contains a single scalar
value (in the same way the compiler checks that Character contains only
a single extended grapheme cluster).

rdar://17966622

Swift SVN r21198
2014-08-14 16:04:39 +00:00
Dmitri Hrybenko
2f80b28c5f stdlib: remove a bogus implementation of an unavailable function
Swift SVN r21193
2014-08-14 11:33:31 +00:00
Doug Gregor
0fc92aabe1 Remove empty Nil.swift from the standard library
Swift SVN r21190
2014-08-14 00:38:46 +00:00
Dmitri Hrybenko
cfa2bdaf83 stdlib/Hashing: use unchecked arithmetic when mixing in the per-execution seed
The per-process seed is actually fixed right now, so this bug was dormant.


Swift SVN r21189
2014-08-14 00:25:44 +00:00
Greg Parker
5a71cacec3 Remove nib-lookup hacks from UIViewController. Fixes rdar://17327189.
Swift SVN r21183
2014-08-13 20:57:55 +00:00
Anna Zaks
c519ecfe4f API Notes File: The product of the 2d nullability audit of Foundation.
As well as the required test/stdlib modifications.

Swift SVN r21181
2014-08-13 19:39:59 +00:00
Enrico Granata
7f87bcef46 This patch works around an issue with JIT relocations in LLDB generated modules by avoiding access to the fieldNames pointer of the nominal type descriptor. Fixes rdar://18007819
Swift SVN r21180
2014-08-13 19:25:48 +00:00
Dave Abrahams
f075c1070a [stdlib] Add a ?? overload with T? on the RHS
Swift SVN r21175
2014-08-13 16:33:35 +00:00
Dmitri Hrybenko
d812966d32 stdlib: remove Optional.hasValue property
rdar://17931456


Swift SVN r21172
2014-08-13 10:51:26 +00:00
Dmitri Hrybenko
6770802036 stdlib: mark Optional initializers as transparent
Swift SVN r21171
2014-08-13 09:47:52 +00:00
Dmitri Hrybenko
502b4bf67b stdlib: coding style, trailing whitespace
Swift SVN r21170
2014-08-13 09:47:49 +00:00
Doug Gregor
8df878c02a Give CGRect/CGSize/CGVector initializers that take Doubles.
Now that CGFloat is its own distinct type, it's useful to have Double
initializers to go along with the Int initializers we added a while
back <rdar://problem/17224725>.

Swift SVN r21156
2014-08-12 21:54:50 +00:00