Commit graph

660 commits

Author SHA1 Message Date
satk0
86b1853a21 Improve gcc warning fix 2024-10-07 22:34:01 +02:00
Saúl Ibarra Corretgé
52e0f24048 Fix computed reference on null or undefined 2024-10-07 21:39:59 +02:00
Saúl Ibarra Corretgé
acc0dd9273 Implement proper Symbol.toStringTag for iterators 2024-10-07 21:39:02 +02:00
Ben Noordhuis
9a37c57779
Fix thread-safety issue in quickjs-libc (#578)
`JS_NewClassID(rt, &class_id)` where `class_id` is a global variable
is unsafe when called from multiple threads but that is exactly what
quickjs-libc.c did.

Add a new JS_AddRuntimeFinalizer function that lets quickjs-libc
store the class ids in JSRuntimeState and defer freeing the memory
until the runtime is destroyed. Necessary because object finalizers
such as js_std_file_finalizer need to know the class id and run after
js_std_free_handlers runs.

Fixes: https://github.com/quickjs-ng/quickjs/issues/577
2024-10-07 21:27:38 +02:00
Ben Noordhuis
27715a46bb
Forbid closing stdio from quickjs-libc (#576)
Intrinsically dangerous because it leaves the std{in,out,err} C globals
in an undefined state.
2024-10-07 09:35:09 +02:00
Ben Noordhuis
ddabcf5e93
Run ThreadSanitizer on push to master (#575)
Fixes: https://github.com/quickjs-ng/quickjs/issues/557
2024-10-06 20:17:50 +02:00
Saúl Ibarra Corretgé
4b1a244d3b Run test262-update in a single thread
In order to guarantee the order of the results in the error file.
2024-10-05 12:39:04 +02:00
Saúl Ibarra Corretgé
a0877514b9 fixup! 2024-10-05 12:35:47 +02:00
Saúl Ibarra Corretgé
3dcadf1518 Fix next token parsing after a function definition
Ref: c06c399f4f
Fixes: https://github.com/quickjs-ng/quickjs/issues/572
2024-10-05 12:35:47 +02:00
Richard Davison
5590756b93
Move JS_{Dup,Free}Value and the RT variants from header, reduced duplication 2024-10-04 09:18:12 +02:00
Ben Noordhuis
1eb9608d64
Fix regexp split with zero-length capture group (#566)
The expected result of `"ab".split(/(c)*/)[1]` is `undefined` but
was in fact `"undefined"` due to unintentional stringification.

Fixes: https://github.com/quickjs-ng/quickjs/issues/565
2024-10-01 01:05:01 +02:00
Ben Noordhuis
e1564526ea
Run test262 tests in parallel (#564)
This commit introduces a couple of changes in order to make run-test262
go brr and execute tests in parallel:

- Remove CONFIG_AGENT build option. The disabled version of the build
  was already broken and no one noticed, Remove the define altogether.

- Remove the -C switch. Hard to support in multi-threaded mode.
  I may bring it back some day because it _is_ useful.

- Remove the -r switch. Also hard to support and I never look at
  test262_report.txt anyway so on the chopping block it goes.

- Judicious use of thread-local storage so I don't have to thread
  through state everywhere and embiggen the diff even more.

This is what Real Programmers(TM) do: stay up coding way past midnight
just so the test suite finishes in one minute instead of four.

Fixes: https://github.com/quickjs-ng/quickjs/issues/547
2024-09-30 18:35:35 +02:00
Andrew Johnson
72d4587163
Support printing unicode characters on Windows 2024-09-30 13:30:08 +02:00
Ben Noordhuis
0bf36b98b9
Fix ThreadSanitizer warning in quickjs-libc (#562)
A global function pointer was getting accessed from multiple threads.
Replace it with an atomic integer and an immediate function call.
2024-09-28 22:27:18 +02:00
Ben Noordhuis
6d63b36c0a
Fix printing of slow tests with -T in run-test262 (#563)
It's currently printing them whenever a test takes one millisecond or
longer to complete.

Introduced in commit 7db24cc0da from earlier today, mea culpa.
2024-09-28 22:26:18 +02:00
Ben Noordhuis
7db24cc0da
Add -vv verboser mode switch to run-test262 (#561)
Prints the test name and running time in milliseconds. Supersedes
`-T <ms>` because that switch prints the same info, only for slow
tests.
2024-09-28 14:37:16 +02:00
Ben Noordhuis
4d4dbcf37e
Add -C compact mode switch to run-test262 (#560)
Turns on the reporting mode that is the default on the CI.
2024-09-28 14:01:40 +02:00
Saúl Ibarra Corretgé
d0df61d04a Support the NO_COLOR env variable in the REPL 2024-09-27 19:53:11 +02:00
Ben Noordhuis
348d60985d
Add Iterator.from (#555) 2024-09-27 00:16:50 +02:00
Saúl Ibarra Corretgé
06175d1e0c
Simplify eval_and_print code in REPL
We always use async eval.

Also clean up some console.log usage since we use std.puts all across.
2024-09-26 20:07:24 +02:00
Saúl Ibarra Corretgé
b1dc19c4f7 Add Ctrl-W support for REPL 2024-09-26 09:55:18 +02:00
Ben Noordhuis
9a618ed426
Add Iterator.prototype.toArray (#552)
Churn in test262_errors.txt is due to fixing Iterator inheritance,
necessary to make the prototype method actually callable.
2024-09-25 22:45:02 +02:00
Saúl Ibarra Corretgé
7e82ad80c1 Don't run ci and valgrind for non-code changes when pushing to master 2024-09-25 22:32:25 +02:00
Saúl Ibarra Corretgé
7cfedb0952
New documentation website 2024-09-25 22:21:45 +02:00
Saúl Ibarra Corretgé
946d653c58 Fix clearing screen in REPL with Ctrl-L 2024-09-25 21:14:49 +02:00
Ben Noordhuis
aefdee7b9a
Add Iterator (#548) 2024-09-24 22:07:29 +02:00
Saúl Ibarra Corretgé
2b953a72be Set version to 0.6.1 2024-09-24 19:45:59 +02:00
Ben Noordhuis
beb998c5c5
Enable iterator-helpers test262 feature (#546)
Enable the feature to give us a burndown list of things to implement.
2024-09-24 19:21:47 +02:00
Saúl Ibarra Corretgé
3a96b9cb6f Support private brand checks
Fixes: https://github.com/quickjs-ng/quickjs/issues/541
Ref: 3ab1c2b314
2024-09-24 18:37:02 +02:00
Saúl Ibarra Corretgé
c963112349 Fix use of js_malloc_usable_size
Make sure the one set in the malloc functions is used rather than the
default one, since it will likely use a different allocator.

For some reason, this didn't cause a problem on macOS, but it does in
Linux. Opsie! Added some CI to prevent these kinds of bugs.
2024-09-24 18:36:23 +02:00
Saúl Ibarra Corretgé
1defa63c73
Add version to navigator.userAgent (#542)
A la Deno and Bun.
2024-09-24 18:28:14 +02:00
Saúl Ibarra Corretgé
c25aad7b49
Add ability to (de)serialize symbols
Fixes: https://github.com/quickjs-ng/quickjs/issues/481
2024-09-24 10:01:08 +02:00
Saúl Ibarra Corretgé
d9a43d5a82 Provide a description for unitialized values in JS_ToStringInternal
After 56da486312 it's possible existing
code relied on the current exception not being null to dump it, and the
dumped value just said "[unsupported type]". This change provides a more
descriptive value.
2024-09-24 09:56:34 +02:00
Saúl Ibarra Corretgé
647e32c047 Ignore diff for generated files
Avoids annoyingly having to skip through them when doing git diff.
2024-09-23 23:36:54 +02:00
Saúl Ibarra Corretgé
d3c340373e Now working on 0.7.0 2024-09-21 21:34:30 +02:00
Saúl Ibarra Corretgé
a815d1b7b6 Set version to 0.6.0 2024-09-20 21:26:07 +02:00
Andrew Johnson
fe5be3cad9 Add JS_SetLength API function 2024-09-20 09:49:51 +02:00
Saúl Ibarra Corretgé
6ce2dcc938 Add ability to compile the CLI with mimalloc
Some (unscientific) benchmark results:

| Benchmark (Higher scores are better)  | QuickJS           | QuickJS (mimalloc) |
|---------------------------------------|-------------------|--------------------|
| Richards                              | 1217              | 1229               |
| DeltaBlue                             | 1192              | 1297               |
| Crypto                                | 1195              | 1191               |
| RayTrace                              | 1477              | 2186               |
| EarleyBoyer                           | 2441              | 3246               |
| RegExp                                | 275               | 315                |
| Splay                                 | 2461              | 3765               |
| NavierStokes                          | 2156              | 2119               |
| Score                                 | 1318              | 1553               |

Running the V8 benchmark suite (version 7) on an M1 MacBook Pro.

Fixes: https://github.com/quickjs-ng/quickjs/issues/142
2024-09-20 09:49:01 +02:00
Saúl Ibarra Corretgé
cfeeff91db Refactor JSMallocFunctions to simplify the implementation
Rather than having the user take care of JSMallocState, take care of the
bookkeeping internally (and make JSMallocState non-public since it's no
longer necessary) and keep the allocation functions to the bare minimum.

This has the advantage that using a different allocator is just a few
lines of code, and there is no need to copy the default implementation
just to moficy the call to the allocation function.

Fixes: https://github.com/quickjs-ng/quickjs/issues/285
2024-09-19 20:49:09 +02:00
Saúl Ibarra Corretgé
5f5170796e
regexp: fixed the zero advance logic in quantifiers
Ref: 10fc744ae4
2024-09-14 22:00:48 +02:00
Saúl Ibarra Corretgé
56da486312 Add JS_HasException
Ref: db9dbd0a2b
Ref: 5417ab0159
2024-09-14 21:58:58 +02:00
Ben Noordhuis
8557bd0a0a
Add Set.prototype.isSupersetOf (#532) 2024-09-14 00:19:20 +02:00
Saúl Ibarra Corretgé
f5c388d693
Fix regexp case insensitive flag (#531)
Ref: af308614a8
2024-09-13 23:50:44 +02:00
Saúl Ibarra Corretgé
ac958f1d2f Optional chaining fixes
Ref: f25e5d4094
2024-09-13 23:27:35 +02:00
Ben Noordhuis
0990875ae8
Add Set.prototype.isSubsetOf (#529) 2024-09-13 22:58:47 +02:00
Saúl Ibarra Corretgé
9bb8a68390 Delete tests/test262.patch
We don't use it.
2024-09-13 21:40:43 +02:00
Ben Noordhuis
12940d7877
Add Set.prototype.isDisjointFrom (#528) 2024-09-13 21:04:09 +02:00
Saúl Ibarra Corretgé
fb70e0994b Simplify realloc
Call to our free wrapper when size is 0.
2024-09-11 22:09:27 +02:00
Saúl Ibarra Corretgé
5a41aaa6a3 Use calloc rather than malloc + memset 2024-09-11 22:09:27 +02:00
Saúl Ibarra Corretgé
5765855089 Silence noisy (and useless) MSVC warnings 2024-09-11 20:15:53 +02:00