Commit Graph

484 Commits

Author SHA1 Message Date
Doug Gregor
da772e9155 [Runtime] Make swift::swift_conformsToSwiftProtocol overridable.
This is a funnel point for looking up the protocol conformance descriptor
for a given conforming type + conformance. Make it overridable in case we
need to back-deploy changes or fixes.

Implements rdar://problem/46281660.
2018-11-27 23:37:11 -08:00
Saleem Abdulrasool
50c5a83beb tests: stub out more of the stdlib
Key paths need metadata stubbed out for the unit tests.
2018-11-19 20:17:35 -08:00
swift-ci
c44981ae05 Merge pull request #20635 from compnerd/stubs 2018-11-16 13:03:10 -08:00
Doug Gregor
cc2ee165a1 [ABI] Use generic environment to handle mangled generic keypath types.
Always use mangled type names to represent type metadata in keypath patterns.
For generic types, use the generic environment to pull substituted types
from the instantiation arguments.

Finishes the type metadata part of rdar://problem/38038799.
2018-11-16 10:13:07 -08:00
Saleem Abdulrasool
2848946dc6 unittests: provide additional metadata stubs
Provide additional stubs for known metadata.  These are used in the unit
tests which do not link against the standard library and thus do not
have the known metadata.  Augment the existing metadata stubs with the
new decorated names and entries.
2018-11-16 08:48:54 -08:00
Doug Gregor
986b8f3f9f [Runtime] Make swift_getTypeByMangled(Name|Node) overridable.
Rename the funnel points for demangling strings/nodes to metadata to
swift_getTypeByMangled(Name|Node) and make them overridable. This will let
us back-deploy mangling improvements and bug fixes.
2018-11-15 16:43:38 -08:00
Doug Gregor
723b56e64f [Standard library] Simplify _getTypeByMangledName.
Simplify the signature of the internal _getTypeByMangledName() used by the
standard library to what we actually (currently) use. Drop it as a
compatibility override, because it’s not a useful place to introduce
customization.
2018-11-15 16:10:11 -08:00
Doug Gregor
75947627cf [Runtime] Update unit test for swift_getAssociated(Type|Conformance)Slow. 2018-11-15 09:57:36 -08:00
Doug Gregor
a0e3258ba6 [ABI] Collapse generic witness table into protocol conformance record.
Collapse the generic witness table, which was used only as a uniquing
data structure during witness table instantiation, into the protocol
conformance record. This colocates all of the constant protocol conformance
metadata and makes it possible for us to recover the generic witness table
from the conformance descriptor (including looking at the pattern itself).

Rename swift_getGenericWitnessTable() to swift_instantiateWitnessTable()
to make it clearer what its purpose is, and take the conformance descriptor
directly.
2018-10-22 23:36:31 -07:00
Andrew Trick
e560125d20 Create RuntimeUnittest library for C++ runtime unit tests from lit.
Create a new RuntimeUnittest library alongside the other stdlib unit
tests so we can write C++ runtime unit tests callable from lit.

Move runtime exclusivity tests into the stdlib unittest library and
create lit tests so we can verify that the runtime crashes with an
error message.
2018-10-13 10:06:35 -07:00
Andrew Trick
2ecb48a89d Remove exclusivity support for Swift 3 mode.
Remove the compiler support for exclusivity warnings.

Leave runtime support for exclusivity warnings in non-release builds
only for unit testing convenience.

Remove a test case that checked the warning log output.

Modify test cases that relied on successful compilation in the
presence of exclusivity violations.

Fixes: <rdar://problem/45146046> Remaining -swift-version 3 tests for exclusivity
2018-10-12 09:08:42 -07:00
Doug Gregor
c3d0ba8df4 [IRGen/Runtime] Witness tables with dependent associated types need instantiation.
Associated type witnesses in a witness table are cache entries, which are
updated by the runtime when the associated types are first accessed. The
presence of an associated type witness that involves type parameters requires
the runtime to instantiate the witness table; account for that in the runtime.
The presence of any associated type witness makes the witness table
non-constant.
2018-09-26 23:19:33 -07:00
Joe Groff
bbbf02e5f8 Merge pull request #19415 from jckarter/better-missing-metadata-warnings
Make runtime warnings about missing metadata more descriptive.
2018-09-20 15:40:17 -07:00
Joe Groff
e9b45178a0 Make runtime warnings about missing metadata more descriptive.
Describe the consequences of missing metadata instead of just posting a scary
message about a bug.  Furthermore, since these warnings tend to show up in
playgrounds, and probably aren't relevant to the user of a playground, suppress
them when running in a playground. rdar://problem/44642942
2018-09-20 13:03:54 -07:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Erik Eckstein
8f35a3eff7 runtime: remove pinning in reference counting and pinning runtime entry points
rdar://problem/35401813
2018-08-25 11:14:18 -07:00
Joe Groff
47f046ef52 Merge pull request #18768 from jckarter/keypath-let
Preserve 'let'-ness of stored properties in key paths.
2018-08-17 14:32:30 -07:00
Joe Groff
70c60e5186 KeyPaths: Make references to let properties properly immutable. 2018-08-17 10:59:36 -07:00
Mike Ash
46309d9794 [Runtime] Rename swift_unknown* functions to swift_unknownObject*.
These functions don't accept local variable heap memory, although the names make it sound like they work on anything. When you try, they mistakenly identify such things as ObjC objects, call through to the equivalent objc_* function, and crash confusingly. This adds Object to the name of each one to make it more clear what they accept.

