-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Make EntryPointInfo::callsCount usable by redeferral heuristic. #1757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1763,7 +1763,7 @@ void BailOutRecord::ScheduleFunctionCodeGen(Js::ScriptFunction * function, Js::S | |
bailOutRecordNotConst->bailOutCount++; | ||
|
||
Js::FunctionEntryPointInfo *entryPointInfo = function->GetFunctionEntryPointInfo(); | ||
uint8 callsCount = entryPointInfo->callsCount; | ||
uint32 callsCount = entryPointInfo->callsCount; | ||
RejitReason rejitReason = RejitReason::None; | ||
bool reThunk = false; | ||
|
||
|
@@ -2312,11 +2312,7 @@ void BailOutRecord::ScheduleLoopBodyCodeGen(Js::ScriptFunction * function, Js::S | |
|
||
entryPointInfo->totalJittedLoopIterations += entryPointInfo->jittedLoopIterationsSinceLastBailout; | ||
entryPointInfo->jittedLoopIterationsSinceLastBailout = 0; | ||
if (entryPointInfo->totalJittedLoopIterations > UINT8_MAX) | ||
{ | ||
entryPointInfo->totalJittedLoopIterations = UINT8_MAX; | ||
} | ||
uint8 totalJittedLoopIterations = (uint8)entryPointInfo->totalJittedLoopIterations; | ||
uint32 totalJittedLoopIterations = entryPointInfo->totalJittedLoopIterations; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In keeping with @LouisLaf 's suggestion in ScheduleFunctionCodeGen, we should retain the existing code here. |
||
totalJittedLoopIterations = totalJittedLoopIterations <= Js::LoopEntryPointInfo::GetDecrLoopCountPerBailout() ? 0 : totalJittedLoopIterations - Js::LoopEntryPointInfo::GetDecrLoopCountPerBailout(); | ||
|
||
CheckPreemptiveRejit(executeFunction, bailOutKind, bailOutRecordNotConst, totalJittedLoopIterations, interpreterFrame->GetCurrentLoopNum()); | ||
|
@@ -2598,7 +2594,7 @@ void BailOutRecord::ScheduleLoopBodyCodeGen(Js::ScriptFunction * function, Js::S | |
} | ||
} | ||
|
||
void BailOutRecord::CheckPreemptiveRejit(Js::FunctionBody* executeFunction, IR::BailOutKind bailOutKind, BailOutRecord* bailoutRecord, uint8& callsOrIterationsCount, int loopNumber) | ||
void BailOutRecord::CheckPreemptiveRejit(Js::FunctionBody* executeFunction, IR::BailOutKind bailOutKind, BailOutRecord* bailoutRecord, uint32& callsOrIterationsCount, int loopNumber) | ||
{ | ||
if (bailOutKind == IR::BailOutOnNoProfile && executeFunction->IncrementBailOnMisingProfileCount() > CONFIG_FLAG(BailOnNoProfileLimit)) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14506,22 +14506,65 @@ IR::Instr *Lowerer::InsertConvertFloat64ToFloat32( | |
return instr; | ||
} | ||
|
||
void Lowerer::InsertIncUInt8PreventOverflow( | ||
void Lowerer::InsertDecUInt32PreventOverflow( | ||
IR::Opnd *const dst, | ||
IR::Opnd *const src, | ||
IR::Instr *const insertBeforeInstr, | ||
IR::Instr * *const onOverflowInsertBeforeInstrRef) | ||
{ | ||
LowererMD::InsertIncUInt8PreventOverflow(dst, src, insertBeforeInstr, onOverflowInsertBeforeInstrRef); | ||
} | ||
Assert(dst); | ||
Assert(dst->GetType() == TyUint32); | ||
Assert(src); | ||
Assert(src->GetType() == TyUint32); | ||
Assert(insertBeforeInstr); | ||
|
||
void Lowerer::InsertDecUInt8PreventOverflow( | ||
IR::Opnd *const dst, | ||
IR::Opnd *const src, | ||
IR::Instr *const insertBeforeInstr, | ||
IR::Instr * *const onOverflowInsertBeforeInstrRef) | ||
{ | ||
LowererMD::InsertDecUInt8PreventOverflow(dst, src, insertBeforeInstr, onOverflowInsertBeforeInstrRef); | ||
Func *const func = insertBeforeInstr->m_func; | ||
|
||
// Generate: | ||
// subs temp, src, 1 | ||
// bcs $overflow | ||
// mov dst, temp | ||
// b $continue | ||
// $overflow: | ||
// mov dst, 0 | ||
// $continue: | ||
|
||
IR::LabelInstr *const overflowLabel = Lowerer::InsertLabel(false, insertBeforeInstr); | ||
|
||
// subs temp, src, 1 | ||
IR::RegOpnd *const tempOpnd = IR::RegOpnd::New(StackSym::New(TyUint32, func), TyUint8, func); | ||
const IR::AutoReuseOpnd autoReuseTempOpnd(tempOpnd, func); | ||
Lowerer::InsertSub(true, tempOpnd, src, IR::IntConstOpnd::New(1, TyUint32, func, true), overflowLabel); | ||
|
||
// bcs $overflow | ||
Lowerer::InsertBranch(Js::OpCode::BrLt_A, true, overflowLabel, overflowLabel); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With int32, I think we don't even care about the overflow. Plus, with saturation, it doesn't fix the retiring problem, it just delays it. |
||
// mov dst, temp | ||
Lowerer::InsertMove(dst, tempOpnd, overflowLabel); | ||
|
||
const bool dstEqualsSrc = dst->IsEqual(src); | ||
if(!dstEqualsSrc || onOverflowInsertBeforeInstrRef) | ||
{ | ||
// b $continue | ||
// $overflow: | ||
// mov dst, 0 | ||
// $continue: | ||
IR::LabelInstr *const continueLabel = Lowerer::InsertLabel(false, insertBeforeInstr); | ||
Lowerer::InsertBranch(Js::OpCode::Br, continueLabel, overflowLabel); | ||
if(!dstEqualsSrc) | ||
{ | ||
Lowerer::InsertMove(dst, IR::IntConstOpnd::New(0, TyUint32, func, true), continueLabel); | ||
} | ||
|
||
if(onOverflowInsertBeforeInstrRef) | ||
{ | ||
*onOverflowInsertBeforeInstrRef = continueLabel; | ||
} | ||
} | ||
else | ||
{ | ||
// $overflow: | ||
} | ||
} | ||
|
||
void Lowerer::InsertFloatCheckForZeroOrNanBranch( | ||
|
@@ -21850,18 +21893,16 @@ void Lowerer::LowerFunctionBodyCallCountChange(IR::Instr *const insertBeforeInst | |
IR::AddrOpnd::New((Js::Var)func->GetWorkItem()->GetCallsCountAddress(), IR::AddrOpndKindDynamicMisc, func, true), | ||
insertBeforeInstr); | ||
|
||
IR::IndirOpnd *const countOpnd = IR::IndirOpnd::New(countAddressOpnd, 0, TyUint8, func); | ||
IR::IndirOpnd *const countOpnd = IR::IndirOpnd::New(countAddressOpnd, 0, TyUint32, func); | ||
const IR::AutoReuseOpnd autoReuseCountOpnd(countOpnd, func); | ||
if(!isSimpleJit) | ||
{ | ||
// InsertIncUint8PreventOverflow [countAddress] | ||
InsertIncUInt8PreventOverflow(countOpnd, countOpnd, insertBeforeInstr); | ||
Lowerer::InsertAdd(false, countOpnd, countOpnd, IR::IntConstOpnd::New(1, TyUint32, func, true), insertBeforeInstr); | ||
return; | ||
} | ||
|
||
// InsertDecUint8PreventOverflow [countAddress] | ||
IR::Instr *onOverflowInsertBeforeInstr; | ||
InsertDecUInt8PreventOverflow( | ||
InsertDecUInt32PreventOverflow( | ||
countOpnd, | ||
countOpnd, | ||
insertBeforeInstr, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just change this to:
uint32 callsCount = MIN(entryPointInfo->callsCount, 255);
to retain the previous bailout behavior we had with saturation.