diff --git a/compiler/optimizer/optimizations/ecma_inlining.cpp b/compiler/optimizer/optimizations/ecma_inlining.cpp index 3ce6cfa0a56dae95dd14ec9155fd77b7b032ea42..1222abdeaa7301f80db3007c9c2c4d71d22f61e6 100644 --- a/compiler/optimizer/optimizations/ecma_inlining.cpp +++ b/compiler/optimizer/optimizations/ecma_inlining.cpp @@ -26,7 +26,7 @@ namespace panda::compiler::ecmascript { EcmaInlining::EcmaInlining(Graph *graph, uint32_t instructionsCount, uint32_t inlineDepth, uint32_t methodsInlined) - : Inlining(graph, instructionsCount, inlineDepth, methodsInlined), + : Inlining(graph, instructionsCount, inlineDepth, methodsInlined, nullptr), jsFunctions_(graph->GetLocalAllocator()->Adapter()) { instructionsLimit_ = g_options.GetCompilerEcmaInliningMaxInsts(); @@ -49,7 +49,14 @@ bool EcmaInlining::SkipBlock(const BasicBlock *block) const bool EcmaInlining::IsInstSuitableForInline(Inst *inst) const { - return inst->GetOpcode() == Opcode::CallDynamic; + if (inst->GetOpcode() != Opcode::CallDynamic) { + return false; + } + if (std::find(inlined_stack_.begin(), inlined_stack_.end(), inst->CastToCallDynamic()->GetCallMethod()) != + inlined_stack_.end()) { + return false; + } + return true; } bool EcmaInlining::ResolveTargets(CallInst *callInst) @@ -132,15 +139,7 @@ Graph *EcmaInlining::BuildGraph(InlineContext *ctx, CallInst *callInst, CallInst // Don't inline if we reach the limit of instructions and method is big enough. auto inlinedInstsCount = CalculateInstructionsCount(graphInl); - if (!CheckInstructionLimit(callInst, ctx, inlinedInstsCount)) { - stats->SetPbcInstNum(savedPbcInstNum); - [[maybe_unused]] auto runtime = GetGraph()->GetRuntime(); - EVENT_INLINE(runtime->GetMethodFullName(GetGraph()->GetMethod()), runtime->GetMethodFullName(ctx->method), - callInst->GetId(), events::InlineKind::DYNAMIC_MONOMORPHIC, events::InlineResult::LIMIT); - LOG_INLINING(DEBUG) << "Reach the limit of instructions and method is big enough."; - return nullptr; - } - if ((depth_ + 1) < g_options.GetCompilerInliningMaxDepth()) { + if ((depth_ + 1) < OPTIONS.GetCompilerInliningMaxDepth()) { graphInl->RunPass(instructionsCount_ + inlinedInstsCount, depth_ + 1, methodsInlined_ + 1); } instructionsCount_ += CalculateInstructionsCount(graphInl);