From e9bb35c8954cacb64bf466838e9f5856c8b9a3a6 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Sat, 4 Jun 2022 23:43:48 -0600 Subject: [PATCH] emit indexing instructions in single clauses of dynamic predicates --- src/codegen.rs | 4 ++-- src/machine/dispatch.rs | 40 ++++++++++------------------------------ 2 files changed, 12 insertions(+), 32 deletions(-) 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) + ); } } } -- 2.54.0