From 7cf08d05cb1bb1e5b55a5a766e9250652177a44a Mon Sep 17 00:00:00 2001 From: Artem Udovichenko Date: Mon, 19 Sep 2022 16:39:46 +0300 Subject: [PATCH] JSThreead enters native state when the interpreter calls a native method Change-Id: Ic57109c23385915c0eef40a42538068f4c40a6d1 --- runtime/interpreter/interpreter-inl.h | 2 ++ runtime/napi/jsnapi.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/runtime/interpreter/interpreter-inl.h b/runtime/interpreter/interpreter-inl.h index b3cb8b348..e6fbccba5 100644 --- a/runtime/interpreter/interpreter-inl.h +++ b/runtime/interpreter/interpreter-inl.h @@ -18,6 +18,7 @@ #include "plugins/ecmascript/runtime/literal_data_extractor.h" #include "plugins/ecmascript/runtime/template_string.h" #include "plugins/ecmascript/compiler/ecmascript_extensions/thread_environment_api.h" +#include "runtime/include/thread_scopes.h" #include "include/method-inl.h" #include "include/runtime_notification.h" #include "libpandafile/code_data_accessor.h" @@ -107,6 +108,7 @@ JSTaggedValue EcmaInterpreter::ExecuteNative(JSThread *js_thread, JSTaggedValue Frame *frame = JSFrame::CreateNativeFrame(js_thread, method, js_thread->GetCurrentFrame(), nregs, num_args); JSFrame::InitNativeFrameArgs(frame, num_args, args); JSTaggedValue ret_value = JSFrame::ExecuteNativeMethod(js_thread, frame, method, num_args); + ScopedNativeCodeThread s(js_thread); JSFrame::DestroyNativeFrame(js_thread, frame); return ret_value; diff --git a/runtime/napi/jsnapi.cpp b/runtime/napi/jsnapi.cpp index 2a1a49af1..7cb8c741a 100644 --- a/runtime/napi/jsnapi.cpp +++ b/runtime/napi/jsnapi.cpp @@ -1692,6 +1692,7 @@ int32_t JSValueRef::Int32Value(const EcmaVM *vm) Local JSValueRef::ToBoolean(const EcmaVM *vm) { JSThread *thread = vm->GetJSThread(); + ScopedManagedCodeThread s(thread); JSHandle obj = JSNApiHelper::ToJSHandle(this); JSHandle booleanObj = JSHandle(thread, JSTaggedValue(obj->ToBoolean())); return JSNApiHelper::ToLocal(booleanObj); @@ -1700,6 +1701,7 @@ Local JSValueRef::ToBoolean(const EcmaVM *vm) Local JSValueRef::ToNumber(const EcmaVM *vm) { JSThread *thread = vm->GetJSThread(); + ScopedManagedCodeThread s(thread); JSHandle obj = JSNApiHelper::ToJSHandle(this); JSHandle number(thread, JSTaggedValue::ToNumber(thread, obj)); RETURN_VALUE_IF_ABRUPT(thread, JSValueRef::Exception(vm)); -- Gitee