Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions deps/quickjs-release.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
QUICKJS_NG_REPO="quickjs-ng/quickjs"
QUICKJS_NG_TAG="v0.15.0"
QUICKJS_NG_TARBALL_URL="https://api.github.com/repos/quickjs-ng/quickjs/tarball/v0.15.0"
QUICKJS_NG_RELEASE_URL="https://github.com/quickjs-ng/quickjs/releases/tag/v0.15.0"
QUICKJS_NG_RELEASED_AT="2026-05-21T20:51:23Z"
QUICKJS_NG_TAG="v0.15.1"
QUICKJS_NG_TARBALL_URL="https://api.github.com/repos/quickjs-ng/quickjs/tarball/v0.15.1"
QUICKJS_NG_RELEASE_URL="https://github.com/quickjs-ng/quickjs/releases/tag/v0.15.1"
QUICKJS_NG_RELEASED_AT="2026-06-04T14:57:07Z"
1 change: 1 addition & 0 deletions deps/quickjs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ endif()

if(QJS_BUILD_CLI_WITH_MIMALLOC OR QJS_BUILD_CLI_WITH_STATIC_MIMALLOC)
find_package(mimalloc REQUIRED)
target_compile_definitions(qjs_exe PRIVATE QJS_USE_MIMALLOC)
# Upstream mimalloc doesn't provide a way to know if both libraries are supported.
if(QJS_BUILD_CLI_WITH_STATIC_MIMALLOC)
target_link_libraries(qjs_exe PRIVATE mimalloc-static)
Expand Down
63 changes: 63 additions & 0 deletions deps/quickjs/api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,68 @@ static void immutable_array_buffer(void)
JS_FreeRuntime(rt);
}

static void *sab_test_alloc(void *opaque, size_t size)
{
return malloc(size);
}

static void sab_test_free(void *opaque, void *ptr)
{
free(ptr);
}

static void shared_array_buffer_growth(void)
{
JSRuntime *rt = new_runtime();
JSContext *ctx = JS_NewContext(rt);
JSValue ret, exception;

ret = eval(ctx, "new SharedArrayBuffer(16)");
assert(!JS_IsException(ret));
JS_FreeValue(ctx, ret);

ret = eval(ctx,
"const sab = new SharedArrayBuffer(16, { maxByteLength: 16 });"
"sab.grow(16);"
"sab.byteLength === 16 && sab.maxByteLength === 16");
assert(!JS_IsException(ret));
assert(JS_IsBool(ret));
assert(JS_VALUE_GET_BOOL(ret));
JS_FreeValue(ctx, ret);

ret = eval(ctx, "new SharedArrayBuffer(16, { maxByteLength: 16384 })");
assert(JS_IsException(ret));
assert(JS_HasException(ctx));
exception = JS_GetException(ctx);
assert(JS_IsError(exception));
JS_FreeValue(ctx, exception);

JS_FreeContext(ctx);
JS_FreeRuntime(rt);

JSSharedArrayBufferFunctions funcs = {
.sab_alloc = sab_test_alloc,
.sab_free = sab_test_free,
.sab_dup = NULL,
.sab_opaque = NULL,
};

rt = new_runtime();
JS_SetSharedArrayBufferFunctions(rt, &funcs);
ctx = JS_NewContext(rt);
ret = eval(ctx,
"const sab = new SharedArrayBuffer(16, { maxByteLength: 16384 });"
"const u8 = new Uint8Array(sab);"
"sab.grow(16384);"
"u8[1024] === 0 && u8.byteLength === 16384");
assert(!JS_IsException(ret));
assert(JS_IsBool(ret));
assert(JS_VALUE_GET_BOOL(ret));
JS_FreeValue(ctx, ret);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
}

