From 2ebb3a32d4afa367712f0291b2ca517cba711529 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 27 Mar 2018 19:58:55 -0700 Subject: 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. --- vm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'vm.c') 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; -- cgit v1.2.3