- All parts of the compiler now use ‘P1 & P2’ syntax
- The demangler and AST printer wrap the composition in parens if it is
in a metatype lookup
- IRGen mangles compositions differently
- “protocol<>” is now “swift.Any”
- “protocol<_TP1P,_TP1Q>” is now “_TP1P&_TP1Q”
- Tests cases are updated and added to test the new syntax and mangling
If there's no better mapping for a Swift value into an Objective-C object for bridging purposes, we can fall back to boxing the value in a class. This class doesn't have any public interface beyond being `NSObject`-conforming in Objective-C, but is recognized by the Swift runtime so that it can be dynamically cast back to the boxed type.
The general rule here is that something needs to be SWIFT_CC(swift)
if it's just declared in Swift code using _silgen_name, as opposed to
importing something via a header.
Of course, SWIFT_CC(swift) expands to nothing by default for now, and
I haven't made an effort yet to add the indirect-result / context
parameter ABI attributes. This is just a best-effort first pass.
I also took the opportunity to shift a few files to just implement
their shims header and to demote a few things to be private stdlib
interfaces.
Fixes a leak when a bridgeable value type is dynamically cast to a class type, and the cast fails, for instance:
```
let x: Any = "string"
x is NSNumber
```
We would fail to release the bridging object after attempting the cast.
- added read / write lock support
- added non-fatal error support to allow use of mutex in fatal error reporting pathway
- isolated pthread implementation to it own header/cpp file pair
- expanded unit tests to cover new code as well as better test existing mutex
- removed a layer of complexity that added no real value
We have a special rule that Optional<T>.none successfully dynamically casts
to Optional<U>.none for any T and U. However the implementation was incorrect
if the source and destination types had a different size. We would initialize
the source to nil, and then copy to the result.
The correct implementation is to initialize the result using the result
payload type directly, and not call _succeed() at all.
Fixes <https://bugs.swift.org/browse/SR-1056>.
We have a special rule that Optional<T>.none successfully dynamically casts
to Optional<U>.none for any T and U. However the implementation was incorrect
if the source and destination types had a different size. We would initialize
the source to nil, and then copy to the result.
The correct implementation is to initialize the result using the result
payload type directly, and not call _succeed() at all.
Fixes <https://bugs.swift.org/browse/SR-1056>.
The witness-table parameters got added to all witnesses as part of the
resilience work, but the hardcoded witness table in the runtime's
dynamic-casting infrastructure didn't get updated. Nothing seems to be
relying on these right now, so we cannot actually *test* it, but I've
verified that the types line up.
This lets us eliminate the _getObjectiveCType() value witness, which
was working around the lack of proper type witness metadata in witness
tables. Boilerplate -= 1.
This makes sure that runtime functions use proper calling conventions, get the required visibility, etc.
We annotate the most popular runtime functions in terms of how often they are invoked from Swift code.
- Almost all variants of retain/release functions are annotated to use the new calling convention.
- Some popular non-reference counting functions like swift_getGenericMetadata or swift_dynamicCast are annotated as well.
The set of runtime functions annotated to use the new calling convention should exactly match the definitions in RuntimeFunctions.def!
...and explicitly mark symbols we export, either for use by executables or for runtime-stdlib interaction. Until the stdlib supports resilience we have to allow programs to link to these SPI symbols.
The runtime support for casting optionals introduced in 35cb1afa
resulted in a redundant retain.
Fixes SR-459: Weakened optionals don't zero...
rdar://24057977.
This case was previously ignoring the DestroyOnFailure flag, so
we had a leak if a cast to an existential metatype failed for
certain types (tuples, structs, etc).
This more cleanly groups together the initialization steps needed to warm up the conformance cache, so redundant work doesn't need to be done by other interested parties (such as the type-by-name lookup @lhoward's working on).