realize full cheney in copier.rs
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
use prolog::and_stack::*;
|
use prolog::and_stack::*;
|
||||||
use prolog::ast::*;
|
use prolog::ast::*;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::ops::IndexMut;
|
use std::ops::IndexMut;
|
||||||
|
|
||||||
type Trail = Vec<(Ref, HeapCellValue)>;
|
type Trail = Vec<(Ref, HeapCellValue)>;
|
||||||
|
|
||||||
pub(crate) struct RedirectInfo {
|
pub(crate) struct RedirectInfo {
|
||||||
trail: Trail
|
trail: Trail
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait CopierTarget
|
pub(crate) trait CopierTarget
|
||||||
@@ -40,11 +39,6 @@ pub(crate) trait CopierTarget
|
|||||||
let mut scan = self.source();
|
let mut scan = self.source();
|
||||||
let old_h = self.threshold();
|
let old_h = self.threshold();
|
||||||
|
|
||||||
// Lists have a compressed representation as structures,
|
|
||||||
// removing the need for NamedStr, so we use a redirection
|
|
||||||
// table for copying lists.
|
|
||||||
let mut list_redirect = HashMap::new();
|
|
||||||
|
|
||||||
self.push(HeapCellValue::Addr(addr));
|
self.push(HeapCellValue::Addr(addr));
|
||||||
|
|
||||||
while scan < self.threshold() {
|
while scan < self.threshold() {
|
||||||
@@ -54,15 +48,16 @@ pub(crate) trait CopierTarget
|
|||||||
HeapCellValue::Addr(a) =>
|
HeapCellValue::Addr(a) =>
|
||||||
match a.clone() {
|
match a.clone() {
|
||||||
Addr::Lis(a) => {
|
Addr::Lis(a) => {
|
||||||
if let Some(idx) = list_redirect.get(&a) {
|
if let HeapCellValue::Addr(Addr::Lis(b)) = self[a].clone() {
|
||||||
self[scan] = HeapCellValue::Addr(Addr::Lis(*idx));
|
if b >= old_h {
|
||||||
scan += 1;
|
self[scan] = HeapCellValue::Addr(Addr::Lis(b));
|
||||||
continue;
|
scan += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list_redirect.insert(a, self.threshold());
|
let threshold = self.threshold();
|
||||||
|
self[scan] = HeapCellValue::Addr(Addr::Lis(threshold));
|
||||||
self[scan] = HeapCellValue::Addr(Addr::Lis(self.threshold()));
|
|
||||||
|
|
||||||
let hcv = self[a].clone();
|
let hcv = self[a].clone();
|
||||||
self.push(hcv);
|
self.push(hcv);
|
||||||
@@ -70,6 +65,9 @@ pub(crate) trait CopierTarget
|
|||||||
let hcv = self[a+1].clone();
|
let hcv = self[a+1].clone();
|
||||||
self.push(hcv);
|
self.push(hcv);
|
||||||
|
|
||||||
|
trail.push((Ref::HeapCell(a), self[a].clone()));
|
||||||
|
self[a] = HeapCellValue::Addr(Addr::Lis(threshold));
|
||||||
|
|
||||||
scan += 1;
|
scan += 1;
|
||||||
},
|
},
|
||||||
Addr::HeapCell(_) | Addr::StackCell(_, _) => {
|
Addr::HeapCell(_) | Addr::StackCell(_, _) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user