diff --git a/ecmascript/linked_hash_table.cpp b/ecmascript/linked_hash_table.cpp index da33da77538c00f64c79a77c5ed38cab59fdf9ec..67e61e8f84eea7ff1592c1daa40c4822a0732607 100644 --- a/ecmascript/linked_hash_table.cpp +++ b/ecmascript/linked_hash_table.cpp @@ -221,7 +221,7 @@ JSTaggedValue LinkedHashMap::Shrink(const JSThread *thread, const JSHandle::Shrink(thread, table, additionalCapacity)); + LinkedHashTable::Shrink(thread, table, additionalCapacity)); } // LinkedHashSet diff --git a/ecmascript/mem/heap.cpp b/ecmascript/mem/heap.cpp index 9294b267354982e618573b87620122b2fe07d67d..17a5c6d467ca48eaf15a09f01bcfd6f1208f7105 100644 --- a/ecmascript/mem/heap.cpp +++ b/ecmascript/mem/heap.cpp @@ -152,7 +152,9 @@ void Heap::CollectGarbage(TriggerGCType gcType) SetNewSpaceMaximumCapacity(SEMI_SPACE_SIZE_CAPACITY); ResetAppStartup(); } else { - semiSpaceCollector_->RunPhases(); + if (!CheckAndTriggerCompressGC()) { + semiSpaceCollector_->RunPhases(); + } } break; case TriggerGCType::OLD_GC: @@ -228,7 +230,7 @@ void Heap::RecomputeLimits() bool Heap::CheckAndTriggerOldGC() { - if (oldSpace_->GetHeapObjectSize() <= oldSpaceAllocLimit_) { + if (oldSpace_->GetCommittedSize() + hugeObjectSpace_->GetCommittedSize() <= oldSpaceAllocLimit_) { return false; } CollectGarbage(TriggerGCType::OLD_GC); @@ -237,7 +239,7 @@ bool Heap::CheckAndTriggerOldGC() bool Heap::CheckAndTriggerCompressGC() { - if (oldSpace_->GetHeapObjectSize() <= oldSpaceAllocLimit_) { + if (oldSpace_->GetCommittedSize() + hugeObjectSpace_->GetCommittedSize() <= oldSpaceAllocLimit_) { return false; } CollectGarbage(TriggerGCType::COMPRESS_FULL_GC); @@ -246,7 +248,7 @@ bool Heap::CheckAndTriggerCompressGC() bool Heap::CheckAndTriggerNonMovableGC() { - if (nonMovableSpace_->GetHeapObjectSize() <= DEFAULT_NON_MOVABLE_SPACE_LIMIT) { + if (nonMovableSpace_->GetCommittedSize() <= DEFAULT_NON_MOVABLE_SPACE_LIMIT) { return false; } CollectGarbage(TriggerGCType::NON_MOVE_GC); diff --git a/ecmascript/mem/tlab_allocator-inl.h b/ecmascript/mem/tlab_allocator-inl.h index 3a36d26b60004c612f6447f9d85c872df0feccec..9e375449efa015acaab0aa368eaafd3c9c3d053b 100644 --- a/ecmascript/mem/tlab_allocator-inl.h +++ b/ecmascript/mem/tlab_allocator-inl.h @@ -24,7 +24,7 @@ #include "ecmascript/mem/tlab_allocator.h" namespace panda::ecmascript { -static constexpr size_t SEMIGC_YOUNG_BUFFER_SIZE = 32 * 1024; +static constexpr size_t YOUNG_BUFFER_SIZE = 32 * 1024; static constexpr size_t OLD_BUFFER_SIZE = 255 * 1024; TlabAllocator::TlabAllocator(Heap *heap, TriggerGCType gcType) @@ -35,11 +35,15 @@ TlabAllocator::TlabAllocator(Heap *heap, TriggerGCType gcType) TlabAllocator::~TlabAllocator() { - FreeObject::FillFreeObject(heap_->GetEcmaVM(), youngTop_, youngEnd_ - youngTop_); - if (gcType_ == TriggerGCType::SEMI_GC) { - heap_->GetSemiSpaceCollector()->oldSpaceAllocator_.Free(oldTop_, oldEnd_); - } else if (gcType_ == TriggerGCType::COMPRESS_FULL_GC) { - heap_->GetCompressCollector()->oldSpaceAllocator_.Free(oldTop_, oldEnd_); + if (youngTop_ != 0 && youngTop_ != youngEnd_) { + FreeObject::FillFreeObject(heap_->GetEcmaVM(), youngTop_, youngEnd_ - youngTop_); + } + if (oldTop_ != 0 && oldTop_ != oldEnd_) { + if (gcType_ == TriggerGCType::SEMI_GC) { + heap_->GetSemiSpaceCollector()->oldSpaceAllocator_.Free(oldTop_, oldEnd_); + } else if (gcType_ == TriggerGCType::COMPRESS_FULL_GC) { + heap_->GetCompressCollector()->oldSpaceAllocator_.Free(oldTop_, oldEnd_); + } } } @@ -114,7 +118,7 @@ bool TlabAllocator::ExpandYoung() { uintptr_t buffer = 0; if (gcType_ == TriggerGCType::SEMI_GC) { - buffer = heap_->GetSemiSpaceCollector()->AllocateYoung(SEMIGC_YOUNG_BUFFER_SIZE); + buffer = heap_->GetSemiSpaceCollector()->AllocateYoung(YOUNG_BUFFER_SIZE); } else { UNREACHABLE(); } @@ -124,7 +128,7 @@ bool TlabAllocator::ExpandYoung() } youngBegin_ = buffer; youngTop_ = youngBegin_; - youngEnd_ = youngBegin_ + SEMIGC_YOUNG_BUFFER_SIZE; + youngEnd_ = youngBegin_ + YOUNG_BUFFER_SIZE; return true; } @@ -132,7 +136,7 @@ bool TlabAllocator::ExpandOld() { uintptr_t buffer = 0; if (gcType_ == TriggerGCType::SEMI_GC) { - buffer = heap_->GetSemiSpaceCollector()->AllocateOld(OLD_BUFFER_SIZE); + buffer = heap_->GetSemiSpaceCollector()->AllocateOld(YOUNG_BUFFER_SIZE); } else if (gcType_ == TriggerGCType::COMPRESS_FULL_GC) { buffer = heap_->GetCompressCollector()->AllocateOld(OLD_BUFFER_SIZE); } else { @@ -144,7 +148,13 @@ bool TlabAllocator::ExpandOld() } oldBegin_ = buffer; oldTop_ = oldBegin_; - oldEnd_ = oldBegin_ + OLD_BUFFER_SIZE; + if (gcType_ == TriggerGCType::SEMI_GC) { + oldEnd_ = oldBegin_ + YOUNG_BUFFER_SIZE; + } else if (gcType_ == TriggerGCType::COMPRESS_FULL_GC) { + oldEnd_ = oldBegin_ + OLD_BUFFER_SIZE; + } else { + UNREACHABLE(); + } return true; } } // namespace panda::ecmascript