]> Repositorios git - scryer-prolog.git/commitdiff
emit indexing instructions in single clauses of dynamic predicates
authorMark Thom <[email protected]>
Sun, 5 Jun 2022 05:43:48 +0000 (23:43 -0600)
committerMark Thom <[email protected]>
Sun, 5 Jun 2022 05:43:48 +0000 (23:43 -0600)
src/codegen.rs
src/machine/dispatch.rs

index c6e27cb0376f2940b594b8fd0a7c84db4cb6c3c6..5f9a68ce118467cd2976b899f0ae028473990f5f 100644 (file)
@@ -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![]
index 8f3d1e5d05cc1c767f76d83382e0e8978f791230..3664ebee6d204b8f4f2cae2800a85b8f752604b5 100644 (file)
@@ -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)
+                                    );
                                 }
                             }
                         }