Commit Graph

1960 Commits

Author SHA1 Message Date
Saleem Abdulrasool
d026b10366 Merge pull request #20118 from compnerd/silence
runtime: silence the compiler warning about const (NFC)
2018-10-29 09:51:54 -07:00
rposts
ab2dd1098e Towards s390x support (#19822)
* Towards s390x support

* Fix case index on Big Endian
2018-10-29 09:37:02 -07:00
Saleem Abdulrasool
185f9233d3 runtime: silence the compiler warning about const (NFC)
This warning shows up multiple times due to the template specialization.
Explicitly perform the casts with `const_cast` to pacify the compiler.
NFC.
2018-10-28 17:00:27 -07:00
Saleem Abdulrasool
ff20f2b44f runtime: adjust known metadata for SIMD vector types
Rather than use a function, use a templated structure with a constant
expression to metaprogram the alignment of the type.  NFC.

Adjust the templating for the SIMD vector types.  Use the reserved
spelling for the clang extension, and rename the types.  NFC.

The meat of this change is the explicit template specialization for the
float 3 vector and double 3 vector.  Since they are going to be emitted
as float 4 vector underneath everything, we can simply treat them the
same.  This has a benefit of allowing us to share the same
specialization of the witness tables.  Additionally, it works around a
bug in clang where we cannot correctly decorate the extended type with
Microsoft's ABI (which is a separate issue).  Since this saves some
bytes, this is still beneficial.
2018-10-28 02:06:29 -07:00
Michael Gottesman
3f17bb6ddf Carefully split the build's invocation of add_swift_library into host/target variants.
The key thing here is that all of the underlying code is exactly the same. I
purposely did not debride anything. This is to ensure that I am not touching too
much and increasing the probability of weird errors from occurring. Thus the
exact same code should be executed... just the routing changed.
2018-10-27 12:58:51 -07:00
Doug Gregor
c3b806b230 Merge pull request #20097 from DougGregor/protocol-symbolic-reference
[Mangling] Mangle protocol symbolic references in any-generic-type production.
2018-10-27 00:52:43 -07:00
Doug Gregor
72e5f708e4 Merge pull request #20099 from DougGregor/rountrip-builtin-type-metadata
[IRGen] Make (most) builtin type metadata round-trippable.
2018-10-27 00:10:39 -07:00
Doug Gregor
57f83980f6 Add C type equivalents for Builtin.Int1 and Builtin.Int63 2018-10-26 19:35:45 -07:00
Doug Gregor
dafaabecd6 [Mangling] Mangle protocol symbolic references in any-generic-type production.
We were strangely excluding protocols from being symbolically referenced
in the any-generic-type production, which meant that we could not resolve
(e.g.) associated type references to private protocols at runtime. Allow
protocol symbolic references in this position, and cope with it in the
demangler.

Fixes the rest of rdar://problem/44977236.
2018-10-26 18:10:07 -07:00
Slava Pestov
4d69e6f5b8 Runtime: Unconditionally realize superclass metadata in swift_updateClassMetadata()
Previously we were only doing this in assert builds, or if the
new Objective-C runtime metadata update hook mechanism was
available.

However, swift_checkMetadataState() gets called on the superclass
of a class, and it assumes that the metadata entry for the
superclass already exists in the singleton cache.

So even on an older runtime when there's no initialization work
to be done, we have to realize the superclass to populate the
singleton cache so that the check can succeed.

Fixes <rdar://problem/45569020>.
2018-10-26 20:40:27 -04:00
Doug Gregor
e87dea480c [IRGen] Make (most) builtin type metadata round-trippable.
Rather than mapping all of the builtin floating-point and vector
types down to the type metadata symbols for power-of-two integers,
map down to the type metadata symbols provided by the runtime.
This allows us to round-trip type metadata <-> mangled name for all of
the builtin types that have such symbols. When we don’t have a runtime
symbol, we will fail to link if that builtin type gets referenced.
2018-10-26 16:09:21 -07:00
Doug Gregor
65d5d15fc1 [Runtime] Extend known builtin metadata for floating point and vector types.
Expose symbols for metadata for the various builtin floating point types
and vector types. This is used by the demangler to handle builtin names.

This is a narrow fix for rdar://problem/45569984 (where we couldn’t
demangle a builtin vector type). A more extensive fix will require us
to add a general runtime facility for creating opaque type metadata
with specific size/alignment/stride/uniquing name.
2018-10-26 16:05:31 -07:00
Slava Pestov
9024768b0e Runtime: Flesh out swift_updateClassMetadata() to use _objc_realizeClassFromSwift() 2018-10-26 16:54:23 -04:00
Doug Gregor
2668b52aa8 [Runtime] Unique foreign witness tables based on the conformance type descriptor. 2018-10-25 21:43:00 -07:00
Doug Gregor
933dece55d [Runtime] Minor simplification to swift_getWitnessTable(). 2018-10-25 21:43:00 -07:00
Doug Gregor
dd154f6668 [Runtime] Rename swift_instantiateWitnessTable() -> swift_getWitnessTable()
This runtime function doesn’t always perform instantiation; it’s how we
get a witness table given a conformance, type, and set of instantiation
arguments. Name it accordingly.
2018-10-25 20:35:27 -07:00
Doug Gregor
b5bc06e552 [ABI] Eliminate witness table accessors.
Witness table accessors return a witness table for a given type's
conformance to a protocol. They are called directly from IRGen
(when we need the witness table instance) and from runtime conformance
checking (swift_conformsToProtocol digs the access function out of the
protocol conformance record). They have two interesting functions:

