diff options
author | bellard <6490144+bellard@users.noreply.github.com> | 2020-09-06 19:07:30 +0200 |
---|---|---|
committer | bellard <6490144+bellard@users.noreply.github.com> | 2020-09-06 19:07:30 +0200 |
commit | 89007660998db0ee55f0ab3b34bb1a84f86fd3c4 (patch) | |
tree | 84311e5628175a91035ac2a62b16726650f2b62e /qjs.c | |
parent | 1722758717730ac0838418f142d82ca3cff4ad4b (diff) | |
download | quickjs-89007660998db0ee55f0ab3b34bb1a84f86fd3c4.tar.gz quickjs-89007660998db0ee55f0ab3b34bb1a84f86fd3c4.zip |
2020-07-05 release
Diffstat (limited to 'qjs.c')
-rw-r--r-- | qjs.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -270,6 +270,7 @@ void help(void) "-T --trace trace memory allocation\n" "-d --dump dump the memory usage stats\n" " --memory-limit n limit the memory usage to 'n' bytes\n" + " --stack-size n limit the stack size to 'n' bytes\n" " --unhandled-rejection dump unhandled promise rejections\n" "-q --quit just instantiate the interpreter and quit\n"); exit(1); @@ -295,7 +296,8 @@ int main(int argc, char **argv) #ifdef CONFIG_BIGNUM int load_jscalc, bignum_ext = 0; #endif - + size_t stack_size = 0; + #ifdef CONFIG_BIGNUM /* load jscalc runtime if invoked as 'qjscalc' */ { @@ -407,6 +409,14 @@ int main(int argc, char **argv) memory_limit = (size_t)strtod(argv[optind++], NULL); continue; } + if (!strcmp(longopt, "stack-size")) { + if (optind >= argc) { + fprintf(stderr, "expecting stack size"); + exit(1); + } + stack_size = (size_t)strtod(argv[optind++], NULL); + continue; + } if (opt) { fprintf(stderr, "qjs: unknown option '-%c'\n", opt); } else { @@ -428,6 +438,9 @@ int main(int argc, char **argv) } if (memory_limit != 0) JS_SetMemoryLimit(rt, memory_limit); + if (stack_size != 0) + JS_SetMaxStackSize(rt, stack_size); + js_std_init_handlers(rt); ctx = JS_NewContext(rt); if (!ctx) { fprintf(stderr, "qjs: cannot allocate JS context\n"); |