diff --git a/compiler/optimizer/ir_builder/inst_builder.cpp b/compiler/optimizer/ir_builder/inst_builder.cpp index 60dd9124c2bb67c1daa941a7e0c335bfa88c4339..a045f3d6ba6a267305b2ea7b5077eeeb6ae76f4c 100644 --- a/compiler/optimizer/ir_builder/inst_builder.cpp +++ b/compiler/optimizer/ir_builder/inst_builder.cpp @@ -195,8 +195,21 @@ void InstBuilder::AddCatchPhiInputs(const ArenaUnorderedSet &catch } auto input_inst = defs[vreg]; if (input_inst != nullptr && input_inst != catch_phi) { - catch_phi->AppendInput(input_inst); - catch_phi->AppendThrowableInst(throwable_inst); + bool notfound = true; + if (!cphi2input_.empty()) { + auto range = cphi2input_.equal_range(inst); + for (auto i = range.first; i != range.second; ++i) { + if (i->second == input_inst) { + notfound = false; + break; + } + } + } + if (notfound) { + cphi2input_.insert({inst, input_inst}); + catch_phi->AppendInput(input_inst); + catch_phi->AppendThrowableInst(throwable_inst); + } } } } diff --git a/compiler/optimizer/ir_builder/inst_builder.h b/compiler/optimizer/ir_builder/inst_builder.h index 017692059ad9068e67b110265aecf9b79b2dd8b6..7c05e1e6dcf1570ad94c8c8cc7c00f0607cf7f20 100644 --- a/compiler/optimizer/ir_builder/inst_builder.h +++ b/compiler/optimizer/ir_builder/inst_builder.h @@ -47,7 +47,8 @@ public: instructions_buf_(GetGraph()->GetRuntime()->GetMethodCode(GetGraph()->GetMethod())), caller_inst_(caller_inst), inlining_depth_(inlining_depth), - class_id_ {runtime_->GetClassIdForMethod(method_)} + class_id_ {runtime_->GetClassIdForMethod(method_)}, + cphi2input_(GetGraph()->GetAllocator()->Adapter()) { no_type_marker_ = GetGraph()->NewMarker(); visited_block_marker_ = GetGraph()->NewMarker(); @@ -81,6 +82,7 @@ public: { GetGraph()->EraseMarker(no_type_marker_); GetGraph()->EraseMarker(visited_block_marker_); + cphi2input_.clear(); } /** @@ -532,6 +534,8 @@ private: CallInst *caller_inst_ {nullptr}; uint32_t inlining_depth_ {0}; size_t class_id_; + + ArenaMultiMap cphi2input_; #include "intrinsics_ir_build.inl.h" }; } // namespace panda::compiler diff --git a/compiler/optimizer/ir_builder/ir_builder.cpp b/compiler/optimizer/ir_builder/ir_builder.cpp index aed97fe5a0566972fac9b6d8d9542e3efcb625f9..ea1f34f3215758f1905b53a62643983650d5945d 100644 --- a/compiler/optimizer/ir_builder/ir_builder.cpp +++ b/compiler/optimizer/ir_builder/ir_builder.cpp @@ -93,7 +93,7 @@ void IrBuilder::SetMemoryBarrierFlag() bool IrBuilder::CheckMethodLimitations(const BytecodeInstructions &instructions, size_t vregs_count) { // TODO(a.popov) Optimize catch-phi's memory consumption and get rid of this limitation - static constexpr auto TRY_BLOCKS_LIMIT = 128U; + static constexpr auto TRY_BLOCKS_LIMIT = 1280U; size_t bytecode_size_limit = OPTIONS.GetCompilerMaxBytecodeSize();