mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Change value witnesses to take the metatype as 'self'.
The motivations here are that (1) the parametric types that actually need the 'self' argument don't necessarily all want to do what tuples do and put the VWT relative to the metatype at some definable offset and (2) recovering type parameters from the metatype is much better defined than also hopping some relationship back. Plus this allows VWTs to be shared across instances of generic types. Also, I'm going to need to add a VW that takes a metatype, and consistency seems right here. If keeping two values live is actually punishing, I might have to reconsider this. But the VWT is at least always recoverable from the metatype, so.... I ended up abstracting the thing that GenHeap was doing in order to save archetypes for arrays, because I needed it to save metatypes instead of VWTs and because it really needed abstractin'. Swift SVN r3096
This commit is contained in:
@@ -45,11 +45,17 @@ static bool requiresHeapHeader(LayoutKind kind) {
|
||||
llvm_unreachable("bad layout kind!");
|
||||
}
|
||||
|
||||
void swift::irgen::addHeapHeaderToLayout(IRGenModule &IGM,
|
||||
Size &size, Alignment &align,
|
||||
SmallVectorImpl<llvm::Type*> &fields) {
|
||||
/// Return the size of the standard heap header.
|
||||
Size irgen::getHeapHeaderSize(IRGenModule &IGM) {
|
||||
return IGM.getPointerSize() * 2;
|
||||
}
|
||||
|
||||
/// Add the fields for the standard heap header to the given layout.
|
||||
void irgen::addHeapHeaderToLayout(IRGenModule &IGM,
|
||||
Size &size, Alignment &align,
|
||||
SmallVectorImpl<llvm::Type*> &fields) {
|
||||
assert(size.isZero() && align.isOne() && fields.empty());
|
||||
size += IGM.getPointerSize() * 2;
|
||||
size = getHeapHeaderSize(IGM);
|
||||
align = IGM.getPointerAlignment();
|
||||
fields.push_back(IGM.RefCountedStructTy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user