use occurs check when enabled in UnifyValue (#885)

This commit is contained in:
Mark Thom
2021-03-22 22:05:03 -06:00
parent 9f861dfe89
commit 7520fe7000
4 changed files with 23 additions and 76 deletions

View File

@@ -1327,8 +1327,21 @@ impl MachineState {
self.increment_s_ptr(1);
}
MachineMode::Write => {
let heap_val = self.store(self[reg]);
self.heap.push(HeapCellValue::Addr(heap_val));
let h = self.heap.h();
self.heap.push(HeapCellValue::Addr(Addr::HeapCell(h)));
let addr = self.store(self[reg]);
(self.bind_fn)(self, Ref::HeapCell(h), addr);
// the former code of this match arm was:
// let addr = self.store(self[reg]);
// self.heap.push(HeapCellValue::Addr(addr));
// the old code didn't perform the occurs
// check when enabled and so it was changed to
// the above, which is only slightly less
// efficient when the occurs_check is disabled.
}
};
}