Skip to content
Merged
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
40 changes: 11 additions & 29 deletions c/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@
#define IntrinsicsFlags enum QTS_Intrinsic
#define EvalDetectModule int

// Forward declarations for EM_JS callback functions
// These are implemented via EM_JS macro but need forward declarations for C99 compliance
#ifdef __EMSCRIPTEN__
JSValue *qts_host_call_function(JSContext *ctx, JSValueConst *this_ptr, int argc, JSValueConst *argv, uint32_t magic_func_id);
int qts_host_interrupt_handler(JSRuntime *rt);
char *qts_host_load_module_source(JSRuntime *rt, JSContext *ctx, const char *module_name);
char *qts_host_normalize_module(JSRuntime *rt, JSContext *ctx, const char *module_base_name, const char *module_name);
#endif

typedef struct qts_RuntimeData {
bool debug_log;
} qts_RuntimeData;
Expand Down Expand Up @@ -319,10 +328,6 @@ enum QTS_Intrinsic {
QTS_Intrinsic_TypedArrays = 1 << 9,
QTS_Intrinsic_Promise = 1 << 10,
QTS_Intrinsic_BigInt = 1 << 11,
QTS_Intrinsic_BigFloat = 1 << 12,
QTS_Intrinsic_BigDecimal = 1 << 13,
QTS_Intrinsic_OperatorOverloading = 1 << 14,
QTS_Intrinsic_BignumExt = 1 << 15,
};

