mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user