]> Repositorios git - scryer-prolog.git/commitdiff
mark is/2 allocated permanent variables as safe, add CompareNumber terms to ClauseTyp...
authorMark <[email protected]>
Fri, 23 Jun 2023 17:13:51 +0000 (11:13 -0600)
committerMark <[email protected]>
Fri, 23 Jun 2023 20:11:31 +0000 (14:11 -0600)
build/instructions_template.rs
src/codegen.rs
src/debray_allocator.rs

index 7687d4e022dce44e86921b7be69019ec9f4f62b7..8e61ad239a54b32eb51f95b2a5a64b001c38c1b6 100644 (file)
@@ -2311,6 +2311,12 @@ pub fn generate_instructions_rs() -> TokenStream {
                 (atom!(#name), #arity) => true
             }
         );
+
+        is_inlined_arms.push(
+            quote! {
+                (atom!(#name), #arity) => true
+            }
+        );
     }
 
     for (name, arity, variant) in instr_data.compare_term_variants {
index 000c0e65165a01a7767eb01e751ec12b1b85451e..dca532cea08ea71ceb3c353f8b72d1de9933ec9a 100644 (file)
@@ -803,7 +803,6 @@ impl<'b> CodeGenerator<'b> {
         let at = match &terms[0] {
             &Term::Var(ref vr, ref name) => {
                 let var_num = name.to_var_num().unwrap();
-                self.marker.mark_temp_to_safe_perm(var_num);
 
                 self.marker.mark_var::<QueryInstruction>(
                     var_num,
@@ -813,6 +812,8 @@ impl<'b> CodeGenerator<'b> {
                     code,
                 );
 
+                self.marker.mark_safe_var_unconditionally(var_num);
+
                 compile_expr!(self, &terms[1], term_loc, code)
             }
             &Term::Literal(_, c @ Literal::Integer(_) |
index 2cd853c7dfc9d9f270126924d6f6ee0a94261e58..6ad47cfc2aa65344493683d192df53f9e91cc1ed 100644 (file)
@@ -414,8 +414,7 @@ impl DebrayAllocator {
                 self.perm_free_list.pop_front();
 
                 match &mut self.var_data.records[var_num].allocation {
-                    &mut VarAlloc::Perm(p, ref mut allocation) => {
-                        *allocation = PermVarAllocation::Pending;
+                    &mut VarAlloc::Perm(p, _) => {
                         Some(p)
                     }
                     _ => unreachable!()
@@ -426,21 +425,18 @@ impl DebrayAllocator {
         }
     }
 
-    pub(crate) fn mark_temp_to_safe_perm(&mut self, var_num: usize) {
-        match &self.var_data.records[var_num].allocation {
-            &VarAlloc::Temp { to_perm_var_num: Some(perm_var_num), .. } => {
-                let branch_designator = self.current_branch_designator();
+    pub(crate) fn mark_safe_var_unconditionally(&mut self, var_num: usize) {
+        let branch_designator = self.current_branch_designator();
 
-                match &mut self.var_data.records[perm_var_num].allocation {
-                    VarAlloc::Perm(_, PermVarAllocation::Done { deep_safety, shallow_safety, .. }) => {
-                        *deep_safety = VarSafetyStatus::unneeded(branch_designator);
-                        *shallow_safety = VarSafetyStatus::unneeded(branch_designator);
-                    }
-                    _ => unreachable!()
-                }
+        match &mut self.var_data.records[var_num].allocation {
+            VarAlloc::Perm(_, PermVarAllocation::Done { deep_safety, shallow_safety, .. }) => {
+                *deep_safety = VarSafetyStatus::unneeded(branch_designator);
+                *shallow_safety = VarSafetyStatus::unneeded(branch_designator);
             }
-            _ => {
+            VarAlloc::Temp { safety, .. } => {
+                *safety = VarSafetyStatus::unneeded(branch_designator);
             }
+            _ => unreachable!(),
         }
     }
 
@@ -708,11 +704,6 @@ impl Allocator for DebrayAllocator {
         if record.running_count < record.num_occurrences {
             record.running_count += 1;
         } else if r.is_perm() {
-            match &mut self.var_data.records[var_num].allocation {
-                VarAlloc::Perm(_, allocation) => *allocation = PermVarAllocation::Pending,
-                _ => unreachable!(),
-            }
-
             self.perm_free_list.push_back((term_loc.chunk_num(), var_num));
         }