diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-03-25 06:50:11 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-03-25 06:50:11 -0700 |
commit | 7fe16da96f86fe39f3524c91226916975d112c9f (patch) | |
tree | 03ff8e94c5d48ca36e8724cca68420b3050cec77 /vm.c | |
parent | f8cb7daaeda643ddda3413fc3649920e8f232dc5 (diff) | |
download | txr-7fe16da96f86fe39f3524c91226916975d112c9f.tar.gz txr-7fe16da96f86fe39f3524c91226916975d112c9f.tar.bz2 txr-7fe16da96f86fe39f3524c91226916975d112c9f.zip |
vm: allow signals during vm execution.
I have experimented with several approaches, and found that
this one has an immeasurably small effect on performance,
below the noise floor.
* vm.c (vm_jmp): Call sig_check_fast whenever there is a
backwards branch.
(vm_execute): Check for signals once, on entry.
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -670,7 +670,10 @@ NOINLINE static void vm_movrr(struct vm *vm, vm_word_t insn) static void vm_jmp(struct vm *vm, vm_word_t insn) { - vm->ip = vm_insn_bigop(insn); + unsigned ip = vm_insn_bigop(insn); + if (ip < vm->ip) + sig_check_fast(); + vm->ip = ip; } NOINLINE static void vm_if(struct vm *vm, vm_word_t insn) @@ -944,6 +947,8 @@ NOINLINE static void vm_close(struct vm *vm, vm_word_t insn) NOINLINE static val vm_execute(struct vm *vm) { + sig_check_fast(); + for (;;) { vm_word_t insn = vm->code[vm->ip++]; vm_op_t opcode = vm_insn_opcode(insn); |