diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-05-24 07:57:21 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-05-24 07:57:21 -0700 |
commit | 35e439fd6d665ff46442463248022a16b259e1a2 (patch) | |
tree | 77c19eb95564759a6c74e316bfbef3bd1c12d0e1 /stdlib | |
parent | bbb79a948de4688b44ba18ae37a1a6abb30e84d7 (diff) | |
download | txr-35e439fd6d665ff46442463248022a16b259e1a2.tar.gz txr-35e439fd6d665ff46442463248022a16b259e1a2.tar.bz2 txr-35e439fd6d665ff46442463248022a16b259e1a2.zip |
compiler: fbind/lbind: elide unnecessary frames.
* stdlib/compiler.tl (comp-fbind): When after removing unused
functions we are left with an empty list (or the list of
functions was empty to begin with), let's only emit the body
fragment without any frame wrapping. We can't just return
bfrag because that was compiled in the environment which
matches the frame. Instead of the expense of compiling the
code again, we rely on eliminate-frame to move all v registers
up one level.
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/compiler.tl | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl index c5d00612..fd7b2017 100644 --- a/stdlib/compiler.tl +++ b/stdlib/compiler.tl @@ -1111,15 +1111,21 @@ (set ffuns (uni ffuns ff.ffuns) fvars (uni fvars ff.fvars)) (list ff))))) - (new (frag boreg - (append ^((frame ,nenv.lev ,frsize)) - (mappend .code ffrags) - bfrag.code - (maybe-mov boreg bfrag.oreg) - ^((end ,boreg))) - (uni fvars bfrag.fvars) - (uni (diff bfrag.ffuns lexfuns) - (if rec (diff ffuns lexfuns) ffuns)))))))) + (if ffrags + (new (frag boreg + (append ^((frame ,nenv.lev ,frsize)) + (mappend .code ffrags) + bfrag.code + (maybe-mov boreg bfrag.oreg) + ^((end ,boreg))) + (uni fvars bfrag.fvars) + (uni (diff bfrag.ffuns lexfuns) + (if rec (diff ffuns lexfuns) ffuns)))) + (new (frag boreg + (append me.(eliminate-frame bfrag.code nenv) + (maybe-mov boreg bfrag.oreg)) + bfrag.fvars + bfrag.ffuns))))))) (defmeth compiler comp-lambda-impl (me oreg env form) (mac-param-bind form (t par-syntax . body) form |