1) For witness tables requiring instantiation, they call
swift_instantiateWitnessTable directly.
2) For synthesized witness tables that might not be unique, they call
swift_getForeignWitnessTable.

Extend swift_instantiateWitnessTable() to handle both runtime
uniquing (for #2) as well as handling witness tables that don't have
a "generic table", i.e., don't need any actual instantiation. Use it
as the universal entry point for "get a witness table given a specific
conformance descriptor and type", eliminating witness table accessors
entirely.

Make a few related simplifications:

* Drop the "pattern" from the generic witness table. Instead, store
  the pattern in the main part of the conformance descriptor, always.
* Drop the "conformance kind" from the protocol conformance
  descriptor, since it was only there to distinguish between witness
  table (pattern) vs. witness table accessor.
* Internalize swift_getForeignWitnessTable(); IRGen no longer needs to
  call it.

Reduces the code size of the standard library (+assertions build) by
~149k.

Addresses rdar://problem/45489388.
2018-10-25 20:35:27 -07:00
Doug Gregor
5b41ac16db [ABI] Introduce indirect symbolic references to context descriptors.
Extending the mangling of symbolic references to also include indirect
symbolic references. This allows mangled names to refer to context
descriptors (both type and protocol) not in the current source file.

For now, only permit indirect symbolic references within the current module,
because remote mirrors (among other things) is unable to handle relocations.

Co-authored-by: Joe Groff <jgroff@apple.com>
2018-10-23 16:06:42 -07: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
Doug Gregor
c5e226bb16 [Runtime] Use CF superclass metadata in runtime lookups.
When searching the superclasses at runtime, e.g., to find a suitable
protocol conformance record, also consider the superclasses of CF
types, which were recorded in the metadata but otherwise unused.
2018-10-16 21:42:02 -07:00
Doug Gregor
cae1c8cee3 [Runtime] Resolve symbolic references in type mangled name round-trip.
When performing the round-tripping verification for mangled type names,
make sure we resolve symbolic references to something
user-comprehensible that can be meaningfully rem angled.

Part of rdar://problem/37551850.
2018-10-16 21:42:02 -07:00
Andrew Trick
e3a75de818 Merge pull request #19849 from atrick/remove-swift3-exclusivity
Remove exclusivity support for Swift 3 mode.
2018-10-15 11:03:06 -07:00
Andrew Trick
823137b2f4 Remove runtime support for exclusivity warnings. 2018-10-13 10:06:35 -07:00
swift-ci
fefb2779a7 Merge pull request #19864 from DougGregor/remove-resilient-witness-tables 2018-10-12 17:26:11 -07:00
Saleem Abdulrasool
791e36950b Merge pull request #19829 from compnerd/static-registrar
stdlib: install the image registrar in the static runtime
2018-10-12 16:15:11 -07:00
Doug Gregor
41891f6266 [ABI] Move the resilient witness table into the conformance descriptor.
Place resilient witnesses in the protocol conformance descriptor,
tail-allocated after the conditional requirements, so they can be found by
reflection. Drop the resilient witness table and protocol descriptor from
the generic witness table.

Addresses rdar://problem/45228582.
2018-10-12 15:36:20 -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
5aae7741ea Merge pull request #19828 from DougGregor/runtime-perf-get-assoc-type-witness
[ABI] Pass requirement base descriptor to swift_getAssociatedTypeWitnesses()
2018-10-11 14:27:00 -07:00
Mike Ash
794ff31d73 Merge pull request #19794 from mikeash/fix-instruments-and-retain-counts
[Runtime] Fix swift_retainCount for deiniting objects and BridgeObject tagged values. Make swift_bridgeObjectRetain/Release bail out early for tagged values.
2018-10-11 14:32:43 -04:00
Saleem Abdulrasool
f7f1f026f4 stdlib: install the image registrar in the static runtime
We were previously only installing the image registration helper in the shared
runtime location.  When building with a static runtime, we would look in the
wrong location.  Ensure that we install to both locations to repair the static
builds.
2018-10-11 10:42:25 -07:00
Doug Gregor
aba018c1e8 [ABI] Pass requirement base descriptor to swift_getAssociatedTypeWitness().
Have clients pass the requirement base descriptor to
swift_getAssociatedTypeWitness(), so that the witness index is just one
subtraction away, avoiding several dependent loads (witness table ->
conformance descriptor -> protocol descriptor -> requirement offset)
in the hot path.
2018-10-10 22:45:59 -07:00
Mike Ash
101c7cbbdb [Runtime] Fix a leak when reading a weak property with Mirror.
SR-8878 rdar://problem/44872927
2018-10-09 12:48:44 -04:00
Mike Ash
1afd079b78 [Runtime] Fix swift_retainCount for deiniting objects and BridgeObject tagged values. Make swift_bridgeObjectRetain/Release bail out early for tagged values.
The Allocations Instrument overrides swift_retain with a function that records the retain count by calling swift_retainCount. Its assert for bits.getIsDeiniting() is incorrect in that case, so remove it.

The recent change to ObjC tagged pointer bits on x86-64 also caused the various bridgeObjectRetain/Release functions to call through to swift_retain for BridgeObject tagged values on Mac. swift_retain ignored those values so there was no functional change, except when Instruments overrode it and passed them to swift_retainCount, which tried to dereference them and crashed. Modify bridgeObjectRetain/Release to bail out early again. Also modify swift_retainCount to ignore those values in case anything else expects retainCount to work on any pointer swift_retain accepts.

rdar://problem/45102538
2018-10-09 10:04:06 -04:00
Mike Ash
f4db1dd7a4 Merge pull request #19614 from mikeash/no-internal-export
[Stdlib] Change SWIFT_RUNTIME_STDLIB_INTERNAL to not export the symbol.
2018-10-05 09:26:03 -04:00
Doug Gregor
6e0d1d3222 Merge pull request #19719 from DougGregor/superclass-mangled-name
[ABI] Use mangled superclass names from class context descriptors.
2018-10-04 19:58:46 -07:00
Doug Gregor
2b44e8578f [ABI] Use mangled superclass names from class context descriptors.
Rather than rely on the metadata initialization function to compute and
fill in the superclass, use the mangled superclass name to construct the
superclass metadata.
2018-10-04 15:43:24 -07:00
Mike Ash
a78a01a392 [Stdlib] Make _swift_extractDynamicValue INTERNAL as it's used by Foundation. 2018-10-04 13:20:53 -04:00
Mike Ash
fa4178c5e8 [IRGen][Runtime] Adjust the ObjC reserved bits on x86-64 to exactly match what the target uses.
Previously we had a single mask for all x86-64 targets which included both the top and bottom bits. This accommodated simulators, which use the top bit, while macOS uses the bottom bit, but reserved one bit more than necessary on each. This change breaks out x86-64 simulators from non-simulators and reserves only the one bit used on each.

rdar://problem/34805348 rdar://problem/29765919
2018-10-04 12:34:08 -04:00
Doug Gregor
0970ab9ef8 [Runtime] Check demangled superclass names against compiler-provided super.
Introduce a sanity check verifying that we can demangle the superclass
of a class when forming type metadata, and that the result matches the
compiler-provided superclass metadata.
2018-10-03 22:19:25 -07:00
Doug Gregor
a4778e1c0c [ABI] Only emit resilient superclass descriptor references in class metadata.
The superclass descriptor reference in class context descriptors is only used
for metadata bound computations when the superclass is resilient. Only
include the superclass descriptor reference when the class has a resilient
superclass, using a trailing record. It’s a tiny space savings for
classes that don’t have resilient superclasses.
2018-10-03 20:05:28 -07:00
Mike Ash
e18e03171f [Stdlib] Change SWIFT_RUNTIME_STDLIB_INTERNAL to not export the symbol.
The functions in LibcShims are used externally, some directly and some through @inlineable functions. These are changed to SWIFT_RUNTIME_STDLIB_SPI to better match their actual usage. Their names are also changed to add "_swift" to the front to match our naming conventions.

Three functions from SwiftObject.mm are changed to SPI and get a _swift prefix.

A few other support functions are also changed to SPI. They already had a prefix and look like they were meant to be SPI anyway. It was just hard to notice any mixup when they were #defined to the same thing.

rdar://problem/35863717
2018-10-03 09:55:33 -04:00
Doug Gregor
df7744e484 Merge pull request #19480 from DougGregor/mangled-assoc-type-witness
[ABI] Use mangled names for associated type witnesses.
2018-10-01 06:57:45 -07:00
Doug Gregor
9a403a0dae [Runtime] Only cache completed type metadata for associated type witnesses.
This is the scheme used for metadata caches elsewhere, and it
eliminates the need to check the metadata state along the hot path of
swift_getAssociatedTypeWitness().
2018-09-30 21:35:15 -07:00
Doug Gregor
65c0c842ed [ABI] Rework the tagging of default associated type witnesses.
Encode default associated type witnesses using a sentinel prefix byte
(0xFF) in the mangled name rather than as a second low bit on the
reference. Align all of the mangled names used for type references to
2 bytes (so we get that low bit regardless) and separate the symbol
names for default associated type witnesses vs. other kinds of
metadata or reflection metadata.
2018-09-28 23:38:38 -07:00
Doug Gregor
22808d1831 [Runtime] Make swift_getAssociatedTypeWitness() bounds checking an assertion. 2018-09-28 10:48:23 -07:00
Doug Gregor
441fee071a [Witness tables] Use a discriminator bit for default associated type witnesses
Indicate whether a particular associated type witness is a default (whose
mangled name is relative to the protocol) vs. being supplied as part of the
conformance (whose mangled name is relative to the conforming type). The
use of pointer identity to distinguish these cases can fail due to the
coalescing of these linker symbols.
2018-09-27 13:26:31 -07:00
Max Moiseev
b9b568b6ec Merge pull request #19565 from moiseev/try-bang-location-info
try! error message should report the right location
2018-09-27 09:12:46 -07:00
Doug Gregor
1416f8dd7d [Runtime] Witness table accessors no longer take the count. 2018-09-26 23:19:34 -07:00
Doug Gregor
5d2f55751a [Runtime] Substitute into associated types using the original conforming type
When producing an associated type witness from a mangled name, adjust the
conforming type metadata to find the original conforming type, which may
be a superclass of the conforming type given.
2018-09-26 23:19:34 -07:00
Doug Gregor
f64044e762 [Runtime] Improve fatal error when unable to demangle an associated type witness. 2018-09-26 23:19:33 -07:00