Commit graph

314 commits

Author SHA1 Message Date
Ben Noordhuis
b478329cdd
Remove JSFunctionBytecode.has_debug flag (#207)
And merge the debug struct into JSFunctionBytecode because it is now
always present.

Refs: https://github.com/quickjs-ng/quickjs/pull/193#pullrequestreview-1774511177
2023-12-12 00:10:52 +01:00
Saúl Ibarra Corretgé
030a0ddf3f Add navigator.userAgent to qjs CLI 2023-12-11 22:46:01 +01:00
Ben Noordhuis
bace4f635e
Record source column positions (#193)
And:
- display them in stack traces
- expose them as Function.prototype.columnNumber

OP_line_num is renamed to OP_source_loc and the pc2line data structure
is extended with the column number in zigzag encoding.

The bytecode version number BC_VERSION is incremented because pc2line
data is read and written by JS_ReadObject() and JS_WriteObject() when
it is present.

Fixes: https://github.com/quickjs-ng/quickjs/issues/149
2023-12-11 22:36:13 +01:00
Ben Noordhuis
40771c9103
Disable flaky test on Cygwin (#202)
Unclear why sending a SIGQUIT signal sometimes works and sometimes
doesn't but it's probably some kind of race condition in Cygwin's
emulation layer.

Fixes: https://github.com/quickjs-ng/quickjs/issues/184
2023-12-11 22:02:32 +01:00
Saúl Ibarra Corretgé
de44a37ae9 Fix not rebuilding source 2023-12-11 09:59:32 +01:00
Ben Noordhuis
dbed7be3cb
Handle TypedArray detach during iteration (#201)
Per spec: detaching the TA mid-iteration is allowed and should not
not throw an exception.

In the case of TypedArray.prototype.set, because iteration over the
source array is observable, we cannot bail out early when the TA is
first detached.
2023-12-11 09:22:02 +01:00
Ben Noordhuis
f7f1906989
Switch to SIGTERM in child process test (#203)
The hope is that switching from SIGQUIT to SIGTERM will resolve the
test's flakiness on Cygwin.

Refs: https://github.com/quickjs-ng/quickjs/issues/184
2023-12-11 09:21:19 +01:00
Ben Noordhuis
315096461b
Implement TypedArray.prototype.with (#200) 2023-12-10 21:25:31 +01:00
Ben Noordhuis
83dfc635f1
Implement TypedArray.prototype.toSorted (#199) 2023-12-10 21:23:52 +01:00
Ben Noordhuis
05f00a87f7
Implement TypedArray.prototype.toReversed (#198) 2023-12-10 21:21:21 +01:00
Fabrice Bellard
baf50f9236 fixed duplicate static private setter/getter test 2023-12-10 21:03:48 +01:00
Fabrice Bellard
e8b97048d4 Symbol.species is no longer used in TypedArray constructor from a TypedArray 2023-12-10 21:03:48 +01:00
Fabrice Bellard
46996ff258 fixed delete super.x error 2023-12-10 21:03:48 +01:00
Ben Noordhuis
67d90092fe Add regression test for previous commit 2023-12-10 21:03:48 +01:00
Fabrice Bellard
30e4767e67 fixed lexical scope of 'this' with eval (github issue #192) 2023-12-10 21:03:48 +01:00
Ben Noordhuis
f1b7b6da71
Replace JSValueConst with JSValue (#195)
JSValueConst was only used for the now removed CONFIG_CHECK_JSVALUE
build mode. It is kept around as an alias for JSValue in quickjs.h to
avoid breaking everyone's source builds but remove it everywhere else.
2023-12-10 15:15:42 +01:00
Ben Noordhuis
4d57997ee7
Remove CONFIG_CHECK_JSVALUE build mode (#194)
It doesn't produce a working build and I'm somewhat skeptical that
its purported goal of catching reference counting bugs still works.
2023-12-10 13:50:26 +01:00
Ben Noordhuis
4c1b9f8c7f
Fix OP_FMT_none_loc bytecode dumping (#192)
Commit f404980 ("Add fused get_loc0_loc1 opcode") introduced an
off-by-one (sometimes negative) array index bug because OP_get_loc1_loc1
replaced OP_get_loc0 as the first OP_FMT_none_loc opcode.
2023-12-09 23:46:54 +01:00
Ben Noordhuis
f6ed206bd5
Change regexp flags field from uint8 to uint16 (#185)
I need the extra bits to store the 'v' flag as described in
https://github.com/tc39/proposal-regexp-v-flag
2023-12-09 16:47:05 +01:00
Ben Noordhuis
6bd3d5660e
Use JS_ToBigIntFree() instead of JS_ToBigInt() (#190)
Reduces reference count juggling in the happy path and, to a lesser
extent, in error paths.
2023-12-09 14:54:54 +01:00
Ben Noordhuis
4fc814311a
Remove js_new_bf() (#189)
And replace the open-coded JS_NewBigInt() logic at its one call site
with the real thing.
2023-12-09 14:54:33 +01:00
Ben Noordhuis
d17129035d
Remove duplicate JS_GetBigInt call (#188) 2023-12-09 14:54:13 +01:00
Ben Noordhuis
f7d2169999
Rename LRE_FLAG_UTF16 to LRE_FLAG_UNICODE (#186)
Prep work for https://github.com/tc39/proposal-regexp-v-flag a.k.a.
UnicodeSets.
2023-12-08 10:58:00 +01:00
Ben Noordhuis
42b708622c
Use named constant for regexp bytecode size field (#183) 2023-12-07 23:00:32 +01:00
Saúl Ibarra Corretgé
9539e3cc65 Fix private field setters
Ref: 55a4878a60
2023-12-07 22:21:48 +01:00
Felipe Gasper
9de152667f
Add NetBSD support (#177) 2023-12-07 15:48:31 +01:00
Saúl Ibarra Corretgé
7542b14c5b Fix Makefile rebuilding every target 2023-12-07 11:34:52 +01:00
Saúl Ibarra Corretgé
622ce2cc9d Detect JOBS in a more portable way 2023-12-07 10:59:11 +01:00
Saúl Ibarra Corretgé
ffa73c8f18 fixup! 2023-12-07 09:38:09 +01:00
Saúl Ibarra Corretgé
3f66b08b9c Simplify Makefile 2023-12-07 09:38:09 +01:00
Saúl Ibarra Corretgé
e7e938fa50 Update LICENSE
So GH renders it correctly.
2023-12-06 00:00:15 +01:00
Saúl Ibarra Corretgé
2d05150e35 Now working on 0.3.0 2023-12-05 23:27:23 +01:00
Saúl Ibarra Corretgé
a393ebc2f8 Set version to 0.2.0 2023-12-05 23:18:22 +01:00
Saúl Ibarra Corretgé
99f12f4f2f Implement FinalizationRegistry 2023-12-05 22:41:57 +01:00
Saúl Ibarra Corretgé
18b30961ee DRY malloc_usable_size 2023-12-05 12:34:02 +01:00
Saúl Ibarra Corretgé
8128e66145 Add FreeBSD support 2023-12-05 12:34:02 +01:00
Saúl Ibarra Corretgé
478bcf74f2 Add OpenBSD support 2023-12-05 12:34:02 +01:00
Felipe Gasper
56738d8b4b
Add Cygwin compatibility 2023-12-03 18:15:07 +01:00
Ben Noordhuis
9c2614c2fa
Fix building with tcc (#170)
- tcc doesn't support 128 bits integral types, use 64 bits math instead

- suppress some unreachable code warnings
2023-12-03 13:36:51 +01:00
bellard
148a205b71 Fix UB in bf_set_ui()
Ref: https://github.com/bellard/quickjs/issues/131
2023-12-02 16:05:10 +01:00
Nick Vatamaniuc
6b3bed1740
Fix stack overflow in CVE-2023-31922 (#157)
isArray and proxy isArray can call each other indefinitely in a mutually
recursive loop.

Add a stack overflow check in the js_proxy_isArray function before calling
`JS_isArray(ctx, s->target)`.

Original issue: https://github.com/bellard/quickjs/issues/178
CVE: https://nvd.nist.gov/vuln/detail/CVE-2023-31922
2023-12-01 16:31:36 +01:00
Saúl Ibarra Corretgé
bf1facaea3 Always enable stack checking
Seems to work in Emscripten and it can be disabled with
JS_SetMaxStackSize(rt, 0).
2023-12-01 15:29:18 +01:00
Ben Noordhuis
a5b9e54151
Re-enable stack depth checks under ASan (#161)
The default 256 kb stack is too small to run some of the test262 tests
when ASAN is enabled.

Double it to 512 kb and ensure threads created by quickjs have big
enough stacks.
2023-11-30 22:18:23 +01:00
Saúl Ibarra Corretgé
0745c3a12b Add Emscripten target to CI
No testing, just making sure it compiles, and keeps on doing so.

Ref: https://github.com/quickjs-ng/quickjs/issues/75
2023-11-30 21:29:51 +01:00
Saúl Ibarra Corretgé
6f5cda46e7 Test Debug and Release on ClangCL 2023-11-30 09:28:39 +01:00
Saúl Ibarra Corretgé
bfd8c381cb Add support for building with ClangCL on Windows
Since ClangCL is compatible with MSVC this should get us almost there.

Ref: https://clang.llvm.org/docs/MSVCCompatibility.html
2023-11-30 01:23:09 +01:00
Ben Noordhuis
3f10651dc1
Prohibit freezing/sealing module namespace objects (#160) 2023-11-30 00:42:36 +01:00
Ben Noordhuis
b6b70e471c
Add os.cputime() (#159)
And use it in microbench to get slightly more accurate results.
2023-11-30 00:05:48 +01:00
Ben Noordhuis
a140e1cf2c
Make -DDUMP_BYTECODE=64 print executed bytecode (#158)
Basically a poor man's bytecode tracer.
2023-11-29 23:53:01 +01:00
Ben Noordhuis
39c8acd312 Replace JS_DupValue() calls with js_dup() 2023-11-29 23:38:01 +01:00