Skip to content
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

Enable jitting generators by default #6245

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/Backend/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7759,9 +7759,6 @@ IRBuilder::GeneratorJumpTable::BuildJumpTable()
IR::Instr* createInterpreterFrame = IR::Instr::New(Js::OpCode::GeneratorCreateInterpreterStackFrame, genFrameOpnd /* dst */, genRegOpnd /* src */, this->m_func);
this->m_irBuilder->AddInstr(createInterpreterFrame, this->m_irBuilder->m_functionStartOffset);

IR::BranchInstr* skipJumpTable = IR::BranchInstr::New(Js::OpCode::Br, functionBegin, this->m_func);
this->m_irBuilder->AddInstr(skipJumpTable, this->m_irBuilder->m_functionStartOffset);

// Label to insert any initialization code
// $initializationCode:
this->m_irBuilder->AddInstr(initCode, this->m_irBuilder->m_functionStartOffset);
Expand Down Expand Up @@ -7796,6 +7793,12 @@ IRBuilder::GeneratorJumpTable::BuildJumpTable()
instr->SetSrc1(curOffsetOpnd);
this->m_irBuilder->AddInstr(instr, this->m_irBuilder->m_functionStartOffset);

// TODO: Improvements
// If the code falls through to here, it means that none of the offsets matched. This must be the first
// time we create the interpreter frame. Skip this bailout.
IR::BranchInstr* skipBailOutForElidedYield = IR::BranchInstr::New(Js::OpCode::Br, functionBegin, this->m_func);
this->m_irBuilder->AddInstr(skipBailOutForElidedYield, this->m_irBuilder->m_functionStartOffset);

this->m_func->m_bailOutForElidedYieldInsertionPoint = instr;

this->m_irBuilder->AddInstr(functionBegin, this->m_irBuilder->m_functionStartOffset);
Expand Down
1 change: 1 addition & 0 deletions lib/Backend/LinearScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5260,6 +5260,7 @@ void LinearScan::GeneratorBailIn::InsertRestoreSymbols(
{
IR::RegOpnd* dstRegOpnd = IR::RegOpnd::New(dstSym, dstSym->GetType(), this->func);
dstRegOpnd->SetReg(lifetime->reg);
Assert(lifetime->reg != RegNOREG);
instr = LinearScan::InsertMove(dstRegOpnd, srcOpnd, insertionPoint.instrInsertRegSym);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/Lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29076,7 +29076,7 @@ void Lowerer::LowerGeneratorHelper::InsertNullOutGeneratorFrameInEpilogue(IR::La

IR::IndirOpnd* indirOpnd = IR::IndirOpnd::New(dstOpnd, Js::JavascriptGenerator::GetFrameOffset(), TyMachPtr, this->func);
IR::AddrOpnd* addrOpnd = IR::AddrOpnd::NewNull(this->func);
InsertMove(indirOpnd, addrOpnd, insertionPoint);
InsertMove(indirOpnd, addrOpnd, insertionPoint, false /* generateWriteBarrier */);
}

void
Expand Down
3 changes: 2 additions & 1 deletion lib/Common/ConfigFlagsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ PHASE(All)
#define DEFAULT_CONFIG_ES6FunctionNameFull (false)
#endif

#define DEFAULT_CONFIG_JitES6Generators (true)
#define DEFAULT_CONFIG_ES6Generators (true)
#define DEFAULT_CONFIG_ES6IsConcatSpreadable (true)
#define DEFAULT_CONFIG_ES6Math (true)
Expand Down Expand Up @@ -1238,7 +1239,7 @@ FLAGR(Boolean, ESImportMeta, "Enable import.meta keyword", DEFAULT_CONFIG_ESImpo
FLAGR(Boolean, ESGlobalThis, "Enable globalThis", DEFAULT_CONFIG_ESGlobalThis)

// This flag to be removed once JITing generator functions is stable
FLAGNR(Boolean, JitES6Generators , "Enable JITing of ES6 generators", false)
FLAGNR(Boolean, JitES6Generators , "Enable JITing of ES6 generators", DEFAULT_CONFIG_JitES6Generators)

FLAGNR(Boolean, FastLineColumnCalculation, "Enable fast calculation of line/column numbers from the source.", DEFAULT_CONFIG_FastLineColumnCalculation)
FLAGR (String, Filename , "Jscript source file", nullptr)
Expand Down
12 changes: 10 additions & 2 deletions lib/Runtime/Base/FunctionBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,21 @@ namespace Js
bool
FunctionBody::SkipAutoProfileForCoroutine() const
{
return this->IsCoroutine() && CONFIG_ISENABLED(Js::JitES6GeneratorsFlag);
nhat-nguyen marked this conversation as resolved.
Show resolved Hide resolved
#if defined(_ARM64_) || defined(_ARM_)
return false;
nhat-nguyen marked this conversation as resolved.
Show resolved Hide resolved
#else
return this->IsCoroutine() && CONFIG_FLAG(JitES6Generators);
#endif
}

bool
FunctionBody::IsGeneratorAndJitIsDisabled() const
{
return this->IsCoroutine() && !(CONFIG_ISENABLED(Js::JitES6GeneratorsFlag) && !this->GetHasTry() && !this->IsInDebugMode() && !this->IsAsync());
#if defined(_ARM64_) || defined(_ARM_)
return this->IsCoroutine(); // disabled for ARM
#else
return this->IsCoroutine() && !(CONFIG_FLAG(JitES6Generators) && !this->GetHasTry() && !this->IsInDebugMode());
#endif
}

ScriptContext* EntryPointInfo::GetScriptContext()
Expand Down