@@ -2697,8 +2697,8 @@ Instr::GetNextBranchOrLabel() const
2697
2697
IR::Instr *
2698
2698
Instr::GetNextByteCodeInstr () const
2699
2699
{
2700
- uint32 currentOffset = GetByteCodeOffset ();
2701
2700
IR::Instr * nextInstr = GetNextRealInstrOrLabel ();
2701
+ uint32 currentOffset = GetByteCodeOffset ();
2702
2702
const auto getNext = [](IR::Instr* nextInstr) -> IR::Instr*
2703
2703
{
2704
2704
if (nextInstr->IsBranchInstr ())
@@ -2712,28 +2712,27 @@ Instr::GetNextByteCodeInstr() const
2712
2712
}
2713
2713
return nextInstr->GetNextRealInstrOrLabel ();
2714
2714
};
2715
- if (currentOffset == Js::Constants::NoByteCodeOffset)
2715
+ while (nextInstr->GetByteCodeOffset () == Js::Constants::NoByteCodeOffset ||
2716
+ nextInstr->GetByteCodeOffset () == currentOffset)
2716
2717
{
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" );
2718
+ nextInstr = getNext (nextInstr);
2722
2719
}
2723
- else
2720
+
2721
+ // Do not check if the instr trying to bailout is in the function prologue
2722
+ // nextInstr->GetByteCodeOffset() < currentOffset would always be true and we would crash
2723
+ if (currentOffset != Js::Constants::NoByteCodeOffset)
2724
2724
{
2725
- while (nextInstr->GetByteCodeOffset () == Js::Constants::NoByteCodeOffset ||
2726
- nextInstr->GetByteCodeOffset () == currentOffset)
2727
- {
2728
- nextInstr = getNext (nextInstr);
2729
- }
2730
2725
// This can happen due to break block removal
2731
2726
while (nextInstr->GetByteCodeOffset () == Js::Constants::NoByteCodeOffset ||
2732
2727
nextInstr->GetByteCodeOffset () < currentOffset)
2733
2728
{
2734
2729
nextInstr = getNext (nextInstr);
2735
2730
}
2736
2731
}
2732
+ else
2733
+ {
2734
+ AssertMsg (nextInstr->GetByteCodeOffset () == 0 , " Only instrs before the first one are allowed to not have a bytecode offset" );
2735
+ }
2737
2736
return nextInstr;
2738
2737
}
2739
2738
0 commit comments