synchronize offset table growth with the borrowing of offset pointers
This commit is contained in:
@@ -1337,6 +1337,8 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
settings.is_dynamic(),
|
||||
);
|
||||
|
||||
drop(index_ptr);
|
||||
|
||||
let index_ptr = if settings.is_dynamic() {
|
||||
IndexPtr::dynamic_index(code_ptr)
|
||||
} else {
|
||||
@@ -2229,12 +2231,11 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
|
||||
if let Some(filename) = self.listing_src_file_name() {
|
||||
if let Some(ref mut module) = self.wam_prelude.indices.modules.get_mut(&filename) {
|
||||
let code_idx = LS::machine_st(&mut self.payload)
|
||||
let index_ptr = *LS::machine_st(&mut self.payload)
|
||||
.arena
|
||||
.code_index_tbl
|
||||
.lookup_mut(offset.into());
|
||||
|
||||
let index_ptr = *code_idx;
|
||||
let offset = *module.code_dir.entry(key).or_insert(offset);
|
||||
|
||||
set_code_index::<LS>(
|
||||
|
||||
@@ -2696,9 +2696,9 @@ impl Machine {
|
||||
}
|
||||
}
|
||||
&Instruction::CallNamed(arity, name, idx) => {
|
||||
let idx = self.machine_st.arena.code_index_tbl.lookup(idx.into());
|
||||
let idx = *self.machine_st.arena.code_index_tbl.lookup(idx.into());
|
||||
|
||||
try_or_throw!(self.machine_st, self.try_call(name, arity, *idx));
|
||||
try_or_throw!(self.machine_st, self.try_call(name, arity, idx));
|
||||
|
||||
if self.machine_st.fail {
|
||||
self.machine_st.backtrack();
|
||||
@@ -2707,9 +2707,9 @@ impl Machine {
|
||||
}
|
||||
}
|
||||
&Instruction::ExecuteNamed(arity, name, idx) => {
|
||||
let idx = self.machine_st.arena.code_index_tbl.lookup(idx.into());
|
||||
let idx = *self.machine_st.arena.code_index_tbl.lookup(idx.into());
|
||||
|
||||
try_or_throw!(self.machine_st, self.try_execute(name, arity, *idx));
|
||||
try_or_throw!(self.machine_st, self.try_execute(name, arity, idx));
|
||||
|
||||
if self.machine_st.fail {
|
||||
self.machine_st.backtrack();
|
||||
@@ -2718,18 +2718,18 @@ impl Machine {
|
||||
}
|
||||
}
|
||||
&Instruction::DefaultCallNamed(arity, name, idx) => {
|
||||
let idx = self.machine_st.arena.code_index_tbl.lookup(idx.into());
|
||||
let idx = *self.machine_st.arena.code_index_tbl.lookup(idx.into());
|
||||
|
||||
try_or_throw!(self.machine_st, self.try_call(name, arity, *idx));
|
||||
try_or_throw!(self.machine_st, self.try_call(name, arity, idx));
|
||||
|
||||
if self.machine_st.fail {
|
||||
self.machine_st.backtrack();
|
||||
}
|
||||
}
|
||||
&Instruction::DefaultExecuteNamed(arity, name, idx) => {
|
||||
let idx = self.machine_st.arena.code_index_tbl.lookup(idx.into());
|
||||
let idx = *self.machine_st.arena.code_index_tbl.lookup(idx.into());
|
||||
|
||||
try_or_throw!(self.machine_st, self.try_execute(name, arity, *idx));
|
||||
try_or_throw!(self.machine_st, self.try_execute(name, arity, idx));
|
||||
|
||||
if self.machine_st.fail {
|
||||
self.machine_st.backtrack();
|
||||
|
||||
@@ -48,6 +48,7 @@ pub(super) fn set_code_index<'a, LS: LoadState<'a>>(
|
||||
}
|
||||
};
|
||||
|
||||
drop(code_idx_ptr);
|
||||
payload.retraction_info.push_record(record);
|
||||
}
|
||||
|
||||
@@ -507,6 +508,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
let code_ptr = code_index_tbl.lookup((*code_index).into());
|
||||
|
||||
if !code_ptr.is_undefined() && !code_ptr.is_dynamic_undefined() {
|
||||
drop(code_ptr);
|
||||
let old_index_ptr = code_index.replace(code_index_tbl, IndexPtr::undefined());
|
||||
|
||||
self.payload.retraction_info.push_record(
|
||||
@@ -559,6 +561,9 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
let target_code_ptr = code_index_tbl.lookup(target_code_idx.into());
|
||||
|
||||
if module_code_ptr == target_code_ptr {
|
||||
drop(module_code_ptr);
|
||||
drop(target_code_ptr);
|
||||
|
||||
let old_index_ptr = target_code_idx
|
||||
.replace(code_index_tbl, IndexPtr::undefined());
|
||||
payload
|
||||
|
||||
@@ -1228,6 +1228,8 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
.lookup_mut(offset.into());
|
||||
|
||||
if code_idx_ptr.is_undefined() {
|
||||
drop(code_idx_ptr);
|
||||
|
||||
set_code_index::<LS>(
|
||||
&mut self.payload,
|
||||
&compilation_target,
|
||||
@@ -2159,6 +2161,7 @@ impl Machine {
|
||||
.remove_predicate_skeleton(&compilation_target, &key);
|
||||
|
||||
let offset = loader.get_or_insert_code_index(key, compilation_target);
|
||||
|
||||
let mut code_idx = loader
|
||||
.payload
|
||||
.machine_st
|
||||
@@ -2168,6 +2171,8 @@ impl Machine {
|
||||
|
||||
code_idx.set(IndexPtr::undefined());
|
||||
|
||||
drop(code_idx);
|
||||
|
||||
loader.payload.compilation_target = clause_clause_compilation_target;
|
||||
|
||||
while let Some(target_pos) = clause_clause_target_poses.pop() {
|
||||
|
||||
@@ -253,7 +253,7 @@ impl Machine {
|
||||
) -> std::process::ExitCode {
|
||||
if let Some(module) = self.indices.modules.get(&module_name) {
|
||||
if let Some(code_idx) = module.code_dir.get(&key) {
|
||||
let index_ptr = self.machine_st.arena.code_index_tbl.lookup(code_idx.into());
|
||||
let index_ptr = *self.machine_st.arena.code_index_tbl.lookup(code_idx.into());
|
||||
let p = index_ptr.local().unwrap();
|
||||
|
||||
// Leave a halting choice point to backtrack to in case the predicate fails or throws.
|
||||
|
||||
@@ -289,10 +289,10 @@ pub(crate) trait Unifier: DerefMut<Target = MachineState> {
|
||||
(HeapCellValueTag::F64Offset, f2) => {
|
||||
let machine_st = self.deref_mut();
|
||||
|
||||
let f1 = machine_st.arena.f64_tbl.lookup(f1);
|
||||
let f2 = machine_st.arena.f64_tbl.lookup(f2.into());
|
||||
let f1 = *machine_st.arena.f64_tbl.lookup(f1);
|
||||
let f2 = *machine_st.arena.f64_tbl.lookup(f2.into());
|
||||
|
||||
self.fail = **f1 != **f2;
|
||||
self.fail = *f1 != *f2;
|
||||
}
|
||||
_ => {
|
||||
self.fail = true;
|
||||
|
||||
Reference in New Issue
Block a user