diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-10-26 07:25:51 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-10-26 07:25:51 -0700 |
commit | 9733bb6dad3b0c430a82b2592d5519383479cb86 (patch) | |
tree | b894ea6b0a6022e2f5700b1a3e362c721977d9b3 /share | |
parent | c4d91d0128dd998a73d216fe7bb0132c41d901bc (diff) | |
download | txr-9733bb6dad3b0c430a82b2592d5519383479cb86.tar.gz txr-9733bb6dad3b0c430a82b2592d5519383479cb86.tar.bz2 txr-9733bb6dad3b0c430a82b2592d5519383479cb86.zip |
compiler: use symtab caching for global lexicals.
* parser.c (read_file_common): Allow version three
object files.
* share/txr/stdlib/compiler.tl (compiler comp-var): If a
global variable isn't special, then treat it via the getlx
instruction. The symbol gets added to the symtab, and
referenced by index number.
(compiler comp-setq): Similarly, treat a non-special
global variable using the setlx instruction.
(%tlo-ver%): We bump the major version of .tlo files
from 2 to 3, since old txr executables won't recognize
these new instructions. However, we are backward compatible;
hence read_file_common still allows version 2.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/compiler.tl | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 0b8202da..bba9bb7e 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -363,23 +363,30 @@ (new (frag dreg nil)))))) (defmeth compiler comp-var (me oreg env sym) - (iflet ((vbin env.(lookup-var sym))) - (new (frag vbin.loc nil (list sym))) - (let ((dreg me.(get-dreg sym))) - (new (frag oreg ^((getv ,oreg ,dreg)) (list sym)))))) + (let ((vbin env.(lookup-var sym))) + (cond + (vbin (new (frag vbin.loc nil (list sym)))) + ((special-var-p sym) + (let ((dreg me.(get-dreg sym))) + (new (frag oreg ^((getv ,oreg ,dreg)) (list sym))))) + (t (new (frag oreg ^((getlx ,oreg ,me.(get-sidx sym))) (list sym))))))) (defmeth compiler comp-setq (me oreg env form) (mac-param-bind form (op sym value) form (let* ((bind env.(lookup-var sym)) - (vloc (if bind - bind.loc - me.(get-dreg sym))) + (spec (special-var-p sym)) + (vloc (cond + (bind bind.loc) + (spec me.(get-dreg sym)) + (t me.(get-sidx sym)))) (vfrag me.(compile (if bind vloc oreg) env value))) (new (frag vfrag.oreg ^(,*vfrag.code ,*(if bind (maybe-mov vloc vfrag.oreg) - ^((setv ,vfrag.oreg ,vloc)))) + (if spec + ^((setv ,vfrag.oreg ,vloc)) + ^((setlx ,vfrag.oreg ,me.(get-sidx sym)))))) (uni (list sym) vfrag.fvars) vfrag.ffuns))))) @@ -1537,7 +1544,7 @@ (defvarl %big-endian% (equal (ffi-put 1 (ffi uint32)) #b'00000001')) -(defvarl %tlo-ver% ^(2 0 ,%big-endian%)) +(defvarl %tlo-ver% ^(3 0 ,%big-endian%)) (defun open-compile-streams (in-path out-path) (let* ((rsuff (r$ %file-suff-rx% in-path)) |