Skip to content

Commit ef75eac

Browse files
sethbrenithpleath
authored andcommitted
1 parent e73f2ff commit ef75eac

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lib/Backend/IRBuilder.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3749,7 +3749,7 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
37493749
IR::Opnd*
37503750
IRBuilder::GetEnvironmentOperand(uint32 offset)
37513751
{
3752-
SymID symID;
3752+
StackSym* sym = nullptr;
37533753
// The byte code doesn't refer directly to a closure environment. Get the implicit one
37543754
// that's pointed to by the function body.
37553755
if (m_func->DoStackFrameDisplay() && m_func->GetLocalFrameDisplaySym())
@@ -3760,19 +3760,35 @@ IRBuilder::GetEnvironmentOperand(uint32 offset)
37603760
this->AddInstr(
37613761
IR::Instr::New(Js::OpCode::LdSlotArr, regOpnd, fieldOpnd, m_func),
37623762
offset);
3763-
symID = regOpnd->m_sym->m_id;
3763+
sym = regOpnd->m_sym;
37643764
}
37653765
else
37663766
{
3767+
SymID symID;
37673768
symID = this->GetEnvRegForInnerFrameDisplay();
37683769
Assert(symID != Js::Constants::NoRegister);
37693770
if (IsLoopBody() && !RegIsConstant(symID))
37703771
{
37713772
this->EnsureLoopBodyLoadSlot(symID);
37723773
}
3774+
3775+
if (m_func->DoStackNestedFunc() && symID == GetEnvReg())
3776+
{
3777+
// Environment is not guaranteed constant during this function because it could become boxed during execution,
3778+
// so load the environment every time you need it.
3779+
IR::RegOpnd *regOpnd = IR::RegOpnd::New(TyVar, m_func);
3780+
this->AddInstr(
3781+
IR::Instr::New(Js::OpCode::LdEnv, regOpnd, m_func),
3782+
offset);
3783+
sym = regOpnd->m_sym;
3784+
}
3785+
else
3786+
{
3787+
sym = StackSym::FindOrCreate(symID, (Js::RegSlot)symID, m_func);
3788+
}
37733789
}
37743790

3775-
return IR::RegOpnd::New(StackSym::FindOrCreate(symID, (Js::RegSlot)symID, m_func), TyVar, m_func);
3791+
return IR::RegOpnd::New(sym, TyVar, m_func);
37763792
}
37773793

37783794
template <typename SizePolicy>

lib/Backend/Inline.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5146,6 +5146,10 @@ Inline::MapFormals(Func *inlinee,
51465146
else
51475147
{
51485148
instr->SetSrc1(funcObjOpnd);
5149+
5150+
// This usage doesn't correspond with any byte code register, since interpreter stack frames
5151+
// get their function reference via this->function rather than from a register.
5152+
instr->GetSrc1()->SetIsJITOptimizedReg(true);
51495153
}
51505154
}
51515155
else

0 commit comments

Comments
 (0)