summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-10-26 07:22:33 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-10-26 07:22:33 -0700
commitc4d91d0128dd998a73d216fe7bb0132c41d901bc (patch)
treef057f4f0a3a7e4f61bc629851485bf11e6f1805f /share
parentd8185f6ae9d706f68e3ad3da5c1899ffffab415d (diff)
downloadtxr-c4d91d0128dd998a73d216fe7bb0132c41d901bc.tar.gz
txr-c4d91d0128dd998a73d216fe7bb0132c41d901bc.tar.bz2
txr-c4d91d0128dd998a73d216fe7bb0132c41d901bc.zip
vm/asm: new instructions getlx and setlx.
These instructions can be used for accessing cached global variable bindings through the symtab of the vm descriptor. The compiler will use these for optimizing access to global lexical variables. * share/txr/stdlib/asm.tl (op-getlx, op-setlx): New opcode classes. * vm.c (vm_stab): Take the lookup function as an argument, so this can be used for variable bindings. (vm_gcall, vm_gapply): Pass lookup_fun function to vm_stab, as well as the appropriate string for the unbound error. (vm_gettab, vm_settab): New static functions. (vm_execute): Implement GETLX and SETLX using vm_gettab and vm_settab. * vmop.h: Regenerated.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/asm.tl24
1 files changed, 24 insertions, 0 deletions
diff --git a/share/txr/stdlib/asm.tl b/share/txr/stdlib/asm.tl
index 1cbaba87..be442950 100644
--- a/share/txr/stdlib/asm.tl
+++ b/share/txr/stdlib/asm.tl
@@ -755,6 +755,30 @@
(unless (minusp fix)
(add (operand-to-sym y))))))))))))
+(defopcode op-getlx getlx auto
+ (:method asm (me asm syntax)
+ me.(chk-arg-count 2 syntax)
+ (tree-bind (dst idx) asm.(parse-args me syntax '(d n))
+ (cond
+ ((small-op-p dst)
+ asm.(put-insn me.code (enc-small-op dst) idx))
+ (t asm.(put-insn me.code (enc-small-op 1) idx)
+ asm.(asm-one ^(mov ,(operand-to-exp dst) t1))))))
+ (:method dis (me asm dst idx)
+ ^(,me.symbol ,(operand-to-sym dst) ,idx)))
+
+(defopcode op-setlx setlx auto
+ (:method asm (me asm syntax)
+ me.(chk-arg-count 2 syntax)
+ (tree-bind (src idx) asm.(parse-args me syntax '(r n))
+ (cond
+ ((small-op-p src)
+ asm.(put-insn me.code (enc-small-op src) idx))
+ (t asm.(asm-one ^(mov t1 ,(operand-to-exp src)))
+ asm.(put-insn me.code (enc-small-op 1) idx)))))
+ (:method dis (me asm src idx)
+ ^(,me.symbol ,(operand-to-sym src) ,idx)))
+
(defun disassemble-cdf (code data funv *stdout*)
(let ((asm (new assembler buf code)))
(put-line "data:")