@@ -7134,6 +7134,57 @@ Lowerer::LowerStFld(
7134
7134
IR::Opnd *dst = stFldInstr->UnlinkDst();
7135
7135
AssertMsg(dst->IsSymOpnd() && dst->AsSymOpnd()->m_sym->IsPropertySym(), "Expected property sym as dst of field store");
7136
7136
7137
+ BailOutInfo * bailOutInfo = nullptr;
7138
+ bool doCheckLayout = false;
7139
+ IR::PropertySymOpnd * propertySymOpnd = nullptr;
7140
+ if (dst->AsSymOpnd()->IsPropertySymOpnd())
7141
+ {
7142
+ propertySymOpnd = dst->AsPropertySymOpnd();
7143
+ if (stFldInstr->HasBailOutInfo() && !propertySymOpnd->IsTypeCheckSeqCandidate() && propertySymOpnd->TypeCheckRequired())
7144
+ {
7145
+ IR::Instr * instrBailTarget = stFldInstr->ShareBailOut();
7146
+ LowerBailTarget(instrBailTarget);
7147
+ doCheckLayout = true;
7148
+ bailOutInfo = stFldInstr->GetBailOutInfo();
7149
+ switch (helperMethod)
7150
+ {
7151
+ case IR::HelperOp_PatchPutValue:
7152
+ helperMethod = IR::HelperOp_PatchPutValueCheckLayout;
7153
+ break;
7154
+ case IR::HelperOp_PatchPutValuePolymorphic:
7155
+ helperMethod = IR::HelperOp_PatchPutValuePolymorphicCheckLayout;
7156
+ break;
7157
+ case IR::HelperOp_PatchPutValueNoLocalFastPath:
7158
+ helperMethod = IR::HelperOp_PatchPutValueNoLocalFastPathCheckLayout;
7159
+ break;
7160
+ case IR::HelperOp_PatchPutValueNoLocalFastPathPolymorphic:
7161
+ helperMethod = IR::HelperOp_PatchPutValueNoLocalFastPathPolymorphicCheckLayout;
7162
+ break;
7163
+ case IR::HelperOp_PatchPutValueWithThisPtr:
7164
+ helperMethod = IR::HelperOp_PatchPutValueWithThisPtrCheckLayout;
7165
+ break;
7166
+ case IR::HelperOp_PatchPutValueWithThisPtrPolymorphic:
7167
+ helperMethod = IR::HelperOp_PatchPutValueWithThisPtrPolymorphicCheckLayout;
7168
+ break;
7169
+ case IR::HelperOp_PatchPutValueWithThisPtrNoLocalFastPath:
7170
+ helperMethod = IR::HelperOp_PatchPutValueWithThisPtrNoLocalFastPathCheckLayout;
7171
+ break;
7172
+ case IR::HelperOp_PatchPutValueWithThisPtrNoLocalFastPathPolymorphic:
7173
+ helperMethod = IR::HelperOp_PatchPutValueWithThisPtrNoLocalFastPathPolymorphicCheckLayout;
7174
+ break;
7175
+ case IR::HelperOp_PatchInitValue:
7176
+ helperMethod = IR::HelperOp_PatchInitValueCheckLayout;
7177
+ break;
7178
+ case IR::HelperOp_PatchInitValuePolymorphic:
7179
+ helperMethod = IR::HelperOp_PatchInitValuePolymorphicCheckLayout;
7180
+ break;
7181
+ default:
7182
+ AssertOrFailFast(false);
7183
+ break;
7184
+ }
7185
+ }
7186
+ }
7187
+
7137
7188
IR::Opnd * inlineCacheOpnd = nullptr;
7138
7189
if (withInlineCache)
7139
7190
{
@@ -7180,7 +7231,20 @@ Lowerer::LowerStFld(
7180
7231
}
7181
7232
7182
7233
IR::RegOpnd *opndBase = dst->AsSymOpnd()->CreatePropertyOwnerOpnd(m_func);
7183
- m_lowererMD.ChangeToHelperCall(stFldInstr, helperMethod, labelBailOut, opndBase, dst->AsSymOpnd()->IsPropertySymOpnd() ? dst->AsSymOpnd()->AsPropertySymOpnd() : nullptr, isHelper);
7234
+
7235
+ IR::Instr * callInstr =
7236
+ m_lowererMD.ChangeToHelperCall(stFldInstr, helperMethod, labelBailOut, opndBase, propertySymOpnd, isHelper);
7237
+
7238
+ if (doCheckLayout)
7239
+ {
7240
+ callInstr->SetDst(IR::RegOpnd::New(TyUint8, bailOutInfo->bailOutFunc));
7241
+ IR::Instr * bailOutInstr = IR::BailOutInstr::New(Js::OpCode::BailOnNotEqual, IR::BailOutFailedTypeCheck, bailOutInfo, bailOutInfo->bailOutFunc);
7242
+ bailOutInstr->SetSrc1(callInstr->GetDst());
7243
+ bailOutInstr->SetSrc2(IR::IntConstOpnd::New(0, TyUint8, bailOutInfo->bailOutFunc));
7244
+ callInstr->InsertAfter(bailOutInstr);
7245
+ bailOutInfo->polymorphicCacheIndex = propertySymOpnd->m_inlineCacheIndex;
7246
+ LowerBailOnEqualOrNotEqual(bailOutInstr, nullptr, nullptr, nullptr, isHelper);
7247
+ }
7184
7248
7185
7249
return instrPrev;
7186
7250
}
@@ -25565,6 +25629,8 @@ Lowerer::GenerateLdHomeObj(IR::Instr* instr)
25565
25629
25566
25630
IR::LabelInstr *labelDone = IR::LabelInstr::New(Js::OpCode::Label, func, false);
25567
25631
IR::LabelInstr *testLabel = IR::LabelInstr::New(Js::OpCode::Label, func, false);
25632
+ IR::LabelInstr *scriptFuncLabel = IR::LabelInstr::New(Js::OpCode::Label, func, false);
25633
+ LABELNAMESET(scriptFuncLabel, "ScriptFunctionWithHomeObj");
25568
25634
IR::Opnd *opndUndefAddress = this->LoadLibraryValueOpnd(instr, LibraryValue::ValueUndefined);
25569
25635
25570
25636
IR::RegOpnd *instanceRegOpnd = IR::RegOpnd::New(TyMachPtr, func);
@@ -25586,65 +25652,53 @@ Lowerer::GenerateLdHomeObj(IR::Instr* instr)
25586
25652
if (func->GetJITFunctionBody()->HasHomeObj())
25587
25653
{
25588
25654
// Is this a generator function with home obj?
25655
+ if (func->GetJITFunctionBody()->IsCoroutine())
25589
25656
{
25590
- IR::LabelInstr* nextCaseLabel = IR::LabelInstr::New(Js::OpCode::Label, func, false);
25591
- LABELNAMESET(nextCaseLabel, "GeneratorFunctionWithHomeObjAndComputedName");
25592
-
25593
- IR::Opnd* vtableAddressInlineFuncHomObjOpnd = this->LoadVTableValueOpnd(instr, VTableValue::VtableVirtualJavascriptGeneratorFunctionWithHomeObj);
25594
- IR::BranchInstr* inlineFuncHomObjOpndBr = InsertCompareBranch(IR::IndirOpnd::New(instanceRegOpnd, 0, TyMachPtr, func), vtableAddressInlineFuncHomObjOpnd, Js::OpCode::BrNeq_A, nextCaseLabel, instr);
25595
- InsertObjectPoison(instanceRegOpnd, inlineFuncHomObjOpndBr, instr, false);
25596
- IR::IndirOpnd* indirInlineFuncHomeObjOpnd = IR::IndirOpnd::New(instanceRegOpnd, Js::FunctionWithHomeObj<Js::GeneratorVirtualScriptFunction>::GetOffsetOfHomeObj(), TyMachPtr, func);
25597
- Lowerer::InsertMove(instanceRegOpnd, indirInlineFuncHomeObjOpnd, instr);
25598
- InsertBranch(Js::OpCode::Br, testLabel, instr);
25657
+ uint32 homeObjectOffset = Js::FunctionWithHomeObj<Js::GeneratorVirtualScriptFunction>::GetOffsetOfHomeObj();
25599
25658
25600
- instr->InsertBefore(nextCaseLabel);
25601
- }
25602
-
25603
- // Is this a generator function with home obj and computed name?
25604
- {
25605
- IR::LabelInstr* nextCaseLabel = IR::LabelInstr::New(Js::OpCode::Label, func, false);
25606
- LABELNAMESET(nextCaseLabel, "FunctionWithInlineCacheAndHomeObj");
25607
-
25608
- IR::Opnd* vtableAddressInlineFuncHomObjOpnd = this->LoadVTableValueOpnd(instr, VTableValue::VtableVirtualJavascriptGeneratorFunctionWithHomeObjAndComputedName);
25609
- IR::BranchInstr* inlineFuncHomObjOpndBr = InsertCompareBranch(IR::IndirOpnd::New(instanceRegOpnd, 0, TyMachPtr, func), vtableAddressInlineFuncHomObjOpnd, Js::OpCode::BrNeq_A, nextCaseLabel, instr);
25610
- InsertObjectPoison(instanceRegOpnd, inlineFuncHomObjOpndBr, instr, false);
25611
- IR::IndirOpnd* indirInlineFuncHomeObjOpnd = IR::IndirOpnd::New(instanceRegOpnd, Js::FunctionWithComputedName<Js::FunctionWithHomeObj<Js::GeneratorVirtualScriptFunction>>::GetOffsetOfHomeObj(), TyMachPtr, func);
25612
- Lowerer::InsertMove(instanceRegOpnd, indirInlineFuncHomeObjOpnd, instr);
25613
- InsertBranch(Js::OpCode::Br, testLabel, instr);
25614
-
25615
- instr->InsertBefore(nextCaseLabel);
25616
- }
25659
+ // Is this a generator function with home obj and computed name?
25660
+ if (func->GetJITFunctionBody()->HasComputedName())
25661
+ {
25662
+ homeObjectOffset = Js::FunctionWithComputedName<Js::FunctionWithHomeObj<Js::GeneratorVirtualScriptFunction>>::GetOffsetOfHomeObj();
25663
+ }
25617
25664
25618
- // Is this an function with inline cache and home obj?
25619
- {
25620
- IR::LabelInstr* labelInlineFunc = IR::LabelInstr::New(Js::OpCode::Label, func, false );
25621
- LABELNAMESET(labelInlineFunc, "FunctionWithInlineCacheHomeObjAndComputedName");
25665
+ {
25666
+ IR::IndirOpnd* indirOpnd = IR::IndirOpnd::New(instanceRegOpnd, homeObjectOffset, TyMachPtr, func);
25667
+ Lowerer::InsertMove(instanceRegOpnd, indirOpnd, instr );
25668
+ }
25622
25669
25623
- IR::Opnd* vtableAddressInlineFuncHomObjOpnd = this->LoadVTableValueOpnd(instr, VTableValue::VtableScriptFunctionWithInlineCacheAndHomeObj);
25624
- IR::BranchInstr* inlineFuncHomObjOpndBr = InsertCompareBranch(IR::IndirOpnd::New(instanceRegOpnd, 0, TyMachPtr, func), vtableAddressInlineFuncHomObjOpnd, Js::OpCode::BrNeq_A, labelInlineFunc, instr);
25625
- InsertObjectPoison(instanceRegOpnd, inlineFuncHomObjOpndBr, instr, false);
25626
- IR::IndirOpnd* indirInlineFuncHomeObjOpnd = IR::IndirOpnd::New(instanceRegOpnd, Js::FunctionWithHomeObj<Js::ScriptFunctionWithInlineCache>::GetOffsetOfHomeObj(), TyMachPtr, func);
25627
- Lowerer::InsertMove(instanceRegOpnd, indirInlineFuncHomeObjOpnd, instr);
25628
25670
InsertBranch(Js::OpCode::Br, testLabel, instr);
25629
-
25630
- instr->InsertBefore(labelInlineFunc);
25631
25671
}
25632
-
25633
- // Is this a function with inline cache, home obj and computed name?
25672
+ else
25634
25673
{
25635
- IR::LabelInstr* scriptFuncLabel = IR::LabelInstr ::New(Js::OpCode::Label, func, false );
25636
- LABELNAMESET(scriptFuncLabel, "ScriptFunctionWithHomeObj" );
25674
+ IR::RegOpnd* funcObjHasInlineCachesOpnd = IR::RegOpnd ::New(TyUint8, instr->m_func );
25675
+ this->InsertMove(funcObjHasInlineCachesOpnd, IR::IndirOpnd::New(instanceRegOpnd, Js::ScriptFunction::GetOffsetOfHasInlineCaches(), TyUint8, instr->m_func), instr );
25637
25676
25638
- IR::Opnd* vtableAddressInlineFuncHomObjCompNameOpnd = this->LoadVTableValueOpnd(instr, VTableValue::VtableScriptFunctionWithInlineCacheHomeObjAndComputedName);
25639
- IR::BranchInstr* inlineFuncHomObjCompNameBr = InsertCompareBranch(IR::IndirOpnd::New(instanceRegOpnd, 0, TyMachPtr, func), vtableAddressInlineFuncHomObjCompNameOpnd, Js::OpCode::BrNeq_A, scriptFuncLabel, instr);
25677
+ IR::BranchInstr* inlineFuncHomObjCompNameBr = InsertTestBranch(funcObjHasInlineCachesOpnd, funcObjHasInlineCachesOpnd, Js::OpCode::BrEq_A, scriptFuncLabel, instr);
25640
25678
InsertObjectPoison(instanceRegOpnd, inlineFuncHomObjCompNameBr, instr, false);
25641
- IR::IndirOpnd* indirInlineFuncHomeObjCompNameOpnd = IR::IndirOpnd::New(instanceRegOpnd, Js::FunctionWithComputedName<Js::FunctionWithHomeObj<Js::ScriptFunctionWithInlineCache>>::GetOffsetOfHomeObj(), TyMachPtr, func);
25642
- Lowerer::InsertMove(instanceRegOpnd, indirInlineFuncHomeObjCompNameOpnd, instr);
25643
- InsertBranch(Js::OpCode::Br, testLabel, instr);
25644
25679
25645
- instr->InsertBefore(scriptFuncLabel);
25680
+ if (func->GetJITFunctionBody()->HasComputedName())
25681
+ {
25682
+ // Is this a function with inline cache, home obj and computed name?
25683
+ {
25684
+ IR::IndirOpnd* indirInlineFuncHomeObjCompNameOpnd = IR::IndirOpnd::New(instanceRegOpnd, Js::FunctionWithComputedName<Js::FunctionWithHomeObj<Js::ScriptFunctionWithInlineCache>>::GetOffsetOfHomeObj(), TyMachPtr, func);
25685
+ Lowerer::InsertMove(instanceRegOpnd, indirInlineFuncHomeObjCompNameOpnd, instr);
25686
+ InsertBranch(Js::OpCode::Br, testLabel, instr);
25687
+ }
25688
+ }
25689
+ else
25690
+ {
25691
+ // Is this a function with inline cache and home obj?
25692
+ {
25693
+ IR::IndirOpnd* indirInlineFuncHomeObjOpnd = IR::IndirOpnd::New(instanceRegOpnd, Js::FunctionWithHomeObj<Js::ScriptFunctionWithInlineCache>::GetOffsetOfHomeObj(), TyMachPtr, func);
25694
+ Lowerer::InsertMove(instanceRegOpnd, indirInlineFuncHomeObjOpnd, instr);
25695
+ InsertBranch(Js::OpCode::Br, testLabel, instr);
25696
+ }
25697
+ }
25646
25698
}
25647
25699
25700
+ instr->InsertBefore(scriptFuncLabel);
25701
+
25648
25702
// All other cases
25649
25703
{
25650
25704
IR::IndirOpnd* indirOpnd = IR::IndirOpnd::New(instanceRegOpnd, Js::ScriptFunctionWithHomeObj::GetOffsetOfHomeObj(), TyMachPtr, func);
0 commit comments