@@ -2697,8 +2697,8 @@ Instr::GetNextBranchOrLabel() const
2697
2697
IR::Instr *
2698
2698
Instr::GetNextByteCodeInstr () const
2699
2699
{
2700
- IR::Instr * nextInstr = GetNextRealInstrOrLabel ();
2701
2700
uint32 currentOffset = GetByteCodeOffset ();
2701
+ IR::Instr * nextInstr = GetNextRealInstrOrLabel ();
2702
2702
const auto getNext = [](IR::Instr* nextInstr) -> IR::Instr*
2703
2703
{
2704
2704
if (nextInstr->IsBranchInstr ())
@@ -2712,16 +2712,27 @@ Instr::GetNextByteCodeInstr() const
2712
2712
}
2713
2713
return nextInstr->GetNextRealInstrOrLabel ();
2714
2714
};
2715
- while (nextInstr->GetByteCodeOffset () == Js::Constants::NoByteCodeOffset ||
2716
- nextInstr->GetByteCodeOffset () == currentOffset)
2715
+ if (currentOffset == Js::Constants::NoByteCodeOffset)
2717
2716
{
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" );
2719
2722
}
2720
- // This can happen due to break block removal
2721
- while (nextInstr->GetByteCodeOffset () == Js::Constants::NoByteCodeOffset ||
2722
- nextInstr->GetByteCodeOffset () < currentOffset)
2723
+ else
2723
2724
{
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
+ }
2725
2736
}
2726
2737
return nextInstr;
2727
2738
}
0 commit comments