diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-03-18 21:58:52 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-03-18 21:58:52 -0700 |
commit | ead6bfb544e95509e6cd1364ec2fd95d88683b33 (patch) | |
tree | 3931a5aeb25dcacd0cc5ccae43bcc9850743a42e /vmop.h | |
parent | cb107336fa2bfd2cf7f548bf82e0ff1d1484de21 (diff) | |
download | txr-ead6bfb544e95509e6cd1364ec2fd95d88683b33.tar.gz txr-ead6bfb544e95509e6cd1364ec2fd95d88683b33.tar.bz2 txr-ead6bfb544e95509e6cd1364ec2fd95d88683b33.zip |
vm: function table for faster calls.
The vm now supports gcall and gapply opcodes which index
numerically (using an immediate integer field in the
instruction word) into a table of pre-resolved global function
bindings.
* share/txr/stdlib/asm.tl (op-gcall, op-gapply): New opcodes.
(disassemble-c-d): Take the function vector as an argument and
dump it too.
(usr:disassemble): Extract function vector from VM description
and pass it to disassemble-c-d.
* share/txr/stdlib/compiler.tl (usr:compile-toplevel): Pass
empty function symbol vector to vm-make-desc; it's now a
required argument.
* vm.c (struct vm_desc): New members funvec and ftab.
(struct vm_ftent): New struct type.
(vm_make_desc): New argument, funvec. Store funvec in the
descriptor. Allocate a table of vm_ftent structures equal in
number of elements to the function table, and populate it with
resolved bindings.
(vm_desc_funvec, vm_desc_destroy): New static functions.
(vm_desc_mark): Mark the captured bindings in vd->ftab.
(vm_gcall, vm_gapply): New static functions.
(vm_execute): Handle GCALL and GAPPLY opcodes.
(vm_desc_ops): Wire vm_desc_destroy in place of
cobj_destroy_free_op.
(vm_init): Add argument to vm-make-desc intrinsic. Register
vm-desc-funvec intrinsic.
* vm.h (vm_make_desc): Declaration updated.
* vmop.h: Regenerated
Diffstat (limited to 'vmop.h')
-rw-r--r-- | vmop.h | 56 |
1 files changed, 29 insertions, 27 deletions
@@ -34,31 +34,33 @@ typedef enum vm_op { FIN = 5, CALL = 6, APPLY = 7, - MOVRS = 8, - MOVSR = 9, - MOVRR = 10, - MOVRSI = 11, - MOVSMI = 12, - MOVRBI = 13, - JMP = 14, - IF = 15, - IFQ = 16, - IFQL = 17, - UWPROT = 18, - BLOCK = 19, - RETSR = 20, - RETRS = 21, - RETRR = 22, - CATCH = 23, - HANDLE = 24, - GETV = 25, - GETF = 26, - GETL1 = 27, - GETVB = 28, - GETFB = 29, - GETL1B = 30, - SETV = 31, - SETL1 = 32, - BINDV = 33, - CLOSE = 34, + GCALL = 8, + GAPPLY = 9, + MOVRS = 10, + MOVSR = 11, + MOVRR = 12, + MOVRSI = 13, + MOVSMI = 14, + MOVRBI = 15, + JMP = 16, + IF = 17, + IFQ = 18, + IFQL = 19, + UWPROT = 20, + BLOCK = 21, + RETSR = 22, + RETRS = 23, + RETRR = 24, + CATCH = 25, + HANDLE = 26, + GETV = 27, + GETF = 28, + GETL1 = 29, + GETVB = 30, + GETFB = 31, + GETL1B = 32, + SETV = 33, + SETL1 = 34, + BINDV = 35, + CLOSE = 36, } vm_op_t; |