Skip to content

Commit 5e26878

Browse files
committed
Fixed review comments
1 parent 149fb38 commit 5e26878

19 files changed

+48
-92
lines changed

lib/Backend/BailOut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ BailOutRecord::BailOutHelper(Js::JavascriptCallStackLayout * layout, Js::ScriptF
14371437
Js::InterpreterStackFrame* newInstance = nullptr;
14381438
Js::Var* allocation = nullptr;
14391439

1440-
if (executeFunction->IsGenerator() || executeFunction->IsAsync())
1440+
if (executeFunction->IsCoroutine())
14411441
{
14421442
// If the FunctionBody is a generator then this call is being made by one of the three
14431443
// generator resuming methods: next(), throw(), or return(). They all pass the generator

lib/Backend/FlowGraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ FlowGraph::Destroy(void)
10991099
// Skipping Try blocks as we have dependency on blocks to get the last instr(see below in this function)
11001100
if (!fHasTry)
11011101
{
1102-
if (this->func->GetJnFunction()->IsGenerator() || this->func->GetJnFunction()->IsAsync())
1102+
if (this->func->GetJnFunction()->IsCoroutine())
11031103
{
11041104
// the label could be a yield resume label, in which case we also need to remove it from the YieldOffsetResumeLabels list
11051105
this->func->MapUntilYieldOffsetResumeLabels([this, &labelInstr](int i, const YieldOffsetResumeLabel& yorl)

lib/Backend/Func.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Func::Func(JitArenaAllocator *alloc, CodeGenWorkItem* workItem, const Js::Functi
214214
m_nonTempLocalVars = Anew(this->m_alloc, BVSparse<JitArenaAllocator>, this->m_alloc);
215215
}
216216

217-
if (this->m_jnFunction->IsGenerator() || this->m_jnFunction->IsAsync())
217+
if (this->m_jnFunction->IsCoroutine())
218218
{
219219
m_yieldOffsetResumeLabelList = YieldOffsetResumeLabelList::New(this->m_alloc);
220220
}
@@ -846,8 +846,8 @@ Func::AjustLocalVarSlotOffset()
846846
bool
847847
Func::DoGlobOptsForGeneratorFunc()
848848
{
849-
// Disable GlobOpt optimizations for generators and asyn functions initially. Will visit and enable each one by one.
850-
return !m_jnFunction->IsGenerator() && !m_jnFunction->IsAsync();
849+
// Disable GlobOpt optimizations for generators and async functions initially. Will visit and enable each one by one.
850+
return !m_jnFunction->IsCoroutine();
851851
}
852852

853853
void

lib/Backend/IRBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ IRBuilder::BuildImplicitArgIns()
13651365
void
13661366
IRBuilder::BuildGeneratorPreamble()
13671367
{
1368-
if (!this->m_func->GetJnFunction()->IsGenerator() && !this->m_func->GetJnFunction()->IsAsync())
1368+
if (!this->m_func->GetJnFunction()->IsCoroutine())
13691369
{
13701370
return;
13711371
}

lib/Backend/Lower.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5084,7 +5084,7 @@ Lowerer::LowerNewScObjArrayNoArg(IR::Instr *newObjInstr)
50845084
void
50855085
Lowerer::LowerPrologEpilog()
50865086
{
5087-
if (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync())
5087+
if (m_func->GetJnFunction()->IsCoroutine())
50885088
{
50895089
LowerGeneratorResumeJumpTable();
50905090
}
@@ -5121,7 +5121,7 @@ Lowerer::LowerPrologEpilogAsmJs()
51215121
void
51225122
Lowerer::LowerGeneratorResumeJumpTable()
51235123
{
5124-
Assert(m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync());
5124+
Assert(m_func->GetJnFunction()->IsCoroutine());
51255125

51265126
IR::Instr * jumpTableInstr = m_func->m_headInstr;
51275127
AssertMsg(jumpTableInstr->IsEntryInstr(), "First instr isn't an EntryInstr...");
@@ -7568,7 +7568,7 @@ Lowerer::LoadArgumentCount(IR::Instr *const instr)
75687568
instr->SetSrc1(IR::IntConstOpnd::New(instr->m_func->actualCount, TyUint32, instr->m_func, true));
75697569
LowererMD::ChangeToAssign(instr);
75707570
}
7571-
else if (instr->m_func->GetJnFunction()->IsGenerator() || instr->m_func->GetJnFunction()->IsAsync())
7571+
else if (instr->m_func->GetJnFunction()->IsCoroutine())
75727572
{
75737573
IR::SymOpnd* symOpnd = LoadCallInfo(instr);
75747574
instr->SetSrc1(symOpnd);
@@ -9607,7 +9607,7 @@ IR::Instr *Lowerer::LowerRestParameter(IR::Opnd *formalsOpnd, IR::Opnd *dstOpnd,
96079607

96089608
LoadScriptContext(helperCallInstr);
96099609

9610-
BOOL isGenerator = this->m_func->GetJnFunction()->IsGenerator() || this->m_func->GetJnFunction()->IsAsync();
9610+
BOOL isGenerator = this->m_func->GetJnFunction()->IsCoroutine();
96119611

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

9718-
if (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync())
9718+
if (m_func->GetJnFunction()->IsCoroutine())
97199719
{
97209720
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrArgIn);
97219721
}
@@ -9734,7 +9734,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)
97349734
if (argIndex == 1)
97359735
{
97369736
// The "this" argument is not source-dependent and doesn't need to be checked.
9737-
if (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync())
9737+
if (m_func->GetJnFunction()->IsCoroutine())
97389738
{
97399739
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrArgIn);
97409740
ConvertArgOpndIfGeneratorFunction(instrArgIn, generatorArgsPtrOpnd);
@@ -9788,7 +9788,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)
97889788

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

9791-
if (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync())
9791+
if (m_func->GetJnFunction()->IsCoroutine())
97929792
{
97939793
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrInsert);
97949794
}
@@ -9958,7 +9958,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)
99589958
void
99599959
Lowerer::ConvertArgOpndIfGeneratorFunction(IR::Instr *instrArgIn, IR::RegOpnd *generatorArgsPtrOpnd)
99609960
{
9961-
if (this->m_func->GetJnFunction()->IsGenerator() || this->m_func->GetJnFunction()->IsAsync())
9961+
if (this->m_func->GetJnFunction()->IsCoroutine())
99629962
{
99639963
// Replace stack param operand with offset into arguments array held by
99649964
// the generator object.
@@ -10664,7 +10664,7 @@ Lowerer::LoadCallInfo(IR::Instr * instrInsert)
1066410664
IR::SymOpnd * srcOpnd;
1066510665
Func * func = instrInsert->m_func;
1066610666

10667-
if (func->GetJnFunction()->IsGenerator() || func->GetJnFunction()->IsAsync())
10667+
if (func->GetJnFunction()->IsCoroutine())
1066810668
{
1066910669
// Generator function arguments and ArgumentsInfo are not on the stack. Instead they
1067010670
// are accessed off the generator object (which is prm1).
@@ -18111,7 +18111,7 @@ IR::IndirOpnd*
1811118111
Lowerer::GetArgsIndirOpndForTopFunction(IR::Instr* ldElem, IR::Opnd* valueOpnd)
1811218112
{
1811318113
// Load argument set dst = [ebp + index] (or grab from the generator object if m_func is a generator function).
18114-
IR::RegOpnd *baseOpnd = (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync()) ? LoadGeneratorArgsPtr(ldElem) : IR::Opnd::CreateFramePointerOpnd(m_func);
18114+
IR::RegOpnd *baseOpnd = m_func->GetJnFunction()->IsCoroutine() ? LoadGeneratorArgsPtr(ldElem) : IR::Opnd::CreateFramePointerOpnd(m_func);
1811518115
IR::IndirOpnd* argIndirOpnd = nullptr;
1811618116
// The stack looks like this:
1811718117
// ...
@@ -18125,7 +18125,7 @@ Lowerer::GetArgsIndirOpndForTopFunction(IR::Instr* ldElem, IR::Opnd* valueOpnd)
1812518125

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

18128-
uint16 actualOffset = (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync()) ? 1 : GetFormalParamOffset() + 1; //5
18128+
uint16 actualOffset = m_func->GetJnFunction()->IsCoroutine() ? 1 : GetFormalParamOffset() + 1; //5
1812918129
Assert(actualOffset == 5 || m_func->GetJnFunction()->IsGenerator());
1813018130
if (valueOpnd->IsIntConstOpnd())
1813118131
{
@@ -20366,7 +20366,7 @@ Lowerer::GenerateLoadNewTarget(IR::Instr* instrInsert)
2036620366

2036720367
Assert(!func->IsInlinee());
2036820368

20369-
if (func->GetJnFunction()->IsGenerator() || func->GetJnFunction()->IsAsync())
20369+
if (func->GetJnFunction()->IsCoroutine())
2037020370
{
2037120371
instrInsert->SetSrc1(opndUndefAddress);
2037220372
LowererMD::ChangeToAssign(instrInsert);
@@ -21101,7 +21101,7 @@ void Lowerer::GenerateNullOutGeneratorFrame(IR::Instr* insertInstr)
2110121101

2110221102
void Lowerer::LowerFunctionExit(IR::Instr* funcExit)
2110321103
{
21104-
if (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync())
21104+
if (m_func->GetJnFunction()->IsCoroutine())
2110521105
{
2110621106
GenerateNullOutGeneratorFrame(funcExit->m_prev);
2110721107
}

lib/Backend/amd64/LowererMDArch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ LowererMDArch::Init(LowererMD *lowererMD)
140140
IR::Instr *
141141
LowererMDArch::LoadInputParamPtr(IR::Instr *instrInsert, IR::RegOpnd *optionalDstOpnd /* = nullptr */)
142142
{
143-
if (this->m_func->GetJnFunction()->IsGenerator() || this->m_func->GetJnFunction()->IsAsync())
143+
if (this->m_func->GetJnFunction()->IsCoroutine())
144144
{
145145
IR::RegOpnd * argPtrRegOpnd = Lowerer::LoadGeneratorArgsPtr(instrInsert);
146146
IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(argPtrRegOpnd, 1 * MachPtr, TyMachPtr, this->m_func);
@@ -380,7 +380,7 @@ LowererMDArch::LoadHeapArguments(IR::Instr *instrArgs, bool force /* = false */,
380380
this->m_func->SetArgOffset(paramSym, 2 * MachPtr);
381381
IR::Opnd * srcOpnd = IR::SymOpnd::New(paramSym, TyMachReg, func);
382382

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

433-
if (instrFuncExpr->m_func->GetJnFunction()->IsGenerator() || instrFuncExpr->m_func->GetJnFunction()->IsAsync())
433+
if (instrFuncExpr->m_func->GetJnFunction()->IsCoroutine())
434434
{
435435
// the function object for generator calls is a GeneratorVirtualScriptFunction object
436436
// and we need to return the real JavascriptGeneratorFunction object so grab it before

lib/Backend/arm/LowerMD.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,7 @@ LowererMD::Init(Lowerer *lowerer)
19931993
IR::Instr *
19941994
LowererMD::LoadInputParamPtr(IR::Instr * instrInsert, IR::RegOpnd * optionalDstOpnd /* = nullptr */)
19951995
{
1996-
if (this->m_func->GetJnFunction()->IsGenerator() || this->m_func->GetJnFunction()->IsAsync())
1996+
if (this->m_func->GetJnFunction()->IsCoroutine())
19971997
{
19981998
IR::RegOpnd * argPtrRegOpnd = Lowerer::LoadGeneratorArgsPtr(instrInsert);
19991999
IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(argPtrRegOpnd, 1 * MachPtr, TyMachPtr, this->m_func);
@@ -2087,7 +2087,7 @@ LowererMD::LoadStackArgPtr(IR::Instr * instr)
20872087
instr->SetSrc1(tmpOpnd);
20882088
instr->SetSrc2(IR::IntConstOpnd::New(sizeof(Js::Var), TyMachReg, this->m_func));
20892089
}
2090-
else if (this->m_func->GetJnFunction()->IsGenerator() || this->m_func->GetJnFunction()->IsAsync())
2090+
else if (this->m_func->GetJnFunction()->IsCoroutine())
20912091
{
20922092
IR::Instr *instr2 = LoadInputParamPtr(instr, instr->UnlinkDst()->AsRegOpnd());
20932093
instr->Remove();

lib/Backend/i386/LowererMDArch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ LowererMDArch::Init(LowererMD *lowererMD)
137137
IR::Instr *
138138
LowererMDArch::LoadInputParamPtr(IR::Instr *instrInsert, IR::RegOpnd *optionalDstOpnd /* = nullptr */)
139139
{
140-
if (this->m_func->GetJnFunction()->IsGenerator() || this->m_func->GetJnFunction()->IsAsync())
140+
if (this->m_func->GetJnFunction()->IsCoroutine())
141141
{
142142
IR::RegOpnd * argPtrRegOpnd = Lowerer::LoadGeneratorArgsPtr(instrInsert);
143143
IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(argPtrRegOpnd, 1 * MachPtr, TyMachPtr, this->m_func);
@@ -334,7 +334,7 @@ LowererMDArch::LoadHeapArguments(IR::Instr *instrArgs, bool force, IR::Opnd* opn
334334
this->m_func->SetArgOffset(paramSym, 2 * MachPtr);
335335
IR::Opnd *srcOpnd = IR::SymOpnd::New(paramSym, TyMachReg, func);
336336

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

504-
if (instrFuncExpr->m_func->GetJnFunction()->IsGenerator() || instrFuncExpr->m_func->GetJnFunction()->IsAsync())
504+
if (instrFuncExpr->m_func->GetJnFunction()->IsCoroutine())
505505
{
506506
// the function object for generator calls is a GeneratorVirtualScriptFunction object
507507
// and we need to return the real JavascriptGeneratorFunction object so grab it before

lib/Parser/ptree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ struct PnFnc
338338
bool IsDeclaration() const { return HasFlags(kFunctionDeclaration); }
339339
bool IsGeneratedDefault() const { return HasFlags(kFunctionIsGeneratedDefault); }
340340
bool IsGenerator() const { return HasFlags(kFunctionIsGenerator); }
341+
bool IsCoroutine() const { return HasFlags(kFunctionIsGenerator) || HasFlags(kFunctionIsAsync); }
341342
bool IsLambda() const { return HasFlags(kFunctionIsLambda); }
342343
bool IsMethod() const { return HasFlags(kFunctionIsMethod); }
343344
bool IsNested() const { return HasFlags(kFunctionNested); }

lib/Runtime/Base/FunctionBody.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3171,7 +3171,7 @@ namespace Js
31713171

31723172
bool IsGeneratorAndJitIsDisabled()
31733173
{
3174-
return (this->IsGenerator() || this->IsAsync()) && !(CONFIG_ISENABLED(Js::JitES6GeneratorsFlag) && !this->GetHasTry());
3174+
return this->IsCoroutine() && !(CONFIG_ISENABLED(Js::JitES6GeneratorsFlag) && !this->GetHasTry());
31753175
}
31763176

31773177
FunctionBodyFlags * GetAddressOfFlags() { return &this->flags; }

0 commit comments

Comments
 (0)