@@ -2925,11 +2925,7 @@ bool Inline::InlineApplyScriptTarget(IR::Instr *callInstr, const FunctionJITTime
2925
2925
bool originalCallTargetOpndIsJITOpt = callInstr->GetSrc1 ()->GetIsJITOptimizedReg ();
2926
2926
bool safeThis = false ;
2927
2927
2928
- if (targetIsCallback)
2929
- {
2930
- callInstr->ReplaceSrc1 (GetCallbackFunctionOpnd (callInstr));
2931
- }
2932
- else if (!TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, applyFuncInfo, applyLdInstr, applyTargetLdInstr, safeThis, /* isApplyTarget*/ true ))
2928
+ if (!TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, applyFuncInfo, applyLdInstr, applyTargetLdInstr, safeThis, /* isApplyTarget*/ true , targetIsCallback))
2933
2929
{
2934
2930
return false ;
2935
2931
}
@@ -3256,14 +3252,7 @@ Inline::InlineCallTarget(IR::Instr *callInstr, const FunctionJITTimeInfo* inline
3256
3252
bool originalCallTargetOpndIsJITOpt = callInstr->GetSrc1 ()->GetIsJITOptimizedReg ();
3257
3253
bool safeThis = false ;
3258
3254
3259
- if (targetIsCallback)
3260
- {
3261
- if (!isCallInstanceFunction)
3262
- {
3263
- callInstr->ReplaceSrc1 (GetCallbackFunctionOpnd (callInstr));
3264
- }
3265
- }
3266
- else if (!TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, callFuncInfo, callLdInstr, callTargetLdInstr, safeThis, /* isApplyTarget*/ false ))
3255
+ if (!TryGetFixedMethodsForBuiltInAndTarget (callInstr, inlinerData, inlineeData, callFuncInfo, callLdInstr, callTargetLdInstr, safeThis, /* isApplyTarget*/ false , targetIsCallback))
3267
3256
{
3268
3257
return false ;
3269
3258
}
@@ -3394,7 +3383,7 @@ Inline::SkipCallApplyScriptTargetInlining_Shared(IR::Instr *callInstr, const Fun
3394
3383
3395
3384
bool
3396
3385
Inline::TryGetFixedMethodsForBuiltInAndTarget (IR::Instr *callInstr, const FunctionJITTimeInfo* inlinerData, const FunctionJITTimeInfo* inlineeData, const FunctionJITTimeInfo *builtInFuncInfo,
3397
- IR::Instr* builtInLdInstr, IR::Instr* targetLdInstr, bool & safeThis, bool isApplyTarget)
3386
+ IR::Instr* builtInLdInstr, IR::Instr* targetLdInstr, bool & safeThis, bool isApplyTarget, bool isCallback )
3398
3387
{
3399
3388
#if ENABLE_DEBUG_CONFIG_OPTIONS
3400
3389
char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
@@ -3410,6 +3399,29 @@ Inline::TryGetFixedMethodsForBuiltInAndTarget(IR::Instr *callInstr, const Functi
3410
3399
3411
3400
IR::ByteCodeUsesInstr * useCallTargetInstr = IR::ByteCodeUsesInstr::New (callInstr);
3412
3401
3402
+ if (isCallback)
3403
+ {
3404
+ IR::Opnd * functionOpnd = GetCallbackFunctionOpnd (callInstr);
3405
+
3406
+ // Emit Fixed Method check for apply/call
3407
+ safeThis = false ;
3408
+ if (!TryOptimizeCallInstrWithFixedMethod (callInstr, builtInFuncInfo/* funcinfo for apply/call */ , false /* isPolymorphic*/ , true /* isBuiltIn*/ , false /* isCtor*/ , true /* isInlined*/ , safeThis /* unused here*/ ))
3409
+ {
3410
+ callInstr->ReplaceSrc1 (builtInLdInstr->GetDst ());
3411
+ 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" ),
3412
+ inlineeData->GetBody ()->GetDisplayName (), inlineeData->GetDebugNumberSet (debugStringBuffer),
3413
+ inlinerData->GetBody ()->GetDisplayName (), inlinerData->GetDebugNumberSet (debugStringBuffer2),
3414
+ this ->topFunc ->GetJITFunctionBody ()->GetDisplayName (), this ->topFunc ->GetDebugNumberSet (debugStringBuffer3));
3415
+ return false ;
3416
+ }
3417
+ callInstr->m_opcode = originalCallOpCode;
3418
+ callInstr->ReplaceSrc1 (functionOpnd);
3419
+
3420
+ useCallTargetInstr->SetRemovedOpndSymbol (originalCallTargetOpndJITOpt, originalCallTargetStackSym->m_id );
3421
+ callInstr->InsertBefore (useCallTargetInstr);
3422
+ return true ;
3423
+ }
3424
+
3413
3425
safeThis = false ;
3414
3426
// Check if we can get fixed method for call
3415
3427
if (TryOptimizeCallInstrWithFixedMethod (callInstr, builtInFuncInfo/* funcinfo for call*/ , false /* isPolymorphic*/ , true /* isBuiltIn*/ , false /* isCtor*/ , true /* isInlined*/ ,
@@ -3423,7 +3435,7 @@ Inline::TryGetFixedMethodsForBuiltInAndTarget(IR::Instr *callInstr, const Functi
3423
3435
safeThis /* unused here*/ , true /* dontOptimizeJustCheck*/ ))
3424
3436
{
3425
3437
callInstr->ReplaceSrc1 (builtInLdInstr->GetDst ());
3426
- 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" ),
3438
+ 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" ),
3427
3439
inlineeData->GetBody ()->GetDisplayName (), inlineeData->GetDebugNumberSet (debugStringBuffer),
3428
3440
inlinerData->GetBody ()->GetDisplayName (), inlinerData->GetDebugNumberSet (debugStringBuffer2),
3429
3441
this ->topFunc ->GetJITFunctionBody ()->GetDisplayName (), this ->topFunc ->GetDebugNumberSet (debugStringBuffer3));
@@ -3432,7 +3444,7 @@ Inline::TryGetFixedMethodsForBuiltInAndTarget(IR::Instr *callInstr, const Functi
3432
3444
}
3433
3445
else
3434
3446
{
3435
- 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" ),
3447
+ 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" ),
3436
3448
inlineeData->GetBody ()->GetDisplayName (), inlineeData->GetDebugNumberSet (debugStringBuffer),
3437
3449
inlinerData->GetBody ()->GetDisplayName (), inlinerData->GetDebugNumberSet (debugStringBuffer2),
3438
3450
this ->topFunc ->GetJITFunctionBody ()->GetDisplayName (), this ->topFunc ->GetDebugNumberSet (debugStringBuffer3));
0 commit comments