
+# Rebis Development Branch
+
+
+
+This is the Rebis Development Branch (rebis-dev). This iteration of
+Rebis contains sweeping changes to the instruction dispatch loop
+alongside a compacted heap representation. These changes are to
+enhance the performance and robustness of Scryer Prolog and to prepare
+for the introduction of a mark-compacting garbage collector.
+
+Several performance enhancing changes are due before rebis-dev will be
+considered ready for merging into master, among them:
+
+* Replacing choice points pivoting on inlined deterministic predicates
+ (`atom`, `var`, etc) with if/else ladders
+* Inlining all built-ins and system call instructions
+* Greatly reducing the number of instructions used to compile disjunctives
+* Storing short atoms to heap cells without writing them to the atom table
+
## Phase 1
Produce an implementation of the Warren Abstract Machine in Rust, done
}
let mut singleton_var_set: IndexMap<Ref, bool> = IndexMap::new();
- let mut var_list = vec![];
-
- let list_of_var_eqs = push_var_eq_functors(
- &mut self.heap,
- term_write_result.var_dict.iter(),
- &mut self.atom_tbl,
- );
for addr in stackful_preorder_iter(&mut self.heap, term) {
let addr = unmark_cell_bits!(addr);
if let Some(var) = addr.as_var() {
if !singleton_var_set.contains_key(&var) {
singleton_var_set.insert(var, true);
- var_list.push(addr);
} else {
singleton_var_set.insert(var, false);
}
&mut self.atom_tbl,
);
+ let mut var_list = Vec::with_capacity(singleton_var_set.len());
+
+ for (var_name, addr) in term_write_result.var_dict {
+ if let Some(var) = addr.as_var() {
+ let idx = singleton_var_set.get_index_of(&var).unwrap();
+ var_list.push((var_name, addr, idx));
+ }
+ }
+
+ var_list.sort_by(|(_,_,idx_1),(_,_,idx_2)| idx_1.cmp(idx_2));
+
+ let list_of_var_eqs = push_var_eq_functors(
+ &mut self.heap,
+ var_list.iter().map(|(var_name, var,_)| (var_name,var)),
+ &mut self.atom_tbl,
+ );
+
let singleton_addr = self.registers[3];
let singletons_offset = heap_loc_as_cell!(
iter_to_heap_list(&mut self.heap, singleton_var_list.into_iter())
let vars_addr = self.registers[4];
let vars_offset = heap_loc_as_cell!(
- iter_to_heap_list(&mut self.heap, var_list.into_iter())
+ iter_to_heap_list(&mut self.heap, var_list.into_iter().map(|(_,cell,_)| cell))
);
unify_fn!(*self, vars_offset, vars_addr);