MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / bind_label

Method bind_label

cranelift/codegen/src/machinst/buffer.rs:726–748  ·  view source on GitHub ↗

Bind a label to the current offset. A label can only be bound once.

(&mut self, label: MachLabel, ctrl_plane: &mut ControlPlane)

Source from the content-addressed store, hash-verified

724
725 /// Bind a label to the current offset. A label can only be bound once.
726 pub fn bind_label(&mut self, label: MachLabel, ctrl_plane: &mut ControlPlane) {
727 trace!(
728 "MachBuffer: bind label {:?} at offset {}",
729 label,
730 self.cur_offset()
731 );
732 debug_assert_eq!(self.label_offsets[label.0 as usize], UNKNOWN_LABEL_OFFSET);
733 debug_assert_eq!(self.label_aliases[label.0 as usize], UNKNOWN_LABEL);
734 let offset = self.cur_offset();
735 self.label_offsets[label.0 as usize] = offset;
736 self.lazily_clear_labels_at_tail();
737 self.labels_at_tail.push(label);
738
739 // Invariants hold: bound offset of label is <= cur_offset (in fact it
740 // is equal). If the `labels_at_tail` list was complete and precise
741 // before, it is still, because we have bound this label to the current
742 // offset and added it to the list (which contains all labels at the
743 // current offset).
744
745 self.optimize_branches(ctrl_plane);
746
747 // Post-invariant: by `optimize_branches()` (see argument there).
748 }
749
750 /// Lazily clear `labels_at_tail` if the tail offset has moved beyond the
751 /// offset that it applies to.

Callers 15

appendMethod · 0.80
test_elide_jump_to_nextFunction · 0.80
test_flip_condFunction · 0.80
test_islandFunction · 0.80
test_island_backwardFunction · 0.80
test_multiple_redirectFunction · 0.80
test_handle_branch_cycleFunction · 0.80
metadata_recordsFunction · 0.80
emit_with_island_checkFunction · 0.80

Calls 4

cur_offsetMethod · 0.80
optimize_branchesMethod · 0.80
pushMethod · 0.45

Tested by 13

test_elide_jump_to_nextFunction · 0.64
test_flip_condFunction · 0.64
test_islandFunction · 0.64
test_island_backwardFunction · 0.64
test_multiple_redirectFunction · 0.64
test_handle_branch_cycleFunction · 0.64
metadata_recordsFunction · 0.64
test_s390x_binemitFunction · 0.64