From c646386487f70307fc7564d9857de1d901226a78 Mon Sep 17 00:00:00 2001 From: lukai Date: Thu, 29 May 2025 17:17:00 +0800 Subject: [PATCH] Adapt readbarrier Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IBSHKF Signed-off-by: lukai Change-Id: I998d1d3f1e2dc391997781df230c778e1febfac1 --- tooling/agent/debugger_impl.cpp | 32 +++++++++++++++------------ tooling/backend/debugger_executor.cpp | 8 +++---- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index 6862fabc..45a77ffe 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -167,7 +167,8 @@ void DebuggerImpl::SaveParsedScriptsAndUrl(const std::string &fileName, const st bool DebuggerImpl::NotifyScriptParsedBySendable(JSHandle method) { // Find extractor and retrieve infos - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + JSThread *thread = vm_->GetJSThread(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); if (jsPandaFile == nullptr) { LOG_DEBUGGER(ERROR) << "JSPandaFile is nullptr"; return false; @@ -194,7 +195,7 @@ bool DebuggerImpl::NotifyScriptParsedBySendable(JSHandle method) } // Parse and save this file const std::string &source = extractor->GetSourceCode(methodId); - const std::string &recordName = std::string(method->GetRecordNameStr()); + const std::string &recordName = std::string(method->GetRecordNameStr(thread)); SaveParsedScriptsAndUrl(fileName, url, recordName, source); return true; } @@ -1917,9 +1918,10 @@ bool DebuggerImpl::GenerateAsyncFrame(StackFrame *stackFrame, const FrameHandler if (!frameHandler->HasFrame()) { return false; } + JSThread *thread = vm_->GetJSThread(); Method *method = DebuggerApi::GetMethod(frameHandler); auto methodId = method->GetMethodId(); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); if (extractor == nullptr) { LOG_DEBUGGER(DEBUG) << "GenerateAsyncFrame: extractor is null"; @@ -1927,7 +1929,7 @@ bool DebuggerImpl::GenerateAsyncFrame(StackFrame *stackFrame, const FrameHandler } // functionName - std::string functionName = method->ParseFunctionName(); + std::string functionName = method->ParseFunctionName(thread); std::string url = extractor->GetSourceFile(methodId); int32_t scriptId = -1; @@ -1980,9 +1982,10 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, const FrameHandler *f if (!frameHandler->HasFrame()) { return false; } + JSThread *thread = vm_->GetJSThread(); Method *method = DebuggerApi::GetMethod(frameHandler); auto methodId = method->GetMethodId(); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); if (extractor == nullptr) { LOG_DEBUGGER(DEBUG) << "GenerateCallFrame: extractor is null"; @@ -1990,7 +1993,7 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, const FrameHandler *f } // functionName - std::string functionName = method->ParseFunctionName(); + std::string functionName = method->ParseFunctionName(thread); // location std::unique_ptr location = std::make_unique(); @@ -2059,10 +2062,10 @@ std::unique_ptr DebuggerImpl::GetLocalScopeChain(const FrameHandler *fram std::unique_ptr *thisObj) { auto localScope = std::make_unique(); - + JSThread *thread = vm_->GetJSThread(); Method *method = DebuggerApi::GetMethod(frameHandler); auto methodId = method->GetMethodId(); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); if (extractor == nullptr) { LOG_DEBUGGER(ERROR) << "GetScopeChain: extractor is null"; @@ -2112,11 +2115,11 @@ std::vector> DebuggerImpl::GetClosureScopeChains(const Fr std::unique_ptr *thisObj) { std::vector> closureScopes; + JSThread *thread = vm_->GetJSThread(); Method *method = DebuggerApi::GetMethod(frameHandler); EntityId methodId = method->GetMethodId(); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); - JSThread *thread = vm_->GetJSThread(); if (extractor == nullptr) { LOG_DEBUGGER(ERROR) << "GetClosureScopeChains: extractor is null"; @@ -2135,14 +2138,15 @@ std::vector> DebuggerImpl::GetClosureScopeChains(const Fr bool thisFound = (*thisObj)->HasValue(); bool closureVarFound = false; // currentEnv = currentEnv->parent until currentEnv is not lexicalEnv - for (; currentEnv.IsLexicalEnv(); currentEnv = LexicalEnv::Cast(currentEnv.GetTaggedObject())->GetParentEnv()) { + for (; currentEnv.IsLexicalEnv(); + currentEnv = LexicalEnv::Cast(currentEnv.GetTaggedObject())->GetParentEnv(thread)) { LexicalEnv *lexicalEnv = LexicalEnv::Cast(currentEnv.GetTaggedObject()); envHandle.Update(currentEnv); - if (lexicalEnv->GetScopeInfo().IsHole()) { + if (lexicalEnv->GetScopeInfo(thread).IsHole()) { continue; } auto closureScope = std::make_unique(); - auto result = JSNativePointer::Cast(lexicalEnv->GetScopeInfo().GetTaggedObject())->GetExternalPointer(); + auto result = JSNativePointer::Cast(lexicalEnv->GetScopeInfo(thread).GetTaggedObject())->GetExternalPointer(); ScopeDebugInfo *scopeDebugInfo = reinterpret_cast(result); std::unique_ptr closure = std::make_unique(); Local closureScopeObj = ObjectRef::New(vm_); @@ -2154,7 +2158,7 @@ std::vector> DebuggerImpl::GetClosureScopeChains(const Fr } currentEnv = envHandle.GetTaggedValue(); lexicalEnv = LexicalEnv::Cast(currentEnv.GetTaggedObject()); - valueHandle.Update(lexicalEnv->GetProperties(slot)); + valueHandle.Update(lexicalEnv->GetProperties(thread, slot)); Local value = JSNApiHelper::ToLocal(valueHandle); Local varName = StringRef::NewFromUtf8(vm_, name.c_str()); nameCount[name]++; diff --git a/tooling/backend/debugger_executor.cpp b/tooling/backend/debugger_executor.cpp index c7d2a6c0..82740d9f 100644 --- a/tooling/backend/debugger_executor.cpp +++ b/tooling/backend/debugger_executor.cpp @@ -167,7 +167,7 @@ Local DebuggerExecutor::GetLexicalValue(const EcmaVM *vm, const Fram { Local result; - auto [level, slot] = DebuggerApi::GetLevelSlot(frameHandler, name->ToString(vm)); + auto [level, slot] = DebuggerApi::GetLevelSlot(vm->GetJSThread(), frameHandler, name->ToString(vm)); if (level == -1) { return result; } @@ -180,7 +180,7 @@ bool DebuggerExecutor::SetLexicalValue(const EcmaVM *vm, const FrameHandler *fra Local name, Local value) { std::string varName = name->ToString(vm); - auto [level, slot] = DebuggerApi::GetLevelSlot(frameHandler, varName); + auto [level, slot] = DebuggerApi::GetLevelSlot(vm->GetJSThread(), frameHandler, varName); if (level == -1) { return false; } @@ -208,7 +208,7 @@ Local DebuggerExecutor::GetModuleValue(const EcmaVM *vm, const Frame Local result; std::string varName = name->ToString(vm); Method *method = DebuggerApi::GetMethod(frameHandler); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(vm->GetJSThread()); if (jsPandaFile != nullptr && (jsPandaFile->IsBundlePack() || !jsPandaFile->IsNewVersion())) { return result; } @@ -225,7 +225,7 @@ bool DebuggerExecutor::SetModuleValue(const EcmaVM *vm, const FrameHandler *fram { std::string varName = name->ToString(vm); Method *method = DebuggerApi::GetMethod(frameHandler); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(vm->GetJSThread()); if (jsPandaFile != nullptr && (jsPandaFile->IsBundlePack() || !jsPandaFile->IsNewVersion())) { return false; } -- Gitee