static void get_uint8array(void)
{
JSRuntime *rt = new_runtime();
Expand Down Expand Up @@ -1088,6 +1150,7 @@ int main(void)
global_object_prototype();
slice_string_tocstring();
immutable_array_buffer();
shared_array_buffer_growth();
get_uint8array();
new_symbol();
return 0;
Expand Down
4 changes: 4 additions & 0 deletions deps/quickjs/docs/docs/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ Golang bindings for QuickJS-NG using cgo
## [Nordstjernen](https://github.com/nordstjernen-web/nordstjernen)

Nordstjernen web browser.

## [quickjs-cpp](https://github.com/qr243vbi/quickjs-cpp)

Header only library for quickjs-ng with modern C++ interface.
2 changes: 1 addition & 1 deletion deps/quickjs/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'quickjs-ng',
'c',
version: '0.15.0',
version: '0.15.1',
default_options: [
'c_std=gnu11,c11',
'warning_level=3',
Expand Down
16 changes: 10 additions & 6 deletions deps/quickjs/qjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,12 @@ static const JSMallocFunctions mi_mf = {

#define PROG_NAME "qjs"

void help(void)
void help(int exit_status)
{
printf("QuickJS-ng version %s\n"
"usage: " PROG_NAME " [options] [file [args]]\n"
"-h --help list options\n"
"-v --version print version string and then exit\n"
"-e --eval EXPR evaluate EXPR\n"
"-i --interactive go to interactive mode\n"
"-C --script load as JS classic script (default=autodetect)\n"
Expand All @@ -392,7 +393,7 @@ void help(void)
" --memory-limit n limit the memory usage to 'n' Kbytes\n"
" --stack-size n limit the stack size to 'n' Kbytes\n"
"-q --quit just instantiate the interpreter and quit\n", JS_GetVersion());
exit(1);
exit(exit_status);
}

int main(int argc, char **argv)
Expand Down Expand Up @@ -465,8 +466,11 @@ int main(int argc, char **argv)
optarg = arg;
}
if (opt == 'h' || opt == '?' || !strcmp(longopt, "help")) {
help();
continue;
help(0);
}
if (opt == 'v' || !strcmp(longopt, "version")) {
printf("%s\n",JS_GetVersion());
return 0;
}
if (opt == 'e' || !strcmp(longopt, "eval")) {
if (!optarg) {
Expand Down Expand Up @@ -583,12 +587,12 @@ int main(int argc, char **argv)
} else {
fprintf(stderr, "qjs: unknown option '--%s'\n", longopt);
}
help();
help(1);
}
}

if (compile_file && !out)
help();
help(1);

start:

Expand Down
43 changes: 31 additions & 12 deletions deps/quickjs/quickjs-libc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4720,22 +4720,41 @@ static void js_dump_obj(JSContext *ctx, FILE *f, JSValueConst val)
}
}

#define JS_DUMP_ERROR_MAX_CAUSE_DEPTH 10

static void js_std_dump_error1(JSContext *ctx, JSValueConst exception_val)
{
JSValue val;
JSValue val, current;
bool is_error;

is_error = JS_IsError(exception_val);
js_dump_obj(ctx, stderr, exception_val);
if (is_error) {
val = JS_GetPropertyStr(ctx, exception_val, "stack");
} else {
js_std_cmd(/*ErrorBackTrace*/2, ctx, &val);
}
if (!JS_IsUndefined(val)) {
js_dump_obj(ctx, stderr, val);
JS_FreeValue(ctx, val);
int depth;

current = JS_DupValue(ctx, exception_val);
for (depth = 0; ; depth++) {
is_error = JS_IsError(current);
js_dump_obj(ctx, stderr, current);
if (is_error) {
val = JS_GetPropertyStr(ctx, current, "stack");
} else if (depth == 0) {
js_std_cmd(/*ErrorBackTrace*/2, ctx, &val);
} else {
val = JS_UNDEFINED;
}
if (!JS_IsUndefined(val)) {
js_dump_obj(ctx, stderr, val);
JS_FreeValue(ctx, val);
}
if (!is_error || depth >= JS_DUMP_ERROR_MAX_CAUSE_DEPTH)
break;
val = JS_GetPropertyStr(ctx, current, "cause");
if (JS_IsUndefined(val)) {
JS_FreeValue(ctx, val);
break;
}
Comment thread
buke marked this conversation as resolved.
fputs("Caused by: ", stderr);
JS_FreeValue(ctx, current);
current = val;
}
JS_FreeValue(ctx, current);
}

void js_std_dump_error(JSContext *ctx)
Expand Down
7 changes: 7 additions & 0 deletions deps/quickjs/quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -57748,6 +57748,13 @@ static JSValue js_array_buffer_constructor3(JSContext *ctx,
JS_ThrowRangeError(ctx, "invalid max array buffer length");
goto fail;
}
if (alloc_flag && class_id == JS_CLASS_SHARED_ARRAY_BUFFER && max_len &&
*max_len > len && !rt->sab_funcs.sab_alloc) {
JS_ThrowTypeError(ctx,
"growable SharedArrayBuffer requires "
"SAB allocator hooks");
goto fail;
}
abuf = js_malloc(ctx, sizeof(*abuf));
if (!abuf)
goto fail;
Expand Down
2 changes: 1 addition & 1 deletion deps/quickjs/quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ JS_EXTERN int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m,

#define QJS_VERSION_MAJOR 0
#define QJS_VERSION_MINOR 15
#define QJS_VERSION_PATCH 0
#define QJS_VERSION_PATCH 1
#define QJS_VERSION_SUFFIX ""

JS_EXTERN const char* JS_GetVersion(void);
Expand Down
Loading