Inform the buffer of a conditional branch at the given offset, targeting the given label. May be used to optimize branches. The last added label-use must correspond to this branch. Additional requirement: no labels may be bound between `start` and `end` (exclusive on both ends).
(
&mut self,
start: CodeOffset,
end: CodeOffset,
target: MachLabel,
inverted: &[u8],
)
| 854 | /// Additional requirement: no labels may be bound between `start` and `end` |
| 855 | /// (exclusive on both ends). |
| 856 | pub fn add_cond_branch( |
| 857 | &mut self, |
| 858 | start: CodeOffset, |
| 859 | end: CodeOffset, |
| 860 | target: MachLabel, |
| 861 | inverted: &[u8], |
| 862 | ) { |
| 863 | debug_assert!( |
| 864 | !self.open_patchable, |
| 865 | "Branch instruction inserted within a patchable region" |
| 866 | ); |
| 867 | assert!(self.cur_offset() == start); |
| 868 | debug_assert!(end > start); |
| 869 | assert!(!self.pending_fixup_records.is_empty()); |
| 870 | debug_assert!( |
| 871 | inverted.len() == (end - start) as usize, |
| 872 | "branch length = {}, but inverted length = {}", |
| 873 | end - start, |
| 874 | inverted.len() |
| 875 | ); |
| 876 | let fixup = self.pending_fixup_records.len() - 1; |
| 877 | let inverted = Some(SmallVec::from(inverted)); |
| 878 | self.lazily_clear_labels_at_tail(); |
| 879 | self.latest_branches.push(MachBranch { |
| 880 | start, |
| 881 | end, |
| 882 | target, |
| 883 | fixup, |
| 884 | inverted, |
| 885 | labels_at_this_branch: self.labels_at_tail.clone(), |
| 886 | }); |
| 887 | |
| 888 | // Post-invariant: we asserted branch start is current tail; labels at |
| 889 | // branch list is cloned from list of labels at current tail. |
| 890 | } |
| 891 | |
| 892 | fn truncate_last_branch(&mut self) { |
| 893 | debug_assert!( |
no test coverage detected