Commit graph

702 commits

Author SHA1 Message Date
Saúl Ibarra Corretgé
18b0b9a706
Update release CI action versions
actions/upload-artifact@v3 will be deprecated soon. Migrate to v4.

Ref: https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md
2024-11-16 09:26:06 +01:00
Saúl Ibarra Corretgé
706ba05fa6 Fix Linux release CI
There is no need to download git submodules when making releases.
2024-11-15 21:40:51 +01:00
Saúl Ibarra Corretgé
859267cc59 Set version to 0.7.0 2024-11-15 21:29:58 +01:00
Ben Noordhuis
407683bd98 Add Atomics.pause 2024-11-15 20:30:40 +01:00
bptato
42f0945114 Fix NULL deref in JS_NewRuntime2
The API allows for the malloc_usable_size callback to be NULL, so it
must not be dereferenced before the NULL check.
2024-11-15 15:02:59 +01:00
Saúl Ibarra Corretgé
284510f781 Make Iterator.from spec compliant
Create a proper wrapper around the inner iterator and proxy the calls to
next / return.
2024-11-15 13:35:25 +01:00
Saúl Ibarra Corretgé
204070a544 Fix broken link in README 2024-11-15 13:30:06 +01:00
Saúl Ibarra Corretgé
a7a614406d Update README 2024-11-15 13:28:45 +01:00
Saúl Ibarra Corretgé
1350362ba6 Add cloning instructions to building section 2024-11-15 13:28:45 +01:00
Saúl Ibarra Corretgé
987afb7a52 Add list of projects using NG 2024-11-15 13:28:45 +01:00
Saúl Ibarra Corretgé
0575d10da7 Tweak intro and document differences with bellard/quickjs 2024-11-15 13:28:45 +01:00
Saúl Ibarra Corretgé
a365f18c98 Document how to create standalone executables 2024-11-15 13:28:45 +01:00
Saúl Ibarra Corretgé
559029baad Fix Iterator.prototype
Make sure all descriptors are attached to the one and only iterator
prototype.
2024-11-15 13:16:28 +01:00
Ben Noordhuis
554907e88f
Add RegExp.escape (#687) 2024-11-15 12:17:38 +01:00
Ben Noordhuis
b5d41818e2
Fix bytecode stack frame printing (#686)
Handle OP_get_loc0_loc1 specially. Fixes an off-by-one when printing
variable names.

Fixes: https://github.com/quickjs-ng/quickjs/issues/683
2024-11-14 22:50:42 +01:00
Saúl Ibarra Corretgé
6d7448ed3e Implement Iterator.prototype.flatMap 2024-11-14 19:48:41 +01:00
Ben Noordhuis
1cc19e4dbf
Fix detach check in ArrayBuffer.prototype.resize (#681) 2024-11-13 16:04:49 +01:00
Ben Noordhuis
fa4d2454aa
Add Error.isError (#682)
It's strictly speaking not at phase 3 yet (almost!) but it's very easy
to implement and quite useful.
2024-11-13 15:08:06 +01:00
Ben Noordhuis
2a78706484
Update test262 (#680)
test262 now tests Unicode 16 and that fixes a fair number of tests that
started failing after we upgraded to Unicode 16.
2024-11-13 14:36:07 +01:00
Saúl Ibarra Corretgé
17a8772379 Implement Iterator.prototype.map 2024-11-13 12:55:25 +01:00
Saúl Ibarra Corretgé
4933e17d1b Remove error handling for JS_NewInt64, it's infallible
Also use js_int64(v) internally.
2024-11-12 22:33:22 +01:00
Saúl Ibarra Corretgé
c68c416e2e
Implement Iterator.prototype.filter 2024-11-12 22:01:45 +01:00
Ben Noordhuis
000061f635
Improve performance of variable resolver (#672)
Switch to a hash table when the number of variables grows beyond
a threshold.

Speeds up the test case from the linked issue by about 70%.

Fixes: https://github.com/quickjs-ng/quickjs/issues/456
2024-11-12 21:22:47 +01:00
Saúl Ibarra Corretgé
0362c0a4eb
Implement Iterator.prototype.take (#676) 2024-11-12 08:10:19 +01:00
Ben Noordhuis
487129055f
Work around broken atomics in tinycc (#669) 2024-11-12 01:01:52 +01:00
Saúl Ibarra Corretgé
c41ee4f15f Implement Iterator.prototype.drop
Includes the scaffold for other iterator helper methods that require an
Iterator Helper object.
2024-11-11 22:25:24 +01:00
Ben Noordhuis
243b968ee1 Update to Unicode 16.0 2024-11-09 23:14:52 +01:00
Ben Noordhuis
416ab66f0b Update to Unicode 15.1 2024-11-09 23:14:52 +01:00
Ben Noordhuis
6fdb9b4bbb Update Unicode download URL
Seems I forgot to update the unicode_download.sh script when I upgraded
from Unicode 14.0 to 15.0 in November 2023.
2024-11-09 23:14:52 +01:00
Ben Noordhuis
b29332697b Don't use _Thread_local in run-test262.c
Allows building with tcc and old gcc versions again.
2024-11-09 23:14:20 +01:00
Ben Noordhuis
f641d4ff18 Don't use rt->user_opaque in quickjs-libc.c
JS_SetRuntimeOpaque() and JS_GetRuntimeOpaque() are intended for
embedders. Stop using them in quickjs-libc.c
2024-11-09 23:14:20 +01:00
Ben Noordhuis
55b829e666
Update test262_errors.txt after commit 73cc00e (#665)
Commit 73cc00e improves the accuracy of line and column number tracking
but I forgot that that also affects the output of run-test262.
2024-11-09 16:02:44 +01:00
Saúl Ibarra Corretgé
d7c5c7c302 Remove qjs namespace backwards compatibility
Fixes: https://github.com/quickjs-ng/quickjs/issues/650
2024-11-08 22:10:53 +01:00
Saúl Ibarra Corretgé
43151dd78c Fix valgrind and tsan CI
Checkout test262.
2024-11-08 15:09:00 +01:00
Richard Davison
cd2947bded
Don't automatically update test262 submodule 2024-11-08 15:02:48 +01:00
Richard Davison
04307af779 Make "performance" global writable 2024-11-08 08:52:45 +01:00
Ben Noordhuis
73cc00e57e
Improve line:column tracking (#660)
Emit source locations manually for more precise tracking. Don't infer
them from emitted bytecode opcodes because that leads to inaccurate
and sometimes surprising results.

Speeds up code generation (although infinitesimally) as a bonus.

Fixes: https://github.com/quickjs-ng/quickjs/issues/236
2024-11-07 22:03:00 +01:00
Saúl Ibarra Corretgé
c8be383367 Prevent JS_SetOpaque from overriding internal class state
Fixes: https://github.com/quickjs-ng/quickjs/issues/657
2024-11-07 21:26:28 +01:00
Saúl Ibarra Corretgé
e30da0e8bc Don't throw oob exception when setting numeric indexes on TAs
Relevant spec section: https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#sec-typedarraysetelement

It should only throw if Object.defineProperty is used and the TA is
detached or OOB if a RAB is used.

Fixes: https://github.com/quickjs-ng/quickjs/issues/645
2024-11-07 19:48:05 +01:00
Ben Noordhuis
9c5c441744
Fix FinalizationRegistry refcounting bug (#656)
Introduced in commit 61c8fe6 from last month that moved the callback
into the job queue:

1. It leaked `fre->held_val` when no job was enqueued

2. It fumbled the reference count when enqueuing; JS_EnqueueJob already
   takes care of incrementing and decrementing it

Reverts commit 0a70623 from earlier today because that didn't turn out
to be a complete fix.

Fixes: https://github.com/quickjs-ng/quickjs/issues/648
2024-11-07 09:12:34 +01:00
Ben Noordhuis
aedd829e61
Fix DUMP_LEAKS memory leak false positive (#655)
Run DUMP_LEAKS after finalizers run; they call js_free_rt too.

Fixes: https://github.com/quickjs-ng/quickjs/issues/654
2024-11-06 22:56:10 +01:00
Ben Noordhuis
83fe8f1166
Fix exception in WeakRef.prototype.deref (#653)
Set the object's opaque to a sentinel value instead of NULL, to stop
JS_GetOpaque2 from raising an "illegal class" exception.

Fixes: https://github.com/quickjs-ng/quickjs/issues/651
2024-11-06 22:54:47 +01:00
Ben Noordhuis
0a706236d7
Move "no more objects" assert to right place (#649)
No test because I can only get it to trigger with qjs, not run-test262,
but the problem is that we need to run FinalizationRegistry finalizers
before asserting no objects remain.

Fixes: https://github.com/quickjs-ng/quickjs/issues/648
2024-11-06 14:54:52 +01:00
Ben Noordhuis
37fe427d59
Add resizable ArrayBuffers (#646)
This commit implements resizable ArrayBuffers - RABs for short - and
extends typed arrays (TAs) to support fixed-length and length-tracking
modes.

SharedArrayBuffers (SABs) also support the maxByteLength option now but
I cheated and allocate all memory upfront because atomically resizing
memory allocations is hard and this commit is already big and complex.

The lion's share is updating all the TA prototype methods to deal with
RABs resizing underneath them. Method arguments can be arbitrary objects
with arbitrary .valueOf methods and arbitrary side effects, like...
resizing the RAB we're currently operating on.

Fixes: https://github.com/quickjs-ng/quickjs/issues/477
2024-11-05 21:55:42 +01:00
Ben Noordhuis
e569f39bf1
Add stack trace to Test262Error (#644)
Only enabled in verboser mode.

Necessary because Test262Error doesn't subclass from Error. Make it tell
not just _what_ but also _where_.
2024-11-04 23:21:52 +01:00
Ben Noordhuis
c53a0a86da
Detect if stdout is a console in quickjs-libc (#642)
Use regular libc stdio (fwrite) when stdout is redirected, don't
call WriteConsoleA because that circumvents the redirection.

Fixes: https://github.com/quickjs-ng/quickjs/issues/635
2024-10-31 11:08:41 +01:00
Ben Noordhuis
df81c9940f
Make qjs --std switch include bjson module (#640) 2024-10-29 22:56:00 +01:00
Ben Noordhuis
dfe5675f25
Allow 'undefined' in let or const declaration (#639)
Except at the global scope of a classic script because... who knows,
that's just how it is.

Fixes: https://github.com/quickjs-ng/quickjs/issues/633
2024-10-29 22:55:22 +01:00
Ben Noordhuis
42262a7c53
Don't segfault on missing line number data (#641)
Can be reproduced on the CLI but not from a script:

    # should throw "unsupported object class" TypeError
    $ qjs --std -e 'bjson.write(function(){})'
    /path/to/quickjs.c:6510:15: runtime error: applying zero offset to null pointer
2024-10-29 22:52:56 +01:00
Ben Noordhuis
56e5ffa2db
Auto-detect ASan at compile time (#638)
Fixes: https://github.com/quickjs-ng/quickjs/issues/636
2024-10-29 19:54:33 +01:00