@@ -2956,10 +2956,6 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
2956
2956
break;
2957
2957
}
2958
2958
2959
- case Js::OpCode::AsyncSpawn:
2960
- this->LowerBinaryHelperMem(instr, IR::HelperAsyncSpawn);
2961
- break;
2962
-
2963
2959
case Js::OpCode::FrameDisplayCheck:
2964
2960
instrPrev = this->LowerFrameDisplayCheck(instr);
2965
2961
break;
@@ -5088,7 +5084,7 @@ Lowerer::LowerNewScObjArrayNoArg(IR::Instr *newObjInstr)
5088
5084
void
5089
5085
Lowerer::LowerPrologEpilog()
5090
5086
{
5091
- if (m_func->GetJnFunction()->IsGenerator())
5087
+ if (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync() )
5092
5088
{
5093
5089
LowerGeneratorResumeJumpTable();
5094
5090
}
@@ -5125,7 +5121,7 @@ Lowerer::LowerPrologEpilogAsmJs()
5125
5121
void
5126
5122
Lowerer::LowerGeneratorResumeJumpTable()
5127
5123
{
5128
- Assert(m_func->GetJnFunction()->IsGenerator());
5124
+ Assert(m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync() );
5129
5125
5130
5126
IR::Instr * jumpTableInstr = m_func->m_headInstr;
5131
5127
AssertMsg(jumpTableInstr->IsEntryInstr(), "First instr isn't an EntryInstr...");
@@ -7572,7 +7568,7 @@ Lowerer::LoadArgumentCount(IR::Instr *const instr)
7572
7568
instr->SetSrc1(IR::IntConstOpnd::New(instr->m_func->actualCount, TyUint32, instr->m_func, true));
7573
7569
LowererMD::ChangeToAssign(instr);
7574
7570
}
7575
- else if (instr->m_func->GetJnFunction()->IsGenerator())
7571
+ else if (instr->m_func->GetJnFunction()->IsGenerator() || instr->m_func->GetJnFunction()->IsAsync() )
7576
7572
{
7577
7573
IR::SymOpnd* symOpnd = LoadCallInfo(instr);
7578
7574
instr->SetSrc1(symOpnd);
@@ -9611,7 +9607,7 @@ IR::Instr *Lowerer::LowerRestParameter(IR::Opnd *formalsOpnd, IR::Opnd *dstOpnd,
9611
9607
9612
9608
LoadScriptContext(helperCallInstr);
9613
9609
9614
- BOOL isGenerator = this->m_func->GetJnFunction()->IsGenerator();
9610
+ BOOL isGenerator = this->m_func->GetJnFunction()->IsGenerator() || this->m_func->GetJnFunction()->IsAsync() ;
9615
9611
9616
9612
// Elements pointer = ebp + (formals count + formals offset + 1)*sizeof(Var)
9617
9613
IR::RegOpnd *srcOpnd = isGenerator ? generatorArgsPtrOpnd : IR::Opnd::CreateFramePointerOpnd(this->m_func);
@@ -9719,7 +9715,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)
9719
9715
// $createRestArray
9720
9716
instrArgIn->InsertBefore(createRestArrayLabel);
9721
9717
9722
- if (m_func->GetJnFunction()->IsGenerator())
9718
+ if (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync() )
9723
9719
{
9724
9720
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrArgIn);
9725
9721
}
@@ -9738,7 +9734,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)
9738
9734
if (argIndex == 1)
9739
9735
{
9740
9736
// The "this" argument is not source-dependent and doesn't need to be checked.
9741
- if (m_func->GetJnFunction()->IsGenerator())
9737
+ if (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync() )
9742
9738
{
9743
9739
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrArgIn);
9744
9740
ConvertArgOpndIfGeneratorFunction(instrArgIn, generatorArgsPtrOpnd);
@@ -9792,7 +9788,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)
9792
9788
9793
9789
// Now insert all the checks and undef-assigns.
9794
9790
9795
- if (m_func->GetJnFunction()->IsGenerator())
9791
+ if (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync() )
9796
9792
{
9797
9793
generatorArgsPtrOpnd = LoadGeneratorArgsPtr(instrInsert);
9798
9794
}
@@ -9962,7 +9958,7 @@ Lowerer::LowerArgIn(IR::Instr *instrArgIn)
9962
9958
void
9963
9959
Lowerer::ConvertArgOpndIfGeneratorFunction(IR::Instr *instrArgIn, IR::RegOpnd *generatorArgsPtrOpnd)
9964
9960
{
9965
- if (this->m_func->GetJnFunction()->IsGenerator())
9961
+ if (this->m_func->GetJnFunction()->IsGenerator() || this->m_func->GetJnFunction()->IsAsync() )
9966
9962
{
9967
9963
// Replace stack param operand with offset into arguments array held by
9968
9964
// the generator object.
@@ -10668,7 +10664,7 @@ Lowerer::LoadCallInfo(IR::Instr * instrInsert)
10668
10664
IR::SymOpnd * srcOpnd;
10669
10665
Func * func = instrInsert->m_func;
10670
10666
10671
- if (func->GetJnFunction()->IsGenerator())
10667
+ if (func->GetJnFunction()->IsGenerator() || func->GetJnFunction()->IsAsync() )
10672
10668
{
10673
10669
// Generator function arguments and ArgumentsInfo are not on the stack. Instead they
10674
10670
// are accessed off the generator object (which is prm1).
@@ -18115,7 +18111,7 @@ IR::IndirOpnd*
18115
18111
Lowerer::GetArgsIndirOpndForTopFunction(IR::Instr* ldElem, IR::Opnd* valueOpnd)
18116
18112
{
18117
18113
// Load argument set dst = [ebp + index] (or grab from the generator object if m_func is a generator function).
18118
- IR::RegOpnd *baseOpnd = m_func->GetJnFunction()->IsGenerator() ? LoadGeneratorArgsPtr(ldElem) : IR::Opnd::CreateFramePointerOpnd(m_func);
18114
+ IR::RegOpnd *baseOpnd = ( m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync() ) ? LoadGeneratorArgsPtr(ldElem) : IR::Opnd::CreateFramePointerOpnd(m_func);
18119
18115
IR::IndirOpnd* argIndirOpnd = nullptr;
18120
18116
// The stack looks like this:
18121
18117
// ...
@@ -18129,7 +18125,7 @@ Lowerer::GetArgsIndirOpndForTopFunction(IR::Instr* ldElem, IR::Opnd* valueOpnd)
18129
18125
18130
18126
//actual arguments offset is LowererMD::GetFormalParamOffset() + 1 (this)
18131
18127
18132
- uint16 actualOffset = m_func->GetJnFunction()->IsGenerator() ? 1 : GetFormalParamOffset() + 1; //5
18128
+ uint16 actualOffset = ( m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync() ) ? 1 : GetFormalParamOffset() + 1; //5
18133
18129
Assert(actualOffset == 5 || m_func->GetJnFunction()->IsGenerator());
18134
18130
if (valueOpnd->IsIntConstOpnd())
18135
18131
{
@@ -20327,6 +20323,7 @@ Lowerer::GenerateSetHomeObj(IR::Instr* instrInsert)
20327
20323
Func *func = instrInsert->m_func;
20328
20324
20329
20325
IR::LabelInstr *labelScriptFunction = IR::LabelInstr::New(Js::OpCode::Label, func, false);
20326
+ IR::LabelInstr *labelForGeneratorScriptFunction = IR::LabelInstr::New(Js::OpCode::Label, func, false);
20330
20327
20331
20328
IR::Opnd *src2Opnd = instrInsert->UnlinkSrc2();
20332
20329
IR::Opnd *src1Opnd = instrInsert->UnlinkSrc1();
@@ -20338,10 +20335,16 @@ Lowerer::GenerateSetHomeObj(IR::Instr* instrInsert)
20338
20335
LowererMD::CreateAssign(funcObjRegOpnd, src1Opnd, instrInsert);
20339
20336
20340
20337
IR::Opnd * vtableAddressOpnd = this->LoadVTableValueOpnd(instrInsert, VTableValue::VtableJavascriptGeneratorFunction);
20338
+ InsertCompareBranch(IR::IndirOpnd::New(funcObjRegOpnd, 0, TyMachPtr, func), vtableAddressOpnd,
20339
+ Js::OpCode::BrEq_A, true, labelForGeneratorScriptFunction, instrInsert);
20340
+
20341
+ vtableAddressOpnd = this->LoadVTableValueOpnd(instrInsert, VTableValue::VtableJavascriptAsyncFunction);
20341
20342
InsertCompareBranch(IR::IndirOpnd::New(funcObjRegOpnd, 0, TyMachPtr, func), vtableAddressOpnd,
20342
20343
Js::OpCode::BrNeq_A, true, labelScriptFunction, instrInsert);
20343
20344
20344
- indirOpnd = IR::IndirOpnd::New(funcObjRegOpnd, Js::JavascriptGeneratorFunction::GetOffsetOfScriptFunction() , TyMachPtr, func);
20345
+ instrInsert->InsertBefore(labelForGeneratorScriptFunction);
20346
+
20347
+ indirOpnd = IR::IndirOpnd::New(funcObjRegOpnd, instrInsert->m_func->IsGeneratorFunc() ? Js::JavascriptGeneratorFunction::GetOffsetOfScriptFunction() : Js::JavascriptAsyncFunction::GetOffsetOfScriptFunction() , TyMachPtr, func);
20345
20348
LowererMD::CreateAssign(funcObjRegOpnd, indirOpnd, instrInsert);
20346
20349
20347
20350
instrInsert->InsertBefore(labelScriptFunction);
@@ -20363,7 +20366,7 @@ Lowerer::GenerateLoadNewTarget(IR::Instr* instrInsert)
20363
20366
20364
20367
Assert(!func->IsInlinee());
20365
20368
20366
- if (func->GetJnFunction()->IsGenerator())
20369
+ if (func->GetJnFunction()->IsGenerator() || func->GetJnFunction()->IsAsync() )
20367
20370
{
20368
20371
instrInsert->SetSrc1(opndUndefAddress);
20369
20372
LowererMD::ChangeToAssign(instrInsert);
@@ -21098,7 +21101,7 @@ void Lowerer::GenerateNullOutGeneratorFrame(IR::Instr* insertInstr)
21098
21101
21099
21102
void Lowerer::LowerFunctionExit(IR::Instr* funcExit)
21100
21103
{
21101
- if (m_func->GetJnFunction()->IsGenerator())
21104
+ if (m_func->GetJnFunction()->IsGenerator() || m_func->GetJnFunction()->IsAsync() )
21102
21105
{
21103
21106
GenerateNullOutGeneratorFrame(funcExit->m_prev);
21104
21107
}
0 commit comments