Commit Graph

21502 Commits

Author SHA1 Message Date
Dmitri Hrybenko
3ca4c987f8 stdlib/Fixed point: switch allZeros to be a static property
Swift SVN r18490
2014-05-21 11:31:21 +00:00
Dmitri Hrybenko
2fc5297171 stdlib/Slice: relax assertion to allow Slice<T> to be constructed from a native
empty buffer without storage

rdar://16971593 rdar://16388632


Swift SVN r18489
2014-05-21 11:01:55 +00:00
Dmitri Hrybenko
4693583767 stdlib/Join: fix an ambiguity in 'ExtensibleCollection + ExtensibleCollection'
Allows to use '+' on arrays.

rdar://16984439 rdar://16388632


Swift SVN r18488
2014-05-21 09:32:51 +00:00
John McCall
5ddee671b6 Provide a hacky hook for specifying a class's instance size
and alignment for the purposes of deallocation.

If a class contains a method named __getInstanceSizeAndAlignMask,
and it takes no arguments and returns a pair of words, call
that method directly in order to get the size and alignment
mask instead of trusting the class's formal size and alignment.

This is not a replacement for a proper language solution for
custom allocation, but it'll suffice to fix some immediate
problems with HeapBufferStorage.

If we decide we like this approach, we should really raise
the deallocating destructor up to SIL.

rdar://16979846

Swift SVN r18485
2014-05-21 07:22:39 +00:00
Joe Pamer
1d34a88477 Revert "Fix two problems with implicit conversions: - rdar://problem/16776273, wherein conversions between nil and .None were permitted due to an implicit conversion between nil and COpaquePointer. - rdar://problem/16877526, where we needed to add new equality overloads to handle conversions between nil and .None given the supression of user conversions. (Thanks to Ted for the overloads and test.)"
This reverts commit r18473.

Swift SVN r18477
2014-05-21 00:28:46 +00:00
John McCall
5c3f40c301 Use a data structure with stable pointers for the Objective-C
unowned reference side table.

rdar://16981772

Swift SVN r18476
2014-05-21 00:22:02 +00:00
John McCall
4fccb0607e Don't leak the allocation for objects with outstanding
weak references at deallocation time.

Also, directly call swift_slowDealloc in swift_weakRelease
instead of incorrectly recursing back into
swift_deallocObject.

Also document the correctness of the fast-path check
we do in swift_deallocObject.

rdar://16967569

Swift SVN r18475
2014-05-21 00:22:00 +00:00
Joe Pamer
f469d8f1f6 Fix two problems with implicit conversions:
- rdar://problem/16776273, wherein conversions between nil and .None were permitted
due to an implicit conversion between nil and COpaquePointer.
- rdar://problem/16877526, where we needed to add new equality overloads to handle
conversions between nil and .None given the supression of user conversions.
(Thanks to Ted for the overloads and test.)

Swift SVN r18473
2014-05-20 23:53:34 +00:00
Dave Zarzycki
98ce4f3956 Heap: add an assert that would have caught 16979846
Once 16979846 is fixed, we can double check sizes at free time to ensure
that we're putting them on the right free list.

Swift SVN r18471
2014-05-20 23:23:57 +00:00
Greg Parker
e2ca13c993 <rdar://16529903> Make UIViewController's nib search find Swift class names.
UIViewController is able to find nib files that have names derived from the 
UIViewController subclass's name. This change modifies UIViewController's 
lookup so it is able to find nib files for Swift class names.


Swift SVN r18470
2014-05-20 23:14:52 +00:00
Dave Zarzycki
b46851397c Heap: add missing lock/unlock
Swift SVN r18468
2014-05-20 21:26:25 +00:00
Dave Zarzycki
46a77283e1 Heap: track the last allocation per arena correctly
Swift SVN r18466
2014-05-20 21:21:13 +00:00
Nadav Rotem
499eeb8629 revert 18464.
Swift SVN r18465
2014-05-20 21:13:37 +00:00
Nadav Rotem
5b7564fafd Deduplicate the isNative check. NFC.
Swift SVN r18464
2014-05-20 21:04:07 +00:00
Joe Groff
38130ca9db Remove uniqueness forcing from CMutablePointer array conversion.
Arrays aren't value types anymore, so this is no longer correct. Fixes <rdar://problem/16970879>.

