From c0afce4073e6e374a53bf49188619350aa6f70a0 Mon Sep 17 00:00:00 2001 From: Petrov Igor Date: Mon, 3 Apr 2023 15:42:37 +0300 Subject: [PATCH] [MM] Fix Pin object builtin in case unsupported pinning in GC Signed-off-by: Petrov Igor --- runtime/builtins/builtins_global.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/builtins/builtins_global.cpp b/runtime/builtins/builtins_global.cpp index 607ab1aba..b94c77632 100644 --- a/runtime/builtins/builtins_global.cpp +++ b/runtime/builtins/builtins_global.cpp @@ -1077,9 +1077,11 @@ JSTaggedValue BuiltinsGlobal::PinObject(EcmaRuntimeCallInfo *msg) if (arg->IsHeapObject()) { auto *obj_allocator = vm->GetHeapManager()->GetObjectAllocator().AsObjectAllocator(); auto *gc = vm->GetGC(); - if (gc->GetType() == mem::GCType::GEN_GC && obj_allocator->IsObjectInYoungSpace(arg->GetHeapObject())) { - auto task = MakePandaUnique(GCTaskCause::YOUNG_GC_CAUSE); - gc->WaitForGCInManaged(*task); + if (!gc->IsPinningSupported()) { + [[maybe_unused]] EcmaHandleScope handle_scope(thread); + JSHandle err = + vm->GetFactory()->GetJSError(ErrorType::TYPE_ERROR, "Current GC does not support pinning"); + THROW_NEW_ERROR_AND_RETURN_VALUE(thread, err.GetTaggedValue(), JSTaggedValue::Exception()); } obj_allocator->PinObject(arg->GetHeapObject()); } else { -- Gitee