@@ -2926,11 +2926,7 @@ bool Inline::InlineApplyScriptTarget(IR::Instr *callInstr, const FunctionJITTime
29262926 bool originalCallTargetOpndIsJITOpt = callInstr->GetSrc1 ()->GetIsJITOptimizedReg ();
29272927 bool safeThis = false ;
29282928
2929- if (targetIsCallback)
2930- {
2931- callInstr->ReplaceSrc1 (GetCallbackFunctionOpnd (callInstr));
2932- }
2933- else if (!TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, applyFuncInfo, applyLdInstr, applyTargetLdInstr, safeThis, /* isApplyTarget*/ true ))
2929+ if (!TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, applyFuncInfo, applyLdInstr, applyTargetLdInstr, safeThis, /* isApplyTarget*/ true , targetIsCallback))
29342930 {
29352931 return false ;
29362932 }
@@ -3257,14 +3253,7 @@ Inline::InlineCallTarget(IR::Instr *callInstr, const FunctionJITTimeInfo* inline
32573253 bool originalCallTargetOpndIsJITOpt = callInstr->GetSrc1 ()->GetIsJITOptimizedReg ();
32583254 bool safeThis = false ;
32593255
3260- if (targetIsCallback)
3261- {
3262- if (!isCallInstanceFunction)
3263- {
3264- callInstr->ReplaceSrc1 (GetCallbackFunctionOpnd (callInstr));
3265- }
3266- }
3267- else if (!TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, callFuncInfo, callLdInstr, callTargetLdInstr, safeThis, /* isApplyTarget*/ false ))
3256+ if (!TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, callFuncInfo, callLdInstr, callTargetLdInstr, safeThis, /* isApplyTarget*/ false , targetIsCallback))
32683257 {
32693258 return false ;
32703259 }
@@ -3395,7 +3384,7 @@ Inline::SkipCallApplyScriptTargetInlining_Shared(IR::Instr *callInstr, const Fun
33953384
33963385bool
33973386Inline::TryGetFixedMethodsForBuiltInAndTarget (IR::Instr *callInstr, const FunctionJITTimeInfo* inlinerData, const FunctionJITTimeInfo* inlineeData, const FunctionJITTimeInfo *builtInFuncInfo,
3398- IR::Instr* builtInLdInstr, IR::Instr* targetLdInstr, bool & safeThis, bool isApplyTarget)
3387+ IR::Instr* builtInLdInstr, IR::Instr* targetLdInstr, bool & safeThis, bool isApplyTarget, bool isCallback )
33993388{
34003389#if ENABLE_DEBUG_CONFIG_OPTIONS
34013390 char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
@@ -3411,6 +3400,29 @@ Inline::TryGetFixedMethodsForBuiltInAndTarget(IR::Instr *callInstr, const Functi
34113400
34123401 IR::ByteCodeUsesInstr * useCallTargetInstr = IR::ByteCodeUsesInstr::New (callInstr);
34133402
3403+ if (isCallback)
3404+ {
3405+ IR::Opnd * functionOpnd = GetCallbackFunctionOpnd (callInstr);
3406+
3407+ // Emit Fixed Method check for apply/call
3408+ safeThis = false ;
3409+ if (!TryOptimizeCallInstrWithFixedMethod (callInstr, builtInFuncInfo/* funcinfo for apply/call */ , false /* isPolymorphic*/ , true /* isBuiltIn*/ , false /* isCtor*/ , true /* isInlined*/ , safeThis /* unused here*/ ))
3410+ {
3411+ callInstr->ReplaceSrc1 (builtInLdInstr->GetDst ());
3412+ INLINE_CALLBACKS_TRACE (_u (" INLINING: Skip Inline: Skipping callback.%s target inlining, did not get fixed method for %s \t Inlinee: %s (%s)\t Caller: %s\t (%s) \t Top Func:%s\t (%s)\n " ), isApplyTarget ? _u (" apply" ) : _u (" call" ), isApplyTarget ? _u (" apply" ) : _u (" call" ),
3413+ inlineeData->GetBody ()->GetDisplayName (), inlineeData->GetDebugNumberSet (debugStringBuffer),
3414+ inlinerData->GetBody ()->GetDisplayName (), inlinerData->GetDebugNumberSet (debugStringBuffer2),
3415+ this ->topFunc ->GetJITFunctionBody ()->GetDisplayName (), this ->topFunc ->GetDebugNumberSet (debugStringBuffer3));
3416+ return false ;
3417+ }
3418+ callInstr->m_opcode = originalCallOpCode;
3419+ callInstr->ReplaceSrc1 (functionOpnd);
3420+
3421+ useCallTargetInstr->SetRemovedOpndSymbol (originalCallTargetOpndJITOpt, originalCallTargetStackSym->m_id );
3422+ callInstr->InsertBefore (useCallTargetInstr);
3423+ return true ;
3424+ }
3425+
34143426 safeThis = false ;
34153427 // Check if we can get fixed method for call
34163428 if (TryOptimizeCallInstrWithFixedMethod (callInstr, builtInFuncInfo/* funcinfo for call*/ , false /* isPolymorphic*/ , true /* isBuiltIn*/ , false /* isCtor*/ , true /* isInlined*/ ,
@@ -3424,7 +3436,7 @@ Inline::TryGetFixedMethodsForBuiltInAndTarget(IR::Instr *callInstr, const Functi
34243436 safeThis /* unused here*/ , true /* dontOptimizeJustCheck*/ ))
34253437 {
34263438 callInstr->ReplaceSrc1 (builtInLdInstr->GetDst ());
3427- INLINE_TESTTRACE (_u (" INLINING: Skip Inline: Skipping %s target inlining, did not get fixed method for %s target \t Inlinee: %s (#%d )\t Caller: %s\t (#%d ) \t Top Func:%s\t (#%d )\n " ), isApplyTarget ? _u (" apply" ) : _u (" call" ), isApplyTarget ? _u (" apply" ) : _u (" call" ),
3439+ INLINE_TESTTRACE (_u (" INLINING: Skip Inline: Skipping %s target inlining, did not get fixed method for %s target \t Inlinee: %s (%s )\t Caller: %s\t (%s ) \t Top Func:%s\t (%s )\n " ), isApplyTarget ? _u (" apply" ) : _u (" call" ), isApplyTarget ? _u (" apply" ) : _u (" call" ),
34283440 inlineeData->GetBody ()->GetDisplayName (), inlineeData->GetDebugNumberSet (debugStringBuffer),
34293441 inlinerData->GetBody ()->GetDisplayName (), inlinerData->GetDebugNumberSet (debugStringBuffer2),
34303442 this ->topFunc ->GetJITFunctionBody ()->GetDisplayName (), this ->topFunc ->GetDebugNumberSet (debugStringBuffer3));
@@ -3433,7 +3445,7 @@ Inline::TryGetFixedMethodsForBuiltInAndTarget(IR::Instr *callInstr, const Functi
34333445 }
34343446 else
34353447 {
3436- INLINE_TESTTRACE (_u (" INLINING: Skip Inline: Skipping %s target inlining, did not get fixed method for %s \t Inlinee: %s (#%d )\t Caller: %s\t (#%d ) \t Top Func:%s\t (#%d )\n " ), isApplyTarget ? _u (" apply" ) : _u (" call" ), isApplyTarget ? _u (" apply" ) : _u (" call" ),
3448+ INLINE_TESTTRACE (_u (" INLINING: Skip Inline: Skipping %s target inlining, did not get fixed method for %s \t Inlinee: %s (%s )\t Caller: %s\t (%s ) \t Top Func:%s\t (%s )\n " ), isApplyTarget ? _u (" apply" ) : _u (" call" ), isApplyTarget ? _u (" apply" ) : _u (" call" ),
34373449 inlineeData->GetBody ()->GetDisplayName (), inlineeData->GetDebugNumberSet (debugStringBuffer),
34383450 inlinerData->GetBody ()->GetDisplayName (), inlinerData->GetDebugNumberSet (debugStringBuffer2),
34393451 this ->topFunc ->GetJITFunctionBody ()->GetDisplayName (), this ->topFunc ->GetDebugNumberSet (debugStringBuffer3));
0 commit comments