fix functor! size calculations around indexing_code_ptr

This commit is contained in:
Mark Thom
2025-04-23 22:49:03 -07:00
committed by Mark Thom
parent 258244caf2
commit 706ffe7ad9
4 changed files with 20 additions and 21 deletions

View File

@@ -242,7 +242,6 @@ impl MachineState {
c
}
(HeapCellValueTag::Atom, (_name, arity)) => {
// if arity == 0 { c } else { s }
debug_assert!(arity == 0);
c
}

View File

@@ -1092,7 +1092,7 @@ pub fn heap_bound_store(heap: &impl SizedHeap, value: HeapCellValue) -> HeapCell
}
#[allow(dead_code)]
pub fn print_heap_terms(heap: &Heap, h: usize) {
pub fn print_heap_terms(heap: &impl SizedHeap, h: usize) {
for idx in 0..heap.cell_len() {
let term = heap[idx];
println!("{} : {:?}", h + idx, term);

View File

@@ -7307,20 +7307,19 @@ impl Machine {
walk_code(&self.code, index_ptr, |instr| {
let old_len = functors.len();
instr.enqueue_functors(&mut self.machine_st.arena, &mut functors);
let new_len = functors.len();
for index in old_len..new_len {
let functor_len = functors[index].len();
for functor in &functors[old_len..] {
let functor_len = functor.len();
match functor_len {
0 => {}
1 => {
functor_list.push(heap_loc_as_cell!(h));
h += cell_index!(Heap::compute_functor_byte_size(&functors[index]));
h += cell_index!(Heap::compute_functor_byte_size(functor));
}
_ => {
functor_list.push(str_loc_as_cell!(h));
h += cell_index!(Heap::compute_functor_byte_size(&functors[index]));
h += cell_index!(Heap::compute_functor_byte_size(functor));
}
};
}