When looking for type metadata for bound generic types, consider all of the BoundGenericType's substitutions instead of just its type parameters. This lets us correctly find the associated type metadata from class instances. We still fail to pass associated type metadata alongside value types.
Swift SVN r5054
A generic NominalTypeDecl can have more archetypes than a BoundGenericType referencing that decl if the requirements of its type parameters introduce associated types. This still doesn't quite fix codegen for class methods that use associated types (e.g. <rdar://problem/13793646>) because we still fail to actually bind metadata for the archetypes of those associated types.
Swift SVN r5035
Represent protocol 'P.metatype' types using the type metadata of the contained metatype. Emit 'typeof' value witnesses for protocol types that project the existential container buffer and then call the 'typeof' witness for the contained value. Implement the SIL protocol_metatype instruction the same way.
You can't quite call static methods on protocols yet because protocol_method doesn't know how to look up static methods from an existential metatype yet.
This breaks references to protocol names—they will try to create an existential metatype that refers to the metadata of the protocol type itself, rather than to the metadata of a conforming type. <rdar://problem/13438779> would fix them.
Swift SVN r5033
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
Replace 'constant_ref' with 'function_ref', which references a SILFunction directly, and 'global_addr', which references a global variable VarDecl. Get rid of the SILConstant-to-SILFunction mapping in SILModule and replace it with an ilist of SILFunctions. Allow SILFunctions to be 'external' by not having any blocks in their body.
For now, SILFunctions still carry around their SILConstant "name", because name mangling and IRGen still rely on access to the original decl in order to recover IRGen information, which unfortunately leaves IRGen's CodeRefs in a gross, awkward intermediate state. Lifting mangling, AbstractCC, and other linkage attributes to SIL should clear up this up.
Swift SVN r4865
handling non-fixed layouts.
This uncovered a bug where we weren't rounding up the header
size to the element alignment when allocating an array of archetypes.
Writing up a detailed test case for *that* revealed that we were
never initializing the length field of heap arrays. Fixing that
caused a bunch of tests to crash trying to release stuff. So...
I've left this in a workaround state right now because I have to
catch a plane.
Swift SVN r4804
and supporting logic.
PathComponent and LValue are (apparently unnecessarily) kept alive by
projectPhysicalClassMemberAddress (rdar://13671033)
Swift SVN r4773
The argument to archetype_method can be a metatype, so allow that. While we're here, implement lowering for AssociatedMetatypeInst, and fix initial bringup of SIL-IRGen so that polymorphic arguments get emitted into the entry point BB instead of a random other BB.
Swift SVN r4741
ArchetypeMethodInst, like ProtocolMethodInst, actually needs to be modeled as returning a thick function type, in order to represent the metadata parameter to the witness table function. With that change to SILGen, implement ArchetypeMethodInst IRGen.
Swift SVN r4688
On second thought, having SILConstant be able to point to a TLCD is going
against the goal of making SILConstant be a "SILGen thing". I'll find another
approach.
Swift SVN r4680
Per John's comments, make a GenericBox struct to represent the layout of a generic box allocation, move all the layout calculations into methods on GenericBox, and alter swift_deallocBox to take the type as an argument so that it's future-proofed for when we start special-casing certain types in allocBox.
Swift SVN r4613
Add a runtime function that, given a generic type metadata pointer, allocates a heap object capable of containing a value of that type. This is a first-pass implementation that always does the worst case thing of stuffing the type metadata into the box with the value and using its value witness table to size, align, and destroy the box. Use swift_allocBox to implement ArchetypeTypeInfo::allocate correctly for heap object allocations. This means SIL's alloc_box $T now works for archetypes, and a simple generics test now (almost) compiles through SIL!
Swift SVN r4599
At the top level, if 'operator' is followed by 'infix', 'prefix', or 'postfix', consider it a contextual keyword, and parse an operator decl following it that looks like:
operator {infix|postfix|prefix} <+> {
attributes…
}
Prefix and postfix operator decls currently admit no attributes. Infix operators have 'associativity {left|right|none}' and 'precedence <int>' attributes.
This patch implements parsing for operator declarations but does not yet attach the declared attributes to func decls for the operators.
Swift SVN r4596
Pack the uncurry level onto SILConstant, and modify SILConstant constructors to determine the natural uncurry level of their referenced entity by default. While we're here, improve how SILConstant represents different kinds of constants by using a real enum for the kind. Type closure entry points by giving them an extra curry level for their context. The implementation of ApplyInst and ClosureInst hasn't been updated yet, so tests that lower closures to SIL are temporarily broken.
Swift SVN r4354
Push LLVM attribute generation from expandAbstractCC into getFunctionSignature and CallEmission so that they can generate sret and/or byval attributes per-argument according to the calling convention. Copy our bogus rule for emitting sret returns (more than three elements in the explosion) and reuse it to pass large struct values as byvals rather than as explosions. This should be good enough to get both 'NSRect' and
'NSRange', 'NSSize' etc. to pass correctly to ObjC methods. Next step is to set the AbstractCC correctly for imported func decls so that standalone C functions follow the same bogus rule.
Swift SVN r3993
Alter CalleeSource and Callee to keep their own internal vector of substitutions and concatentate multiple SpecializationExpr substitutions. Update EmitPolymorphicArguments::emit to emit arguments out of the substitution list based on the generic parameters of the current function type instead of assuming that the substitution list and generic parameter list match up.
Swift SVN r3937
Witness table fulfillments for protocol types were being ignored because we didn't record them with the proper key--we were just dropping the protocol on the floor and recording null. Fixing this fixes <rdar://problem/12965934> and obviates r3904.
Swift SVN r3907
Static methods and constructors receive class metadata from which they can derive their polymorphic parameters, so adding additional metatype arguments to the function is redundant.
Swift SVN r3862
Factor out the parts of GenProto's prepareExistentialMemberRefCall necessary to map to SIL's ProtocolMethodInst. Similar to ConstantRefInst, we map the ProtocolMethodInst to an incomplete CallEmission and emit the call when all curry levels have been applied.
Swift SVN r3794
Factor out the witness table initialization and projection logic from GenProto so that IRGenSIL can use it to implement the ProjectExistential and InitExistential instructions. Also map the CopyAddr and DestroyAddr instructions to value witness table calls so that value semantics on protocol values (and other address-only values) work. The added test compiles but doesn't run yet because invoking methods on a protocol value still requires implementing the ProtocolMethod instruction.
Swift SVN r3787
The test changes are that we're setting a class body on
some types that we weren't before. For some of these,
this is okay; for others, it's more questionable, but
ultimately not *harmful*.
Swift SVN r3746