diff --git a/src/machine/machine_state_impl.rs b/src/machine/machine_state_impl.rs index fdaa6aeb..80f6c61f 100644 --- a/src/machine/machine_state_impl.rs +++ b/src/machine/machine_state_impl.rs @@ -557,6 +557,11 @@ impl MachineState { } pub fn compare_term_test(&self, h1: HeapCellValue, h2: HeapCellValue) -> Option { + // all derefs downstack from this function are heap bound so + // dereference stack vars pointing into the heap while possible + let h1 = self.store(h1); + let h2 = self.store(h2); + for term_pair in ParallelHeapIter::from(self, h1, h2) { match term_pair { TermPair::Vars(v1_offset, v2_offset) if v1_offset != v2_offset => {