Skip to content

Commit

Permalink
AArch64: don't assert inst within worst-case size when island emitted. (
Browse files Browse the repository at this point in the history
bytecodealliance#4627)

We assert after emitting each instruction that its size was less than
the "worst-case size", which is used to determine when we need to
proactively emit an island so pending branch fixups don't go out of
bounds. However, the `EmitIsland` pseudo-inst itself can cause an
arbitrarily large island to be emitted; this should not have to fit
within the worst-case size (because island size is explicitly accounted
for by the threshold computation). This PR fixes the assert accordingly.

Fixes bytecodealliance#4626.
  • Loading branch information
cfallin authored Aug 6, 2022
1 parent 95e72db commit c5e3c0c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cranelift/codegen/src/isa/aarch64/inst/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3140,7 +3140,13 @@ impl MachInstEmit for Inst {
}

let end_off = sink.cur_offset();
debug_assert!((end_off - start_off) <= Inst::worst_case_size());
debug_assert!(
(end_off - start_off) <= Inst::worst_case_size()
|| matches!(self, Inst::EmitIsland { .. }),
"Worst case size exceed for {:?}: {}",
self,
end_off - start_off
);

state.clear_post_insn();
}
Expand Down

0 comments on commit c5e3c0c

Please sign in to comment.