Commit Graph

4650 Commits

Author SHA1 Message Date
Dmitri Gribenko
b1fdf56f5c stdlib: mark _preprocessingPass with @noescape 2015-12-23 14:56:15 -08:00
Dmitri Gribenko
2c20730419 stdlib: use more idiomatic closure syntax 2015-12-23 14:56:15 -08:00
Arsen Gasparyan
adccf23037 Simplifying the Bool creation with NSNumber 2015-12-24 01:20:37 +03:00
Doug Gregor
9369c4eb78 SpriteKit overlay: remove the subscript from SKNode
In iOS 8.0/OS X 10.10, SpriteKit introduced an
-objectForKeyedSubscript: method that enabled subscripting in
Objective-C. However, this subscript wasn't generally useful in Swift
because it took AnyObject and produced AnyObject, so the SpriteKit
overlay defined a subscript that took a String and produced an
[SKNode].

Subsequently, in iOS 9.0/OS X 10.10, -objectForKeyedSubscript: got
type annotations that gave it the appropriate Swift signature, which
made the subscript defined in the overlay redundant.

The twisty logic of the Clang importer would suppress the imported
subscript when it saw the one in the overlay, hiding the
redundancy. My cleanup of that logic in
0c0a0fab4b caused uses of the subscript
to be redundant.

Removal of the redundant code in the overlay is the overall best
answer, because it minimizes the size of the overlay and leaves the
API in the Objective-C header. However, this will introduce a
regression for SpriteKit applications targeting iOS 7.0/OS X 10.8,
where the overlay was compensating for the lack of this operation
before iOS 8.0 / OS X 10.8. There are workarounds here we can
investigate, although they're fairly hacky.
2015-12-23 14:17:14 -08:00
Joe Groff
1092704f78 Remove unused static function. 2015-12-23 13:34:47 -08:00
Joe Groff
fe4782ef05 Runtime: Rename swift_isClassOrObjCExistential to -Type.
To conform with the other 'is*Type' queries.
2015-12-23 13:34:47 -08:00
Joe Groff
8edde2c503 Runtime: Push swift_demangleSimpleClass into XCTest overlay.
The only place it's used.
2015-12-23 11:19:42 -08:00
Dmitri Gribenko
3877d04a73 Merge pull request #731 from ken0nek/add-spaces-before-and-after-arrow
Add spaces before and after closure arrow
2015-12-23 10:53:22 -08:00
Max Moiseev
200be71583 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-23 10:28:04 -08:00
Joe Groff
359e18f54f Runtime: Internalize 'usesNativeSwiftReferenceCounting_nonnull' check.
It's used as a helper by some other entry points, but isn't used outside the runtime.
2015-12-23 09:17:09 -08:00
Joe Groff
a3354c70ed Runtime: Remove extern "C" from non-API helper function. 2015-12-23 09:17:08 -08:00
Joe Groff
46cd14efbd Runtime: Move Unicode utilities to stdlib.
These are used by String; they aren't part of the core runtime.
2015-12-23 09:17:08 -08:00
Joe Groff
4b461684e3 Remove unused _swift_isClass function. 2015-12-23 09:17:08 -08:00
Joe Groff
bdffe703b0 Runtime: Rename reportMissingMethod to deletedMethodError.
The runtime entry doesn't just report the error, unlike the other report* functions, it also does the crashing.
2015-12-23 09:17:07 -08:00
practicalswift
81e7439a9a Fix typos. 2015-12-23 11:16:34 +01:00
John McCall
b1e3120a28 Include access functions for the metadata and witness tables
of associated types in protocol witness tables.

We use the global access functions when the result isn't
dependent, and a simple accessor when the result can be cheaply
recovered from the conforming metadata.  Otherwise, we add a
cache slot to a private section of the witness table, forcing
an instantiation per conformance.  Like generic type metadata,
concrete instantiations of generic conformances are memoized.

