Improve behaviour when adding literal to non-literal, materialise local if its value will be changed

Currently the implementation of materializing locals causes compilation to be non-linear in degenerate cases
This commit is contained in:
Jef
2018-12-18 19:15:29 +01:00
parent 5418241dc6
commit 72855e48c7
2 changed files with 79 additions and 4 deletions

View File

@@ -250,7 +250,11 @@ pub fn translate(
};
}
Operator::End => {
// TODO: Merge `End`s
// TODO: Merge `End`s so that we can
// A) Move values directly into RAX when returning from deeply-nested blocks.
// B) Avoid restoring locals when not necessary.
// This doesn't require lookahead but it does require turning this loop into a kind
// of state machine.
let control_frame = control_frames.pop().expect("control stack is never empty");
let arity = control_frame.arity();