backtrack on emission of unsafe register instructions on internal branches

This commit is contained in:
Mark
2023-06-22 18:28:10 -06:00
parent 0e583d620a
commit 9ea6cb4cab
3 changed files with 39 additions and 44 deletions

View File

@@ -103,25 +103,15 @@ impl BranchCodeStack {
for (inner_idx, code) in self.stack[idx].iter_mut().enumerate() {
if inner_idx + 1 == inner_len {
jump_span -= code.len() + 1; // = jump_span.saturating_sub(code.len() + 1);
jump_span -= code.len() + 1;
} else {
jump_span -= code.len() + 1;
code.push_back(instr!("jmp_by_call", jump_span as usize));
// saturate at 0 if underflow happens, which only
// happens when jump_span is no longer needed
// anyway. still, we don't want to panic at
// underflow.
jump_span -= 1;
}
}
}
// eliminate terminating jump instruction in last arm of last
// branch.
// self.stack.last_mut()
// .and_then(|branch| branch.last_mut())
// .map(|code| code.pop_back());
}
fn pop_branch(&mut self, depth: usize, settings: CodeGenSettings) -> CodeDeque {
@@ -1242,14 +1232,6 @@ impl<'b> CodeGenerator<'b> {
code.extend(code_segment.into_iter());
}
/*
for line in &code {
println!("{:?}", line);
}
println!("");
*/
Ok(code)
}
}