correct bug in bb_b_put, correct stack truncation bug resulting in erroneous failures (affecting issue #255 and the in-progress tabling library)
This commit is contained in:
@@ -21,7 +21,7 @@ bb_b_put(Key, NewValue) :-
|
|||||||
( '$bb_get_with_offset'(Key, OldValue, OldOffset) ->
|
( '$bb_get_with_offset'(Key, OldValue, OldOffset) ->
|
||||||
call_cleanup((store_global_var_with_offset(Key, NewValue) ; false),
|
call_cleanup((store_global_var_with_offset(Key, NewValue) ; false),
|
||||||
reset_global_var_at_offset(Key, OldValue, OldOffset))
|
reset_global_var_at_offset(Key, OldValue, OldOffset))
|
||||||
; call_cleanup((store_global_var(Key, NewValue, _) ; false),
|
; call_cleanup((store_global_var_with_offset(Key, NewValue) ; false),
|
||||||
reset_global_var_at_key(Key))
|
reset_global_var_at_key(Key))
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|||||||
@@ -117,8 +117,10 @@ impl MachineState {
|
|||||||
self.stack.index_and_frame_mut(e)[i] = self[RegType::Temp(i)].clone();
|
self.stack.index_and_frame_mut(e)[i] = self[RegType::Temp(i)].clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.stack.index_and_frame_mut(e)[self.num_of_args + 1] = Addr::Con(Constant::CutPoint(self.b0));
|
self.stack.index_and_frame_mut(e)[self.num_of_args + 1] =
|
||||||
self.stack.index_and_frame_mut(e)[self.num_of_args + 2] = Addr::Con(Constant::Usize(self.num_of_args));
|
Addr::Con(Constant::CutPoint(self.b0));
|
||||||
|
self.stack.index_and_frame_mut(e)[self.num_of_args + 2] =
|
||||||
|
Addr::Con(Constant::Usize(self.num_of_args));
|
||||||
|
|
||||||
self.verify_attributes();
|
self.verify_attributes();
|
||||||
|
|
||||||
|
|||||||
@@ -552,8 +552,8 @@ pub(crate) trait CallPolicy: Any {
|
|||||||
attr_var_init_queue_b,
|
attr_var_init_queue_b,
|
||||||
attr_var_init_bindings_b);
|
attr_var_init_bindings_b);
|
||||||
|
|
||||||
machine_st.b = machine_st.stack.index_or_frame(b).prelude.b;
|
|
||||||
machine_st.truncate_stack();
|
machine_st.truncate_stack();
|
||||||
|
machine_st.b = machine_st.stack.index_or_frame(b).prelude.b;
|
||||||
|
|
||||||
machine_st.hb = machine_st.heap.h;
|
machine_st.hb = machine_st.heap.h;
|
||||||
machine_st.p += offset;
|
machine_st.p += offset;
|
||||||
@@ -597,11 +597,11 @@ pub(crate) trait CallPolicy: Any {
|
|||||||
|
|
||||||
machine_st.attr_var_init.backtrack(
|
machine_st.attr_var_init.backtrack(
|
||||||
attr_var_init_queue_b,
|
attr_var_init_queue_b,
|
||||||
attr_var_init_bindings_b
|
attr_var_init_bindings_b,
|
||||||
);
|
);
|
||||||
|
|
||||||
machine_st.b = machine_st.stack.index_or_frame(b).prelude.b;
|
|
||||||
machine_st.truncate_stack();
|
machine_st.truncate_stack();
|
||||||
|
machine_st.b = machine_st.stack.index_or_frame(b).prelude.b;
|
||||||
|
|
||||||
machine_st.hb = machine_st.heap.h;
|
machine_st.hb = machine_st.heap.h;
|
||||||
machine_st.p += 1;
|
machine_st.p += 1;
|
||||||
@@ -881,7 +881,7 @@ pub(crate) trait CallPolicy: Any {
|
|||||||
if machine_st.fail {
|
if machine_st.fail {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
machine_st.p = CodePtr::CallN(arity, machine_st.p.local(), machine_st.last_call);
|
machine_st.p = CodePtr::CallN(arity, machine_st.p.local(), machine_st.last_call);
|
||||||
}
|
}
|
||||||
ClauseType::Inlined(inlined) => {
|
ClauseType::Inlined(inlined) => {
|
||||||
@@ -1069,7 +1069,6 @@ fn cut_body(machine_st: &mut MachineState, addr: Addr) -> bool {
|
|||||||
machine_st.b = b0;
|
machine_st.b = b0;
|
||||||
machine_st.tidy_trail();
|
machine_st.tidy_trail();
|
||||||
machine_st.tidy_pstr_trail();
|
machine_st.tidy_pstr_trail();
|
||||||
machine_st.truncate_stack();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -1157,7 +1156,6 @@ impl CutPolicy for SCCCutPolicy {
|
|||||||
machine_st.b = b0;
|
machine_st.b = b0;
|
||||||
machine_st.tidy_trail();
|
machine_st.tidy_trail();
|
||||||
machine_st.tidy_pstr_trail();
|
machine_st.tidy_pstr_trail();
|
||||||
machine_st.truncate_stack();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|||||||
@@ -2074,7 +2074,6 @@ impl MachineState {
|
|||||||
|
|
||||||
pub(super) fn unwind_stack(&mut self) {
|
pub(super) fn unwind_stack(&mut self) {
|
||||||
self.b = self.block;
|
self.b = self.block;
|
||||||
self.truncate_stack();
|
|
||||||
self.fail = true;
|
self.fail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3329,7 +3328,6 @@ impl MachineState {
|
|||||||
self.b = b0;
|
self.b = b0;
|
||||||
self.tidy_trail();
|
self.tidy_trail();
|
||||||
self.tidy_pstr_trail();
|
self.tidy_pstr_trail();
|
||||||
self.truncate_stack();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.p += 1;
|
self.p += 1;
|
||||||
|
|||||||
@@ -2025,7 +2025,6 @@ impl MachineState {
|
|||||||
|
|
||||||
if nb > 0 && self.stack.index_or_frame(b).prelude.b == nb {
|
if nb > 0 && self.stack.index_or_frame(b).prelude.b == nb {
|
||||||
self.b = self.stack.index_or_frame(nb).prelude.b;
|
self.b = self.stack.index_or_frame(nb).prelude.b;
|
||||||
self.truncate_stack();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => self.fail = true,
|
_ => self.fail = true,
|
||||||
|
|||||||
Reference in New Issue
Block a user