Skip to content

Commit a9fcfde

Browse files
committed
[MERGE #5249 @Cellule] IRBuilder implicit operations before first statement boundary
Merge pull request #5249 from Cellule:ldenv_offset Do the implicit operations LdEnv, NewScopeSlots, LdFrameDisplay, as indicated by function body attributes before the first StatementBoundary OS#17472973
2 parents 9df80f1 + 1e94022 commit a9fcfde

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/Backend/IRBuilder.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ IRBuilder::Build()
431431

432432
AssertMsg(sizeof(SymID) >= sizeof(Js::RegSlot), "sizeof(SymID) != sizeof(Js::RegSlot)!!");
433433

434-
offset = m_functionStartOffset;
435-
436434
// Skip the last EndOfBlock opcode
437435
Assert(!OpCodeAttr::HasMultiSizeLayout(Js::OpCode::EndOfBlock));
438436
uint32 lastOffset = m_func->GetJITFunctionBody()->GetByteCodeLength() - Js::OpCodeUtil::EncodedSize(Js::OpCode::EndOfBlock, Js::SmallLayout);
@@ -489,19 +487,15 @@ IRBuilder::Build()
489487
if (m_func->IsJitInDebugMode())
490488
{
491489
// This is first bailout in the function, the locals at stack have not initialized to undefined, so do not restore them.
492-
this->InsertBailOutForDebugger(offset, IR::BailOutForceByFlag | IR::BailOutBreakPointInFunction | IR::BailOutStep, nullptr);
490+
this->InsertBailOutForDebugger(m_functionStartOffset, IR::BailOutForceByFlag | IR::BailOutBreakPointInFunction | IR::BailOutStep, nullptr);
493491
}
494492

495493
#ifdef BAILOUT_INJECTION
496494
// Start bailout inject after the constant and arg load. We don't bailout before that
497495
IR::Instr * lastInstr = m_lastInstr;
498496
#endif
499497

500-
if (m_statementReader.AtStatementBoundary(&m_jnReader))
501-
{
502-
statementIndex = this->AddStatementBoundary(statementIndex, offset);
503-
}
504-
498+
offset = Js::Constants::NoByteCodeOffset;
505499
if (!this->IsLoopBody())
506500
{
507501
IR::Instr *instr;
@@ -544,7 +538,7 @@ IRBuilder::Build()
544538
{
545539
IR::RegOpnd *funcExprScopeOpnd = BuildDstOpnd(funcExprScopeReg);
546540
instr = IR::Instr::New(Js::OpCode::NewPseudoScope, funcExprScopeOpnd, m_func);
547-
this->AddInstr(instr, (uint)-1);
541+
this->AddInstr(instr, offset);
548542
}
549543

550544
Js::RegSlot closureReg = m_func->GetJITFunctionBody()->GetLocalClosureReg();
@@ -593,15 +587,15 @@ IRBuilder::Build()
593587
this->AddInstr(
594588
IR::Instr::New(
595589
Js::OpCode::InitLocalClosure, this->BuildDstOpnd(m_func->GetLocalClosureSym()->m_id), m_func),
596-
(uint32)-1);
590+
offset);
597591

598592
this->AddInstr(
599593
IR::Instr::New(
600594
Js::OpCode::StSlot,
601595
this->BuildFieldOpnd(
602596
Js::OpCode::StSlot, m_func->GetLocalClosureSym()->m_id, 0, (Js::PropertyIdIndexType)-1, PropertyKindSlots),
603597
closureOpnd, m_func),
604-
(uint32)-1);
598+
offset);
605599
}
606600
}
607601

@@ -658,19 +652,25 @@ IRBuilder::Build()
658652
this->AddInstr(
659653
IR::Instr::New(
660654
Js::OpCode::InitLocalClosure, this->BuildDstOpnd(m_func->GetLocalFrameDisplaySym()->m_id), m_func),
661-
(uint32)-1);
655+
offset);
662656

663657
this->AddInstr(
664658
IR::Instr::New(
665659
Js::OpCode::StSlot,
666660
this->BuildFieldOpnd(Js::OpCode::StSlot, m_func->GetLocalFrameDisplaySym()->m_id, 0, (Js::PropertyIdIndexType)-1, PropertyKindSlots),
667661
dstOpnd, m_func),
668-
(uint32)-1);
662+
offset);
669663
}
670664
}
671665
}
672666
}
673667

668+
offset = m_functionStartOffset;
669+
if (m_statementReader.AtStatementBoundary(&m_jnReader))
670+
{
671+
statementIndex = this->AddStatementBoundary(statementIndex, offset);
672+
}
673+
674674
// For label instr we can add bailout only after all labels were finalized. Put to list/add in the end.
675675
JsUtil::BaseDictionary<IR::Instr*, int, JitArenaAllocator> ignoreExBranchInstrToOffsetMap(m_tempAlloc);
676676

0 commit comments

Comments
 (0)