- A spot fix in SILGen for reabstracting the result of a downcast, which fixes checked casts to function types.
- Associate the layout information in type metadata records with the most abstract representation of the type. This is the correct thing to do in cases where we need the metadata as a tag for an opaque value--if we store a value in an Any, or pass it as an unconstrained generic parameter, we must maximally reabstract it. This fixes the value semantics of existentials containing trivial metatypes.
- To ensure that we get runtime layout of structs and enums correct when they contain reabstractable types, introduce a "metadata for layout" concept, which doesn't need to describe the canonical metadata for the type, but only needs to describe a type with equivalent layout and value semantics. This is a correctness fix that allows us to correctly lay out generic types containing dependent tuples and functions, and although we don't really take advantage of it here, it's also a potential runtime performance win down the road, because we could potentially produce direct metadata for a primitive type that's layout-equivalent with a runtime-instantiated type. To aid in type safety here, push SILType deeper into IRGen in places where we potentially care about specific representations of types.
- Finally, fix an inconsistency between the runtime and IRGen's concept of what spare bits unmanaged references and thick metatypes have.
Together, these fixes address rdar://problem/16406907, rdar://problem/17822208, rdar://problem/18189508, and likely many other related issues, and also fixes crash suite cases 012 and 024.
Swift SVN r21963
This was preventing generic subclasses of NSObject unnecessarily
rdar://problem/17417625, and there is no reason to compute the
encoding for each one: it will always be @?.
Swift SVN r21777
If a type has to be passed or returned resiliently, it
will necessarily be passed indirectly, which is already
represented in SILFunctionType. There is no need to
represent this as a separate channel of information.
NFC. Also fixes a problem where the signature cache
for ExtraData::Block was writing past the end of an
array (but into the storage for an adjacent array
which was fortunately never used).
ExtraData should also disappear as a concept, but we're
still relying on that for existential protocol witnesses.
Swift SVN r21548
unexpected forematter from the superclass.
This requires a pretty substantial shift in the
generic-metadata allocation/initialization dance
because (1) we can't allocate class metadata without
knowing what the superclass is and (2) the offset
from the metadata cache entry to the address point is
no longer determined solely by the metadata pattern.
While I'm making invasive changes to metadata, fix
two race conditions in metadata creation. The first
is that we need to ensure that only one thread succeeds
at lazily creating a generic-metadata cache. The second
is that we need to ensure that only one thread actually
attempts to create a particular metadata; any others
should block until the metadata is successfully built.
This commit finishes rdar://17776354. LLDB will
need to adjust to the runtime-private metadata layout
changes.
Swift SVN r20537
We were already effectively doing this everywhere /except/ when building
the standard library (which used -O2), so just use the model we want going
forward.
Swift SVN r20455
Instead of hacking together inaccurate metadata only for object-typed properties, make an effort to produce accurate metadata for all types of properties, and accurately capture the "copy", "dynamic", and "weak" semantics of some properties. This is necessary for Core Data to accurately synthesize property accessors for non-object properties; currently it will generate bogus object accessors over properties with non-object type. <rdar://problem/17373368>
This isn't fully accurate, since Clang hides property type encoding behind a 'getObjCEncodingForPropertyDecl' that only accepts an ObjCPropertyDecl. With some refactoring, it should be possible to expose this.
Swift SVN r19567
Although block types are invariant to ABI layout, they do need to be accurately encoded in method and block signatures for XPC to work correctly.
Swift SVN r19049
We do this hack for @objc methods at the top level, emitting them as external in SIL and making them private in IRGen, to prevent SIL optimizations from dropping the functions as unused (see <rdar://problem/17074598>), but we weren't doing so for @objc classes in local contexts, and they were getting dropped. Fixes <rdar://problem/16982281>.
Swift SVN r18668
This is still a kludge setting the visibility of ObjC thunks at IRGen rather than SILGen time, but resolves <rdar://problem/16906857>.
Swift SVN r18063
When we partially apply an inner-pointer method or property, the thunk or partial_apply that applies "self" needs to be the one that handles lifetime-extending "self". Verify that a partial_apply-ed inner pointer method is not inner pointer and implement lifetime extension in the partial apply thunk. Fixes <rdar://problem/16803701>.
Swift SVN r17321
These initializers are class methods, so provide them with the
metatype value rather than allocating an object. Moreover, they
generally return autoreleased, so we need to retain them out of the
autorelease pool before returning the produced 'self'.
Finishes the SILGen and IRGen portions of
<rdar://problem/16509024>. We still can't enable this in practice
because we're getting duplicate initializers, as predicated in the
hacky r16531.
Swift SVN r16555
Implement the init_block_storage_header SIL instruction by teaching IRGen how to produce block descriptors, including copy/dispose helpers and block signatures.
Swift SVN r16478
...I hope. It is frustrating that testing this effectively
seems to require a massively different build environment.
More of rdar://16565958.
Swift SVN r16468
Formatting names into strings repeatedly, and using those for semantic
analysis, is generally considered poor form. Additionally, use the
camelCase utilities to perform the string manipulation we need, and
cache results on the ObjCAttr so we don't repeatedly do string
manipulation.
Swift SVN r16334
These bits are orthogonal to each other, so combine them into one, and diagnose attempts to produce a type that's both. Spot-fix a bunch of places this revealed by inspection that we would have crashed in SILGen or IRGen if blocks were be handled.
Swift SVN r16088
Replace HeapTypeInfo::hasSwiftRefcount with a "getSwiftRefcounting" method, returning an enum indicating whether a heap object has native/ObjC/block/unknown refcounting semantics. Use _Block_copy and _Block_release for block refcounting.
Swift SVN r16041
We can just get it from the instance type, if the instance type has been fully initialized, which is the case except during parsing of type decls when the decls' own types are being formed.
Swift SVN r15598
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
in extended protocol meta-data. wip. Will have tests
when it is complete. // rdar://16308986
(note that you need the latest clang pulled or
your compile will fail).
Swift SVN r15270
accessors.
Optimize these accessors by making them check for
BoundGenericXType instead of BoundGenericType and dyn_cast'ing
the Decl. (The latter used to be necessary before we split
BoundGenericType.)
Swift SVN r15037
We should also remove it from IRGen's Explosion API; IRGen
should always use maximal explosion, and SILGen will tell us
whether or not we need to put that in memory somewhere.
But that can be a later commit.
Swift SVN r14242
We're mostly not that bad about this right now, but lazy
emission is going to wreak havoc.
Note that SILGen itself doesn't really make very good decisions
about the order in which to emit functions, but step one
towards fixing that is actually respecting it.
Swift SVN r14200
Introduce the SIL instructions thick_to_objc_metatype and
objc_to_thick_metatype to convert between the 'thick' and
'Objective-C' representations of a metatype. Most of this code is
trivial support code for these conversions: printing, parsing,
(de-)serialization, etc., for which testing will come online in
subsequent patches or is incidental in other tests.
Lower Objective-C metatype values down to objc_class* at the IR level
and implement IRGen support for these SIL instructions. SIL-only test
case at the moment because SILGen never creates these instructions.
Swift SVN r14087
Updates to signature expansion, entrypoint lowering, and callsite
lowering so that each selects the ABI types for all arguments at once
rather than an argument at a time (as well as considering whether the
return value is returned indirectly). This is required to get the
correct behavior in cases where we run out of argument registers and
need to pass arguments as indirect byvals.
This is mostly just refactoring existing code to move loops inside inner
functions as well as dealing with return values at the same time as
arguments.
Swift SVN r13781
There are some straggling references to the context generic param list, but nothing uses the non-interface param or result types anymore!
Swift SVN r13725