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

Method code_words

cranelift/codegen/src/isa/unwind/winarm64.rs:71–89  ·  view source on GitHub ↗

Calculate the number of words needed to encode the unwind codes.

(&self)

Source from the content-addressed store, hash-verified

69impl UnwindInfo {
70 /// Calculate the number of words needed to encode the unwind codes.
71 pub fn code_words(&self) -> u8 {
72 let mut bytes = 0u16;
73 for code in self.unwind_codes.iter() {
74 let next_bytes = match code {
75 UnwindCode::SaveFpLrPair { .. }
76 | UnwindCode::AllocS { .. }
77 | UnwindCode::PacSignLr
78 | UnwindCode::SetFp => 1,
79 UnwindCode::SaveReg { .. }
80 | UnwindCode::SaveFReg { .. }
81 | UnwindCode::AllocM { .. }
82 | UnwindCode::AddFp { .. } => 2,
83 UnwindCode::AllocL { .. } => 4,
84 };
85 bytes = bytes.checked_add(next_bytes).unwrap();
86 }
87
88 bytes.div_ceil(4).try_into().unwrap()
89 }
90
91 /// Emits the unwind information into the given mutable byte slice.
92 ///

Callers 1

pushMethod · 0.80

Calls 4

iterMethod · 0.45
unwrapMethod · 0.45
checked_addMethod · 0.45
try_intoMethod · 0.45

Tested by

no test coverage detected