[deserialization] Add ClassDecl -> VTable map to SILModule.

Swift SVN r15545
This commit is contained in:
Michael Gottesman
2014-03-27 03:52:00 +00:00
parent fdaa10b94f
commit a571cd83f9
3 changed files with 15 additions and 0 deletions

View File

@@ -125,6 +125,9 @@ private:
llvm::DenseMap<const NormalProtocolConformance *, SILWitnessTable *>
WitnessTableLookupCache;
/// Lookup table for SIL vtables from class decls.
llvm::DenseMap<const ClassDecl *, SILVTable *> VTableLookupTable;
/// This is a cache of intrinsic Function declarations to numeric ID mappings.
llvm::DenseMap<Identifier, IntrinsicInfo> IntrinsicIDCache;
@@ -314,6 +317,9 @@ public:
std::pair<SILWitnessTable *, ArrayRef<Substitution>>
lookUpWitnessTable(const ProtocolConformance *C);
/// Look up the VTable mapped to the given ClassDecl. Returns null on failure.
SILVTable *lookUpVTable(const ClassDecl *C);
// Given a protocol conformance, attempt to create a witness table declaration
// for it.
SILWitnessTable *

View File

@@ -479,3 +479,11 @@ void SILModule::linkAllWitnessTables() {
void SILModule::linkAllVTables() {
SILLoader->getAllVTables();
}
SILVTable *SILModule::lookUpVTable(const ClassDecl *C) {
auto R = VTableLookupTable.find(C);
if (R == VTableLookupTable.end())
return nullptr;
return R->second;
}

View File

@@ -32,6 +32,7 @@ SILVTable *SILVTable::create(SILModule &M, ClassDecl *Class,
alignof(SILVTable));
SILVTable *vt = ::new (buf) SILVTable(Class, Entries);
M.vtables.push_back(vt);
M.VTableLookupTable[Class] = vt;
return vt;
}