JSContext *QTS_NewContext(JSRuntime *rt, IntrinsicsFlags intrinsics) {
Expand Down Expand Up @@ -370,24 +375,7 @@ JSContext *QTS_NewContext(JSRuntime *rt, IntrinsicsFlags intrinsics) {
if (intrinsics & QTS_Intrinsic_Promise) {
JS_AddIntrinsicPromise(ctx);
}
if (intrinsics & QTS_Intrinsic_BigInt) {
JS_AddIntrinsicBigInt(ctx);
}
#ifdef CONFIG_BIGNUM
if (intrinsics & QTS_Intrinsic_BigFloat) {
JS_AddIntrinsicBigFloat(ctx);
}
if (intrinsics & QTS_Intrinsic_BigDecimal) {
JS_AddIntrinsicBigDecimal(ctx);
}
if (intrinsics & QTS_Intrinsic_BignumExt) {
JS_EnableBignumExt(ctx, TRUE);
}
if (intrinsics & QTS_Intrinsic_OperatorOverloading) {
JS_AddIntrinsicOperators(ctx);
}
#endif

// Note: BigInt is now always part of QuickJS core, no need for separate intrinsic
return ctx;
}

Expand Down Expand Up @@ -809,7 +797,7 @@ MaybeAsync(JSValue *) QTS_Eval(JSContext *ctx, BorrowedHeapChar *js_code, size_t
}

IF_DEBUG {
snprintf(msg, LOG_LEN, "QTS_Eval: eval_result = %d", eval_result);
snprintf(msg, LOG_LEN, "QTS_Eval: eval_result = %d", JS_VALUE_GET_TAG(eval_result));
qts_log(msg);
}

Expand Down Expand Up @@ -896,12 +884,6 @@ OwnedHeapChar *QTS_Typeof(JSContext *ctx, JSValueConst *value) {
result = "number";
} else if (JS_IsBigInt(ctx, *value)) {
result = "bigint";
#ifdef CONFIG_BIGNUM
} else if (JS_IsBigFloat(*value)) {
result = "bigfloat";
} else if (JS_IsBigDecimal(*value)) {
result = "bigdecimal";
#endif
} else if (JS_IsFunction(ctx, *value)) {
result = "function";
} else if (JS_IsBool(*value)) {
Expand Down
6 changes: 4 additions & 2 deletions doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This variant was built with the following settings:

The original [bellard/quickjs](https://github.com/bellard/quickjs) library.

Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15.
Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15.

## Release mode: release

Expand Down Expand Up @@ -61,6 +61,7 @@ Full variant JSON description:
"syncMode": "sync",
"description": "Compiled to pure Javascript, no WebAssembly required.",
"emscriptenInclusion": "asmjs",
"emscriptenVersion": "3.1.43",
"exports": {
"import": {
"emscriptenEnvironment": ["web", "worker", "node"]
Expand All @@ -80,7 +81,8 @@ Variant-specific Emscripten build flags:
"--pre-js $(TEMPLATES)/pre-extension.js",
"--pre-js $(TEMPLATES)/pre-wasmMemory.js",
"-s WASM=0",
"-s SINGLE_FILE=1"
"-s SINGLE_FILE=1",
"-s WASM_ASYNC_COMPILATION=0"
]
```

Expand Down
2 changes: 1 addition & 1 deletion doc/@jitl/quickjs-asmjs-mjs-release-sync/exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Compiled to pure Javascript, no WebAssembly required.

| Variable | Setting | Description |
| -- | -- | -- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15. |
| releaseMode | release | Optimized for performance; use when building/deploying your application. |
| syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
| emscriptenInclusion | asmjs | The C library code is compiled to Javascript, no WebAssembly used. Sometimes called "asmjs". This is the slowest possible option, and is intended for constrained environments that do not support WebAssembly, like quickjs-for-quickjs. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This variant was built with the following settings:

The original [bellard/quickjs](https://github.com/bellard/quickjs) library.

Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15.
Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15.

## Release mode: debug

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Variant with the WASM data embedded into a browser ESModule.

| Variable | Setting | Description |
| -- | -- | -- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15. |
| releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
| syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The [QuickJSAsyncRuntime](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md) and [QuickJSAsyncContext](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md) classes expose the ASYNCIFY-specific APIs. |
| emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
Expand Down
2 changes: 1 addition & 1 deletion doc/@jitl/quickjs-singlefile-browser-debug-sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This variant was built with the following settings:

The original [bellard/quickjs](https://github.com/bellard/quickjs) library.

Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15.
Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15.

## Release mode: debug

Expand Down
2 changes: 1 addition & 1 deletion doc/@jitl/quickjs-singlefile-browser-debug-sync/exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Variant with the WASM data embedded into a browser ESModule.

| Variable | Setting | Description |
| -- | -- | -- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15. |
| releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
| syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
| emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This variant was built with the following settings:

The original [bellard/quickjs](https://github.com/bellard/quickjs) library.

Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15.
Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15.

## Release mode: release

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Variant with the WASM data embedded into a browser ESModule.

| Variable | Setting | Description |
| -- | -- | -- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15. |
| releaseMode | release | Optimized for performance; use when building/deploying your application. |
| syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The [QuickJSAsyncRuntime](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md) and [QuickJSAsyncContext](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md) classes expose the ASYNCIFY-specific APIs. |
| emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This variant was built with the following settings:

The original [bellard/quickjs](https://github.com/bellard/quickjs) library.

Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15.
Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15.

## Release mode: release

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Variant with the WASM data embedded into a browser ESModule.

| Variable | Setting | Description |
| -- | -- | -- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15. |
| releaseMode | release | Optimized for performance; use when building/deploying your application. |
| syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
| emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
Expand Down
2 changes: 1 addition & 1 deletion doc/@jitl/quickjs-singlefile-cjs-debug-asyncify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This variant was built with the following settings:

The original [bellard/quickjs](https://github.com/bellard/quickjs) library.

Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15.
Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15.

## Release mode: debug

Expand Down
2 changes: 1 addition & 1 deletion doc/@jitl/quickjs-singlefile-cjs-debug-asyncify/exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Variant with the WASM data embedded into a universal (Node and Browser compatibl

| Variable | Setting | Description |
| -- | -- | -- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15. |
| releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
| syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The [QuickJSAsyncRuntime](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md) and [QuickJSAsyncContext](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md) classes expose the ASYNCIFY-specific APIs. |
| emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
Expand Down
2 changes: 1 addition & 1 deletion doc/@jitl/quickjs-singlefile-cjs-debug-sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This variant was built with the following settings:

The original [bellard/quickjs](https://github.com/bellard/quickjs) library.

Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15.
Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15.

## Release mode: debug

Expand Down
2 changes: 1 addition & 1 deletion doc/@jitl/quickjs-singlefile-cjs-debug-sync/exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Variant with the WASM data embedded into a universal (Node and Browser compatibl

| Variable | Setting | Description |
| -- | -- | -- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15. |
| releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
| syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
| emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This variant was built with the following settings:

The original [bellard/quickjs](https://github.com/bellard/quickjs) library.

Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15.
Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15.

## Release mode: release

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Variant with the WASM data embedded into a universal (Node and Browser compatibl

| Variable | Setting | Description |
| -- | -- | -- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15. |
| releaseMode | release | Optimized for performance; use when building/deploying your application. |
| syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The [QuickJSAsyncRuntime](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md) and [QuickJSAsyncContext](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md) classes expose the ASYNCIFY-specific APIs. |
| emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
Expand Down
Loading
Loading