From 750e8e59299418db1698085e0388509de52532ce Mon Sep 17 00:00:00 2001 From: huyunhui Date: Mon, 11 Aug 2025 17:18:35 +0800 Subject: [PATCH] Removw wholeLine Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICTO5C Signed-off-by: huyunhui --- ets2panda/compiler/core/ETSemitter.cpp | 4 +- ets2panda/compiler/core/JSemitter.cpp | 4 +- ets2panda/compiler/core/emitter.cpp | 83 +------------------ ets2panda/compiler/core/emitter.h | 1 - .../compiler/debugger/debuginfoDumper.cpp | 5 -- 5 files changed, 4 insertions(+), 93 deletions(-) diff --git a/ets2panda/compiler/core/ETSemitter.cpp b/ets2panda/compiler/core/ETSemitter.cpp index 1151febda8..213d89e22e 100644 --- a/ets2panda/compiler/core/ETSemitter.cpp +++ b/ets2panda/compiler/core/ETSemitter.cpp @@ -178,11 +178,9 @@ pandasm::Function *ETSFunctionEmitter::GenFunctionSignature() return funcElement; } -void ETSFunctionEmitter::GenVariableSignature(pandasm::debuginfo::LocalVariable &variableDebug, +void ETSFunctionEmitter::GenVariableSignature([[maybe_unused]] pandasm::debuginfo::LocalVariable &variableDebug, [[maybe_unused]] varbinder::LocalVariable *variable) const { - variableDebug.signature = Signatures::ANY; - variableDebug.signatureType = Signatures::ANY; } void ETSFunctionEmitter::GenSourceFileDebugInfo(pandasm::Function *func) diff --git a/ets2panda/compiler/core/JSemitter.cpp b/ets2panda/compiler/core/JSemitter.cpp index 9be5a0b5c4..ca34b109cf 100644 --- a/ets2panda/compiler/core/JSemitter.cpp +++ b/ets2panda/compiler/core/JSemitter.cpp @@ -44,11 +44,9 @@ pandasm::Function *JSFunctionEmitter::GenFunctionSignature() #endif } -void JSFunctionEmitter::GenVariableSignature(pandasm::debuginfo::LocalVariable &variableDebug, +void JSFunctionEmitter::GenVariableSignature([[maybe_unused]] pandasm::debuginfo::LocalVariable &variableDebug, [[maybe_unused]] varbinder::LocalVariable *variable) const { - variableDebug.signature = "any"; - variableDebug.signatureType = "any"; } void JSFunctionEmitter::GenSourceFileDebugInfo(pandasm::Function *func) diff --git a/ets2panda/compiler/core/emitter.cpp b/ets2panda/compiler/core/emitter.cpp index f6027fc99e..de089293fa 100644 --- a/ets2panda/compiler/core/emitter.cpp +++ b/ets2panda/compiler/core/emitter.cpp @@ -137,64 +137,6 @@ util::StringView FunctionEmitter::SourceCode() const return cg_->VarBinder()->Program()->SourceCode(); } -static Format MatchFormat(const IRNode *node, const Formats &formats) -{ - std::array regs {}; - auto regCnt = node->Registers(®s); - auto registers = Span(regs.data(), regs.data() + regCnt); - - const auto *iter = formats.begin(); - - for (; iter != formats.end(); iter++) { // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) - auto format = *iter; - size_t limit = 0; - for (const auto &formatItem : format.GetFormatItem()) { - if (formatItem.IsVReg()) { - limit = 1U << formatItem.BitWidth(); - break; - } - } - - if (std::all_of(registers.begin(), registers.end(), [limit](const VReg *reg) { return reg->IsValid(limit); })) { - return format; - } - } - - ES2PANDA_UNREACHABLE(); - return *iter; -} - -static size_t GetIRNodeWholeLength(const IRNode *node) -{ - Formats formats = node->GetFormats(); - if (formats.empty()) { - return 0; - } - - size_t len = 1; - const auto format = MatchFormat(node, formats); - - for (auto fi : format.GetFormatItem()) { - len += fi.BitWidth() / 8U; - } - - return len; -} - -static std::string WholeLine(const lexer::SourceRange &range) -{ - auto program = range.start.Program(); - ES2PANDA_ASSERT(program != nullptr); - auto source = program->SourceCode(); - if (source.Empty()) { - return {}; - } - - ES2PANDA_ASSERT(range.end.index <= source.Length()); - ES2PANDA_ASSERT(range.end.index >= range.start.index); - return source.Substr(range.start.index, range.end.index).EscapeSymbol(); -} - void FunctionEmitter::GenInstructionDebugInfo(const IRNode *ins, pandasm::Ins *pandaIns) { const ir::AstNode *astNode = ins->Node(); @@ -210,17 +152,6 @@ void FunctionEmitter::GenInstructionDebugInfo(const IRNode *ins, pandasm::Ins *p auto nodeRange = astNode->Range(); pandaIns->insDebug.SetLineNumber(nodeRange.start.line + 1U); - - if (cg_->IsDebug()) { - size_t insLen = GetIRNodeWholeLength(ins); - if (insLen != 0) { - pandaIns->insDebug.SetBoundLeft(offset_); - pandaIns->insDebug.SetBoundRight(offset_ + insLen); - } - - offset_ += insLen; - pandaIns->insDebug.SetWholeLine(WholeLine(nodeRange)); - } } void FunctionEmitter::GenFunctionInstructions(pandasm::Function *func) @@ -275,23 +206,13 @@ void FunctionEmitter::GenFunctionCatchTables(pandasm::Function *func) } static void GenLocalVariableInfo(pandasm::debuginfo::LocalVariable &variableDebug, varbinder::Variable *var, - std::tuple info, ScriptExtension extension) + std::tuple info, + [[maybe_unused]] ScriptExtension extension) { const auto [start, varsLength, totalRegsNum] = info; variableDebug.name = var->Name().Mutf8(); - if (extension == ScriptExtension::JS) { - variableDebug.signature = "any"; - variableDebug.signatureType = "any"; - } else { - ES2PANDA_ASSERT(var->AsLocalVariable()->TsType() != nullptr); - std::stringstream ss; - var->AsLocalVariable()->TsType()->ToDebugInfoType(ss); - variableDebug.signature = ss.str(); - variableDebug.signatureType = ss.str(); // NOTE: Handle typeParams, either class or interface - } - variableDebug.reg = static_cast(IRNode::MapRegister(var->AsLocalVariable()->Vreg().GetIndex(), totalRegsNum)); variableDebug.start = start; diff --git a/ets2panda/compiler/core/emitter.h b/ets2panda/compiler/core/emitter.h index 7e2623cc38..35e3e84c4b 100644 --- a/ets2panda/compiler/core/emitter.h +++ b/ets2panda/compiler/core/emitter.h @@ -98,7 +98,6 @@ protected: private: const CodeGen *cg_; ProgramElement *programElement_; - size_t offset_ {0}; }; class Emitter { diff --git a/ets2panda/compiler/debugger/debuginfoDumper.cpp b/ets2panda/compiler/debugger/debuginfoDumper.cpp index 77a380803e..9a010351b5 100644 --- a/ets2panda/compiler/debugger/debuginfoDumper.cpp +++ b/ets2panda/compiler/debugger/debuginfoDumper.cpp @@ -217,10 +217,7 @@ void DebugInfoDumper::WritePosInfo(const pandasm::debuginfo::Ins &posInfo) ss_ << std::endl; Indent(); ss_ << "\"debug_pos_info\": {"; - WriteProperty("boundLeft", posInfo.BoundLeft()); - WriteProperty("boundRight", posInfo.BoundRight()); WriteProperty("sourceLineNum", posInfo.LineNumber()); - WriteProperty("wholeLine", posInfo.WholeLine(), false); Indent(); ss_ << "}" << std::endl; } @@ -229,8 +226,6 @@ void DebugInfoDumper::WriteVariableInfo(const pandasm::debuginfo::LocalVariable { ss_ << "{"; WriteProperty("name", localVariableDebug.name); - WriteProperty("signature", localVariableDebug.signature); - WriteProperty("signatureType", localVariableDebug.signatureType); WriteProperty("reg", localVariableDebug.reg); WriteProperty("start", static_cast(localVariableDebug.start)); WriteProperty("length", static_cast(localVariableDebug.length), false); -- Gitee