Skip to content

Commit

Permalink
nouns: function to assert a noun doesn't contain any forwarding pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
eamsden committed Oct 1, 2023
1 parent 994c657 commit 3022bf9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rust/ares/src/noun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,20 @@ impl Noun {
Noun { raw }
}

pub unsafe fn assert_no_forwarding_pointers(self) {
let mut dbg_stack = Vec::new();
dbg_stack.push(self);
while !dbg_stack.is_empty() {
let noun = dbg_stack.pop().unwrap();
if noun.raw & FORWARDING_MASK == FORWARDING_TAG {
panic!("Noun {:#x} has a forwarding pointer as a child", self.raw);
} else if let Ok(cell) = noun.as_cell() {
dbg_stack.push(cell.tail());
dbg_stack.push(cell.head());
}
}
}

/** Produce the total size of a noun, in words
*
* This counts the total size, see mass_frame() to count the size in the current frame.
Expand Down

0 comments on commit 3022bf9

Please sign in to comment.