diff --git a/runtime/ecma_entrypoints.cpp b/runtime/ecma_entrypoints.cpp index 5804990871784402a7aeb35253190b58c795a9ef..73245ee68f41b18357bcc14fb74d9923d7c7a718 100644 --- a/runtime/ecma_entrypoints.cpp +++ b/runtime/ecma_entrypoints.cpp @@ -26,12 +26,12 @@ extern "C" uintptr_t JSGetGlobalVarAddress(uint32_t id) auto thread = JSThread::GetCurrent(); JSTaggedValue key = GetConstantPool(thread)->GetObjectFromCache(id); auto global_obj = thread->GetGlobalObject(); + [[maybe_unused]] EcmaHandleScope scope(thread); + JSHandle global_handle(thread, global_obj); ObjectOperator op(thread, global_obj, key); auto res = op.GetValue(); if (res.IsUndefined() || !res.IsPropertyBox()) { PropertyAttributes attributes = PropertyAttributes::Default(true, true, false); - [[maybe_unused]] EcmaHandleScope scope(thread); - JSHandle global_handle(thread, global_obj); // Reread key because GC can move it in ctor of ObjectOperator JSHandle key_handle(thread, GetConstantPool(thread)->GetObjectFromCache(id)); op.AddProperty(global_handle, key_handle, attributes); diff --git a/runtime/interpreter/ecma-interpreter-inl.h b/runtime/interpreter/ecma-interpreter-inl.h index 915c68f6fcb30a1d90ac5cc115c442bbfb762316..2f1a48c65dad02bcd21f85ad7db5edf61105610f 100644 --- a/runtime/interpreter/ecma-interpreter-inl.h +++ b/runtime/interpreter/ecma-interpreter-inl.h @@ -372,6 +372,9 @@ public: return; } + // CSA reports js_function usage after GC triggered in ThrowStackOverflowException. + // In this case control doesn't reach this point. + // SUPPRESS_CSA_NEXTLINE(alpha.core.WasteObjHeader) ConstantPool *constant_pool = ConstantPool::Cast(js_function->GetConstantPool().GetHeapObject()); JSTaggedValue lexical_env = js_function->GetLexicalEnv(); diff --git a/runtime/interpreter/fast_runtime_stub-inl.h b/runtime/interpreter/fast_runtime_stub-inl.h index 8d3f59f1b28281082a177672c8abe4b31eef0eb0..a5fa6d121b6ff3f1df630ba7f31426fb67b3025c 100644 --- a/runtime/interpreter/fast_runtime_stub-inl.h +++ b/runtime/interpreter/fast_runtime_stub-inl.h @@ -669,14 +669,17 @@ JSTaggedValue FastRuntimeStub::FastGetPropertyByName(JSThread *thread, JSHandle< { INTERPRETER_TRACE(thread, FastGetPropertyByName); ASSERT(key->IsStringOrSymbol()); - JSTaggedValue raw_key = key.GetTaggedValue(); - if (raw_key.IsString() && !EcmaString::Cast(raw_key.GetTaggedObject())->IsInternString()) { - raw_key = JSTaggedValue(thread->GetEcmaVM()->GetFactory()->InternString(key)); + JSTaggedType raw_key = key->GetRawData(); + if (key->IsString() && !EcmaString::Cast(key->GetTaggedObject())->IsInternString()) { + raw_key = ToUintPtr(thread->GetEcmaVM()->GetFactory()->InternString(key)); } - JSTaggedValue result = FastRuntimeStub::GetPropertyByName(thread, receiver.GetTaggedValue(), raw_key); + [[maybe_unused]] size_t gc = thread->GetEcmaVM()->GetGC()->GetCounter(); + JSTaggedValue result = + FastRuntimeStub::GetPropertyByName(thread, receiver.GetTaggedValue(), JSTaggedValue(raw_key)); if (result.IsHole()) { + ASSERT_PRINT(gc == thread->GetEcmaVM()->GetGC()->GetCounter(), "GC happend where it is not supposed"); [[maybe_unused]] EcmaHandleScope handle_scope(thread); - return JSTaggedValue::GetProperty(thread, receiver, JSHandle(thread, raw_key)) + return JSTaggedValue::GetProperty(thread, receiver, JSHandle(thread, JSTaggedValue(raw_key))) .GetValue() .GetTaggedValue(); }