allocate cut variables as temporaries when in non-allocating clause (#2183)

This commit is contained in:
Mark
2023-11-28 12:58:54 -07:00
parent b8ef367824
commit de5de0cfaf
3 changed files with 27 additions and 10 deletions

View File

@@ -736,7 +736,7 @@ impl Allocator for DebrayAllocator {
&mut self,
var_num: usize,
lvl: Level,
cell: &'a Cell<VarReg>,
cell: &Cell<VarReg>,
term_loc: GenContext,
code: &mut CodeDeque,
) {
@@ -776,7 +776,7 @@ impl Allocator for DebrayAllocator {
&mut self,
var_num: usize,
lvl: Level,
cell: &'a Cell<VarReg>,
cell: &Cell<VarReg>,
term_loc: GenContext,
code: &mut CodeDeque,
r: RegType,
@@ -840,10 +840,18 @@ impl Allocator for DebrayAllocator {
self.in_use.insert(o);
}
fn mark_cut_var(&mut self, var_num: usize, chunk_num: usize) -> RegType {
fn mark_cut_var<'a, Target: CompilationTarget<'a>>(
&mut self,
var_num: usize,
term_loc: GenContext,
code: &mut CodeDeque,
) -> RegType {
match self.get_binding(var_num) {
RegType::Perm(0) | RegType::Temp(0) => {
RegType::Perm(self.alloc_perm_var(var_num, chunk_num))
RegType::Perm(0) => RegType::Perm(self.alloc_perm_var(var_num, term_loc.chunk_num())),
RegType::Temp(0) => {
let cell = Cell::default();
self.mark_var::<Target>(var_num, Level::Shallow, &cell, term_loc, code);
cell.get().norm()
}
r => r,
}