From: Mark Date: Fri, 23 Jun 2023 17:13:51 +0000 (-0600) Subject: mark is/2 allocated permanent variables as safe, add CompareNumber terms to ClauseTyp... X-Git-Tag: v0.9.2~123^2~4 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=4ad113a6f8180fd3839b93eec09f49a4ff457702;p=scryer-prolog.git mark is/2 allocated permanent variables as safe, add CompareNumber terms to ClauseType::is_inlined --- diff --git a/build/instructions_template.rs b/build/instructions_template.rs index 7687d4e0..8e61ad23 100644 --- a/build/instructions_template.rs +++ b/build/instructions_template.rs @@ -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 { diff --git a/src/codegen.rs b/src/codegen.rs index 000c0e65..dca532ce 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -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::( 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(_) | diff --git a/src/debray_allocator.rs b/src/debray_allocator.rs index 2cd853c7..6ad47cfc 100644 --- a/src/debray_allocator.rs +++ b/src/debray_allocator.rs @@ -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)); }