Skip to content

Commit ab517fb

Browse files
committed
Handle cases where we try to bailout before the first bytecode instr.
OS#17686612
1 parent 00e7f7e commit ab517fb

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

lib/Backend/IR.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,8 +2697,8 @@ Instr::GetNextBranchOrLabel() const
26972697
IR::Instr *
26982698
Instr::GetNextByteCodeInstr() const
26992699
{
2700-
IR::Instr * nextInstr = GetNextRealInstrOrLabel();
27012700
uint32 currentOffset = GetByteCodeOffset();
2701+
IR::Instr * nextInstr = GetNextRealInstrOrLabel();
27022702
const auto getNext = [](IR::Instr* nextInstr) -> IR::Instr*
27032703
{
27042704
if (nextInstr->IsBranchInstr())
@@ -2712,16 +2712,27 @@ Instr::GetNextByteCodeInstr() const
27122712
}
27132713
return nextInstr->GetNextRealInstrOrLabel();
27142714
};
2715-
while (nextInstr->GetByteCodeOffset() == Js::Constants::NoByteCodeOffset ||
2716-
nextInstr->GetByteCodeOffset() == currentOffset)
2715+
if (currentOffset == Js::Constants::NoByteCodeOffset)
27172716
{
2718-
nextInstr = getNext(nextInstr);
2717+
while (nextInstr->GetByteCodeOffset() == Js::Constants::NoByteCodeOffset)
2718+
{
2719+
nextInstr = getNext(nextInstr);
2720+
}
2721+
AssertMsg(nextInstr->GetByteCodeOffset() == 0, "Only instrs before the first one are allowed to not have a bytecode offset");
27192722
}
2720-
// This can happen due to break block removal
2721-
while (nextInstr->GetByteCodeOffset() == Js::Constants::NoByteCodeOffset ||
2722-
nextInstr->GetByteCodeOffset() < currentOffset)
2723+
else
27232724
{
2724-
nextInstr = getNext(nextInstr);
2725+
while (nextInstr->GetByteCodeOffset() == Js::Constants::NoByteCodeOffset ||
2726+
nextInstr->GetByteCodeOffset() == currentOffset)
2727+
{
2728+
nextInstr = getNext(nextInstr);
2729+
}
2730+
// This can happen due to break block removal
2731+
while (nextInstr->GetByteCodeOffset() == Js::Constants::NoByteCodeOffset ||
2732+
nextInstr->GetByteCodeOffset() < currentOffset)
2733+
{
2734+
nextInstr = getNext(nextInstr);
2735+
}
27252736
}
27262737
return nextInstr;
27272738
}

0 commit comments

Comments
 (0)