Commit Graph

21803 Commits

Author SHA1 Message Date
Dmitri Hrybenko
4cf865de73 stdlib: factor all _NSXXXBase classes to a single place
Swift SVN r21969
2014-09-16 11:13:06 +00:00
Dmitri Hrybenko
c756296373 stdlib/Array: annotate invalid bitcasts
Swift SVN r21968
2014-09-16 10:25:31 +00:00
Greg Parker
0aef787331 Use read-write locks to protect metadata caches.
Fixes rdar://18346143.


Swift SVN r21966
2014-09-16 02:48:14 +00:00
Joe Groff
1c4e08a9c8 Fix up a tangle of issues related to reabstraction.
- A spot fix in SILGen for reabstracting the result of a downcast, which fixes checked casts to function types.
- Associate the layout information in type metadata records with the most abstract representation of the type. This is the correct thing to do in cases where we need the metadata as a tag for an opaque value--if we store a value in an Any, or pass it as an unconstrained generic parameter, we must maximally reabstract it. This fixes the value semantics of existentials containing trivial metatypes.
- To ensure that we get runtime layout of structs and enums correct when they contain reabstractable types, introduce a "metadata for layout" concept, which doesn't need to describe the canonical metadata for the type, but only needs to describe a type with equivalent layout and value semantics. This is a correctness fix that allows us to correctly lay out generic types containing dependent tuples and functions, and although we don't really take advantage of it here, it's also a potential runtime performance win down the road, because we could potentially produce direct metadata for a primitive type that's layout-equivalent with a runtime-instantiated type. To aid in type safety here, push SILType deeper into IRGen in places where we potentially care about specific representations of types.
- Finally, fix an inconsistency between the runtime and IRGen's concept of what spare bits unmanaged references and thick metatypes have.

Together, these fixes address rdar://problem/16406907, rdar://problem/17822208, rdar://problem/18189508, and likely many other related issues, and also fixes crash suite cases 012 and 024.

Swift SVN r21963
2014-09-16 01:44:34 +00:00
Greg Parker
215d852f8d Fix cached metadata lookup for generics that have an address point offset.
Attempt to detect thread races in metadata caches.


Swift SVN r21962
2014-09-16 01:27:38 +00:00
Doug Gregor
d93eaed9f7 Switch BooleanLiteralConvertible over to an initializer requirement.
Conforming to BooleanLiteralConvertible now requires

  init(booleanLiteral: Bool)

rather than

  static func convertFromBooleanLiteral(value: Bool) -> Self

This posed a problem for NSNumber's conformance to
BooleanLiteralConvertible. A class needs a required initializer to
satisfy an initializer requirement, but one cannot add a required
initializer via an extension. To that end, we hack the Clang importer
to import NSNumber's initWithBool with the name

  init(booleanLiteral:)

and add back the expected init(bool:) initializer in the
overlay. These tricks make NSNumber even harder to subclass, but we
don't really care: it's nearly impossible to do well anyway, and is
generally a Bad Idea.

Part of rdar://problem/18154091.

Swift SVN r21961
2014-09-15 23:59:30 +00:00
Anna Zaks
22b4dcda36 Create an overlay for ALAssetsLibrary:enumerateGroupsWithTypes which accepts ALAssetsGroup types.
This is a case of type mismatch due to the parameter type not being a proper
NS_OPTIONS enum. However, it crashes at runtime on 32 bit, so let's introduce an
overlay while waiting for the proper fix.

Addresses radar://18201112

Swift SVN r21957
2014-09-15 22:10:51 +00:00
Anna Zaks
ec46eefb2f Overload dispatch_get_global_queue to work with QOS_CLASS.. constants
Addresses radar://18272350

Swift SVN r21956
2014-09-15 22:10:50 +00:00
Dmitri Hrybenko
03e2717f0a stdlib/Array: add bounds checks to NSSwiftArray.objectAtIndex()
rdar://18336202

Swift SVN r21945
2014-09-15 15:50:43 +00:00
Dmitri Hrybenko
df82379a65 stdlib/Array: add bounds checks in NSSwiftArray.getObjects()
rdar://18320164

Swift SVN r21943
2014-09-15 15:26:49 +00:00
Dmitri Hrybenko
cdbd3bae84 stdlib/Dictionary: remove workaround that is no longer needed
Swift SVN r21942
2014-09-15 14:08:56 +00:00
Dmitri Hrybenko
50d497c05f stdlib/Array: fix an issue in fast enumeration
Array did not initialize fast enumeration state if it was empty.
Surprisingly, this did not break code that is generated by Clang
currently.  (But as far as I understand fast enumeration, it may abort
the program because mutation pointer is null.)

