Commit graph

556 commits

Author SHA1 Message Date
zeromake
902cc2cf0e
Add native module support on Windows 2024-09-10 22:47:40 +02:00
Saúl Ibarra Corretgé
ada24f33f3
Make a RelWithDebInfo build when testing with ASAN in the CI
Traces should be more useful if we keep debug data in.
2024-09-10 22:19:36 +02:00
Saúl Ibarra Corretgé
7ad980704c Report async failures via exit code
Fixes: https://github.com/quickjs-ng/quickjs/issues/340
2024-09-10 21:42:01 +02:00
Saúl Ibarra Corretgé
5bf35450cd Use an integer as the timer handle
Port of
9e561d5c2e
but adapted.
2024-09-09 23:42:53 +02:00
Saúl Ibarra Corretgé
54afb19745 Make the timeout test more resilient
Since we don't keep timers sorted by deadline but by insertion order,
the test is flaky in slow environments (GHA seemingly). Increase the
timeouts to give it a bigger chance of success.

ASan / UBSan builds are notoriously slow, so skip the test in those.
2024-09-09 22:42:51 +02:00
Saúl Ibarra Corretgé
194c45c4b5 Include winsock2.h before windows.h
Fixes a compilation warning.
2024-09-09 22:41:47 +02:00
Saúl Ibarra Corretgé
3ae4c0764f Mark non-exported functions as static
MSVC throws a warning.
2024-09-09 22:41:47 +02:00
Ben Noordhuis
b751ed5026
Add Set.prototype.intersection (#511) 2024-09-09 22:08:24 +02:00
Ben Noordhuis
6ba2448751
Add Set.prototype.symmetricDifference (#507) 2024-09-09 19:39:30 +02:00
Saúl Ibarra Corretgé
61c8fe6fb0 Run FinalizationRegistry callback in the job queue
The spec says HostMakeJobCallback has to be used on the callback: https://tc39.es/ecma262/multipage/managing-memory.html#sec-finalization-registry-cleanup-callback

That makes the following (arguably contrived) example run forever until
memory is exhausted.

```js
let count = 0;
function main() {
    console.log(`main! ${++count}`);
    const registry = new FinalizationRegistry(() => {
        globalThis.foo = main();
    });
    registry.register([]);
    registry.register([]);
    return registry;
}
main();

console.log(count);
```

That is unlike V8, which runs 0 times. This can be explained by the
difference in GC implementations and since FinRec makes GC observable,
here we are!

Fixes: https://github.com/quickjs-ng/quickjs/issues/432
2024-09-09 11:32:36 +02:00
Saúl Ibarra Corretgé
c740aa07c1 Fix zero-length gnu_printf format string warning
```
src/quickjs/quickjs.c: In function ‘JS_ReadString’:
src/quickjs/quickjs.c:34274:26: warning: zero-length gnu_printf format string [-Wformat-zero-length]
34274 |         bc_read_trace(s, "");  // hex dump and indentation
      |                          ^~
src/quickjs/quickjs.c: In function ‘JS_ReadFunctionBytecode’:
src/quickjs/quickjs.c:34334:30: warning: zero-length gnu_printf format string [-Wformat-zero-length]
34334 |             bc_read_trace(s, "");   // hex dump + indent
```

Ref: https://github.com/quickjs-ng/quickjs/issues/502
2024-09-09 11:18:02 +02:00
Saúl Ibarra Corretgé
ad834a1445 Fix Error.prepareStackTrace tests on Windows
- Reset state before doing assertions since they also throw errors
- Make the path check independent of the path separator
2024-09-08 21:50:20 +02:00
Ben Noordhuis
7513260d9a
Add Set.prototype.difference (#504) 2024-09-07 09:44:55 +02:00
Saúl Ibarra Corretgé
da591954a8 Add ability to specify dump flags with an env variable
Useful for CI for example.
2024-09-06 23:52:54 +02:00
Saúl Ibarra Corretgé
89d9305582 Fix DUMP_MODULE_RESOLVE flag checks
Make sure to always check if the flag is enabled.
2024-09-06 23:19:47 +02:00
Saúl Ibarra Corretgé
b5d2210096 Document -D/--dump-flags in CLI output 2024-09-06 23:19:11 +02:00
Ben Noordhuis
8e81a88a18
Add Set.prototype.union (#499) 2024-09-06 09:24:21 +02:00
Saúl Ibarra Corretgé
77884360d6 Silence format-zero-length warning 2024-09-05 23:24:57 +02:00
Saúl Ibarra Corretgé
048f4278c0 Fix misleading indentation compilation errors 2024-09-05 23:24:57 +02:00
Saúl Ibarra Corretgé
114b8a4095 Enable all debug flags when compiling in debug mode
They still need to be individually enabled either via API or with the -D
CLI flag, but there is no need to modify the code and re-compile.
2024-09-05 23:24:57 +02:00
Ben Noordhuis
8c58e01928
Fix FinalizationRegistry with primitive held value (#496)
Apparently test262 does not test FinalizationRegistry#register() with
held values that are not objects.

Fixes: https://github.com/quickjs-ng/quickjs/issues/494
2024-09-04 12:32:32 +02:00
Ben Noordhuis
9bc41a8a00
Add Float16Array (#491) 2024-09-03 20:32:17 +02:00
Ben Noordhuis
0e5e9c2c49
Fix broken DUMP_BYTECODE debug option (#489)
Broken in commit 1baa6763f8 when unicode_from_utf8 was renamed to
utf8_decode_len.
2024-08-25 11:53:30 +02:00
Ben Noordhuis
568ac13ff5
Optimize js_map_write, don't loop twice (#488) 2024-08-23 17:53:17 +02:00
Ben Noordhuis
4e52027fe7
Fix invalid free() in run-test262 (#487) 2024-08-23 17:53:02 +02:00
Ben Noordhuis
cee3b88edb
Fix async iterator missing throw method behavior (#485) 2024-08-22 09:02:11 +02:00
Ben Noordhuis
408fed8fa5
Update test262 (#484)
test262/implementation-contributed/v8/mjsunit was removed upstream in
commit tc39/test262@a15874163e so this
commit also removes the v8 test runner; it's no longer functional.
2024-08-21 23:36:09 +02:00
Ben Noordhuis
3a58376485
Support (de)serializing Map and Set objects (#483)
Fixes: https://github.com/quickjs-ng/quickjs/issues/482
2024-08-19 12:20:42 +02:00
Saúl Ibarra Corretgé
5db156fb08 Use INT32_MAX instead of inline value 2024-08-13 12:56:11 +02:00
Ben Noordhuis
da1d3cb994
Accept more flags in bjson read/write methods (#479)
Change the last argument from a boolean to an integer and export the
JS_READ_* and JS_WRITE_* flags on the bjson module object.
2024-08-12 16:53:39 +02:00
Ben Noordhuis
5a50ce3b08
Export bjson module (#478)
I find it convenient to have access to JS_ReadObject and JS_WriteObject
from JS land. That's precisely the functionality that tests/bjson.c
provides, ergo, move it into quickjs-libc.c
2024-08-11 11:04:08 +02:00
Andrew Johnson
a959457309 Add recommended workaround for dlsym void* return cast 2024-07-30 11:09:21 +02:00
Andrew Johnson
1aa0020cce Guard int128_t typedef 2024-07-30 11:09:21 +02:00
Andrew Johnson
b65ed3bb73 Remove unnecessary forward reference for OpCodeEnum 2024-07-30 11:09:21 +02:00
Andrew Johnson
4bfffe8e12 Mark indirect goto and address-as-label as extensions 2024-07-30 11:09:21 +02:00
Andrew Johnson
8f1ac67ea9 Avoid void pointer to function pointer casts 2024-07-30 11:09:21 +02:00
Andrew Johnson
9ba23f269c Forward reference to enum type 2024-07-30 11:09:21 +02:00
Andrew Johnson
4dead002e4 Mark __int128 as extension 2024-07-30 11:09:21 +02:00
Andrew Johnson
7b0e05dea9 Use ISO C syntax for flexible array members 2024-07-30 11:09:21 +02:00
Kevin Wang
c4d3833966 Fix declaring property named get/set/async 2024-07-25 23:21:16 +02:00
Dmitry Volyntsev
da5b95dcaf Fix GC leak in js_proxy_get()
Fixes: https://github.com/bellard/quickjs/issues/277
2024-07-16 23:04:18 +02:00
Saúl Ibarra Corretgé
bc1e3cd009
Update README.md 2024-07-16 22:28:52 +02:00
Fabrice Bellard
009a60218f regexp: fix non greedy quantizers with zero length matches
Cherry-picked from:
36911f0d3a
2024-07-16 22:23:37 +02:00
Saúl Ibarra Corretgé
763010663b Add auxiliary structure for retrieving SAB tabs 2024-07-15 16:53:52 +02:00
Saúl Ibarra Corretgé
3ed591c02d Introduce JS_ReadObject2
Analogously to JS_WriteObject2, it allows the user to get a tab with all
the SAB objects that were read.

This can help adjust reference counts in a scenario where a SAB that was
written increased it and it's necessary to decrease it upon reading it.
2024-07-15 16:53:52 +02:00
Saúl Ibarra Corretgé
c011898ea0 Fix memory leak in JS_WriteObject2
If a SAB was written sab_tab will have been allocated. Free it if the
user didn't provide a way to retrieve it.
2024-07-15 08:59:20 +02:00
Andrew Johnson
7faef8680d Extern after windows.h 2024-07-15 00:23:49 +02:00
Andrew Johnson
af084de6f9 Add 'extern' statements to public headers for C++ compatibility 2024-07-15 00:23:49 +02:00
Saúl Ibarra Corretgé
f9d1029ea3 Fix Linux with GCC 4.8 CI
Complains in the post-ckeckout step:

```
 Post job cleanup.
/usr/bin/docker exec  f32fc88d37a181d710e2802cbad0646c9780efe4af35a093fe68d09d8201a74e sh -c "cat /etc/*release | grep ^ID"
/__e/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /__e/node20/bin/node)
```
2024-07-12 16:42:00 +02:00
Nathan Rajlich
b071d36ab5 Rename qjsc -r to qjsc -b 2024-07-04 10:27:39 +02:00