[ares] [hamt] jam and cue work with mutable hamt

This commit is contained in:
Edward Amsden 2023-02-21 04:58:53 -06:00
parent e2743e24e7
commit abfd642868
3 changed files with 7 additions and 1 deletions

View File

@ -141,7 +141,7 @@ impl<T: Copy> MutHamt<T> {
assert!(leaf.len == 1);
let new_stem = stack.struct_alloc::<MutStem<T>>(1);
let leaf_mug = mug_u32(stack, (*leaf.buffer).0);
let leaf_chunk = (leaf_mug >> (depth * 5)) & 0x1f;
let leaf_chunk = (leaf_mug >> ((depth + 1) * 5)) & 0x1f;
(*new_stem).bitmap = chunk_to_bit(leaf_chunk);
(*new_stem).typemap = 0;
(*new_stem).buffer[leaf_chunk as usize] = MutEntry{ leaf: leaf};

View File

@ -114,6 +114,9 @@ pub fn mug_u32_one(noun: Noun) -> Option<u32> {
}
pub fn mug_u32(stack: &mut NockStack, noun: Noun) -> u32 {
if let Some(mug) = get_mug(noun) {
return mug;
}
assert_acyclic!(noun);
stack.push(1);
unsafe {

View File

@ -194,6 +194,9 @@ pub fn jam(stack: &mut NockStack, noun: Noun) -> Atom {
jam_backref(stack, &mut state, backref);
},
}
unsafe {
stack.reclaim_in_previous_frame::<Noun>();
};
continue 'jam;
};
backref_map.insert(stack, &mut noun, state.cursor as u64);