diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-04-17 15:04:45 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-04-17 15:04:45 -0700 |
commit | 559e2cace50b534d7591d7bb6f0ba68afe09dc68 (patch) | |
tree | 9c11bbdc94e44b5cd15650c57fd0ddf2d670a5e1 /stdlib/txr-case.tl | |
parent | 3508483456416a42f26bffec9c02cdad47e18765 (diff) | |
download | txr-559e2cace50b534d7591d7bb6f0ba68afe09dc68.tar.gz txr-559e2cace50b534d7591d7bb6f0ba68afe09dc68.tar.bz2 txr-559e2cace50b534d7591d7bb6f0ba68afe09dc68.zip |
compiler: better handling for mutated locals in funargs.
Instead of the conservative strategy in compiler comp-var of
loading variables into t-registers, and relying on optimization
to remove them, let's just go back to the old way: variables
are just registers. For function calls, we can detect mutated
variables and generate the conservative code.
* stdlib/compiler.tl (frag): New slots vbin and alt-oreg.
When a variable access is compiled, the binding is recorded
in vbin, and the desired output register in alt-oreg.
(simplify-var-spy): New struct type, used for detecting
mutated lexical variables when we compile a function argument
list.
(compiler comp-var): Revert to the old compilation strategy
for lexicals: the code fragment is empty, and the output
register is just the v-reg. However, we record the variable
binding and remember the caller's desired register in the
new frag fields.
(compiler comp-setq): Also revert the strategy here.
Here we get our frag from a recursive compilation, so
we just annotate it.
(compiler comp-call-impl): Use the simplify-var-spy to
obtain a list of the lexical variables that were mutated.
This is used for rewriting the frags, if necessary.
(handle-mutated-var-args): New function. If the mutated-vars
list is non-empty, it rewrites the frag list. Every element
in the frag which is a compiled reference to a lexical
variable which is mutated over the evaluation of the arg list
is substituted with a conservative frag which loads the
variable into a temporary register. That register thus
samples the value of the variable at the correct point in the
left-to-right evaluation, so the function is called with
the correct values.
Diffstat (limited to 'stdlib/txr-case.tl')
0 files changed, 0 insertions, 0 deletions