summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-03-25 06:50:11 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-03-25 06:50:11 -0700
commit9bc89dcc1e9590a42a9d5bbd982321726f4f38f6 (patch)
tree03ff8e94c5d48ca36e8724cca68420b3050cec77
parentbe4768a9802bb7f7ab044935551e9ee12eefcf1b (diff)
downloadtxr-9bc89dcc1e9590a42a9d5bbd982321726f4f38f6.tar.gz
txr-9bc89dcc1e9590a42a9d5bbd982321726f4f38f6.tar.bz2
txr-9bc89dcc1e9590a42a9d5bbd982321726f4f38f6.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.
-rw-r--r--vm.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/vm.c b/vm.c
index 3fc03d68..da06d156 100644
--- a/vm.c
+++ b/vm.c
@@ -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);