Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lib/Backend/BailOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ BailOutRecord::BailOutHelper(Js::JavascriptCallStackLayout * layout, Js::ScriptF
Js::InterpreterStackFrame* newInstance = nullptr;
Js::Var* allocation = nullptr;

if (executeFunction->IsGenerator())
if (executeFunction->IsCoroutine())
{
// If the FunctionBody is a generator then this call is being made by one of the three
// generator resuming methods: next(), throw(), or return(). They all pass the generator
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/FlowGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ FlowGraph::Destroy(void)
// Skipping Try blocks as we have dependency on blocks to get the last instr(see below in this function)
if (!fHasTry)
{
if (this->func->GetJnFunction()->IsGenerator())
if (this->func->GetJnFunction()->IsCoroutine())
{
// the label could be a yield resume label, in which case we also need to remove it from the YieldOffsetResumeLabels list
this->func->MapUntilYieldOffsetResumeLabels([this, &labelInstr](int i, const YieldOffsetResumeLabel& yorl)
Expand Down
6 changes: 3 additions & 3 deletions lib/Backend/Func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Func::Func(JitArenaAllocator *alloc, CodeGenWorkItem* workItem, const Js::Functi
m_nonTempLocalVars = Anew(this->m_alloc, BVSparse<JitArenaAllocator>, this->m_alloc);
}

if (this->m_jnFunction->IsGenerator())
if (this->m_jnFunction->IsCoroutine())
{
m_yieldOffsetResumeLabelList = YieldOffsetResumeLabelList::New(this->m_alloc);
}
Expand Down Expand Up @@ -846,8 +846,8 @@ Func::AjustLocalVarSlotOffset()
bool
Func::DoGlobOptsForGeneratorFunc()
{
// Disable GlobOpt optimizations for generators initially. Will visit and enable each one by one.
return !m_jnFunction->IsGenerator();
// Disable GlobOpt optimizations for generators and async functions initially. Will visit and enable each one by one.
return !m_jnFunction->IsCoroutine();
}

void
Expand Down
6 changes: 0 additions & 6 deletions lib/Backend/Func.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,6 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
Assert(this->m_jnFunction); // For now we always have a function body
return this->m_jnFunction->GetIsGlobalFunc();
}
bool IsGeneratorFunc() const
{
Assert(this->IsTopFunc());
Assert(this->m_jnFunction); // For now we always have a function body
return this->m_jnFunction->IsGenerator();
}
bool IsLambda() const
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

{
Assert(this->IsTopFunc());
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ IRBuilder::BuildImplicitArgIns()
void
IRBuilder::BuildGeneratorPreamble()
{
if (!this->m_func->GetJnFunction()->IsGenerator())
if (!this->m_func->GetJnFunction()->IsCoroutine())
{
return;
}
Expand Down
1 change: 0 additions & 1 deletion lib/Backend/JnHelperMethodList.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ HELPERCALL(ScopedLdSuperCtor, Js::JavascriptOperators::OP_ScopedLdSuperCtor,
HELPERCALL(SetHomeObj, Js::JavascriptOperators::OP_SetHomeObj, 0)

HELPERCALL(ResumeYield, Js::JavascriptOperators::OP_ResumeYield, AttrCanThrow)
HELPERCALL(AsyncSpawn, Js::JavascriptOperators::OP_AsyncSpawn, AttrCanThrow)

#include "ExternalHelperMethodList.h"

Expand Down
39 changes: 21 additions & 18 deletions lib/Backend/Lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2956,10 +2956,6 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
break;
}

case Js::OpCode::AsyncSpawn:
this->LowerBinaryHelperMem(instr, IR::HelperAsyncSpawn);
break;

case Js::OpCode::FrameDisplayCheck:
instrPrev = this->LowerFrameDisplayCheck(instr);
break;
Expand Down Expand Up @@ -5088,7 +5084,7 @@ Lowerer::LowerNewScObjArrayNoArg(IR::Instr *newObjInstr)
void
Lowerer::LowerPrologEpilog()
{
if (m_func->GetJnFunction()->IsGenerator())
if (m_func->GetJnFunction()->IsCoroutine())
{
LowerGeneratorResumeJumpTable();
}
Expand Down Expand Up @@ -5125,7 +5121,7 @@ Lowerer::LowerPrologEpilogAsmJs()
void
Lowerer::LowerGeneratorResumeJumpTable()
{
Assert(m_func->GetJnFunction()->IsGenerator());
Assert(m_func->GetJnFunction()->IsCoroutine());

IR::Instr * jumpTableInstr = m_func->m_headInstr;
AssertMsg(jumpTableInstr->IsEntryInstr(), "First instr isn't an EntryInstr...");
Expand Down Expand Up @@ -7572,7 +7568,7 @@ Lowerer::LoadArgumentCount(IR::Instr *const instr)
instr->SetSrc1(IR::IntConstOpnd::New(instr->m_func->actualCount, TyUint32, instr->m_func, true));
LowererMD::ChangeToAssign(instr);
}
else if (instr->m_func->GetJnFunction()->IsGenerator())
else if (instr->m_func->GetJnFunction()->IsCoroutine())
{
IR::SymOpnd* symOpnd = LoadCallInfo(instr);
instr->SetSrc1(symOpnd);
Expand Down Expand Up @@ -9611,7 +9607,7 @@ IR::Instr *Lowerer::LowerRestParameter(IR::Opnd *formalsOpnd, IR::Opnd *dstOpnd,

LoadScriptContext(helperCallInstr);

BOOL isGenerator = this->m_func->GetJnFunction()->IsGenerator();
BOOL isGenerator = this->m_func->GetJnFunction()->IsCoroutine();

// Elements pointer = ebp + (formals count + formals offset + 1)*sizeof(Var)
IR::RegOpnd *srcOpnd = isGenerator ? generatorArgsPtrOpnd : IR::Opnd::CreateFramePointerOpnd(this->m_func);
Expand Down Expand Up @@ -9719,7 +9715,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)
// $createRestArray
instrArgIn->InsertBefore(createRestArrayLabel);

if (m_func->GetJnFunction()->IsGenerator())
if (m_func->GetJnFunction()->IsCoroutine())
{
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrArgIn);
}
Expand All @@ -9738,7 +9734,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)
if (argIndex == 1)
{
// The "this" argument is not source-dependent and doesn't need to be checked.
if (m_func->GetJnFunction()->IsGenerator())
if (m_func->GetJnFunction()->IsCoroutine())
{
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrArgIn);
ConvertArgOpndIfGeneratorFunction(instrArgIn, generatorArgsPtrOpnd);
Expand Down Expand Up @@ -9792,7 +9788,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)

// Now insert all the checks and undef-assigns.

if (m_func->GetJnFunction()->IsGenerator())
if (m_func->GetJnFunction()->IsCoroutine())
{
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrInsert);
}
Expand Down Expand Up @@ -9962,7 +9958,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)
void
Lowerer::ConvertArgOpndIfGeneratorFunction(IR::Instr *instrArgIn, IR::RegOpnd *generatorArgsPtrOpnd)
{
if (this->m_func->GetJnFunction()->IsGenerator())
if (this->m_func->GetJnFunction()->IsCoroutine())
{
// Replace stack param operand with offset into arguments array held by
// the generator object.
Expand Down Expand Up @@ -10668,7 +10664,7 @@ Lowerer::LoadCallInfo(IR::Instr * instrInsert)
IR::SymOpnd * srcOpnd;
Func * func = instrInsert->m_func;

if (func->GetJnFunction()->IsGenerator())
if (func->GetJnFunction()->IsCoroutine())
{
// Generator function arguments and ArgumentsInfo are not on the stack. Instead they
// are accessed off the generator object (which is prm1).
Expand Down Expand Up @@ -18115,7 +18111,7 @@ IR::IndirOpnd*
Lowerer::GetArgsIndirOpndForTopFunction(IR::Instr* ldElem, IR::Opnd* valueOpnd)
{
// Load argument set dst = [ebp + index] (or grab from the generator object if m_func is a generator function).
IR::RegOpnd *baseOpnd = m_func->GetJnFunction()->IsGenerator() ? LoadGeneratorArgsPtr(ldElem) : IR::Opnd::CreateFramePointerOpnd(m_func);
IR::RegOpnd *baseOpnd = m_func->GetJnFunction()->IsCoroutine() ? LoadGeneratorArgsPtr(ldElem) : IR::Opnd::CreateFramePointerOpnd(m_func);
IR::IndirOpnd* argIndirOpnd = nullptr;
// The stack looks like this:
// ...
Expand All @@ -18129,7 +18125,7 @@ Lowerer::GetArgsIndirOpndForTopFunction(IR::Instr* ldElem, IR::Opnd* valueOpnd)

//actual arguments offset is LowererMD::GetFormalParamOffset() + 1 (this)

uint16 actualOffset = m_func->GetJnFunction()->IsGenerator() ? 1 : GetFormalParamOffset() + 1; //5
uint16 actualOffset = m_func->GetJnFunction()->IsCoroutine() ? 1 : GetFormalParamOffset() + 1; //5
Assert(actualOffset == 5 || m_func->GetJnFunction()->IsGenerator());
if (valueOpnd->IsIntConstOpnd())
{
Expand Down Expand Up @@ -20327,6 +20323,7 @@ Lowerer::GenerateSetHomeObj(IR::Instr* instrInsert)
Func *func = instrInsert->m_func;

IR::LabelInstr *labelScriptFunction = IR::LabelInstr::New(Js::OpCode::Label, func, false);
IR::LabelInstr *labelForGeneratorScriptFunction = IR::LabelInstr::New(Js::OpCode::Label, func, false);

IR::Opnd *src2Opnd = instrInsert->UnlinkSrc2();
IR::Opnd *src1Opnd = instrInsert->UnlinkSrc1();
Expand All @@ -20338,10 +20335,16 @@ Lowerer::GenerateSetHomeObj(IR::Instr* instrInsert)
LowererMD::CreateAssign(funcObjRegOpnd, src1Opnd, instrInsert);

IR::Opnd * vtableAddressOpnd = this->LoadVTableValueOpnd(instrInsert, VTableValue::VtableJavascriptGeneratorFunction);
InsertCompareBranch(IR::IndirOpnd::New(funcObjRegOpnd, 0, TyMachPtr, func), vtableAddressOpnd,
Js::OpCode::BrEq_A, true, labelForGeneratorScriptFunction, instrInsert);

vtableAddressOpnd = this->LoadVTableValueOpnd(instrInsert, VTableValue::VtableJavascriptAsyncFunction);
InsertCompareBranch(IR::IndirOpnd::New(funcObjRegOpnd, 0, TyMachPtr, func), vtableAddressOpnd,
Js::OpCode::BrNeq_A, true, labelScriptFunction, instrInsert);

indirOpnd = IR::IndirOpnd::New(funcObjRegOpnd, Js::JavascriptGeneratorFunction::GetOffsetOfScriptFunction() , TyMachPtr, func);
instrInsert->InsertBefore(labelForGeneratorScriptFunction);

indirOpnd = IR::IndirOpnd::New(funcObjRegOpnd, Js::JavascriptGeneratorFunction::GetOffsetOfScriptFunction(), TyMachPtr, func);
LowererMD::CreateAssign(funcObjRegOpnd, indirOpnd, instrInsert);

instrInsert->InsertBefore(labelScriptFunction);
Expand All @@ -20363,7 +20366,7 @@ Lowerer::GenerateLoadNewTarget(IR::Instr* instrInsert)

Assert(!func->IsInlinee());

if (func->GetJnFunction()->IsGenerator())
if (func->GetJnFunction()->IsCoroutine())
{
instrInsert->SetSrc1(opndUndefAddress);
LowererMD::ChangeToAssign(instrInsert);
Expand Down Expand Up @@ -21098,7 +21101,7 @@ void Lowerer::GenerateNullOutGeneratorFrame(IR::Instr* insertInstr)

void Lowerer::LowerFunctionExit(IR::Instr* funcExit)
{
if (m_func->GetJnFunction()->IsGenerator())
if (m_func->GetJnFunction()->IsCoroutine())
{
GenerateNullOutGeneratorFrame(funcExit->m_prev);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Backend/amd64/LowererMDArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ LowererMDArch::Init(LowererMD *lowererMD)
IR::Instr *
LowererMDArch::LoadInputParamPtr(IR::Instr *instrInsert, IR::RegOpnd *optionalDstOpnd /* = nullptr */)
{
if (this->m_func->GetJnFunction()->IsGenerator())
if (this->m_func->GetJnFunction()->IsCoroutine())
{
IR::RegOpnd * argPtrRegOpnd = Lowerer::LoadGeneratorArgsPtr(instrInsert);
IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(argPtrRegOpnd, 1 * MachPtr, TyMachPtr, this->m_func);
Expand Down Expand Up @@ -380,7 +380,7 @@ LowererMDArch::LoadHeapArguments(IR::Instr *instrArgs, bool force /* = false */,
this->m_func->SetArgOffset(paramSym, 2 * MachPtr);
IR::Opnd * srcOpnd = IR::SymOpnd::New(paramSym, TyMachReg, func);

if (this->m_func->GetJnFunction()->IsGenerator())
if (this->m_func->GetJnFunction()->IsCoroutine())
{
// the function object for generator calls is a GeneratorVirtualScriptFunction object
// and we need to pass the real JavascriptGeneratorFunction object so grab it instead
Expand Down Expand Up @@ -430,7 +430,7 @@ LowererMDArch::LoadFuncExpression(IR::Instr *instrFuncExpr)
paramOpnd = IR::SymOpnd::New(paramSym, TyMachReg, this->m_func);
}

if (instrFuncExpr->m_func->GetJnFunction()->IsGenerator())
if (instrFuncExpr->m_func->GetJnFunction()->IsCoroutine())
{
// the function object for generator calls is a GeneratorVirtualScriptFunction object
// and we need to return the real JavascriptGeneratorFunction object so grab it before
Expand Down
4 changes: 2 additions & 2 deletions lib/Backend/arm/LowerMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ LowererMD::Init(Lowerer *lowerer)
IR::Instr *
LowererMD::LoadInputParamPtr(IR::Instr * instrInsert, IR::RegOpnd * optionalDstOpnd /* = nullptr */)
{
if (this->m_func->GetJnFunction()->IsGenerator())
if (this->m_func->GetJnFunction()->IsCoroutine())
{
IR::RegOpnd * argPtrRegOpnd = Lowerer::LoadGeneratorArgsPtr(instrInsert);
IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(argPtrRegOpnd, 1 * MachPtr, TyMachPtr, this->m_func);
Expand Down Expand Up @@ -2087,7 +2087,7 @@ LowererMD::LoadStackArgPtr(IR::Instr * instr)
instr->SetSrc1(tmpOpnd);
instr->SetSrc2(IR::IntConstOpnd::New(sizeof(Js::Var), TyMachReg, this->m_func));
}
else if (this->m_func->GetJnFunction()->IsGenerator())
else if (this->m_func->GetJnFunction()->IsCoroutine())
{
IR::Instr *instr2 = LoadInputParamPtr(instr, instr->UnlinkDst()->AsRegOpnd());
instr->Remove();
Expand Down
6 changes: 3 additions & 3 deletions lib/Backend/i386/LowererMDArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ LowererMDArch::Init(LowererMD *lowererMD)
IR::Instr *
LowererMDArch::LoadInputParamPtr(IR::Instr *instrInsert, IR::RegOpnd *optionalDstOpnd /* = nullptr */)
{
if (this->m_func->GetJnFunction()->IsGenerator())
if (this->m_func->GetJnFunction()->IsCoroutine())
{
IR::RegOpnd * argPtrRegOpnd = Lowerer::LoadGeneratorArgsPtr(instrInsert);
IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(argPtrRegOpnd, 1 * MachPtr, TyMachPtr, this->m_func);
Expand Down Expand Up @@ -334,7 +334,7 @@ LowererMDArch::LoadHeapArguments(IR::Instr *instrArgs, bool force, IR::Opnd* opn
this->m_func->SetArgOffset(paramSym, 2 * MachPtr);
IR::Opnd *srcOpnd = IR::SymOpnd::New(paramSym, TyMachReg, func);

if (this->m_func->GetJnFunction()->IsGenerator())
if (this->m_func->GetJnFunction()->IsCoroutine())
{
// the function object for generator calls is a GeneratorVirtualScriptFunction object
// and we need to pass the real JavascriptGeneratorFunction object so grab it instead
Expand Down Expand Up @@ -501,7 +501,7 @@ LowererMDArch::LoadFuncExpression(IR::Instr *instrFuncExpr)
paramOpnd = IR::SymOpnd::New(paramSym, TyMachReg, func);
}

if (instrFuncExpr->m_func->GetJnFunction()->IsGenerator())
if (instrFuncExpr->m_func->GetJnFunction()->IsCoroutine())
{
// the function object for generator calls is a GeneratorVirtualScriptFunction object
// and we need to return the real JavascriptGeneratorFunction object so grab it before
Expand Down
1 change: 1 addition & 0 deletions lib/Common/BackendApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ enum VTableValue {
VtableJavascriptRegExp,
VtableScriptFunction,
VtableJavascriptGeneratorFunction,
VtableJavascriptAsyncFunction,
VtableStackScriptFunction,
VtableConcatStringMulti,
VtableCompoundString,
Expand Down
Loading