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 /vm.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 'vm.h')
-rw-r--r-- | vm.h | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -25,7 +25,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -val vm_make_desc(val nlevels, val nregs, val bytecode, val datavec); +val vm_make_desc(val nlevels, val nregs, val bytecode, + val datavec, val funvec); val vm_execute_toplevel(val desc); val vm_execute_closure(val fun, struct args *); void vm_init(void); |