From a38f7c852461c8b27452f2425080ec63a26ae68c Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Tue, 1 Mar 2022 23:59:33 -0700 Subject: [PATCH] save arguments to delayed goal before calling verify_attrs (#1304) --- src/machine/attributed_variables.rs | 12 ++++++------ src/machine/dispatch.rs | 4 +++- src/machine/mod.rs | 6 ++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/machine/attributed_variables.rs b/src/machine/attributed_variables.rs index a158d3af..f74d3981 100644 --- a/src/machine/attributed_variables.rs +++ b/src/machine/attributed_variables.rs @@ -108,21 +108,21 @@ impl MachineState { attr_vars.into_iter() } - pub(super) fn verify_attr_interrupt(&mut self, p: usize) { - self.allocate(self.num_of_args + 3); + pub(super) fn verify_attr_interrupt(&mut self, p: usize, arity: usize) { + self.allocate(arity + 3); let e = self.e; let and_frame = self.stack.index_and_frame_mut(e); - for i in 1..self.num_of_args + 1 { + for i in 1..arity + 1 { and_frame[i] = self.registers[i]; } - and_frame[self.num_of_args + 1] = + and_frame[arity + 1] = fixnum_as_cell!(Fixnum::build_with(self.b0 as i64)); - and_frame[self.num_of_args + 2] = + and_frame[arity + 2] = fixnum_as_cell!(Fixnum::build_with(self.num_of_args as i64)); - and_frame[self.num_of_args + 3] = + and_frame[arity + 3] = fixnum_as_cell!(Fixnum::build_with(self.attr_var_init.cp as i64)); self.verify_attributes(); diff --git a/src/machine/dispatch.rs b/src/machine/dispatch.rs index fe22678d..830eedb7 100644 --- a/src/machine/dispatch.rs +++ b/src/machine/dispatch.rs @@ -576,7 +576,9 @@ impl Machine { self.machine_st.attr_var_init.cp = p; } &Instruction::VerifyAttrInterrupt => { - self.run_verify_attr_interrupt(); + let (_, arity) = self.code[VERIFY_ATTR_INTERRUPT_LOC].to_name_and_arity(); + let arity = std::cmp::max(arity, self.machine_st.num_of_args); + self.run_verify_attr_interrupt(arity); } &Instruction::Add(ref a1, ref a2, t) => { let stub_gen = || functor_stub(atom!("is"), 2); diff --git a/src/machine/mod.rs b/src/machine/mod.rs index 7c2be32d..6ce7a7d7 100644 --- a/src/machine/mod.rs +++ b/src/machine/mod.rs @@ -511,11 +511,9 @@ impl Machine { } #[inline(always)] - pub(crate) fn run_verify_attr_interrupt(&mut self) { //, cp: usize) { + pub(crate) fn run_verify_attr_interrupt(&mut self, arity: usize) { let p = self.machine_st.attr_var_init.verify_attrs_loc; - - // self.machine_st.attr_var_init.cp = cp; - self.machine_st.verify_attr_interrupt(p); + self.machine_st.verify_attr_interrupt(p, arity); } #[inline(always)] -- 2.54.0