Introduce a "@box T" type for SIL.

Represents a heap allocation containing a value of type T, which we'll be able to use to represent the payloads of indirect enum cases, and also improve codegen of current boxes, which generates non-uniqued box metadata on every allocation, which is dumb. No codegen changes or IRGen support yet; that will come later.

This time, fix a paste-o that caused SILBlockStorageTypes to get replaced with SILBoxTypes during type substitution. Oops.

Swift SVN r29489
This commit is contained in:
Joe Groff
2015-06-18 15:21:52 +00:00
parent 7bf996152b
commit e57c470019
25 changed files with 168 additions and 4 deletions

View File

@@ -258,6 +258,7 @@ struct ASTContext::Implementation {
llvm::FoldingSet<GenericFunctionType> GenericFunctionTypes;
llvm::FoldingSet<SILFunctionType> SILFunctionTypes;
llvm::DenseMap<CanType, SILBlockStorageType *> SILBlockStorageTypes;
llvm::DenseMap<CanType, SILBoxType *> SILBoxTypes;
llvm::DenseMap<BuiltinIntegerWidth, BuiltinIntegerType*> IntegerTypes;
llvm::FoldingSet<ProtocolCompositionType> ProtocolCompositionTypes;
llvm::FoldingSet<BuiltinVectorType> BuiltinVectorTypes;
@@ -1491,6 +1492,7 @@ size_t ASTContext::getTotalMemory() const {
// Impl.GenericFunctionTypes ?
// Impl.SILFunctionTypes ?
llvm::capacity_in_bytes(Impl.SILBlockStorageTypes) +
llvm::capacity_in_bytes(Impl.SILBoxTypes) +
llvm::capacity_in_bytes(Impl.IntegerTypes) +
// Impl.ProtocolCompositionTypes ?
// Impl.BuiltinVectorTypes ?
@@ -2869,6 +2871,20 @@ CanSILBlockStorageType SILBlockStorageType::get(CanType captureType) {
return CanSILBlockStorageType(storageTy);
}
CanSILBoxType SILBoxType::get(CanType boxType) {
ASTContext &ctx = boxType->getASTContext();
auto found = ctx.Impl.SILBoxTypes.find(boxType);
if (found != ctx.Impl.SILBoxTypes.end())
return CanSILBoxType(found->second);
void *mem = ctx.Allocate(sizeof(SILBlockStorageType),
alignof(SILBlockStorageType));
auto storageTy = new (mem) SILBoxType(boxType);
ctx.Impl.SILBoxTypes.insert({boxType, storageTy});
return CanSILBoxType(storageTy);
}
CanSILFunctionType SILFunctionType::get(GenericSignature *genericSig,
ExtInfo ext, ParameterConvention callee,
ArrayRef<SILParameterInfo> interfaceParams,