From 4942049daee4f7fc4c1a39d6377d99d8e93617b2 Mon Sep 17 00:00:00 2001 From: zhao1d Date: Fri, 22 Aug 2025 15:42:30 +0800 Subject: [PATCH] Optimize CIR pass compilation efficiency Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICU9NE Signed-off-by: zhao1d Change-Id: Icd548caa9c8b3cdc8e3e2ae594fa32b96dbafd01 --- ecmascript/compiler/circuit_builder.cpp | 4 ++-- ecmascript/compiler/graph_linearizer.cpp | 2 +- ecmascript/compiler/scheduler.cpp | 2 +- ecmascript/compiler/typed_bytecode_lowering.cpp | 8 ++++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ecmascript/compiler/circuit_builder.cpp b/ecmascript/compiler/circuit_builder.cpp index a5501bfac9..9b591c8091 100644 --- a/ecmascript/compiler/circuit_builder.cpp +++ b/ecmascript/compiler/circuit_builder.cpp @@ -368,14 +368,14 @@ void CircuitBuilder::ClearConstantCache(GateRef gate) void CircuitBuilder::DeoptCheck(GateRef condition, GateRef frameState, DeoptType type) { - std::string comment = Deoptimizier::DisplayItems(type); auto currentLabel = env_->GetCurrentLabel(); auto currentControl = currentLabel->GetControl(); auto currentDepend = currentLabel->GetDepend(); ASSERT(acc_.GetOpCode(frameState) == OpCode::FRAME_STATE); GateRef deoptCheck = GetCircuit()->NewGate(circuit_->DeoptCheck(), MachineType::I1, { currentControl, currentDepend, condition, - frameState, Int64(static_cast(type))}, GateType::NJSValue(), comment.c_str()); + frameState, Int64(static_cast(type))}, GateType::NJSValue(), + this->cmpCfg_->IsTraceBC() ? Deoptimizier::DisplayItems(type).c_str() : nullptr); // Add a state output to avoid schedule a phi node to deoptCheck's BB by mistake GateRef trueBB = circuit_->NewGate(circuit_->OrdinaryBlock(), { deoptCheck }); auto dependRelay = DependRelay(trueBB, currentDepend); diff --git a/ecmascript/compiler/graph_linearizer.cpp b/ecmascript/compiler/graph_linearizer.cpp index bbfbe88359..43883ba927 100644 --- a/ecmascript/compiler/graph_linearizer.cpp +++ b/ecmascript/compiler/graph_linearizer.cpp @@ -229,7 +229,7 @@ public: size_t UnionFind(size_t idx) { - std::stack allIdxs; + std::stack> allIdxs; allIdxs.emplace(idx); size_t pIdx = parentIdx_[idx]; while (pIdx != allIdxs.top()) { diff --git a/ecmascript/compiler/scheduler.cpp b/ecmascript/compiler/scheduler.cpp index e921879b3d..720141659b 100644 --- a/ecmascript/compiler/scheduler.cpp +++ b/ecmascript/compiler/scheduler.cpp @@ -20,7 +20,7 @@ namespace panda::ecmascript::kungfu { size_t UnionFind(std::vector &semiDom, std::vector &parent, std::vector &minIdx, size_t idx) { - std::stack allIdxs; + std::stack> allIdxs; allIdxs.emplace(idx); size_t pIdx = parent[idx]; while (pIdx != allIdxs.top()) { diff --git a/ecmascript/compiler/typed_bytecode_lowering.cpp b/ecmascript/compiler/typed_bytecode_lowering.cpp index 0517a10973..5e8b0d064c 100644 --- a/ecmascript/compiler/typed_bytecode_lowering.cpp +++ b/ecmascript/compiler/typed_bytecode_lowering.cpp @@ -458,7 +458,9 @@ template void TypedBytecodeLowering::SpeculateNumbers(const BinOpTypeInfoAccessor &tacc) { AddProfiling(tacc.GetGate()); - pgoTypeLog_.CollectGateTypeLogInfo(tacc.GetGate(), true); + if (IsLogEnabled()) { + pgoTypeLog_.CollectGateTypeLogInfo(tacc.GetGate(), true); + } GateRef left = tacc.GetLeftGate(); GateRef right = tacc.GetReightGate(); GateRef result = builder_.TypedBinaryOp(left, right, tacc.GetParamType()); @@ -469,7 +471,9 @@ template void TypedBytecodeLowering::SpeculateNumber(const UnOpTypeInfoAccessor &tacc) { AddProfiling(tacc.GetGate()); - pgoTypeLog_.CollectGateTypeLogInfo(tacc.GetGate(), false); + if (IsLogEnabled()) { + pgoTypeLog_.CollectGateTypeLogInfo(tacc.GetGate(), false); + } GateRef result = builder_.TypedUnaryOp(tacc.GetValue(), tacc.GetParamType()); acc_.ReplaceHirAndReplaceDeadIfException(tacc.GetGate(), builder_.GetStateDepend(), result); } -- Gitee