@@ -2926,11 +2926,7 @@ bool Inline::InlineApplyScriptTarget(IR::Instr *callInstr, const FunctionJITTime
2926
2926
bool originalCallTargetOpndIsJITOpt = callInstr->GetSrc1 ()->GetIsJITOptimizedReg ();
2927
2927
bool safeThis = false ;
2928
2928
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))
2934
2930
{
2935
2931
return false ;
2936
2932
}
@@ -3257,14 +3253,7 @@ Inline::InlineCallTarget(IR::Instr *callInstr, const FunctionJITTimeInfo* inline
3257
3253
bool originalCallTargetOpndIsJITOpt = callInstr->GetSrc1 ()->GetIsJITOptimizedReg ();
3258
3254
bool safeThis = false ;
3259
3255
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))
3268
3257
{
3269
3258
return false ;
3270
3259
}
@@ -3395,7 +3384,7 @@ Inline::SkipCallApplyScriptTargetInlining_Shared(IR::Instr *callInstr, const Fun
3395
3384
3396
3385
bool
3397
3386
Inline::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 )
3399
3388
{
3400
3389
#if ENABLE_DEBUG_CONFIG_OPTIONS
3401
3390
char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
@@ -3411,6 +3400,29 @@ Inline::TryGetFixedMethodsForBuiltInAndTarget(IR::Instr *callInstr, const Functi
3411
3400
3412
3401
IR::ByteCodeUsesInstr * useCallTargetInstr = IR::ByteCodeUsesInstr::New (callInstr);
3413
3402
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
+
3414
3426
safeThis = false ;
3415
3427
// Check if we can get fixed method for call
3416
3428
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
3424
3436
safeThis /* unused here*/ , true /* dontOptimizeJustCheck*/ ))
3425
3437
{
3426
3438
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" ),
3428
3440
inlineeData->GetBody ()->GetDisplayName (), inlineeData->GetDebugNumberSet (debugStringBuffer),
3429
3441
inlinerData->GetBody ()->GetDisplayName (), inlinerData->GetDebugNumberSet (debugStringBuffer2),
3430
3442
this ->topFunc ->GetJITFunctionBody ()->GetDisplayName (), this ->topFunc ->GetDebugNumberSet (debugStringBuffer3));
@@ -3433,7 +3445,7 @@ Inline::TryGetFixedMethodsForBuiltInAndTarget(IR::Instr *callInstr, const Functi
3433
3445
}
3434
3446
else
3435
3447
{
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" ),
3437
3449
inlineeData->GetBody ()->GetDisplayName (), inlineeData->GetDebugNumberSet (debugStringBuffer),
3438
3450
inlinerData->GetBody ()->GetDisplayName (), inlinerData->GetDebugNumberSet (debugStringBuffer2),
3439
3451
this ->topFunc ->GetJITFunctionBody ()->GetDisplayName (), this ->topFunc ->GetDebugNumberSet (debugStringBuffer3));
0 commit comments