rdar://problem/37285743
2018-08-15 17:48:23 -04:00
Doug Gregor
a54a6d8d7f [ABI] Rework protocol descriptor metadata.
Reimplement protocol descriptors for Swift protocols as a kind of
context descriptor, dropping the Objective-C protocol compatibility
layout. The new protocol descriptors have several advantages over the
current implementation:

* They drop all of the unused fields required for layout-compatibility
  with Objective-C protocols.
* They encode the full requirement signature of the protocol. This
  maintains more information about the protocol itself, including
  (e.g.) correctly encoding superclass requirements.
* They fit within the general scheme of context descriptors, rather than
  being their own thing, which allows us to share more code with
  nominal type descriptors.
* They only use relative pointers, so they’re smaller and can be placed
  in read-only memory

 Implements rdar://problem/38815359.
2018-07-23 22:12:42 -07:00
Doug Gregor
89e322032a [Runtime] Minor cleanups to reduce dependency on Swift/ObjC protocol overlap.
As a small step toward splitting apart the Swift and Objective-C protocol
descriptors, eliminate most places where we rely on a shared representation.
2018-07-23 17:08:58 -07:00
Doug Gregor
03c3baab6e [Runtime] TargetProtocolDescriptorRef cleanups.
Eliminate an unnecessary nullptr constructor and make the Metadata
unit test compile when Objective-C interoperability is disabled.
2018-07-22 21:05:45 -07:00
Doug Gregor
bec722df57 [Runtime/IRGen] Switch swift_getExistentialTypeMetadata() to ProtocolDescriptorRef.
Switch one entry point in the runtime (swift_getExistentialTypeMetadata)
to use ProtocolDescriptorRef rather than a protocol descriptor. Update
IRGen to produce ProtocolDescriptorRef instances for its calls, setting
the discriminator bit appropriately.

Within the runtime, verify that all instances of ProtocolDescriptorRef have
the right layout, i.e., the discriminator bit is set for @objc protocols
but not Swift protocols.
2018-07-21 07:48:34 -07:00
Doug Gregor
3464929638 [ABI] Rework existential type metadata to use ProtocolDescriptorRef.
Use ProtocolDescriptorRefs within the runtime representation of
existential type metadata (TargetExistentialTypeMetadata) instead of
bare protocol descriptor pointers. Start rolling out the use of
ProtocolDescriptorRef in a few places in the runtime that touch this
code. Note that we’re not yet establishing any strong invariants on
the TargetProtocolDescriptorRef instances.

While here, replace TargetExistentialTypeMetadata’s hand-rolled pointer 
arithmetic with swift::ABI::TrailingObjects and centralize knowledge of
its layout better.
2018-07-20 20:54:49 -07:00
Mike Ash
b1d1ca2145 [Runtime] Fix warning about implicitly converting nullptr to bool in CompatibilityOverride.cpp tests.
rdar://problem/40625829
2018-07-03 14:37:53 -04:00
Doug Gregor
7952a19f31 [Mangling] Introduce known manglings for many more standard library types.
Since the mangling scheme and set of standard library types is effectively
fixed now, introduce known mangling substitutions for a number of new
standard library types, filling out the S[A-Za-z] space.

