Fix dump bug

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAZ8KE

Signed-off-by: xwcai98 <caixinwei5@huawei.com>
Change-Id: I23805eb135b6a753b95a0dfe3211fc8fddc467ad
This commit is contained in:
xwcai98 2024-10-23 15:07:00 +08:00
parent be29f2f4b5
commit 31b2a0cdb9
2 changed files with 16 additions and 1 deletions

View File

@ -269,6 +269,16 @@ public:
isVerifying_ = verifying;
}
void SetGCState(bool inGC)
{
inGC_ = inGC;
}
bool InGC() const
{
return inGC_;
}
void NotifyHeapAliveSizeAfterGC(size_t size)
{
heapAliveSizeAfterGC_ = size;
@ -372,6 +382,7 @@ protected:
LOG_GC(FATAL) << "Recursion in HeapCollectGarbage(isShared=" << static_cast<int>(heapType_)
<< ") Constructor, depth: " << heap_->recursionDepth_;
}
heap_->SetGCState(true);
}
~RecursionScope()
{
@ -379,6 +390,7 @@ protected:
LOG_GC(FATAL) << "Recursion in HeapCollectGarbage(isShared=" << static_cast<int>(heapType_)
<< ") Destructor, depth: " << heap_->recursionDepth_;
}
heap_->SetGCState(false);
}
private:
BaseHeap *heap_ {nullptr};
@ -416,6 +428,7 @@ protected:
// ONLY used for heap verification.
bool shouldVerifyHeap_ {false};
bool isVerifying_ {false};
bool inGC_ {false};
int32_t recursionDepth_ {0};
#ifndef NDEBUG
bool triggerCollectionOnNewObject_ {true};

View File

@ -44,7 +44,9 @@ Region *HeapRegionAllocator::AllocateAlignedRegion(Space *space, size_t capacity
if (mapMem == nullptr) { // LOCV_EXCL_BR_LINE
if (thread != nullptr && thread->GetEcmaVM()->IsInitialized()) {
Heap *localHeap = const_cast<Heap *>(thread->GetEcmaVM()->GetHeap());
localHeap->DumpHeapSnapshotBeforeOOM();
if (!localHeap->InGC()) {
localHeap->DumpHeapSnapshotBeforeOOM();
}
heap->ThrowOutOfMemoryErrorForDefault(thread, DEFAULT_REGION_SIZE,
"HeapRegionAllocator::AllocateAlignedRegion", false);
}