Skip to content

Commit 781d5ed

Browse files
committed
Add StSuperFldStrict and profiled version because strictness is not preserved in some backend calls to StSuperFld
1 parent e675e67 commit 781d5ed

17 files changed

+69
-8
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3442,6 +3442,7 @@ BackwardPass::ProcessBlock(BasicBlock * block)
34423442
case Js::OpCode::StSlotBoxTemp:
34433443
case Js::OpCode::StSlotChkUndecl:
34443444
case Js::OpCode::StSuperFld:
3445+
case Js::OpCode::StSuperFldStrict:
34453446
case Js::OpCode::ProfiledStElemI_A:
34463447
case Js::OpCode::ProfiledStElemI_A_Strict:
34473448
case Js::OpCode::ProfiledStFld:
@@ -3450,6 +3451,7 @@ BackwardPass::ProcessBlock(BasicBlock * block)
34503451
case Js::OpCode::ProfiledStRootFld:
34513452
case Js::OpCode::ProfiledStRootFldStrict:
34523453
case Js::OpCode::ProfiledStSuperFld:
3454+
case Js::OpCode::ProfiledStSuperFldStrict:
34533455
// Unfortunately, being fed into a store means that we could have aliasing, and the
34543456
// consequence is that it may be re-read and then dereferenced. Note that we can do
34553457
// this case if we poison any array symbol that we store to on the way out, but the

