@@ -1010,6 +1010,13 @@ Inline::InlinePolymorphicFunctionUsingFixedMethods(IR::Instr *callInstr, const F
10101010 return instrNext;
10111011}
10121012
1013+ IR::RegOpnd * Inline::GetCallbackFunctionOpnd (IR::Instr * callInstr)
1014+ {
1015+ IR::Instr * callApplyLdInstr = callInstr->GetSrc1 ()->GetStackSym ()->GetInstrDef ();
1016+ IR::Instr * targetDefInstr = callApplyLdInstr->GetSrc1 ()->AsPropertySymOpnd ()->GetObjectSym ()->GetInstrDef ();
1017+ return targetDefInstr->GetDst ()->AsRegOpnd ();
1018+ }
1019+
10131020IR::Instr * Inline::TryGetCallbackDefInstrForCallInstr (IR::Instr * callInstr)
10141021{
10151022 // Try to find a function argument that could be inlined.
@@ -2891,7 +2898,12 @@ bool Inline::InlineApplyScriptTarget(IR::Instr *callInstr, const FunctionJITTime
28912898 StackSym* originalCallTargetStackSym = callInstr->GetSrc1 ()->GetStackSym ();
28922899 bool originalCallTargetOpndIsJITOpt = callInstr->GetSrc1 ()->GetIsJITOptimizedReg ();
28932900 bool safeThis = false ;
2894- if (!targetIsCallback && !TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, applyFuncInfo, applyLdInstr, applyTargetLdInstr, safeThis, /* isApplyTarget*/ true ))
2901+
2902+ if (targetIsCallback)
2903+ {
2904+ callInstr->ReplaceSrc1 (GetCallbackFunctionOpnd (callInstr));
2905+ }
2906+ else if (!TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, applyFuncInfo, applyLdInstr, applyTargetLdInstr, safeThis, /* isApplyTarget*/ true ))
28952907 {
28962908 return false ;
28972909 }
@@ -3216,7 +3228,12 @@ Inline::InlineCallTarget(IR::Instr *callInstr, const FunctionJITTimeInfo* inline
32163228 StackSym* originalCallTargetStackSym = callInstr->GetSrc1 ()->GetStackSym ();
32173229 bool originalCallTargetOpndIsJITOpt = callInstr->GetSrc1 ()->GetIsJITOptimizedReg ();
32183230 bool safeThis = false ;
3219- if (!targetIsCallback && !TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, callFuncInfo, callLdInstr, callTargetLdInstr, safeThis, /* isApplyTarget*/ false ))
3231+
3232+ if (targetIsCallback)
3233+ {
3234+ callInstr->ReplaceSrc1 (GetCallbackFunctionOpnd (callInstr));
3235+ }
3236+ else if (!TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, callFuncInfo, callLdInstr, callTargetLdInstr, safeThis, /* isApplyTarget*/ false ))
32203237 {
32213238 return false ;
32223239 }
@@ -4433,17 +4450,7 @@ Inline::PrepareInsertionPoint(IR::Instr *callInstr, const FunctionJITTimeInfo *f
44334450 Assert (insertBeforeInstr->m_func == callInstr->m_func );
44344451 IR::BailOutKind bailOutKind = IR::BailOutOnInlineFunction;
44354452
4436- IR::RegOpnd * funcOpnd;
4437- if (isCallbackCallApplyTarget)
4438- {
4439- IR::Instr * callApplyLdInstr = callInstr->GetSrc1 ()->GetStackSym ()->GetInstrDef ();
4440- IR::Instr * targetDefInstr = callApplyLdInstr->GetSrc1 ()->AsPropertySymOpnd ()->GetObjectSym ()->GetInstrDef ();
4441- funcOpnd = targetDefInstr->GetDst ()->AsRegOpnd ();
4442- }
4443- else
4444- {
4445- funcOpnd = callInstr->GetSrc1 ()->AsRegOpnd ();
4446- }
4453+ IR::RegOpnd * funcOpnd = callInstr->GetSrc1 ()->AsRegOpnd ();
44474454
44484455 // FunctionBody check is the primary bailout instruction, create it first
44494456 IR::BailOutInstr* primaryBailOutInstr = IR::BailOutInstr::New (Js::OpCode::BailOnNotEqual, bailOutKind, insertBeforeInstr, callInstr->m_func );
0 commit comments