From: Mark Thom Date: Sun, 5 Jun 2022 05:43:48 +0000 (-0600) Subject: emit indexing instructions in single clauses of dynamic predicates X-Git-Tag: v0.9.1~11 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=e9bb35c8954cacb64bf466838e9f5856c8b9a3a6;p=scryer-prolog.git emit indexing instructions in single clauses of dynamic predicates --- diff --git a/src/codegen.rs b/src/codegen.rs index c6e27cb0..5f9a68ce 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -1156,7 +1156,7 @@ impl<'b> CodeGenerator<'b> { if let Some(arg) = arg { let index = code.len(); - if clauses.len() > 1 { + if clauses.len() > 1 || self.settings.is_dynamic() { code_offsets.index_term(arg, index, &mut clause_index_info, self.atom_tbl); } } @@ -1178,7 +1178,7 @@ impl<'b> CodeGenerator<'b> { code.extend(clause_code.into_iter()); } - let index_code = if clauses.len() > 1 { + let index_code = if clauses.len() > 1 || self.settings.is_dynamic() { code_offsets.compute_indices(skip_stub_try_me_else) } else { vec![] diff --git a/src/machine/dispatch.rs b/src/machine/dispatch.rs index 8f3d1e5d..3664ebee 100644 --- a/src/machine/dispatch.rs +++ b/src/machine/dispatch.rs @@ -998,29 +998,19 @@ impl Machine { match self.find_living_dynamic_else(p + next_i) { Some(_) => { self.retry_me_else(next_i); - - try_or_throw!( - self.machine_st, - (self.machine_st.increment_call_count_fn)(&mut self.machine_st) - ); } None => { self.trust_me(); - - try_or_throw!( - self.machine_st, - (self.machine_st.increment_call_count_fn)(&mut self.machine_st) - ); } } } else { self.trust_me(); - - try_or_throw!( - self.machine_st, - (self.machine_st.increment_call_count_fn)(&mut self.machine_st) - ); } + + try_or_throw!( + self.machine_st, + (self.machine_st.increment_call_count_fn)(&mut self.machine_st) + ); } } } @@ -1079,29 +1069,19 @@ impl Machine { match self.find_living_dynamic_else(p + next_i) { Some(_) => { self.retry_me_else(next_i); - - try_or_throw!( - self.machine_st, - (self.machine_st.increment_call_count_fn)(&mut self.machine_st) - ); } None => { self.trust_me(); - - try_or_throw!( - self.machine_st, - (self.machine_st.increment_call_count_fn)(&mut self.machine_st) - ); } } } else { self.trust_me(); - - try_or_throw!( - self.machine_st, - (self.machine_st.increment_call_count_fn)(&mut self.machine_st) - ); } + + try_or_throw!( + self.machine_st, + (self.machine_st.increment_call_count_fn)(&mut self.machine_st) + ); } } }