🐛 exec_check also needs CHECK_INTERRUPT

This commit is contained in:
ValKmjolnir 2025-02-05 17:56:57 +08:00
parent e405c3e6d4
commit 09cd3027e9
1 changed files with 11 additions and 10 deletions

View File

@ -569,15 +569,15 @@ void vm::run(const codegen& gen,
);
#ifndef _MSC_VER
// interrupt check macro for computed goto mode.
#define CHECK_INTERRUPT { \
if (interrupt_ptr && interrupt_ptr->load()) { \
throw std::runtime_error("VM execution interrupted by timeout"); \
} \
}
// using labels as values/computed goto
// Define an interrupt check macro for computed goto mode.
#define CHECK_INTERRUPT { \
if (interrupt_ptr && interrupt_ptr->load()) { \
throw std::runtime_error("VM execution interrupted by timeout"); \
} \
}
const void* oprs[] = {
&&vmexit,
&&repl,
@ -705,15 +705,16 @@ vmexit:
return;
#ifndef _MSC_VER
// may cause stackoverflow
// IR which may cause stackoverflow
#define exec_check(op) {\
op();\
CHECK_INTERRUPT;\
if (ctx.top<ctx.canary)\
goto *code[++ctx.pc];\
die("stack overflow");\
goto *code[++ctx.pc];\
}
// do not cause stackoverflow
// IR which does not cause stackoverflow
#define exec_nodie(op) {\
op();\
CHECK_INTERRUPT;\