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

Method parse

crates/environ/src/stack_map.rs:11–27  ·  view source on GitHub ↗
(section: &'a [u8])

Source from the content-addressed store, hash-verified

9
10impl<'a> StackMapSection<'a> {
11 fn parse(section: &'a [u8]) -> Option<StackMapSection<'a>> {
12 let mut section = Bytes(section);
13 // NB: this matches the encoding written by `append_to` in the
14 // `compile::stack_map` module.
15 let pc_count = section.read::<U32<LittleEndian>>().ok()?;
16 let pc_count = usize::try_from(pc_count.get(LittleEndian)).ok()?;
17 let (pcs, section) =
18 object::slice_from_bytes::<U32<LittleEndian>>(section.0, pc_count).ok()?;
19 let (pointers_to_stack_map, section) =
20 object::slice_from_bytes::<U32<LittleEndian>>(section, pc_count).ok()?;
21 let stack_map_data = object::slice_from_all_bytes::<U32<LittleEndian>>(section).ok()?;
22 Some(StackMapSection {
23 pcs,
24 pointers_to_stack_map,
25 stack_map_data,
26 })
27 }
28
29 fn lookup(&self, pc: u32) -> Option<StackMap<'a>> {
30 let pc_index = self

Callers

nothing calls this directly

Calls 2

okMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected