From 208d4b082a52477bd8da65df6073505087197ca2 Mon Sep 17 00:00:00 2001 From: Petrov Igor Date: Fri, 21 Apr 2023 11:50:15 +0300 Subject: [PATCH] [MM][CSA] Fix constantpool usage in intrinsics Signed-off-by: Petrov Igor --- runtime/intrinsics-inl.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/runtime/intrinsics-inl.h b/runtime/intrinsics-inl.h index e5093800e..5a24b73d0 100644 --- a/runtime/intrinsics-inl.h +++ b/runtime/intrinsics-inl.h @@ -1598,19 +1598,20 @@ INLINE_ECMA_INTRINSICS uint64_t GetPropIterator(JSThread *thread, uint64_t obj) // NOLINTNEXTLINE(misc-definitions-in-headers) INLINE_ECMA_INTRINSICS uint64_t DefineGeneratorFunc(JSThread *thread, uint32_t method_id, uint64_t env, uint64_t cp) { - auto constantpool = ConstantPool::Cast(cp); - auto result = JSFunction::Cast(constantpool->GetObjectFromCache(method_id).GetHeapObject()); + auto *constantpool = ConstantPool::Cast(cp); + auto *result = JSFunction::Cast(constantpool->GetObjectFromCache(method_id).GetHeapObject()); auto lexenv = JSTaggedValue(env); if (!result->GetLexicalEnv().IsUndefined()) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle lexenv_handle(thread, lexenv); - auto res = SlowRuntimeStub::DefineGeneratorFunc(thread, result->GetCallTarget()); + JSHandle constantpool_handle(thread, JSTaggedValue(constantpool)); + auto res = SlowRuntimeStub::DefineGeneratorFunc(thread, result->GetCallTarget()); // Can trigger GC if (res.IsException()) { return res.GetRawData(); } result = JSFunction::Cast(res.GetHeapObject()); lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC - result->SetConstantPool(thread, JSTaggedValue(constantpool)); + result->SetConstantPool(thread, constantpool_handle.GetTaggedValue()); } result->SetLexicalEnv(thread, lexenv); return JSTaggedValue(result).GetRawData(); @@ -1657,19 +1658,20 @@ INLINE_ECMA_INTRINSICS uint64_t CreateAsyncGeneratorObj(JSThread *thread, uint64 // NOLINTNEXTLINE(misc-definitions-in-headers) INLINE_ECMA_INTRINSICS uint64_t DefineAsyncFunc(JSThread *thread, uint32_t method_id, uint64_t env, uint64_t cp) { - auto constantpool = ConstantPool::Cast(cp); - auto result = JSFunction::Cast(constantpool->GetObjectFromCache(method_id).GetHeapObject()); + auto *constantpool = ConstantPool::Cast(cp); + auto *result = JSFunction::Cast(constantpool->GetObjectFromCache(method_id).GetHeapObject()); auto lexenv = JSTaggedValue(env); if (!result->GetLexicalEnv().IsUndefined()) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle lexenv_handle(thread, lexenv); - auto res = SlowRuntimeStub::DefineAsyncFunc(thread, result->GetCallTarget()); + JSHandle constantpool_handle(thread, JSTaggedValue(constantpool)); + auto res = SlowRuntimeStub::DefineAsyncFunc(thread, result->GetCallTarget()); // Can trigger GC if (res.IsException()) { return res.GetRawData(); } result = JSFunction::Cast(res.GetHeapObject()); lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC - result->SetConstantPool(thread, JSTaggedValue(constantpool)); + result->SetConstantPool(thread, constantpool_handle.GetTaggedValue()); } result->SetLexicalEnv(thread, lexenv); return JSTaggedValue(result).GetRawData(); @@ -1679,19 +1681,20 @@ INLINE_ECMA_INTRINSICS uint64_t DefineAsyncFunc(JSThread *thread, uint32_t metho INLINE_ECMA_INTRINSICS uint64_t DefineAsyncGeneratorFunc(JSThread *thread, uint32_t method_id, uint64_t env, uint64_t cp) { - auto constantpool = ConstantPool::Cast(cp); - auto result = JSFunction::Cast(constantpool->GetObjectFromCache(method_id).GetHeapObject()); + auto *constantpool = ConstantPool::Cast(cp); + auto *result = JSFunction::Cast(constantpool->GetObjectFromCache(method_id).GetHeapObject()); auto lexenv = JSTaggedValue(env); if (!result->GetLexicalEnv().IsUndefined()) { [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle lexenv_handle(thread, lexenv); - auto res = SlowRuntimeStub::DefineAsyncGeneratorFunc(thread, result->GetCallTarget()); + JSHandle constantpool_handle(thread, JSTaggedValue(constantpool)); + auto res = SlowRuntimeStub::DefineAsyncGeneratorFunc(thread, result->GetCallTarget()); // Can trigger GC if (res.IsException()) { return res.GetRawData(); } result = JSFunction::Cast(res.GetHeapObject()); lexenv = lexenv_handle.GetTaggedValue(); // May be moved by GC - result->SetConstantPool(thread, JSTaggedValue(constantpool)); + result->SetConstantPool(thread, constantpool_handle.GetTaggedValue()); } result->SetLexicalEnv(thread, lexenv); return JSTaggedValue(result).GetRawData(); -- Gitee