Impossible to exit infinite while loop #197

fixed in JS
This commit is contained in:
BADIM-PC\Vadim 2017-12-20 14:42:34 +03:00
parent a60099a587
commit 0e997f5d33
2 changed files with 13 additions and 3 deletions

View File

@ -2817,7 +2817,7 @@ typedef struct duk_hthread duk_context;
#undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK #undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK
#undef DUK_USE_EXEC_PREFER_SIZE #undef DUK_USE_EXEC_PREFER_SIZE
#define DUK_USE_EXEC_REGCONST_OPTIMIZE #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_EXPLICIT_NULL_INIT
#undef DUK_USE_EXTSTR_FREE #undef DUK_USE_EXTSTR_FREE
#undef DUK_USE_EXTSTR_INTERN_CHECK #undef DUK_USE_EXTSTR_INTERN_CHECK
@ -2854,7 +2854,7 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_HTML_COMMENTS #define DUK_USE_HTML_COMMENTS
#define DUK_USE_IDCHAR_FASTPATH #define DUK_USE_IDCHAR_FASTPATH
#undef DUK_USE_INJECT_HEAP_ALLOC_ERROR #undef DUK_USE_INJECT_HEAP_ALLOC_ERROR
#undef DUK_USE_INTERRUPT_COUNTER #define DUK_USE_INTERRUPT_COUNTER
#undef DUK_USE_INTERRUPT_DEBUG_FIXUP #undef DUK_USE_INTERRUPT_DEBUG_FIXUP
#define DUK_USE_JC #define DUK_USE_JC
#define DUK_USE_JSON_BUILTIN #define DUK_USE_JSON_BUILTIN
@ -2933,6 +2933,8 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_VOLUNTARY_GC #define DUK_USE_VOLUNTARY_GC
#define DUK_USE_ZERO_BUFFER_DATA #define DUK_USE_ZERO_BUFFER_DATA
int duk_timeout_check(void*);
/* /*
* You may add overriding #define/#undef directives below for * You may add overriding #define/#undef directives below for
* customization. You of course cannot un-#include or un-typedef * customization. You of course cannot un-#include or un-typedef

View File

@ -755,11 +755,19 @@ static const struct{duk_c_function func; s32 params;} ApiFunc[] =
{duk_sync, 3}, {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) static void initDuktape(tic_machine* machine)
{ {
closeJavascript(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); duk_push_global_stash(duk);