Swift SVN r21940
2014-09-15 13:49:56 +00:00
Dmitri Hrybenko
4a1dfdb6ad stdlib/Array: remove default parameters in bridging routines, and
reorder function declarations

Swift SVN r21938
2014-09-15 07:08:09 +00:00
Dmitri Hrybenko
001db58bb1 stdlib: remove trailing whitespace and fix coding style
Swift SVN r21906
2014-09-12 13:23:21 +00:00
Dmitri Hrybenko
d7acb06c64 stdlib/Dictionary: use 'delayed bridging' to keep pointers, returned
from a bridged NSDictionary, stable

We used to return a fresh pointer value every time an NSDictionary
element is requested, but, unfortunately, our SDK has bugs.

Fixes rdar://18191358 for Dictionary.

Swift SVN r21905
2014-09-12 13:20:30 +00:00
Joe Groff
8338e69c86 Actually set up the 'rawValue' argument label on derived enum initializers.
Somehow, protocol conformance checking didn't actually care that this was missing...

Swift SVN r21898
2014-09-12 01:29:51 +00:00
Dave Abrahams
213f59e546 [stdlib] doc-comment Arrays.swift.gyb
Swift SVN r21897
2014-09-12 00:35:09 +00:00
Dave Abrahams
8ec2b299f3 [stdlib] Algorithm.swift: doc-comment public API
Swift SVN r21890
2014-09-11 20:20:19 +00:00
Joe Groff
491e47cb83 Rename RawRepresentable.raw -> rawValue.
Per API review with Ali. While we're here, give the initializer a corresponding 'rawValue' argument label, and change the associated type name to RawValue to match.

Swift SVN r21888
2014-09-11 20:13:47 +00:00
Dave Abrahams
107dca088c [stdlib] Separate Sequence type for enumerate
Avoids surprise in case someone makes a generator with reference
semantics

Swift SVN r21886
2014-09-11 19:57:20 +00:00
Dave Abrahams
1e9e7734f0 Revert "[stdlib] any/all algorithms, keyword for contains"
This reverts r21810 and r21811 due to lack of design consensus

Swift SVN r21880
2014-09-11 17:42:32 +00:00
Dmitri Hrybenko
d3be963abf RaceTest: add radar references for bug workarounds
Swift SVN r21876
2014-09-11 16:07:42 +00:00
Dmitri Hrybenko
d68a5c4c98 stdlib: finish implementation of atomics for initializing an ARC
reference, add tests

Swift SVN r21873
2014-09-11 14:52:58 +00:00
Dmitri Hrybenko
a61e4c205a stdlib: document that sort() is not a stable sort
Swift SVN r21870
2014-09-11 10:59:50 +00:00
Dmitri Hrybenko
5000a983a6 stdlib/Unmanaged: change the precondition for non-null pointer to a
debug precondition

Swift SVN r21869
2014-09-11 08:52:55 +00:00
Dave Abrahams
904e0c4203 [stdlib] Fix sorted()
Remove the overload for MutableCollectionType and make it return a
regular Array, as the comment said.  Together with r21829 this fixes
<rdar://problem/18286522>

Swift SVN r21844
2014-09-10 19:05:12 +00:00
Dmitri Hrybenko
756d129ec6 Rename StdlibUnittest.{getPtr -> getPointer}
Swift SVN r21839
2014-09-10 14:41:20 +00:00
Dmitri Hrybenko
b68d147ca1 stdlib/Unmanaged: trap when attempting to create an Unmanaged from a
null pointer

Swift SVN r21838
2014-09-10 14:15:06 +00:00
Dmitri Hrybenko
4b19606551 stdlib: fix definition of atomics for 32-bit platforms
Swift SVN r21837
2014-09-10 13:05:14 +00:00
Dmitri Hrybenko
96d00d70b5 StdlibUnittest: add infrastructure for race tests (see examples)
This will be used to test rdar://18191358

Swift SVN r21836
2014-09-10 11:58:45 +00:00
Dmitri Hrybenko
1bac1e6855 stdlib/Dictionary: convert some 'var's to 'let's
Swift SVN r21835
2014-09-10 11:38:44 +00:00
Dmitri Hrybenko
57983579ac stdlib: move declarations of runtime entry points for atomics to
Runtime.swift.gyb

Swift SVN r21832
2014-09-10 08:07:45 +00:00
Dave Abrahams
09793716cb [stdlib] try to measure sequences before array-izing
When creating an array from a SequenceType not statically known to be a
CollectionType, don't neglect to pre-allocate based on its
underestimated count.

