Commit Graph

335 Commits

Author SHA1 Message Date
Joe
3938d5682a [SE-0095] [Runtime], [Demangler], & AST printer updated to new composition syntax
- 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
2016-07-19 12:01:37 -07:00
Joe Groff
e25c751693 Merge pull request #3538 from jckarter/id-as-any-swiftvalue-box
Runtime: Implement an opaque 'SwiftValue' ObjC class to hold bridged values.
2016-07-18 09:05:37 -07:00
Dmitri Gribenko
1edf5326a1 runtime: remove workaround for Clang 3.5
All supported OSes have Clang 3.6+.
2016-07-15 21:44:01 -06:00
Joe Groff
bc8433f186 Runtime: Implement an opaque 'SwiftValue' ObjC class to hold bridged values.
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.
2016-07-15 15:56:25 -07:00
Joe Groff
02640fc1bc Runtime: Look through existentials when bridging to id. 2016-07-12 19:21:13 -07:00
Slava Pestov
67f7e773dd Runtime: Add preliminary _swift_bridgeUnknownToObject() entry point. 2016-07-12 13:49:39 -07:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Arnold Schwaighofer
8cae9874e3 Fix the assert 2016-06-27 15:29:32 -07:00
Arnold Schwaighofer
542a8b410a Fast-path dynamicCast from a class instance in an existential container to AnyObject
rdar://26981164
2016-06-27 13:29:09 -07:00
practicalswift
4485f76794 [gardening] Use consistent capitalization for "Objective-C". 2016-06-14 22:24:43 +02:00
Chris Lattner
7e201996e8 Update the reflection printer to not omit parens from single argument
function types.  This exposes something which I think is a bug in the
reflection encoding, I'll chat with Slava about it.
2016-05-06 21:07:08 -07:00
John McCall
50d58b2732 Add a lot of calling-convention annotations to the standard library / runtime.
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.
2016-05-04 10:31:23 -07:00
Greg Parker
3af0796d4c [runtime] addressed review comments outlined in #1950 (Merge pull request #2332 from shawnce/SR-946_polish)
[runtime] addressed review comments outlined in #1950
2016-04-28 21:01:25 -07:00
Shawn Erickson
d78c6e3403 [runtime] addressed review comments outlined in #1950 2016-04-28 10:39:35 -07:00
Joe Groff
804f78bfa8 Runtime: Don't leak bridged object when value-to-bridged-object cast fails.
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.
2016-04-27 17:21:38 -07:00
Greg Parker
590d41c00a [runtime] enhanced and refactored recently added Mutex abstraction (Merge pull request #1950 from shawnce/SR-946_rw)
[runtime] enhanced and refactored recently added Mutex abstraction
2016-04-26 16:18:12 -07:00
Greg Parker
709951e82e [runtime] Fix a leak when a cast from an existential fails.
rdar://25011739.
2016-04-06 14:42:33 -07:00
Shawn Erickson
a0452be947 [runtime] enhanced and refactored recently added Mutex abstraction
- 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
2016-04-06 13:02:37 -07:00
Slava Pestov
7c0bd2f660 Runtime: Fix problems with nil-to-nil casts
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>.
2016-03-31 17:21:20 -07:00
Ben Langmuir
f8287f4376 Revert "Runtime: Fix problems with nil-to-nil casts"
This was causing test failures in -optimize mode (build-sript -o).

This reverts commit e72caad3d7.
2016-03-31 08:59:49 -07:00
Slava Pestov
e72caad3d7 Runtime: Fix problems with nil-to-nil casts
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>.
2016-03-30 14:24:58 -07:00
Dmitri Gribenko
82509cbd74 Merge pull request #1731 from shawnce/SR-946
SR-946 - Unify mutexes in the Swift runtime
2016-03-29 08:56:39 -07:00
Andrew Trick
1bd9dc97b4 SR-912: Runtime exception casting an Any nil to an Optional.
This is a simple runtime fix for the following case:

func cast<U>(t: Any) -> U {
  return t as! U
}
cast(nil as Int?) as Int?
2016-03-22 17:47:05 -07:00
Shawn Erickson
3292124f87 [runtime] - switched most runtime code to use swift::Mutex and swift::Condition (see SR-946) 2016-03-20 22:56:48 -07:00
Doug Gregor
9c530f1d93 [Runtime] Add witness-table parameters to _ObjectiveCBridgeable witnesses.
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.
2016-03-18 16:30:53 -07:00
Doug Gregor
67dad6041c [Runtime] Use the _ObjectiveCBridgeable._ObjectiveCType type witness directly.
This lets us eliminate the _getObjectiveCType() value witness, which
was working around the lack of proper type witness metadata in witness
tables. Boilerplate -= 1.
2016-03-18 16:11:38 -07:00
Max Moiseev
cf4bafe9e3 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-03 13:22:03 -08:00
Roman Levenstein
99fd8b6080 Rename some macros based on the PR review comments.
- use  the SWIFT prefix for all macros
- make names of some macros shorter
2016-02-25 05:31:00 -08:00
Roman Levenstein
de3b850ce8 Use more descriptive names for calling conventions.
Rename RuntimeCC into DefaultCC
Rename RuntimeCC1 into RegisterPreservingCC
Remove RuntimeCC0 because it was identical to DefaultCC.
2016-02-25 05:31:00 -08:00
Roman Levenstein
68b6181642 Annotate runtime functions using the newly introduced annotations from runtime/Config.h.
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!
2016-02-25 05:30:59 -08:00
Dmitri Gribenko
3d3d4540e1 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-20 14:37:49 -08:00
Dmitri Gribenko
7e88bd7b2f stdlib: remove dead code 2016-02-20 02:30:46 -08:00
Dmitri Gribenko
65d840c0ae stdlib: lowercase cases in Optional and ImplicitlyUnwrappedOptional 2016-02-18 00:40:33 -08:00
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
Joe Groff
f7291b21ec Runtime: Build with -fvisibility=hidden.
...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.
2016-02-08 08:06:02 -08:00
Max Moiseev
61c837209b Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-04 16:13:39 -08:00
Harlan Haskins
b55d8d9c3c [Runtime] Add backtrace reporting on fatalError in debug builds 2016-01-29 13:42:06 -08:00
Max Moiseev
08e1e4a043 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-11 16:51:11 -08:00
Greg Parker
35448a1179 Merge pull request #861 from jder/fix-fail-cast-overrelease
[SR-392][Runtime] Avoid overrelease when failing cast to protocol
2016-01-09 08:40:45 -08:00
Greg Parker
8ee8adb36e [stdlib] Move protocol conformance checking and caching into its own file. 2016-01-09 01:00:31 -08:00
Slava Pestov
b45cec0dff Runtime: Fix a warning 2016-01-08 19:21:23 -08:00
Jesse Rusak
30224016c5 [SR-392][Runtime] Avoid overrelease when failing cast to protocol
Fixes a regression introduced in e09027ca which causes us to release
the wrong value when a cast fails.
2016-01-08 19:02:37 -05:00
Andrew Trick
9cf84c24ca Fix a leak when interpolating optional references.
The runtime support for casting optionals introduced in 35cb1afa
resulted in a redundant retain.

Fixes SR-459: Weakened optionals don't zero...
rdar://24057977.
2016-01-08 13:51:02 -08:00
Greg Parker
f91dd6fa60 Merge pull request #857 from jder/fix-existential-cast-leak
[SR-426][Runtime] Use _fail to ensure src is deallocated in cast
2016-01-08 01:44:35 -08:00
Doug Gregor
1a38e0ad3b Merge branch 'master' into swift-3-api-guidelines 2016-01-06 15:32:55 -08:00
Greg Parker
3f6356110b Remove a stale comment.
This comment should have been removed by d0be84e.
2016-01-04 23:12:52 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
Jesse Rusak
2aaa4846e8 [SR-426][Runtime] Use _fail to ensure src is deallocated in cast
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).
2016-01-03 15:07:34 -05:00
Chris Lattner
a30ae2bf55 Merge pull request #836 from zachpanz88/new-year
Update copyright date
2015-12-31 19:36:14 -08:00
Joe Groff
d0be84e1f3 Runtime: Refactor conformance cache initialization to include installation of the dyld callbacks.
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).
2015-12-31 17:11:17 -08:00