Reduces standard library binary size by ~195k.
2018-06-19 23:24:38 -07:00
Lily Vulcano
1377ab7d7e Turn on ‘as’ bridging on Darwin. 2018-05-30 15:07:22 -07:00
swift-ci
435375d258 Merge pull request #16798 from aschwaighofer/opaque_existentials_bitwise_takable 2018-05-23 13:13:02 -07:00
Mike Ash
93470fb9b9 Merge pull request #16794 from mikeash/fix-ConcurrentReadableArray-double-free
[Runtime] Fix double-frees in ConcurrentReadableArray.
2018-05-23 14:38:33 -04:00
Arnold Schwaighofer
98506e03cf IRGen: Opaque existentials are now bitwise takable
Now that the existential inline buffer is bitwise takable so are opaque
existentials.
2018-05-23 11:17:54 -07:00
Mike Ash
a4863c4dcd [Runtime] Fix ConcurrentReadableArray's handling of FreeList to not double-free items. Also implement a destructor so it can be used for non-globals.
rdar://problem/40484362
2018-05-23 11:29:26 -04:00
Arnold Schwaighofer
6267860a7e IRGen: Remove initializeBufferWithTakeOfBuffer in favor of memcpy
And update the existential container's initializeWithTake implementation
in the runtime. After only allowing bitwise takable values in the
inline buffer we can use memcpy to move existential container values.

rdar://31414907
SR-343
2018-05-22 13:05:00 -07:00
Ben Langmuir
628b6a1fc7 Revert "Turn on ‘as’ bridging on Linux." 2018-05-17 14:54:35 -07:00
Lily Vulcano
b9455930ee Turn on ‘as’ bridging on Darwin. 2018-05-17 09:59:39 -07:00
Saleem Abdulrasool
f4c24d6e2e Merge pull request #16403 from lanza/inspect-arch-sdk
Configure the swiftImageInspectionShared to generate arch & sdk speci…
2018-05-10 09:42:35 -07:00
Nathan Lanza
9815368788 Configure the swiftImageInspectionShared to generate arch & sdk specific libraries
Previously, swiftImageInspectionShared generated one specific library at
`lib/libswiftImageInspectionShared.a` for only the main arch and sdk.
Generic cross compilation and various changes to the build system to get
cross compilation to work will require swiftImageInspectionShared to
generate libraries at the proper subdirectory. Change the outputs to
agree with paths such as `lib/swift/linux/x86_64`
2018-05-03 12:33:45 -07:00
David Zarzycki
2e19423bf8 [Unit Tests] NFC: Pass nullptr rather than dummy empty array 2018-04-30 17:10:52 -04:00
David Zarzycki
95473a10d7 [Misc] NFC: Fix random build warnings
Unused variables/methods, language extensions, extra semicolons, intentional
self assignment, platform specific quirks, etc.
2018-04-30 12:52:43 -04:00
Mike Ash
99c15bc641 Merge pull request #15429 from mikeash/casting-hooks
[Runtime] Add hooks for back-deploying dynamic casting and type lookup changes
2018-03-30 19:54:35 -07:00
Mike Ash
cd0d075aad [Runtime] Only enable the CompatibilityOverride test Mach-O/Apple.
rdar://problem/36997475
2018-03-29 17:18:45 -04:00
Slava Pestov
72b56ec66b Runtime: New mechanism for resilient witness table instantiation 2018-03-29 14:03:58 -07:00
Slava Pestov
d1c6e1d24a SIL: Generalize default witness tables now that defaulted witnesses don't have to go at the end
NFC until the new witness table instantiation mechanism is enabled.
2018-03-29 14:03:58 -07:00
Mike Ash
f8241caa59 [Runtime] Rename __swift_lite section to __swift_hooks.
rdar://problem/36997475
2018-03-29 12:16:01 -04:00
Saleem Abdulrasool
8695224324 Merge pull request #14598 from AndrewSB/pthreads=😥
unittests/runtime: Migrate tests from pthreads to std::thread
2018-03-28 22:28:07 -04:00
Mike Ash
3019265ffd [Runtime] Fix spurious test failure in CompatibilityOverride.cpp.
rdar://problem/36997475
2018-03-28 15:12:06 -04:00
Mike Ash
34be7f6f15 Merge branch 'master' into casting-hooks 2018-03-28 14:45:48 -04:00
Mike Ash
f4224b092e [Runtime] Redo compatibility overrides boilerplate using a .def file.
rdar://problem/36997475
2018-03-28 13:39:55 -04:00
John McCall
6d99a7755a Restructure how we finalize VWTs in the runtime to potentially allow asynchronous queries.
I keep finding reasons to want such queries and then deciding that they're
unnecessary.  Let's at least do this much, though.
2018-03-26 01:13:45 -04:00
Mike Ash
cf3ee980a8 Merge pull request #14283 from mikeash/fix-urc-overflow-to-side-table-in-deinit
[Runtime] Fix unowned refcount overflow to side table during deinit.
2018-03-22 09:15:20 -07:00
Mike Ash
d024fd7487 [Runtime] Fill out a bunch more compatibility hooks.
rdar://problem/36997475
2018-03-22 09:14:55 -07:00