summaryrefslogtreecommitdiffstats
path: root/vm.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-03-27 19:58:55 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-03-27 19:58:55 -0700
commit2ebb3a32d4afa367712f0291b2ca517cba711529 (patch)
tree1efe94cb89e7e491e18b94333b100252352339fa /vm.c
parent5e57a1502ec05156d4455b91e452b38c0dc482b4 (diff)
downloadtxr-2ebb3a32d4afa367712f0291b2ca517cba711529.tar.gz
txr-2ebb3a32d4afa367712f0291b2ca517cba711529.tar.bz2
txr-2ebb3a32d4afa367712f0291b2ca517cba711529.zip
vm/asm: new prof instruction.
* share/txr/stdlib/asm.tl (prof): New opcode. (op-prof): New opcode class. * vm.c (vm_prof_callback, vm_prof): New static functions. (vm_execute): Handle PROF opcode via vm_prof. * vmop.h: Regenerated.
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index cc1df792..e5489c2c 100644
--- a/vm.c
+++ b/vm.c
@@ -332,6 +332,19 @@ static void vm_do_frame(struct vm *vm, vm_word_t insn, int capturable)
vm->lev = lev - 1;
}
+static val vm_prof_callback(mem_t *ctx)
+{
+ struct vm *vm = coerce(struct vm *, ctx);
+ return vm_execute(vm);
+}
+
+static void vm_prof(struct vm *vm, vm_word_t insn)
+{
+ unsigned dest = vm_insn_operand(insn);
+ val result = prof_call(vm_prof_callback, coerce(mem_t *, vm));
+ vm_set(vm->dspl, dest, result);
+}
+
static void vm_frame(struct vm *vm, vm_word_t insn)
{
vm_do_frame(vm, insn, 1);
@@ -822,6 +835,9 @@ static val vm_execute(struct vm *vm)
return vm_end(vm, insn);
case FIN:
return vm_fin(vm, insn);
+ case PROF:
+ vm_prof(vm, insn);
+ break;
case CALL:
vm_call(vm, insn);
break;