From 502c029fe771a069652acf79ab1da2d088f1d6b0 Mon Sep 17 00:00:00 2001 From: Artem Udovichenko Date: Tue, 6 Sep 2022 16:50:37 +0300 Subject: [PATCH] Use weak array for IC * Collect IC only at OOM Change-Id: I6394270671159f9fbbc90e2d167bf129dc198f9e Signed-off-by: Artem Udovichenko --- runtime/mem/ecma_reference_processor.cpp | 10 ++++++++-- runtime/object_factory.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/runtime/mem/ecma_reference_processor.cpp b/runtime/mem/ecma_reference_processor.cpp index bfc978f0b..8762f45d4 100644 --- a/runtime/mem/ecma_reference_processor.cpp +++ b/runtime/mem/ecma_reference_processor.cpp @@ -82,8 +82,14 @@ bool EcmaReferenceProcessor::IsReference([[maybe_unused]] const BaseClass *base_ auto object_type = hcls->GetObjectType(); switch (object_type) { case panda::ecmascript::JSType::TAGGED_ARRAY: - return EnumerateArrayElements(static_cast(ref), - is_reference_checker); + // Weak tagged array is used for inline caches. + // It is reasonable to collect IC only in OOM case else it leads + // to big perf degradation. + if (gc_->GetLastGCCause() == GCTaskCause::OOM_CAUSE) { + return EnumerateArrayElements(static_cast(ref), + is_reference_checker); + } + break; case panda::ecmascript::JSType::JS_WEAK_REF: { panda::ecmascript::JSTaggedValue referent = static_cast(ref)->GetReferent(); diff --git a/runtime/object_factory.cpp b/runtime/object_factory.cpp index 9b64ef0a2..88353d282 100644 --- a/runtime/object_factory.cpp +++ b/runtime/object_factory.cpp @@ -1915,7 +1915,7 @@ JSHandle ObjectFactory::NewProfileTypeInfo(uint32_t length) ASSERT(length > 0); size_t size = TaggedArray::ComputeSize(JSTaggedValue::TaggedTypeSize(), length); - auto header = heapHelper_.AllocateNonMovableOrHugeObject(arrayClass_, size); + auto header = heapHelper_.AllocateNonMovableOrHugeObject(weakArrayClass_, size); JSHandle array(thread_, header); array->InitializeWithSpecialValue(JSTaggedValue::Undefined(), length); -- Gitee