lib/Backend/GlobOpt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13636,6 +13636,7 @@ GlobOpt::CheckJsArrayKills(IR::Instr *const instr)
1363613636
case Js::OpCode::StFld:
1363713637
case Js::OpCode::StFldStrict:
1363813638
case Js::OpCode::StSuperFld:
13639+
case Js::OpCode::StSuperFldStrict:
1363913640
{
1364013641
Assert(instr->GetDst());
1364113642

lib/Backend/GlobOptExpr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ GlobOpt::ProcessArrayValueKills(IR::Instr *instr)
828828
case Js::OpCode::StFldStrict:
829829
case Js::OpCode::StRootFldStrict:
830830
case Js::OpCode::StSuperFld:
831+
case Js::OpCode::StSuperFldStrict:
831832
case Js::OpCode::StSlot:
832833
case Js::OpCode::StSlotChkUndecl:
833834
case Js::OpCode::DeleteFld:

lib/Backend/GlobOptFields.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ GlobOpt::ProcessFieldKills(IR::Instr *instr, BVSparse<JitArenaAllocator> *bv, bo
429429
case Js::OpCode::StSlot:
430430
case Js::OpCode::StSlotChkUndecl:
431431
case Js::OpCode::StSuperFld:
432+
case Js::OpCode::StSuperFldStrict:
432433
Assert(dstOpnd != nullptr);
433434
sym = dstOpnd->AsSymOpnd()->m_sym;
434435
if (inGlobOpt)

lib/Backend/IR.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,8 @@ bool IR::Instr::IsStFldVariant() const
10361036
this->m_opcode == Js::OpCode::StLocalFld ||
10371037
this->m_opcode == Js::OpCode::StRootFld ||
10381038
this->m_opcode == Js::OpCode::StRootFldStrict ||
1039-
this->m_opcode == Js::OpCode::StSuperFld;
1039+
this->m_opcode == Js::OpCode::StSuperFld ||
1040+
this->m_opcode == Js::OpCode::StSuperFldStrict;
10401041
}
10411042

10421043
bool IR::Instr::IsStElemVariant() const

lib/Backend/IRBuilder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4763,10 +4763,12 @@ IRBuilder::BuildElementC2(Js::OpCode newOpcode, uint32 offset, Js::RegSlot insta
47634763
break;
47644764

47654765
case Js::OpCode::ProfiledStSuperFld:
4766+
case Js::OpCode::ProfiledStSuperFldStrict:
47664767
Js::OpCodeUtil::ConvertNonCallOpToNonProfiled(newOpcode);
47674768
// fall-through
47684769

47694770
case Js::OpCode::StSuperFld:
4771+
case Js::OpCode::StSuperFldStrict:
47704772
{
47714773
propertyId = m_func->GetJITFunctionBody()->GetPropertyIdFromCacheId(propertyIdIndex);
47724774
fieldSymOpnd = this->BuildFieldOpnd(newOpcode, instanceSlot, propertyId, (Js::PropertyIdIndexType) - 1, PropertyKindData, propertyIdIndex);

lib/Backend/JnHelperMethodList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ HELPERCALLCHK(ProfiledLdRootFld, Js::ProfilingHelpers::ProfiledLdRootFld_Jit, 0)
413413
HELPERCALLCHK(ProfiledLdRootMethodFld, Js::ProfilingHelpers::ProfiledLdRootMethodFld_Jit, 0)
414414
HELPERCALLCHK(ProfiledStFld, Js::ProfilingHelpers::ProfiledStFld_Jit, 0)
415415
HELPERCALLCHK(ProfiledStSuperFld, Js::ProfilingHelpers::ProfiledStSuperFld_Jit, 0)
416+
HELPERCALLCHK(ProfiledStSuperFld_Strict, Js::ProfilingHelpers::ProfiledStSuperFld_Strict_Jit, 0)
416417
HELPERCALLCHK(ProfiledStFld_Strict, Js::ProfilingHelpers::ProfiledStFld_Strict_Jit, 0)
417418
HELPERCALLCHK(ProfiledStRootFld, Js::ProfilingHelpers::ProfiledStRootFld_Jit, 0)
418419
HELPERCALLCHK(ProfiledStRootFld_Strict, Js::ProfilingHelpers::ProfiledStRootFld_Strict_Jit, 0)

lib/Backend/Lower.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
159159
{
160160
bool noMathFastPath;
161161
bool noFieldFastPath;
162-
bool isStrictMode = this->m_func->GetJITFunctionBody()->IsStrictMode();
163162
noFieldFastPath = !defaultDoFastPath;
164163
noMathFastPath = !defaultDoFastPath;
165164

@@ -538,7 +537,12 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
538537

539538
case Js::OpCode::StSuperFld:
540539
instrPrev = GenerateCompleteStFld(instr, !noFieldFastPath, IR::HelperOp_PatchPutValueWithThisPtrNoLocalFastPath, IR::HelperOp_PatchPutValueWithThisPtrNoLocalFastPathPolymorphic,
541-
IR::HelperOp_PatchPutValueWithThisPtr, IR::HelperOp_PatchPutValueWithThisPtrPolymorphic, true, isStrictMode ? Js::PropertyOperation_StrictMode : Js::PropertyOperation_None);
540+
IR::HelperOp_PatchPutValueWithThisPtr, IR::HelperOp_PatchPutValueWithThisPtrPolymorphic, true, Js::PropertyOperation_None);
541+
break;
542+
543+
case Js::OpCode::StSuperFldStrict:
544+
instrPrev = GenerateCompleteStFld(instr, !noFieldFastPath, IR::HelperOp_PatchPutValueWithThisPtrNoLocalFastPath, IR::HelperOp_PatchPutValueWithThisPtrNoLocalFastPathPolymorphic,
545+
IR::HelperOp_PatchPutValueWithThisPtr, IR::HelperOp_PatchPutValueWithThisPtrPolymorphic, true, Js::PropertyOperation_StrictMode);
542546
break;
543547

544548
case Js::OpCode::StRootFld:
@@ -7132,7 +7136,7 @@ Lowerer::LowerProfiledStFld(IR::JitProfilingInstr *stFldInstr, Js::PropertyOpera
71327136

71337137
m_lowererMD.LoadHelperArgument(stFldInstr, IR::Opnd::CreateFramePointerOpnd(m_func));
71347138

7135-
if (stFldInstr->m_opcode == Js::OpCode::StSuperFld)
7139+
if (stFldInstr->m_opcode == Js::OpCode::StSuperFld || stFldInstr->m_opcode == Js::OpCode::StSuperFldStrict)
71367140
{
71377141
m_lowererMD.LoadHelperArgument(stFldInstr, stFldInstr->UnlinkSrc2());
71387142
}
@@ -7159,6 +7163,10 @@ Lowerer::LowerProfiledStFld(IR::JitProfilingInstr *stFldInstr, Js::PropertyOpera
71597163
helper = IR::HelperProfiledStSuperFld;
71607164
break;
71617165

7166+
case Js::OpCode::StSuperFldStrict:
7167+
helper = IR::HelperProfiledStSuperFld_Strict;
7168+
break;
7169+
71627170
default:
71637171
helper =
71647172
flags & Js::PropertyOperation_Root
@@ -7224,7 +7232,7 @@ Lowerer::LowerStFld(
72247232
}
72257233

72267234
IR::Opnd *src = stFldInstr->UnlinkSrc1();
7227-
if (stFldInstr->m_opcode == Js::OpCode::StSuperFld)
7235+
if (stFldInstr->m_opcode == Js::OpCode::StSuperFld || stFldInstr->m_opcode == Js::OpCode::StSuperFldStrict)
72287236
{
72297237
m_lowererMD.LoadHelperArgument(stFldInstr, stFldInstr->UnlinkSrc2());
72307238
}

lib/Runtime/ByteCode/ByteCodeDumper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,12 +767,14 @@ namespace Js
767767
break;
768768
}
769769
case OpCode::StSuperFld:
770+
case OpCode::StSuperFldStrict:
770771
{
771772
Output::Print(_u(" R%d.%s(this=R%d) = R%d #%d"), data->Instance, pPropertyName->GetBuffer(),
772773
data->Value2, data->Value, data->PropertyIdIndex);
773774
break;
774775
}
775776
case OpCode::ProfiledStSuperFld:
777+
case OpCode::ProfiledStSuperFldStrict:
776778
{
777779
Output::Print(_u(" R%d.%s(this=R%d) = R%d #%d"), data->Instance, pPropertyName->GetBuffer(),
778780
data->Value2, data->Value, data->PropertyIdIndex);

lib/Runtime/ByteCode/ByteCodeEmitter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7006,7 +7006,8 @@ void EmitAssignment(
70067006
Js::RegSlot tmpReg = byteCodeGenerator->EmitLdObjProto(Js::OpCode::LdHomeObjProto, lhs->AsParseNodeBin()->pnode1->location, funcInfo);
70077007
funcInfo->ReleaseLoc(lhs->AsParseNodeSuperReference()->pnodeThis);
70087008
uint cacheId = funcInfo->FindOrAddInlineCacheId(tmpReg, propertyId, false, true);
7009-
byteCodeGenerator->Writer()->PatchablePropertyWithThisPtr(Js::OpCode::StSuperFld, rhsLocation, tmpReg, lhs->AsParseNodeSuperReference()->pnodeThis->location, cacheId);
7009+
Js::OpCode stFldOpCode = funcInfo->GetIsStrictMode() ? Js::OpCode::StSuperFldStrict : Js::OpCode::StSuperFld;
7010+
byteCodeGenerator->Writer()->PatchablePropertyWithThisPtr(stFldOpCode, rhsLocation, tmpReg, lhs->AsParseNodeSuperReference()->pnodeThis->location, cacheId);
70107011
}
70117012
else
70127013
{

0 commit comments

Comments
 (0)