1 use cranelift_bitset::CompoundBitSet; 2 use serde_derive::{Deserialize, Serialize}; 3 4 /// A map for determining where live GC references live in a stack frame. 5 /// 6 /// Note that this is currently primarily documented as cranelift's 7 /// `binemit::StackMap`, so for detailed documentation about this please read 8 /// the docs over there. 9 #[derive(Debug, Serialize, Deserialize)] 10 pub struct StackMap { 11 bits: CompoundBitSet, 12 mapped_words: u32, 13 } 14 15 impl StackMap { 16 /// Creates a new `StackMap`, typically from a preexisting 17 /// `binemit::StackMap`. 18 pub fn new(mapped_words: u32, bits: CompoundBitSet) -> StackMap { 19 StackMap { bits, mapped_words } 20 } 21 22 /// Returns a specified bit. 23 pub fn get_bit(&self, bit_index: usize) -> bool { 24 self.bits.contains(bit_index) 25 } 26 27 /// Returns the number of words represented by this stack map. 28 pub fn mapped_words(&self) -> u32 { 29 self.mapped_words 30 } 31 } 32