There's a fair amount of code in this patch that can't be
dynamically tested at the moment because of the widespread
reliance on recursive expansion of archetypes / dependent
types.  That's something we're now theoretically in a position
to change, and as we do so, we'll test more of this code.
2015-12-23 00:37:24 -08:00
Dmitri Gribenko
b703259ca6 Merge pull request #736 from nielsandriesse/patch-1
[stdlib] Fix reserveCapacity() call in RangeReplaceableCollectionType +(_:_:)
2015-12-22 16:22:17 -08:00
Doug Gregor
5b35c786b8 Standard library unit testing: use static "#if" for OS kind determination.
There is absolutely no point in making this a runtime check, because
the library will be built differently on the different platforms
anyway. We only need to determine the version at runtime.
2015-12-22 16:18:28 -08:00
Slava Pestov
36ddea64ae Merge pull request #729 from ken0nek/fix-can-not
Convert [Cc]an not -> [Cc]annot
2015-12-22 16:06:20 -08:00
Joe Groff
d3cba67344 Runtime: Move assert implementation details to stdlib.
Many of the report* entry points are specific to the stdlib assert implementation, so belong in the stdlib. Keep a single `reportError` entry point in the runtime to handle the CrashReporter/ASL interface, and call down to it from the assert implementation functions.
2015-12-22 15:54:42 -08:00
Niels Andriesse
6381ec6114 [stdlib] Remove redundant +(_:_:) overload in RangeReplaceableCollectionType 2015-12-23 10:53:01 +11:00
Niels Andriesse
56a995f0df [stdlib] Add performance optimization in RangeReplaceableCollectionType +(_:_:) 2015-12-23 10:51:37 +11:00
Chris Lattner
5bcd4bc3bd Merge pull request #738 from practicalswift/another-typo-round
[Typos] Fix typos
2015-12-22 15:41:49 -08:00
practicalswift
6e3b700b44 Fix typos. 2015-12-23 00:31:13 +01:00
Slava Pestov
e0451c8f70 IRGen: Redo concrete subclasses of generic classes
Now, such classes will emit a metadata pattern and use the
generic metadata instantiation logic.

This was all wired up to handle the case of no generic
parameters previously, to support resilient struct layout
in the runtime.

The swift_initializeSuperclass() entry point still exists,
providing a fast path for when there's no field layout to
do, which is currently always true if we have a concrete
class.

This entry point no longer needs the global lock, since
now we get a per-class lock from the metadata cache.
Also, previously we would call the superclass accessor
function on every access of class metadata for a concrete
subclass of a generic class. Now that we re-use the
existing metadata cache logic, this extra call only occurs
during initialization.

Both swift_initializeSuperclass() and
swift_initClassMetadata_UniversalStrategy() used to take
the superclass as a parameter, but this isn't really
necessary, since it was loaded out of the class metadata
immediately prior to the call by the caller. Removing
this parameter makes the ABI a little simpler.

Once class layout supports resilient types, we will also
use swift_initClassMetadata_UniversalStrategy() to lay
out classes with resilient types as fields.

Singleton metadata caches will still allocate a copy of
the template, which is a slight performance regression
from the previous implementation of concrete subclasses
of generic classes. This will be optimized soon.

Right now, the template can always be modified in place;
in the future, it will be possible to modify in place as
long as the superclass is fixed-layout; a resilient superclass
might add or remove fields, thus we cannot leave room for
it in the metadata of the subclass, and will need to grow
the metadata and slide field offsets at runtime using a
new entry point.

Also, the representation of the cache itself could be
optimized to handle the singleton case, since all we
really need here is a lock without any kind of mapping
table.
2015-12-22 15:30:17 -08:00
Slava Pestov
096ea38ae1 Runtime: Factor out "class has formal superclass" logic, NFC 2015-12-22 15:30:17 -08:00
Slava Pestov
68fa74af10 Runtime: Don't use gcc ?: extension, NFC 2015-12-22 15:30:17 -08:00
Niels Andriesse
c333aed696 [stdlib] Fix reserveCapacity() call in RangeReplaceableCollectionType +(_:_:) 2015-12-23 10:01:36 +11:00
Joe Groff
e1589a0a3a Runtime: Implement convertNSErrorToErrorType and v.v. in Swift.
These are compiler hooks that belong in the Foundation overlay; they don't need to be in the core runtime.
2015-12-22 14:41:23 -08:00
Joe Groff
4b7ed84c42 Revert "Runtime: Remove retainCount entry points."
This reverts 51e0594e1c. The corelibs are using this entry point.
2015-12-22 13:06:42 -08:00
Joe Groff
37b827c8c5 stdlib: Override ObjC weak support in SwiftNativeNSXXXBase to use Swift refcounting.
Noticed by inspection.
2015-12-22 11:52:34 -08:00
ken0nek
e7e70cea92 Add spaces before and after closure arrow in stdlib 2015-12-23 04:52:15 +09:00
Joe Groff
51e0594e1c Runtime: Remove retainCount entry points.
They're only used for testing and ObjC interop, so don't need to be exported from the runtime.
2015-12-22 11:51:59 -08:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00
Max Moiseev
51865a17b2 _debugRequire => _stdlibAssert etc. 2015-12-22 10:18:36 -08:00
Max Moiseev
547b6501c9 Fixing the build after merge 2015-12-22 10:14:18 -08:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
Dmitri Gribenko
7be67b5476 Merge pull request #721 from jasonnoahchoi/prespecialized
Change c-style for loop to for-in loop based on proposal SE-0007
2015-12-22 03:17:39 -08:00
Slava Pestov
c35d9bd092 IRGen: Simplify generated code for generic class metadata instantiation
Move the following from IRGen to runtime:

- Copying generic parameters from superclass to subclass
- Copying field offsets from superclass to subclass
- Initializing the Objective-C runtime name of the subclass

This eliminates some duplication between the generic subclass and
concrete subclass of a generic class cases.

Also this should reduce generated code size and have no impact on
performance (the instantiation logic only runs once per substituted
type).
2015-12-22 02:09:03 -08:00
Suguru Kishimoto
b87782d95e [Fix] Use count += 1 instead of count++ . 2015-12-22 18:14:20 +09:00
Jason Choi
ad1a15d0b0 Change c-style for loop to for-in loop based on proposal SE-0007 2015-12-22 01:01:11 -08:00
Dmitri Gribenko
b1b3822506 Merge pull request #572 from patters/remove-bad-comment
Remove outdated, incorrect comment
2015-12-21 22:58:12 -08:00
Chris Lattner
be53728691 Mark the ++ and -- operators in the standard library as deprecated for Swift 2.2,
to be removed in Swift 3.0.  I plan to improve the QoI of this deprecation in a
subsequent commit.
2015-12-21 22:10:25 -08:00
Chris Lattner
b85992eeb5 fix typo from the previous commit that led to validation test failures. 2015-12-21 20:57:15 -08:00
Chris Lattner
685b4ede1f Reapply: Remove the last uses of ++/-- from the stdlib directory.
This reverts commit fc6a406a56.
2015-12-21 20:54:28 -08:00
Chris Lattner
66f7ef1295 Move stdlib off ++ and -- 2015-12-21 18:07:36 -08:00
Chris Lattner
d5dba4eda2 Move stdlib/private off ++/-- 2015-12-21 18:07:36 -08:00
Joe Groff
cf87b9d571 IRGen: Generate swift_fixLifetime marker as a private stub.
This lets us remove `swift_fixLifetime` as a real runtime entry point. Also, avoid generating the marker at all if the LLVM ARC optimizer won't be run, as in -Onone or -disable-llvm-arc-optimizer mode.
2015-12-21 18:06:18 -08:00
Joe Groff
a5ba9e06cd Runtime: Remove unused swift_allocPOD implementation.
A vestige of the old box implementation that's now dead.
2015-12-21 18:06:18 -08:00
Michael Gottesman
fc6a406a56 Revert "Remove the last uses of ++/-- from the stdlib directory."
This reverts commit 0caebf2fb4.
2015-12-21 19:21:38 -06:00