diff --git a/ecmascript/debugger/debugger_api.cpp b/ecmascript/debugger/debugger_api.cpp index 01962646c483c3ed58d5d5e6eea873d6a1bd4a1d..61b4ce858add2f01e87f24e83b841985d45d23e1 100644 --- a/ecmascript/debugger/debugger_api.cpp +++ b/ecmascript/debugger/debugger_api.cpp @@ -417,10 +417,12 @@ std::pair DebuggerApi::GetLevelSlot(const JSThread *thread, c return std::make_pair(-1, 0); } -Local DebuggerApi::GetGlobalValue(const EcmaVM *ecmaVm, Local name) +Local DebuggerApi::GetGlobalValue(const EcmaVM *ecmaVm, const FrameHandler *frameHandler, + Local name) { JSTaggedValue result; - JSTaggedValue globalObj = ecmaVm->GetGlobalEnv()->GetGlobalObject(); + Local globalEnv = GetCurrentGlobalEnv(ecmaVm, frameHandler); + JSHandle globalObj = JSNApiHelper::ToJSHandle(JSNApi::GetGlobalObject(ecmaVm, globalEnv)); JSThread *thread = ecmaVm->GetJSThread(); JSTaggedValue key = JSNApiHelper::ToJSTaggedValue(*name); @@ -431,18 +433,19 @@ Local DebuggerApi::GetGlobalValue(const EcmaVM *ecmaVm, Local(JSHandle(thread, result)); } - JSTaggedValue globalVar = FastRuntimeStub::GetGlobalOwnProperty(thread, globalObj, key); + JSTaggedValue globalVar = FastRuntimeStub::GetGlobalOwnProperty(thread, globalObj.GetTaggedValue(), key); if (!globalVar.IsHole()) { return JSNApiHelper::ToLocal(JSHandle(thread, globalVar)); } else { - result = SlowRuntimeStub::TryLdGlobalByNameFromGlobalProto(thread, globalObj, key); + result = SlowRuntimeStub::TryLdGlobalByNameFromGlobalProto(thread, globalObj.GetTaggedValue(), key); return JSNApiHelper::ToLocal(JSHandle(thread, result)); } return Local(); } -bool DebuggerApi::SetGlobalValue(const EcmaVM *ecmaVm, Local name, Local value) +bool DebuggerApi::SetGlobalValue(const EcmaVM *ecmaVm, const FrameHandler *frameHandler, + Local name, Local value) { JSTaggedValue result; JSTaggedValue globalObj = ecmaVm->GetGlobalEnv()->GetGlobalObject(); diff --git a/ecmascript/debugger/debugger_api.h b/ecmascript/debugger/debugger_api.h index 2996f201e648916f4f19219752cee19dce6f55ad..2f8dc388253208b4567aed6282b7dbe49e4762e4 100644 --- a/ecmascript/debugger/debugger_api.h +++ b/ecmascript/debugger/debugger_api.h @@ -102,8 +102,10 @@ public: uint32_t slot, Local value); static std::pair GetLevelSlot(const JSThread *ecmaVm, const FrameHandler *frameHandler, std::string_view name); - static Local GetGlobalValue(const EcmaVM *ecmaVm, Local name); - static bool SetGlobalValue(const EcmaVM *ecmaVm, Local name, Local value); + static Local GetGlobalValue(const EcmaVM *ecmaVm, const FrameHandler *frameHandler, + Local name); + static bool SetGlobalValue(const EcmaVM *ecmaVm, const FrameHandler *frameHandler, + Local name, Local value); static Local GetCurrentGlobalEnv(const EcmaVM *ecmaVm, const FrameHandler *frameHandler = nullptr); // JSThread diff --git a/ecmascript/debugger/js_debugger.h b/ecmascript/debugger/js_debugger.h index 508fc3604321d84f98084e6247dd0840d8efd400..e8d9e2c3d2eaf5c0303f311cdb6ecd1780e8cefe 100644 --- a/ecmascript/debugger/js_debugger.h +++ b/ecmascript/debugger/js_debugger.h @@ -199,7 +199,7 @@ public: } } - void SetDebuggerAccessor(JSHandle &globalEnv) override + void SetDebuggerAccessor(const JSHandle &globalEnv) override { if (hooks_ == nullptr) { return; diff --git a/ecmascript/debugger/js_debugger_interface.h b/ecmascript/debugger/js_debugger_interface.h index ddcc83e704dbe456d03e211360624b37df68065b..0e137d3223d51e24dbf52ecb9358276c0d8cafd8 100644 --- a/ecmascript/debugger/js_debugger_interface.h +++ b/ecmascript/debugger/js_debugger_interface.h @@ -104,7 +104,7 @@ public: virtual void GenerateAsyncFrames(std::shared_ptr asyncStack, bool skipTopFrame) = 0; - virtual void SetDebuggerAccessor(JSHandle &globalEnv) = 0; + virtual void SetDebuggerAccessor(const JSHandle &globalEnv) = 0; /** * \brief called by the ecmavm when symbolic breakpoint hits. Thread where symbolic breakpoint hits is stopped until diff --git a/ecmascript/debugger/notification_manager.h b/ecmascript/debugger/notification_manager.h index fe80966987f07aae1bc65e6fc2d5d6ffbc551e00..5cae456b6401657af33dc8322ace3513de8a5a75 100644 --- a/ecmascript/debugger/notification_manager.h +++ b/ecmascript/debugger/notification_manager.h @@ -44,7 +44,7 @@ public: virtual void MethodEntry(JSHandle method, JSHandle envHandle) = 0; virtual void MethodExit(JSHandle method) = 0; virtual void GenerateAsyncFrames(std::shared_ptr asyncStack, bool skipTopFrame) = 0; - virtual void SetDebuggerAccessor(JSHandle &globalEnv) = 0; + virtual void SetDebuggerAccessor(const JSHandle &globalEnv) = 0; }; class NotificationManager { @@ -144,7 +144,7 @@ public: } } - void SetDebuggerAccessorEvent(JSHandle &globalEnv) const + void SetDebuggerAccessorEvent(const JSHandle &globalEnv) const { for (auto it: listeners_) { it->SetDebuggerAccessor(globalEnv); diff --git a/ecmascript/dfx/tracing/tracing.cpp b/ecmascript/dfx/tracing/tracing.cpp index 99ac031e78f5b7472d92f36f3dce7e061f3235f9..3d4a4ffbfc9285a10d2a03e6f3d3e96fd16d954f 100755 --- a/ecmascript/dfx/tracing/tracing.cpp +++ b/ecmascript/dfx/tracing/tracing.cpp @@ -315,7 +315,7 @@ void Tracing::MethodExit([[maybe_unused]] JSHandle method) return; } -void Tracing::SetDebuggerAccessor([[maybe_unused]] JSHandle &globalEnv) +void Tracing::SetDebuggerAccessor([[maybe_unused]] const JSHandle &globalEnv) { return; } diff --git a/ecmascript/dfx/tracing/tracing.h b/ecmascript/dfx/tracing/tracing.h index 01b3f59bc8b6c74aeee8a3fd232518b60fd92e7a..3e501c8dd298e5db68c2210574491ba813dbd6bd 100755 --- a/ecmascript/dfx/tracing/tracing.h +++ b/ecmascript/dfx/tracing/tracing.h @@ -117,7 +117,7 @@ public: void MethodEntry(JSHandle method, JSHandle envHandle) override; void MethodExit(JSHandle method) override; void GenerateAsyncFrames(std::shared_ptr asyncStack, bool skipTopFrame) override; - void SetDebuggerAccessor(JSHandle &globalEnv) override; + void SetDebuggerAccessor(const JSHandle &globalEnv) override; bool IsTracing() {