StatisticHeapDetail stack check failed

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IB1EG8?from=project-issue
Signed-off-by: jinjiawei <jinjiawei2@huawei.com>
Change-Id: I17ec4c023daf884819af37d4fcb93f4511da9ad5
This commit is contained in:
jinjiawei 2024-11-01 14:28:33 +08:00
parent 11995afb9d
commit e05b865a84
4 changed files with 13 additions and 8 deletions

View File

@ -400,8 +400,8 @@ void JSThread::IterateHandleWithCheck(const RootVisitor &visitor, const RootRang
}
size_t globalCount = 0;
static const int JS_TYPE_LAST = static_cast<int>(JSType::TYPE_LAST);
int typeCount[JS_TYPE_LAST] = { 0 };
static const int JS_TYPE_SUM = static_cast<int>(JSType::TYPE_LAST) + 1;
int typeCount[JS_TYPE_SUM] = { 0 };
int primitiveCount = 0;
bool isStopObjectLeakCheck = EnableGlobalObjectLeakCheck() && !IsStartGlobalLeakCheck() && stackTraceFd_ > 0;
bool isStopPrimitiveLeakCheck = EnableGlobalPrimitiveLeakCheck() && !IsStartGlobalLeakCheck() && stackTraceFd_ > 0;
@ -450,7 +450,7 @@ void JSThread::IterateHandleWithCheck(const RootVisitor &visitor, const RootRang
OPTIONAL_LOG(GetEcmaVM(), INFO) << "Global type Primitive count:" << primitiveCount;
// Print global object type statistic.
static const int MIN_COUNT_THRESHOLD = 50;
for (int i = 0; i < JS_TYPE_LAST; i++) {
for (int i = 0; i < JS_TYPE_SUM; i++) {
if (typeCount[i] > MIN_COUNT_THRESHOLD) {
OPTIONAL_LOG(GetEcmaVM(), INFO) << "Global type " << JSHClass::DumpJSType(JSType(i))
<< " count:" << typeCount[i];

View File

@ -43,6 +43,7 @@ namespace panda::ecmascript {
if ((space)->IsOOMDumpSpace()) { \
DumpHeapSnapshotBeforeOOM(); \
} \
StatisticHeapDetail(); \
ThrowOutOfMemoryError(GetJSThread(), size, message); \
(object) = reinterpret_cast<TaggedObject *>((space)->Allocate(size)); \
}
@ -436,6 +437,7 @@ TaggedObject *Heap::AllocateHugeObject(size_t size)
size_t oomOvershootSize = config_.GetOutOfMemoryOvershootSize();
oldSpace_->IncreaseOutOfMemoryOvershootSize(oomOvershootSize);
DumpHeapSnapshotBeforeOOM();
StatisticHeapDetail();
object = reinterpret_cast<TaggedObject *>(hugeObjectSpace_->Allocate(size, thread_));
ThrowOutOfMemoryError(thread_, size, "Heap::AllocateHugeObject");
object = reinterpret_cast<TaggedObject *>(hugeObjectSpace_->Allocate(size, thread_));

View File

@ -1265,6 +1265,7 @@ void Heap::CollectGarbage(TriggerGCType gcType, GCReason reason)
oldSpace_->ResetCommittedOverSizeLimit();
if (oldSpace_->CommittedSizeExceed()) {
DumpHeapSnapshotBeforeOOM(false);
StatisticHeapDetail();
ThrowOutOfMemoryError(thread_, oldSpace_->GetMergeSize(), " OldSpace::Merge");
}
oldSpace_->ResetMergeSize();
@ -1378,6 +1379,7 @@ void Heap::CheckNonMovableSpaceOOM()
if (nonMovableSpace_->GetHeapObjectSize() > MAX_NONMOVABLE_LIVE_OBJ_SIZE) {
sweeper_->EnsureAllTaskFinished();
DumpHeapSnapshotBeforeOOM(false);
StatisticHeapDetail();
ThrowOutOfMemoryError(thread_, nonMovableSpace_->GetHeapObjectSize(), "Heap::CheckNonMovableSpaceOOM", true);
}
}
@ -2544,14 +2546,14 @@ void Heap::StatisticHeapObject(TriggerGCType gcType) const
void Heap::StatisticHeapDetail()
{
Prepare();
static const int JS_TYPE_LAST = static_cast<int>(JSType::TYPE_LAST);
int typeCount[JS_TYPE_LAST] = { 0 };
static const int JS_TYPE_SUM = static_cast<int>(JSType::TYPE_LAST) + 1;
int typeCount[JS_TYPE_SUM] = { 0 };
static const int MIN_COUNT_THRESHOLD = 1000;
nonMovableSpace_->IterateOverObjects([&typeCount] (TaggedObject *object) {
typeCount[static_cast<int>(object->GetClass()->GetObjectType())]++;
});
for (int i = 0; i < JS_TYPE_LAST; i++) {
for (int i = 0; i < JS_TYPE_SUM; i++) {
if (typeCount[i] > MIN_COUNT_THRESHOLD) {
LOG_ECMA(INFO) << "NonMovable space type " << JSHClass::DumpJSType(JSType(i))
<< " count:" << typeCount[i];
@ -2562,7 +2564,7 @@ void Heap::StatisticHeapDetail()
oldSpace_->IterateOverObjects([&typeCount] (TaggedObject *object) {
typeCount[static_cast<int>(object->GetClass()->GetObjectType())]++;
});
for (int i = 0; i < JS_TYPE_LAST; i++) {
for (int i = 0; i < JS_TYPE_SUM; i++) {
if (typeCount[i] > MIN_COUNT_THRESHOLD) {
LOG_ECMA(INFO) << "Old space type " << JSHClass::DumpJSType(JSType(i))
<< " count:" << typeCount[i];
@ -2573,7 +2575,7 @@ void Heap::StatisticHeapDetail()
activeSemiSpace_->IterateOverObjects([&typeCount] (TaggedObject *object) {
typeCount[static_cast<int>(object->GetClass()->GetObjectType())]++;
});
for (int i = 0; i < JS_TYPE_LAST; i++) {
for (int i = 0; i < JS_TYPE_SUM; i++) {
if (typeCount[i] > MIN_COUNT_THRESHOLD) {
LOG_ECMA(INFO) << "Active semi space type " << JSHClass::DumpJSType(JSType(i))
<< " count:" << typeCount[i];

View File

@ -189,6 +189,7 @@ private:
<< sheap_->GetHugeObjectSpace()->GetCommittedSize();
} else {
if (dump) {
heap_->StatisticHeapDetail();
heap_->DumpHeapSnapshotBeforeOOM();
}
LOG_ECMA(FATAL) << "BaseDeserializer::OutOfMemory when deserialize obj size: " << size