Swift SVN r18455
2014-05-20 17:21:21 +00:00
Dmitri Hrybenko
8910632338 stdlib/Dictionary: allow NSDictionary to be bridged to Dictionary<K, V> non-verbatim
Dictionary's isBridgedToObjectiveC() was overly restrictive.  This went
unnoticed because the tests were using internal Dictionary APIs to construct
the desired state, instead of going thourgh casts.

rdar://16973429


Swift SVN r18454
2014-05-20 16:06:52 +00:00
Dmitri Hrybenko
bbf7b0af98 stdlib/Dictionary: add 'removeAll:' API
rdar://16953595

Swift SVN r18453
2014-05-20 14:52:01 +00:00
Dmitri Hrybenko
652859f301 stdlib/Array: reduce duplication in ExtensibleCollection conformances
Swift SVN r18452
2014-05-20 12:45:03 +00:00
Dmitri Hrybenko
36a5eaeb8e stdlib/Array: all array types are ExtensibleCollections
Swift SVN r18451
2014-05-20 12:04:57 +00:00
Dmitri Hrybenko
46790743be stdlib/Join: new: add a generic join() function that behaves like NSArray's
componentsJoinedByString:, or Python's join(), but is generic, operating on any
ExtensibleCollection

Part of rdar://16388632


Swift SVN r18450
2014-05-20 11:56:15 +00:00
Dmitri Hrybenko
f51ebe8444 stdlib/Assert: fix typo in internal API name
Swift SVN r18436
2014-05-19 22:47:57 +00:00
Dave Zarzycki
4c6b8d070f Runtime: Lock the metadata caches
This fixes: <rdar://problem/15889015>

Swift SVN r18434
2014-05-19 22:30:00 +00:00
Dmitri Hrybenko
bbc6a92a4c stdlib/Assert: don't print stdlib filename and line number in stdlib traps
rdar://16958193


Swift SVN r18431
2014-05-19 21:37:51 +00:00
Dave Abrahams
418bec853f [stdlib] 1-character fix for Array.reserve
...plus the testing that makes that fix stick.  Fixes <rdar://16958865>

Swift SVN r18429
2014-05-19 21:20:48 +00:00
Dave Abrahams
4d4a7e9622 [stdlib] Add UnsafePointer precondition checks
We had array code attempting to do things with negative element counts;
let's catch those errors!

Swift SVN r18428
2014-05-19 21:20:47 +00:00
Dave Zarzycki
19987bfc59 Runtime: fix zeroing weak
This bug was a result of code drift between the hand written assembly
and the generic code. Thankfully we disabled the hand written assembly a
while a go, which made this bug easier to find.

This fixes: <rdar://problem/16954674>

Swift SVN r18425
2014-05-19 18:22:32 +00:00
Joe Groff
182986b595 Use swift_unknownRelease instead of swift_release in swift_bridgeNonVerbatimFromObjectiveC.
Swift SVN r18424
2014-05-19 18:08:24 +00:00
Dmitri Hrybenko
2bc1088de3 stdlib/Dictionary: finish removing the assumption that keys and values are
bridged back from Objective-C verbatim

The internal API assertingGet(KeyType) is dead code now, so no tests.


Swift SVN r18421
2014-05-19 14:56:32 +00:00
Dmitri Hrybenko
af11f8f8b7 stdlib/Dictionary: continue removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes == operator.


Swift SVN r18420
2014-05-19 14:48:53 +00:00
Doug Gregor
5c532d6111 Introduce a fast path for Array.bridgeFromObjectiveC()
We were using the bridged non-verbatim path
(_arrayBridgeFromObjectiveC) for bridged-verbatim types. While that
path can do the right thing (and does when the standard library's
internal checking is turned off), it's unnecessarily inefficient.

Swift SVN r18418
2014-05-19 14:18:39 +00:00
Dmitri Hrybenko
0d20e71f51 stdlib/Dictionary: continue removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes generate: API and DictionaryGenerator.


Swift SVN r18415
2014-05-19 11:48:44 +00:00
Dmitri Hrybenko
6d3026266f stdlib/Dictionary: continue removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes removeValueForKey: API.


Swift SVN r18413
2014-05-19 11:33:25 +00:00
Dmitri Hrybenko
2aabfeaaca stdlib/Dictionary: remove comment that is no longer true
Swift SVN r18412
2014-05-19 11:21:07 +00:00
Dmitri Hrybenko
72354e8a47 stdlib/Dictionary: continue removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes removeAtIndex: API.


