mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Use 1 MB as the default stack size
In addition: - Move the WASI override to quickjs.c - Allow it to be user defined Ref: https://github.com/quickjs-ng/quickjs/issues/749#issuecomment-2540167690
This commit is contained in:
parent
374915ad0c
commit
be2db73000
4 changed files with 7 additions and 8 deletions
|
@ -3636,7 +3636,7 @@ static JSValue js_worker_ctor(JSContext *ctx, JSValue new_target,
|
||||||
/* no join at the end */
|
/* no join at the end */
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
// musl libc gives threads 80 kb stacks, much smaller than
|
// musl libc gives threads 80 kb stacks, much smaller than
|
||||||
// JS_DEFAULT_STACK_SIZE (256 kb)
|
// JS_DEFAULT_STACK_SIZE (1 MB)
|
||||||
pthread_attr_setstacksize(&attr, 2 << 20); // 2 MB, glibc default
|
pthread_attr_setstacksize(&attr, 2 << 20); // 2 MB, glibc default
|
||||||
ret = pthread_create(&tid, &attr, worker_func, args);
|
ret = pthread_create(&tid, &attr, worker_func, args);
|
||||||
pthread_attr_destroy(&attr);
|
pthread_attr_destroy(&attr);
|
||||||
|
|
|
@ -1843,9 +1843,10 @@ JSRuntime *JS_NewRuntime2(const JSMallocFunctions *mf, void *opaque)
|
||||||
rt->js_class_id_alloc = JS_CLASS_INIT_COUNT;
|
rt->js_class_id_alloc = JS_CLASS_INIT_COUNT;
|
||||||
|
|
||||||
rt->stack_size = JS_DEFAULT_STACK_SIZE;
|
rt->stack_size = JS_DEFAULT_STACK_SIZE;
|
||||||
#ifdef __ASAN__
|
#ifdef __wasi__
|
||||||
rt->stack_size *= 2; // stack frames are bigger under AddressSanitizer
|
rt->stack_size = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JS_UpdateStackTop(rt);
|
JS_UpdateStackTop(rt);
|
||||||
|
|
||||||
rt->current_exception = JS_UNINITIALIZED;
|
rt->current_exception = JS_UNINITIALIZED;
|
||||||
|
|
|
@ -280,10 +280,8 @@ static inline JS_BOOL JS_VALUE_IS_NAN(JSValue v)
|
||||||
#define JS_PROP_DEFINE_PROPERTY (1 << 18) /* internal use */
|
#define JS_PROP_DEFINE_PROPERTY (1 << 18) /* internal use */
|
||||||
#define JS_PROP_REFLECT_DEFINE_PROPERTY (1 << 19) /* internal use */
|
#define JS_PROP_REFLECT_DEFINE_PROPERTY (1 << 19) /* internal use */
|
||||||
|
|
||||||
#if defined(__wasi__)
|
#ifndef JS_DEFAULT_STACK_SIZE
|
||||||
#define JS_DEFAULT_STACK_SIZE 0
|
#define JS_DEFAULT_STACK_SIZE (1024 * 1024)
|
||||||
#else
|
|
||||||
#define JS_DEFAULT_STACK_SIZE (256 * 1024)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* JS_Eval() flags */
|
/* JS_Eval() flags */
|
||||||
|
|
|
@ -515,7 +515,7 @@ static JSValue js_evalScript_262(JSContext *ctx, JSValue this_val,
|
||||||
static void start_thread(js_thread_t *thrd, void *(*start)(void *), void *arg)
|
static void start_thread(js_thread_t *thrd, void *(*start)(void *), void *arg)
|
||||||
{
|
{
|
||||||
// musl libc gives threads 80 kb stacks, much smaller than
|
// musl libc gives threads 80 kb stacks, much smaller than
|
||||||
// JS_DEFAULT_STACK_SIZE (256 kb)
|
// JS_DEFAULT_STACK_SIZE (1 MB)
|
||||||
static const unsigned stacksize = 2 << 20; // 2 MB, glibc default
|
static const unsigned stacksize = 2 << 20; // 2 MB, glibc default
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE h, cp;
|
HANDLE h, cp;
|
||||||
|
|
Loading…
Reference in a new issue