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

Method new

cranelift/codegen/src/ir/user_stack_maps.rs:144–172  ·  view source on GitHub ↗

Coalesce the given entries into a new `UserStackMap`.

(
        entries: &[UserStackMapEntry],
        stack_slot_offsets: &PrimaryMap<ir::StackSlot, u32>,
    )

Source from the content-addressed store, hash-verified

142impl UserStackMap {
143 /// Coalesce the given entries into a new `UserStackMap`.
144 pub(crate) fn new(
145 entries: &[UserStackMapEntry],
146 stack_slot_offsets: &PrimaryMap<ir::StackSlot, u32>,
147 ) -> Self {
148 let mut by_type = SmallVec::<[(ir::Type, CompoundBitSet); 1]>::default();
149
150 for entry in entries {
151 let offset = stack_slot_offsets[entry.slot] + entry.offset;
152 let offset = usize::try_from(offset).unwrap();
153
154 // Don't bother trying to avoid an `O(n)` search here: `n` is
155 // basically always one in practice; even if it isn't, there aren't
156 // that many different CLIF types.
157 let index = by_type
158 .iter()
159 .position(|(ty, _)| *ty == entry.ty)
160 .unwrap_or_else(|| {
161 by_type.push((entry.ty, CompoundBitSet::with_capacity(offset + 1)));
162 by_type.len() - 1
163 });
164
165 by_type[index].1.insert(offset);
166 }
167
168 UserStackMap {
169 by_type,
170 sp_to_sized_stack_slots: None,
171 }
172 }
173
174 /// Finalize this stack map by filling in the SP-to-stack-slots offset.
175 pub(crate) fn finalize(&mut self, sp_to_sized_stack_slots: u32) {

Callers

nothing calls this directly

Calls 6

unwrapMethod · 0.45
positionMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected