diff --git a/src/ext/duktape/duk_config.h b/src/ext/duktape/duk_config.h index df25012..6786810 100644 --- a/src/ext/duktape/duk_config.h +++ b/src/ext/duktape/duk_config.h @@ -2817,7 +2817,7 @@ typedef struct duk_hthread duk_context; #undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK #undef DUK_USE_EXEC_PREFER_SIZE #define DUK_USE_EXEC_REGCONST_OPTIMIZE -#undef DUK_USE_EXEC_TIMEOUT_CHECK +#define DUK_USE_EXEC_TIMEOUT_CHECK duk_timeout_check #undef DUK_USE_EXPLICIT_NULL_INIT #undef DUK_USE_EXTSTR_FREE #undef DUK_USE_EXTSTR_INTERN_CHECK @@ -2854,7 +2854,7 @@ typedef struct duk_hthread duk_context; #define DUK_USE_HTML_COMMENTS #define DUK_USE_IDCHAR_FASTPATH #undef DUK_USE_INJECT_HEAP_ALLOC_ERROR -#undef DUK_USE_INTERRUPT_COUNTER +#define DUK_USE_INTERRUPT_COUNTER #undef DUK_USE_INTERRUPT_DEBUG_FIXUP #define DUK_USE_JC #define DUK_USE_JSON_BUILTIN @@ -2933,6 +2933,8 @@ typedef struct duk_hthread duk_context; #define DUK_USE_VOLUNTARY_GC #define DUK_USE_ZERO_BUFFER_DATA +int duk_timeout_check(void*); + /* * You may add overriding #define/#undef directives below for * customization. You of course cannot un-#include or un-typedef diff --git a/src/jsapi.c b/src/jsapi.c index 58f7457..930d1b0 100644 --- a/src/jsapi.c +++ b/src/jsapi.c @@ -755,11 +755,19 @@ static const struct{duk_c_function func; s32 params;} ApiFunc[] = {duk_sync, 3}, }; +s32 duk_timeout_check(void* udata) +{ + tic_machine* machine = (tic_machine*)udata; + tic_tick_data* tick = machine->data; + + return tick->forceExit && tick->forceExit(tick->data); +} + static void initDuktape(tic_machine* machine) { closeJavascript(machine); - duk_context* duk = machine->js = duk_create_heap_default(); + duk_context* duk = machine->js = duk_create_heap(NULL, NULL, NULL, machine, NULL); { duk_push_global_stash(duk);