Re-apply "Reduce memory footprint of the Swift compiler"

Use malloc/free for allocating/freeing SIL instructions instead of using the BumpPtrAllocator. This allows for memory reuse and significantly reduces the memory footprint of the compiler.

For example, a peak memory usage during a compilation of the standard library and StdlibUnitTest is reduced by 25%-30%. The performance of the compiler seems to be not affected by this change, i.e. no slowdown is measured.

The use-after-free issues reported by build bots are fixed now.

rdar://23303031
This commit is contained in:
Roman Levenstein
2015-12-09 11:31:58 -08:00
parent 13b679d9ba
commit 46b58ac699
7 changed files with 85 additions and 37 deletions

View File

@@ -124,6 +124,21 @@ SILModule::~SILModule() {
delete (SILTypeListUniquingType*)TypeListUniquing;
}
void *SILModule::allocate(unsigned Size, unsigned Align) const {
if (getASTContext().LangOpts.UseMalloc)
return AlignedAlloc(Size, Align);
return BPA.Allocate(Size, Align);
}
void *SILModule::allocateInst(unsigned Size, unsigned Align) const {
return AlignedAlloc(Size, Align);
}
void SILModule::deallocateInst(SILInstruction *I) {
AlignedFree(I);
}
SILWitnessTable *
SILModule::createWitnessTableDeclaration(ProtocolConformance *C,
SILLinkage linkage) {