This is more resilient, since we want to be able to add more information behind the address point of type objects. The start of the metadata object is now an internal "full metadata" symbol.
Note that we can't do this for known opaque metadata from the C++ runtime, since clang doesn't have a good way to emit offset symbol aliases, so for non-nominal metadata objects we still emit an adjustment inline. We also aren't able to generate references to aliases within the same module due to an MC bug with alias refs on i386 and armv7 (rdar://problem/22450593).
Swift SVN r31523
This is more resilient, since we want to be able to add more information behind the address point of type objects, and also makes IR a lot less cluttered. The start of the metadata object is now an internal "full metadata" symbol.
Note that we can't do this for known opaque metadata from the C++ runtime, since clang doesn't have a good way to emit offset symbol aliases, so for non-nominal metadata objects we still emit an adjustment inline.
Swift SVN r31515
These will be used for reflection, and eventually to speed up generic
operations on single payload enums as well.
Progress on <rdar://problem/21739870>.
Swift SVN r30214
This nicely gathers all the layout information together in one contiguous bundle we can potentially emit independently for use in generic type layout. A step on the way to rdar://problem/19898165.
Swift SVN r30128
...so that the debugger can use it too. We may end up needing to move more
things from LinkEntity to Mangler in this way, but this is the baseline for
what's needed to properly display private types.
The suffix "Full" here is intended to represent that the Swift prefix "_T"
is included already; if there's a better name for this I'd be glad to change
it.
rdar://problem/18353463
Swift SVN r22031
initializeBufferWithTakeOfBuffer value witness.
Attempt to use initializeBufferWithTakeOfBuffer in
some appropriate places.
There are some changes enabled by this which are
coming in a follow-up patch.
Swift SVN r20741
functions, and make those functions memoize the result.
This memoization can be both threadsafe and extremely
fast because of the memory ordering rules of the platforms
we're targeting: x86 is very permissive, and ARM has a
very convenient address-dependence rule which happens to
exactly match the semantics we need.
Swift SVN r20381
Add value witnesses for destroyArray, initializeArrayWithCopy, and initializeArrayWithTake{FrontToBack,BackToFront}, and fill out the runtime value witness table implementations. Stub out the IRGen ones for now.
Swift SVN r16772
Centralize the logic for figuring out what name to use for a class or
protocol in the Objective-C runtime. When the flag is enabled (it's
still disabled by default), use mangled names for all Swift-defined
classes, including those that are @objc. Note that the naming is
determined in the AST, because we're also going to use this logic when
printing an Objective-C header for Clang's consumption. The mangled
names will always start with _Tt, so they're easy to recognize and
demangle in various tools or, eventually, in the Objective-C runtime.
The new test (test/IRGen/objc_mangling.sil) is the only test of this
behavior at the moment. The other test changes are due to the
centralized logic tweaking the names of internal constants (_DATA_*,
_CATEGORY_*, etc.).
This is the majority of <rdar://problem/15506580>.
Swift SVN r15588
This representation is inspired by Clang's internal representation.
The current attribute representation, which is basically a union
of "stuff" in DeclAttributes, is not amendable to richer
attributes, such as @availability, that need to be implemented.
In Clang, attributes are modeled with actual objects that
encode both semantic and syntactic information (e.g., source ranges)
that facilitate richer checking, better diagnostics, and better tools.
This change is foundational for implementing @availability, but
also is a better long-term representation. As a migratory path,
it creates some duplications, with AttrKind and DeclAttrKind, the
two which should eventually become the same thing.
As part of this patch, there is some additional parser recovery
(for the new attribute representation) for duplicate attributes.
The parser now parses the entire duplicate attribute, which could
be quite complex, and then issues a diagnostic that the attribute
is a duplicate (and discarding it). This delayed diagnostic
also allows us to present ranges for the duplicate attribute, which
provides a better user experience.
Swift SVN r15365
Emit vtable entries for abstract initializers. When we're constructing
an object using an abstract initializer based on a metatype value that
is not statically derivable, use the vtable entry to call the
subclass's allocating constructor.
Most of the IRGen work here is hacking around the lossy SILDeclRef ->
(Code|Function)Ref -> SILDeclRef conversion. I'd feel bad about this
if John hadn't already agreed to clean this up at some point.
Swift SVN r14238
It was convenient to just assume that the SILModule defines
the deallocating destructor function. This should probably
be represented somehow in e.g. the sil_vtable instead of
being an implicit dependency.
Swift SVN r12412
Note that this lowering currently assumes that the static type of the class is its dynamic type. This should be a flag on the dealloc_ref instruction, not an assumption.
Swift SVN r12144
used only for debug info and within the _Tt namespace.
The DWARF output created by swift is intentionally flat, therefore
archetypes need to be emitted with their DeclContext. While increasing the
length of the mangled names in some cases (substitutions help a lot) it
has the advantage of making names completely self-contained.
There is a lengthy thread on swift-debugger discussing this change.
Swift SVN r10348
Produce protocol descriptors when we see a protocol definition in the current module. If the protocol is @objc, go through the existing path for generating full Protocol* metadata for objc objects; otherwise, emit our layout-compatible but strong-external-linkage Swift protocol descriptor record.
Swift SVN r9867
Build a nominal type descriptor when we emit the metadata or generic metadata pattern for a nominal type, and put a reference into the formerly null slot in the struct or enum metadata. We need to make a place for them in class metadata; that'll come next.
Swift SVN r9492
Among other things this enables mangled names for tuples.
This adds a pointer to the DeclContext to SILFunction and which is used
to provide the necessary context to the Mangler.
Fixes rdar://problem/14808764 and rdar://problem/14813658.
Swift SVN r8070
To instantiate the value witness table for generic types, we were instantiating the generic type at () for all of its parameters and hoping for the best. That's insane. Instead, let's use the DeclaredTypeInContext for the generic type so the archetypes actually get usefully bound inside the witnesses. This way, the witness implementations should be independent of generic parameters, so we can also mangle the unbound type into the witness symbols.
Swift SVN r7901
These value witness table entries will be conditionally available for types that support specialized union representation through extra inhabitants and/or spare bits and for union value witnesses:
- storeExtraInhabitant, to store an extra inhabitant representation;
- getExtraInhabitantIndex, to recognize an extra inhabitant representation;
- getUnionTag, to get a union's discriminator; and
- inplaceProjectUnionData, to extract the value in place from a union.
This just sets up the enumerators and related IR types and mangling; nothing emits these witnesses yet.
Swift SVN r7234
We need to handle three cases:
- If a protocol conformance has no associated types, or the associated type witnesses all have statically resolvable metadata, we can expose a *direct* witness table symbol.
- If a protocol conformance has associated types with runtime-instantiated metadata, we need to gate the witness table behind a *lazy* initializer function to fill in the metadata fields.
- If a protocol conformance has associated types where the type or one of its conformances are *dependent* on its parent's generic parameters, we need to instantiate multiple witness tables at runtime.
Swift SVN r6805
the debug info, to aid the debugger in figuring out the implementation
language of a given type in multi-language environments.
FYI, where applicable, we also emit the
DW_AT_APPLE_runtime_class(DW_AT_lang_Swift) attribute.
The demangler accepts type names with the "_Tt" prefix without the --type
switch.
Swift SVN r6714
We mangle the type of the property, not the type of the accessor, so the uncurry level of the accessor is irrelevant to the mangler and causes the mangler to mangle properties of function type incorrectly--'var x : () -> ()', for instance, gets mangled to '_T6module1xfT_T_g' (with a lowercase uncurried 'f') instead of the proper '_T6module1xFT_T_g'. This broke the ListMaker test because SILGen and IRGen were coming up with inconsistent manglings for the 'handler' property of UndoManager in NSUndoManagerExts. Fixes <rdar://problem/13926113>.
Swift SVN r5229
storage in a flags word in the value witness table. Pack the
alignment into only 16 bits of this word. Optimize tuple value
witnesses based on whether they're POD and inline.
Swift SVN r5138
Add a SWIFT_FALLTHROUGH macro that expands to [[clang::fallthrough]] for Clang and nothing for other compilers. No functionality change.
Swift SVN r5043
To be able to get the dynamic type of a generic value, the 'typeof' operation needs to be part of the value witness for the type. Add 'typeof' to the value witness table layout, and in the runtime, provide standard typeof witnesses for static, Swift class, and ObjC class values.
Swift SVN r5013
Sever the last load-bearing link between SILFunction and SILConstant by naming SILFunctions with their mangled symbol names. Move the core of the mangler up to SIL, and teach SILGen how to use it to mangle a SILConstant.
Swift SVN r4964