diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-02-14 10:25:57 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-02-14 13:37:04 -0800 |
commit | abe744ceb522434907094dc3d946d12177d51fce (patch) | |
tree | f8ce4acce9591d9b06b83e675e573145b799b9be | |
parent | e598f74891592a67d31985182af24243a2e6ccd5 (diff) | |
download | txr-abe744ceb522434907094dc3d946d12177d51fce.tar.gz txr-abe744ceb522434907094dc3d946d12177d51fce.tar.bz2 txr-abe744ceb522434907094dc3d946d12177d51fce.zip |
asm/vm/compiler: introduce jend pseudo-instruction.
The jend pseudo-instruction is a simple alias for end. It
indicates a jumping end: an end that does not fall through to
the next instruction but could go somewhere else.
This is for "future correctness" as well as clarity. The
difference is important in analysis of code into basic blocks.
Currently this won't make a difference because all the jend
instructions except for the one at the end of compiled
top-level form are followed by a label which kicks off a basic
block anyway.
* share/txr/stdlib/asm.tl (defopcode-alias): New macro.
(jend): New opcode, defined as alias for end.
* share/txr/stdlib/compiler.tl (comp-unwind-protect,
comp-lambda-impl, compile-toplevel): Use jend instruction for
a jumping end: the one after the protected code block of a
uwprot, the one at the end of a function, and the one at the
end of a top-level form.
-rw-r--r-- | share/txr/stdlib/asm.tl | 7 | ||||
-rw-r--r-- | share/txr/stdlib/compiler.tl | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/share/txr/stdlib/asm.tl b/share/txr/stdlib/asm.tl index 8b63a557..89ad4b3a 100644 --- a/share/txr/stdlib/asm.tl +++ b/share/txr/stdlib/asm.tl @@ -343,7 +343,11 @@ (defstruct ,class ,orig-class (:static symbol ',symbol) (:static code ,code)) - (register-opcode (new ,class))))) + (register-opcode (new ,class)))) + + (defmacro defopcode-alias (alias-symbol orig-symbol) + ^(let ((oc [%oc-hash% ',orig-symbol])) + (set [%oc-hash% ',alias-symbol] oc)))) (defopcode op-label label nil (:method asm (me asm syntax) @@ -387,6 +391,7 @@ (:method dis (me asm extension res) ^(,me.symbol ,(operand-to-sym res)))) +(defopcode-alias jend end) (defopcode-derived op-prof prof auto op-end) diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index a735739b..d034ab21 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -693,7 +693,7 @@ (t (new (frag pfrag.oreg ^((uwprot ,lclean) ,*pfrag.code - (end nil) + (jend nil) ,lclean ,*cfrag.code (end nil)) @@ -807,7 +807,7 @@ ,lhand ,*(mappend .code cfrags) ,lhend - (end ,tfrag.oreg) + (jend ,tfrag.oreg) (end ,tfrag.oreg)) (uni tfrag.fvars [reduce-left uni cfrags nil .fvars]) (uni tfrag.ffuns [reduce-left uni cfrags nil .ffuns]))))))) @@ -1050,7 +1050,7 @@ ,*(if need-dframe ^((end ,boreg))) ,*me.(maybe-mov boreg bfrag.oreg) - (end ,boreg) + (jend ,boreg) ,lskip) (uni fvars (diff bfrag.fvars lexsyms)) (uni [reduce-left uni ifrags nil .ffuns] @@ -1819,7 +1819,7 @@ co.(check-treg-leak) as.(asm co.(optimize ^(,*(mappend .code (nreverse co.lt-frags)) ,*frag.code - (end ,frag.oreg)))) + (jend ,frag.oreg)))) (vm-make-desc co.nlev (succ as.max-treg) as.buf co.(get-datavec) co.(get-symvec))))) (defun compiler-emit-warnings () |