Commit Graph

297 Commits

Author SHA1 Message Date
Joe Groff
05dfec0cda Push the conformance accessor hack down into getTypeByMangledName. 2019-04-17 14:44:40 -07:00
Mike Ash
855dd8d5fb [Tests] Use a plain array of std::atomic rather than a vector of atomic.
The restrictions on std::atomic make a it fragile to have a vector of them, and this failed to compile on Linux in CI.

While I'm in there, clean up a couple of tests that repeated a raw `10` for the thread count.

rdar://problem/49709062
2019-04-09 10:52:53 -04:00
Mishal Shah
c4626baf88 Un-set CMAKE_C_COMPILER_LAUNCHER and CMAKE_CXX_COMPILER_LAUNCHER in s… (#23806)
[CMake] Add check for distcc before setting CMAKE_C_COMPILER_LAUNCHER and CMAKE_CXX_COMPILER_LAUNCHER
2019-04-08 12:53:35 -07:00
Mike Ash
6172f72af9 [Tests] Make Mutex.cpp tests more reliable.
Many of these tests would fail if one of the test threads didn't begin execution within 100 milliseconds. They would hit while (!done) the very first time and never execute the loop body. That does happen from time to time, and the result would be a spurious failure. Change the loops to do {} while(!done) to ensure they always execute at least one iteration.

Many tests also had the test threads concurrently write results to a std::vector, which appeared to be causing some failures in my local testing when I had extra sleeps inserted to simulate pathological scheduling. Change the results vectors to be vectors of std::atomic to ensure that this concurrent writing is safe.

These changes shouldn't affect its ability to test the functionality it intends to test.

rdar://problem/49386389
2019-04-05 16:40:08 -04:00
Saleem Abdulrasool
4b9f8464e4 unittests: add a hack to use the host compiler
Unfortunately, ASAN breaks with the just built compiler.  The runtime
and the runtime tests should really use the same compiler.  As a
workaround, if the host compiler is clang, just use that for the time
being.  This should fix the build on the ASAN bots.
2019-02-27 11:37:45 -08:00
Saleem Abdulrasool
27fab1d582 build: use the just-built clang for runtime unittests
The runtime is meant to be built with the just built clang (as this
absolutely requires clang) as the runtime is a target library.  The host
tools can be built with the host compiler.  Swap out the compiler for
the unittests as we do for the runtime itself.
2019-02-25 16:13:12 -08:00
Saleem Abdulrasool
9897716e4b unittests: fixes for Swift's custom build system
Because we do not have proper libraries in our system, we cannot attach
interface link libraries, especially in light of the
incorporate_object_library implementation.  Explicitly add the
dependency on DbgHelp for the unit tests.
2019-02-21 22:39:00 -08:00
John McCall
d07efd37e0 Requestify the mangling-to-metadata APIs.
Note that I've called out a couple of suspicious places where we
are requesting abstract metadata for superclasses but probably
need to be requesting something more complete.
2019-02-05 16:20:48 -05:00
John McCall
de4564877a Separate CC attrs in the compatibility-override macro; NFC. 2019-02-05 16:20:48 -05:00
John McCall
724c192120 Propagate the XI count into the get/store XI tag callbacks.
This allows callers to avoid needing to reload these tags in common cases.
2018-12-11 22:18:44 -05:00
John McCall
2ba7090fe8 Remove the extra-inhabitant value witness functions.
This is essentially a long-belated follow-up to Arnold's #12606.
The key observation here is that the enum-tag-single-payload witnesses
are strictly more powerful than the XI witnesses: you can simulate
the XI witnesses by using an extra case count that's <= the XI count.
Of course the result is less efficient than the XI witnesses, but
that's less important than overall code size, and we can work on
fast-paths for that.

The extra inhabitant count is stored in a 32-bit field (always present)
following the ValueWitnessFlags, which now occupy a fixed 32 bits.
This inflates non-XI VWTs on 32-bit targets by a word, but the net effect
on XI VWTs is to shrink them by two words, which is likely to be the
more important change.  Also, being able to access the XI count directly
should be a nice win.
2018-12-11 22:18:44 -05:00
Jason Mittertreiner
4e0b092fbe Fixing Driver tests on Windows (#20209) 2018-12-10 18:27:37 -08:00
Joe Groff
bce1f5ef4a Runtime: Provide ABI space for source location info in unconditional casts.
Currently ignored, but this will allow future compilers to pass down source location information for cast
failure runtime errors without backward deployment constraints.
2018-12-06 14:58:14 -08:00
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