Swift SVN r21829
2014-09-10 03:21:14 +00:00
Jordan Rose
d438ebc228 Sink Swift's adapter for NSZone into the ObjectiveC overlay.
While Foundation actually defines the NSZone typedef and what you can do with
it, the ObjectiveC module makes use of it in its raw form: "struct _NSZone *".
To avoid a circular dependency, sink our adapter down to the ObjectiveC
overlay.

Swift SVN r21827
2014-09-10 02:32:52 +00:00
Anna Zaks
122ea9dc92 Add overlay cover for dispatch_data_empty
Swift SVN r21821
2014-09-10 00:50:43 +00:00
Dave Abrahams
c467825bc2 [stdlib] any/all algorithms, keyword for contains
Expose any, all on Array and all the Lazy sequence adapters.  Make the
'contains' algorithm that takes a predecate unavailable in favor of
'any', which does the same thing.

Fixes <rdar://problem/18190149> [algorithm] `contains` syntax is ambiguous

Swift SVN r21810
2014-09-09 20:39:39 +00:00
Dave Abrahams
69075bc61d [stdlib] Kill unintended argument label
Fixes <rdar://problem/18232095> Remove mandatory keyword from generic String init

Swift SVN r21801
2014-09-09 03:50:40 +00:00
Anna Zaks
7be3363210 Reapply Swift Overlay: Make most common security return codes work with OSStatus
This reverts commit 043dbaafa20f3a1bbb1c71cd748a651ad57ba7b4.

Swift SVN r21794
2014-09-09 01:47:03 +00:00
Dmitri Hrybenko
6a85dc4c0f stdlib: fix strange indentation
Swift SVN r21769
2014-09-08 08:33:37 +00:00
Joe Groff
419ba5cbea Change RawRepresentable to use failable initializers and property requirements.
Redefine the RawRepresentable protocol to use an 'init?' method instead of 'fromRaw(Raw)', and a 'raw' get-only property instead of 'toRaw()'. Update the compiler to support deriving conformances for enums and option sets with the new protocol. rdar://problem/18216832

Swift SVN r21762
2014-09-06 18:40:14 +00:00
Anna Zaks
ecf471bbff Revert "Swift Overlay: Make most common security return codes work with OSStatus"
This is causing buildbot breakage while building the Security library.

Swift SVN r21761
2014-09-06 05:30:23 +00:00
Anna Zaks
d51c1736f0 Swift Overlay: Make most common security return codes work with OSStatus
Swift SVN r21759
2014-09-06 00:46:21 +00:00
Anna Zaks
412d59009c CGVector initializers should have named parameters.
This ensures they are consistent with other types like CGPoint.

Swift SVN r21758
2014-09-06 00:46:19 +00:00
Dmitri Hrybenko
7d51b2b7fe stdlib: improve comment for sorted() overload with predicate and reduce
comment duplication with gyb code

Swift SVN r21742
2014-09-05 15:27:25 +00:00
Michael Gottesman
e8df864581 [stdlib] Change _fixLifetime<T> to use Builtin.fixLifetime now that we lower fix_lifetime to swift_keepAlive in IRGen.
Also remove the old swift_keepAlive and rename swift_keepAlive2 => swift_fixLifetime.

rdar://16464507

Swift SVN r21723
2014-09-04 22:58:37 +00:00
Michael Gottesman
9514ba5a7d [irgen] Lower fix_lifetime => swift_keepAlive().
I introduced a function swift_keepAlive2() which has a different signature from
swift_keepAlive() until I can verify that the stdlib is using the new
infrastructure.

The difference in signature is that swift_keepAlive2 takes just a pointer while
swift_keepAlive also takes a metadata value that is not necessary for our
purposes anymore.

Swift SVN r21718
2014-09-04 21:53:18 +00:00
Dmitri Hrybenko
2f15883283 stdlib/NSString APIs: fix indentation
Swift SVN r21713
2014-09-04 18:06:37 +00:00
Doug Gregor
eaefb5e2b0 String's NSString API: Replace factory methods with failable initializers.
Addresses rdar://problem/18225788.


Swift SVN r21710
2014-09-04 17:21:33 +00:00
Dmitri Hrybenko
149d3aaa8f stdlib: docs: sort() is not a stable sort
rdar://17570356


Swift SVN r21703
2014-09-04 11:27:53 +00:00
Doug Gregor
692ff2f52a Enable imports of failable initializers by default.
Swift SVN r21699
2014-09-04 06:32:12 +00:00