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

Method resolve_label_offset

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

Resolve a label to an offset, if known. May return `UNKNOWN_LABEL_OFFSET`.

(&self, mut label: MachLabel)

Source from the content-addressed store, hash-verified

764
765 /// Resolve a label to an offset, if known. May return `UNKNOWN_LABEL_OFFSET`.
766 pub(crate) fn resolve_label_offset(&self, mut label: MachLabel) -> CodeOffset {
767 let mut iters = 0;
768 while self.label_aliases[label.0 as usize] != UNKNOWN_LABEL {
769 label = self.label_aliases[label.0 as usize];
770 // To protect against an infinite loop (despite our assurances to
771 // ourselves that the invariants make this impossible), assert out
772 // after 1M iterations. The number of basic blocks is limited
773 // in most contexts anyway so this should be impossible to hit with
774 // a legitimate input.
775 iters += 1;
776 assert!(iters < 1_000_000, "Unexpected cycle in label aliases");
777 }
778 self.label_offsets[label.0 as usize]
779
780 // Post-invariant: no mutations.
781 }
782
783 /// Emit a reference to the given label with the given reference type (i.e.,
784 /// branch-instruction format) at the current offset. This is like a

Callers 5

optimize_branchesMethod · 0.80
should_apply_fixupMethod · 0.80
handle_fixupMethod · 0.80
finishMethod · 0.80
emitMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected