`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
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
It's currently printing them whenever a test takes one millisecond or
longer to complete.
Introduced in commit 7db24cc0da from earlier today, mea culpa.
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.
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.
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
This way dependent projects only need to add this:
```
link_libraries(qjs)
```
or
```
target_link_libraries(mytarget qjs)
```
And CMake will link the resulting target with the libraries that qjs
needs too.