This is yet another waypoint on the path towards the final
generic-metadata design. The immediate goal is to make the
pattern a private implementation detail and to give the runtime
more visibility into the allocation and caching of generic types.
The key path pattern needs to include a reference to the external descriptor, along with hooks for lowering its type arguments and indices, if any. The runtime will need to instantiate and interpolate the external component when the key path object is instantiated.
While we're here, let's also reserve some more component header bytes for future expansion, since this is an ABI we're going to be living with for a while.
Within conformance records, reference Objective-C class objects
indirectly so the runtime can update those references appropriately.
We don't need to do this for classes with Swift metadata.
Fixes the ABI-affecting part of rdar://problem/36310179.
LLVM r322806 defaults to make symbols with non-default visibility be marked
as dso_local. However, there is also an assertion that DLLImport symbols
are not dso_local, since that combination makes no sense. These changes
revealed some problems in Swift's IR linkage for PublicExternal,
HiddenExternal and PrivateExternal SIL linkage. Those mean different things
for definitions vs. declarations.
PublicExternal definitions were marked with DLLExport but with
AvailableExternally linkage. That seems inconsistent. AvailableExternally
symbols are not supposed to be emitted at all.
HiddenExternal and PrivateExternal symbols were using the same visibility
and storage class regardless of whether they were declarations or
definitions. This change fixes that so that those symbols are either hidden
or DLLImport but not both at the same time.
rdar://problem/36683229
This makes resolving mangled names to nominal types in the same module more efficient, and for eventual secrecy improvements, also allows types in the same module to be referenced from mangled typerefs without encoding any source-level name information about them.
* Implement #warning and #error
* Fix #warning/#error in switch statements
* Fix AST printing for #warning/#error
* Add to test case
* Add extra handling to ParseDeclPoundDiagnostic
* fix dumping
* Consume the right paren even in the failure case
* Diagnose extra tokens on the same line after a diagnostic directive
Extend protocol conformance descriptors with two more bits of information:
* For retroactive conformances, add the module in which the conformance
occurs. This will eventually be used for error reporting/ambiguity
resolution when retroactive conformances collide.
* For conditional conformances, add the conditional requirements. We need
these for runtime evaluation of conditional conformances.
A "retroactive" protocol conformance is a conformance that is provided
by a module that is neither the module that defines the protocol nor
the module that defines the conforming type. It is possible for such
conformances to conflict at runtime, if defined in different modules
that were not both visible to the compiler at the same time.
When mangling a bound generic type, also mangle retroactive protocol
conformances that were needed to satisfy the generic requirements of
the generic type. This prevents name collisions between (e.g.) types
formed using retroactive conformances from different modules. The
impact on the size of the mangling is expected to be relatively small,
because most conformances are not retroactive.
Fixes the ABI part of rdar://problem/14375889.
This new format more efficiently represents existing information, while
more accurately encoding important information about nested generic
contexts with same-type and layout constraints that need to be evaluated
at runtime. It's also designed with an eye to forward- and
backward-compatible expansion for ABI stability with future Swift
versions.
All Swift-defined nominal types have their runtime metadata recorded
in a special section, so it can be found later. This recording is
suppressed when that type is stated to conform to a protocol, because
the runtime can find nominal types in either place.
Imported types would get their conformances recorded, but would not
get recorded in the runtime metadata record otherwose. Therefore, the
runtime would not be able to find such types by name.
For any foreign type whose metadata we emit, make sure that metadata
can be found by a runtime lookup.
Emit protocol conformance descriptors as separate symbols, rather than
inlining them within the section for protocol conformance records. We
want separate symbols for protocol conformances both because it is easier
to make them variable-length (as required for conditional
conformances) and because we want to reference them from witness
tables (both of which are coming up).
Protocol conformance records are becoming richer and more interesting;
separate out the "flags" word and add the various other fields that we
want there (is-retroactive, is-synthesized-nonunique, # of conditional
requirements).
This is going to be used for "always emit into client" functions,
such as default argument generators and stored property
initializers.
- In dead function elimination, these functions behave identically to
public functions, serving as "anchors" for the mark-and-sweep
analysis.
- There is no external variant of this linkage, because external
declarations can use HiddenExternal linkage -- the definition should
always be emitted by another translation unit in the same Swift
module.
- When deserialized, they receive shared linkage, because we want the
linker to coalesce multiple copies of the same deserialized
definition if it was deserialized from multiple translation units
in the same Swift module.
- When IRGen emits a definition with this linkage, it receives the
same LLVM-level linkage as a hidden definition, ensuring it does not
have a public entry point.
The nominal type access functions took all of the generic arguments
directly, which is hard to call from the runtime. Instead, pass up to
three generic arguments directly (because it’s good for code size), and put the rest into an array.
This has three principal advantages:
- It gives some additional type-safety when working
with known accessors.
- It makes it significantly easier to test whether a declaration
is an accessor and encourages the use of a common idiom.
- It saves a small amount of memory in both FuncDecl and its
serialized form.
Introduce a new section that contains (relative) references to all of the
Swift protocol descriptors emitted into this module. We'll use this to
find protocol descriptors by name.
Lazy functions may never be lowered during IRGenSIL, but they must be
lowered if they have code coverage instrumentation. Otherwise, records
in the coverage mapping may reference non-existent name data, because
the corresponding function (with the instrprof_increment intrinsic) has
no entry in the profile symbol table.
rdar://36061003
Only foreign classes and other imported types were making use of the
type metadata reference form in conformance records. Switch those over
to using nominal type descriptors, so we're using nominal type
descriptors for everything possible.
Only Objective-C-defined classes use a different representation now.
The separate section of type references uses the same type reference format
as in protocol conformance records. As with protocol conformance records,
mangle the type reference kind into the lower two bits. Then, eliminate the
separate "flags" field from the type metadata record. Finally, rename
the section because the Swift 5 stable format for this section is
different from prior formats, and the two runtimes need to be able to
coexist.
Eliminate the separate flags field in protocol conformance records, now that
all of the information is stored in spare bits elsewhere. Reserve this
32-bit value for future use to describe conditional requirements.
Use the spare bits within the type reference field to describe the kinds
of type metadata records, so that we no longer need to rely on a
separate "flags" field.
Rather than emitting unique, direct type metadata for non-foreign
types, emit a reference to the nominal type descriptor. This collapses
the set of type metadata reference kinds to 3: nominal type
descriptor, (indirect) Objective-C class object, and nonuniqued
foreign type metadata.
Now that references to Objective-C class objects are indirected
(via UniqueIndirectClass), classes with Swift type metadata can be
directly referenced (via UniqueDirectType) rather than hopping through
swift_getObjCClassMetadata().
Within conformance records, reference Objective-C class objects
indirectly so the runtime can update those references appropriately.
We don't need to do this for classes with Swift metadata.