Swift SVN r18411
2014-05-19 11:20:34 +00:00
Dmitri Hrybenko
c4492b4544 stdlib/Dictionary: continue removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes subscript(KeyType) API.


Swift SVN r18409
2014-05-19 10:36:11 +00:00
Dmitri Hrybenko
785aabd53e stdlib/Dictionary: start removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes subscript(Index) API.


Swift SVN r18408
2014-05-19 10:03:59 +00:00
Doug Gregor
57f75b7448 Implement bridging from NSNumber to Int/UInt/Float/Double/Bool.
This makes fun bridging like

  var obj: AnyObject! = [3.14159, 2.71828, 0] as Double[]
  if let intArr = obj as Int[] {
    println("Array of doubles as ints is \(intArr)")
  }

"work", given that NSNumber is the common class type through which we
are bridging.




Swift SVN r18398
2014-05-19 07:33:15 +00:00
Dave Abrahams
fba449f83d [stdlib] Add an eager reverse() for Array
Swift SVN r18390
2014-05-19 04:40:39 +00:00
Dave Abrahams
13962588a9 [stdlib] add reverse(c), s/Reverse/ReverseView/g
Now reverse() is available as a peer to map() and filter()
Addresses <rdar://problem/15919204>

Swift SVN r18389
2014-05-19 04:30:16 +00:00
John McCall
f7c2aed668 Add an implicit conversion from CFString to String.
Unfortunately, we can't add an implicit conversion from
String to CFString, or anything analogous like string
literal support, without introducing ambiguities
when converting to AnyObject.

rdar://16271682

Swift SVN r18387
2014-05-19 04:00:46 +00:00
Dave Abrahams
d17c4171da [stdlib] 80-column fixes
Swift SVN r18382
2014-05-19 02:08:19 +00:00
Dave Abrahams
5a4891a2db [stdlib] make Array.replaceRange be a method
By beating the compiler into submission with a "bouncing through
non-methods" method, I have made it accept my crazed intention that
Array and friends should interoperate with all Sequences and
Collections!  Filing <rdar://problem/16954833> to document the failure
of the method method.

Swift SVN r18378
2014-05-19 01:08:08 +00:00
Dave Abrahams
6dade3f1c8 [stdlib] Test Array.removeLast
Also improve its failure message

Swift SVN r18376
2014-05-19 00:36:37 +00:00
Dave Abrahams
1622fa5b9d [stdlib] assert => _precondition/_sanityCheck
Swift SVN r18374
2014-05-19 00:27:37 +00:00
Doug Gregor
bb95a324f9 Introduce new entry point _arrayBridgeFromObjectiveC for checked T[] -> U[] conversions.
This entry point is used when T is bridged verbatim and U is bridged
non-verbatim. It attempts to bridge each T from Objective-C to a U,
and returns nil if any of the elements cannot be bridged back to a U.

For now, only _convertNSArrayToArray and Array.bridgeFromObjectiveC
depend on this. It will soon be used for checked casts from, e.g.,
AnyObject[] to String[].

This is part of <rdar://problem/16952771> and general array bridging.

Swift SVN r18369
2014-05-18 23:44:27 +00:00
Dave Abrahams
8537f014bf [stdlib] Add lazy and Array filter algorithm
This came up during API review

Swift SVN r18364
2014-05-18 22:24:43 +00:00
Dmitri Hrybenko
a3ef3a8671 stdlib: sort file list
Swift SVN r18360
2014-05-18 22:00:58 +00:00
Dave Zarzycki
94d5c81b4b Heap: ignore arena tail loss during enumeration
<rdar://problem/16953578> SwiftZone malloc enumeration is returning "PTR_IN_USE" blocks that extend past their VM region

Swift SVN r18352
2014-05-18 21:12:21 +00:00
Dave Abrahams
241f4e9b46 [stdlib] Avoid Suicide Sequences
In a naive implementation of a Sequence adapter, adapting a
non-self-destructive (multi-pass) Sequence having a reference-semantics
Generator produces a self-destructive adapted view.  This is technically
correct because Sequences are allowed to be self-destructive, and
theoretically every multi-pass Sequence would be a Collection.  However
Sequences are much easier to build than Collections, so users are likely
to make them, and it would be extremely surprising if adapting a
self-preserving Sequence yielded a self-destructive one.

Swift SVN r18350
2014-05-18 20:38:33 +00:00
Doug Gregor
4e5f69c259 Try to fix build on ARM32.
Swift SVN r18349
2014-05-18 20:36:39 +00:00