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
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
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
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
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
Saúl Ibarra Corretgé
9539e3cc65
Fix private field setters
...
Ref: 55a4878a60
2023-12-07 22:21:48 +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
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é
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
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
Ben Noordhuis
f1d6e9e5ff
Replace JS_NewBool() calls with js_bool()
2023-11-29 23:38:01 +01:00
Ben Noordhuis
a28d1b822c
Replace JS_NewUint32() calls with js_uint32()
2023-11-29 23:38:01 +01:00
Ben Noordhuis
087441559e
Replace JS_NewFloat64() calls with js_float64()
2023-11-29 23:38:01 +01:00
Ben Noordhuis
46155806fc
Replace JS_NewInt32() calls with js_int32()
2023-11-29 23:38:01 +01:00
Ben Noordhuis
f181b3e54f
Remove dead code ( #155 )
2023-11-29 10:13:13 +01:00
Marcin Kolny
699744562e
Enable support for GCC compler v < 4.9
...
GCCv4.8 and lower doesn't ship with stdatomic implementation
(even though they don't define __STD_NO_ATOMICS__ for c11).
If the code is compiled with GCCv4.8 and older, we use builtin
GCC atomic operations instead.
The patch was initially proposed in quickjs's mailing group:
https://www.freelists.org/post/quickjs-devel/PATCH-support-for-older-gcc-versions-whitespace-changes-excluded
2023-11-29 09:22:27 +01:00
Divy Srivastava
6b78c7f3e1
Implement polymorphic inline caches ( #120 )
2023-11-29 09:12:02 +01:00
Ben Noordhuis
5c3077e091
Implement RegExp serialization ( #153 )
...
JS_WriteObject() and JS_ReadObject() now support RegExp objects.
2023-11-29 08:50:53 +01:00
Ben Noordhuis
a6e73ca73c
Handle serialization endianness transparently ( #152 )
...
Change JS_WriteObject() and JS_WriteObject2() to write little-endian
data and update JS_ReadObject() to byte-swap data when running on a
big-endian system.
Obsoletes the JS_WRITE_OBJ_BSWAP flag, it is now a no-op.
Fixes: https://github.com/quickjs-ng/quickjs/issues/125
2023-11-28 22:49:01 +01:00
Saúl Ibarra Corretgé
5c136edbcf
Implement WeakRef
2023-11-28 13:26:33 +01:00
Saúl Ibarra Corretgé
1df9615638
Generalize weakref handling logic
2023-11-28 13:26:33 +01:00
Ben Noordhuis
b5148b212e
Implement static class initializer blocks ( #144 )
...
Spec compliance bug: "await" is illegal inside initializer blocks
_except_ when used as an identifier in a function expression, like so:
class C {
static {
var f = function await() {}
}
}
It is somewhat complicated to make the parser understand the distinction
and such code is probably rare or non-existent so I decided to leave
well enough alone for now.
2023-11-26 21:11:48 +01:00
Ben Noordhuis
51633afe56
Remove no-op OP_swap+OP_swap bytecode sequence ( #143 )
...
Observed in generated code for static initializers. We could in theory
track and correct it in js_parse_class() but doing it as a peephole
optimization is both easier and more general.
2023-11-26 16:54:43 +01:00
Ben Noordhuis
8df335a7b9
Expose class name to static initializers ( #139 )
...
Fixes: https://github.com/quickjs-ng/quickjs/issues/138
2023-11-26 01:09:18 +01:00
Saúl Ibarra Corretgé
d74b2e7ec1
Squelch a -Wcast-function-type warnings
...
Ref: https://github.com/quickjs-ng/quickjs/issues/131
2023-11-26 00:08:48 +01:00
Saúl Ibarra Corretgé
7776cc3b75
Fix getting array buffer when building Uint8Array
2023-11-25 00:42:44 +01:00
Saúl Ibarra Corretgé
27287519aa
Fix implicit enum conversion
...
Ref: https://github.com/quickjs-ng/quickjs/issues/131
2023-11-25 00:00:45 +01:00
Saúl Ibarra Corretgé
8f2993bd68
Add APIs to build a Uint8Array from binary data directly
2023-11-24 23:05:39 +01:00
Saúl Ibarra Corretgé
268cde8270
Add API to build Date objects
2023-11-24 23:05:27 +01:00
Ben Noordhuis
22a3d80740
Implement Map.groupBy
2023-11-24 11:30:21 +01:00
Ben Noordhuis
3e54403b08
Implement Object.groupBy
2023-11-24 11:30:21 +01:00
Divy Srivastava
a8a5ecb095
Specialize bytecode for default ctor ( #112 )
2023-11-24 01:27:18 +01:00
Saúl Ibarra Corretgé
5e4d45a9d4
Add -ng suffix to CLI output
2023-11-23 00:07:26 +01:00
Ben Noordhuis
165128257f
Fix AsyncGenerator.prototype.return error handling ( #109 )
...
A poisoned .constructor property is observable and the resulting
exception should be delivered to the catch handler, not silently
dropped, otherwise the generator hangs.
2023-11-21 23:57:10 +01:00
Saúl Ibarra Corretgé
8d496b3e3c
Add queueMicrotask
...
Ref: https://github.com/quickjs-ng/quickjs/issues/16
2023-11-21 23:43:17 +01:00
Divy Srivastava
1fcb573e6b
Implement ArrayBuffer.prototype.transfer ( #101 )
2023-11-21 19:29:23 +01:00
Ben Noordhuis
9e8d278161
Use ReferenceError from right realm/context ( #107 )
...
The "this is not initialized" ReferenceError for a class C defined in
context B but instantiated in context A should be an instance of the
ReferenceError from A, not B.
2023-11-21 19:24:15 +01:00
Ben Noordhuis
7c9cf46f97
Make Date methods argument coercion spec compliant ( #104 )
2023-11-21 15:04:38 +01:00
Divy Srivastava
7aabea9db0
Implement Error causes ( #103 )
2023-11-21 14:59:26 +01:00
Ben Noordhuis
d8ea7df950
Reject date strings with negative year zero ( #100 )
2023-11-21 11:43:45 +01:00
Saúl Ibarra Corretgé
5ce2957e23
Make JS_NewClassID thread aware
...
It's as thread-safe as JSRuntime, which isn't thread-safe, but multiple
threads can now allocate them on different runtimes without a problem.
2023-11-21 07:02:34 +01:00
Ben Noordhuis
b56a82d19f
Normalize inputs to String.prototype.localeCompare ( #97 )
...
NFC-normalize the inputs, otherwise strings like "Å" and "A\u030A"
(latin A with combining diacritical mark) don't compare equal.
2023-11-21 00:00:54 +01:00
Saúl Ibarra Corretgé
a721bda7b5
Drop CONFIG_ALL_UNICODE and enable it by default
2023-11-20 10:52:04 +01:00
Ben Noordhuis
bef2a12566
DRY surrogate pair handling ( #95 )
2023-11-20 09:46:02 +01:00
Ben Noordhuis
d1960d1bfe
Implement RegExp 'd' flag ( #86 )
2023-11-20 09:45:44 +01:00
Ben Noordhuis
4727e40ac8
Retrieve RegExp 'g' flag in spec conformant way ( #92 )
2023-11-19 17:26:03 +01:00
Ben Noordhuis
5af98ca858
Remove non-standard Date.__date_clock method ( #88 )
2023-11-18 19:15:05 +01:00
Ben Noordhuis
8ba4f4b824
Remove dead code ( #87 )
2023-11-18 19:14:24 +01:00
Saúl Ibarra Corretgé
ea068d9a70
Add performance.{now,timeOrigin}
...
Ref: https://github.com/quickjs-ng/quickjs/issues/16
2023-11-18 11:16:35 +01:00
Ben Noordhuis
d88e9df9de
Implement TypedArray.prototype.findLast{Index} ( #73 )
2023-11-17 11:56:22 +01:00
Ben Noordhuis
7e955f6f4c
Implement Array.prototype.findLast{Index} ( #70 )
2023-11-17 11:54:21 +01:00
Ben Noordhuis
90d8c6bae0
Fix uninitialized memory access ( #68 )
...
An alternative fix is to zero the `values` and `count` fields in
JS_NewObjectFromShape() irrespective of the object's class_id but
handling it in JS_GetPropertyValue() feels cleaner.
Fixes: https://github.com/quickjs-ng/quickjs/issues/63
2023-11-17 00:12:10 +01:00
Ben Noordhuis
48fc4bb26d
Update Array.prototype[Symbol.unscopables] ( #65 )
...
Add change-array-by-copy methods to Array.prototype[Symbol.unscopables].
2023-11-16 13:05:51 +01:00
Ben Noordhuis
feebfbc6ee
Add Array.prototype.toSpliced ( #64 )
2023-11-16 13:04:53 +01:00
Ben Noordhuis
d2e632e77a
Allow symbols as WeakMap and WeakSet keys ( #58 )
2023-11-16 09:07:59 +01:00
Saúl Ibarra Corretgé
9749a90cc6
Skip stack checks whenbuilding with ASAN
2023-11-14 12:44:16 +01:00
Ben Noordhuis
f404980ec0
Add fused get_loc0_loc1 opcode ( #55 )
...
get_loc0 and get_loc1 are individually very frequent opcodes _and_ they
are very often paired together, making them ideal candidates for opcode
fusion.
Reduces microbench.js running time by about 4%.
2023-11-13 00:54:13 +01:00
Ben Noordhuis
920cfc679a
Add copyright notices ( #51 )
...
I believe we made enough substantial changes to have a credible claim to
copyright holdership.
2023-11-12 22:42:07 +01:00
Ben Noordhuis
e8ff1f4a3a
Remove broken SHORT_OPCODES=0 build mode ( #49 )
2023-11-12 13:35:41 +01:00
Ben Noordhuis
a92e74acac
Remove broken OPTIMIZE=0 build mode ( #47 )
2023-11-12 13:34:08 +01:00
Ben Noordhuis
162a8b7409
Remove trailing whitespace ( #46 )
...
Not purely cosmetic because it breaks navigation with { and } in the
One True Editor.
2023-11-12 10:01:40 +01:00
Ben Noordhuis
15f798db27
Implement Array.prototype.with ( #45 )
2023-11-11 23:35:46 +01:00
Ben Noordhuis
a19b07af37
Implement Array.prototype.toSorted ( #44 )
2023-11-11 21:51:02 +01:00
Ben Noordhuis
cfe4251c9a
Implement String.prototype.toWellFormed ( #43 )
...
Reworks isWellFormed to be consistent style-wise with toWellFormed.
2023-11-11 21:50:46 +01:00
Ben Noordhuis
0720b068ca
Implement String.prototype.isWellFormed ( #41 )
2023-11-11 13:47:22 +01:00
Ben Noordhuis
7b64da2325
Improve BigInt hashing ( #38 )
...
Fixes: https://github.com/quickjs-ng/quickjs/issues/35
2023-11-10 21:01:09 +01:00
Ben Noordhuis
8d62210e7d
Remove non-standard BigInt methods ( #37 )
...
Fixes: https://github.com/quickjs-ng/quickjs/issues/20
2023-11-10 20:10:52 +01:00
Saúl Ibarra Corretgé
55e845c5dd
Add JS_GetVersion
2023-11-10 16:48:49 +01:00
Ben Noordhuis
38f88c0898
Remove CONFIG_BIGNUM, always enable BigInt ( #34 )
...
Fixes: https://github.com/quickjs-ng/quickjs/issues/17
2023-11-10 16:09:54 +01:00
Ole André Vadla Ravnås
3c144fd553
Add JS_GetAnyOpaque() to support polymorphism
...
To be able to check if the class ID is one of multiple known ones, where
the data has a common structure.
2023-11-10 11:01:22 +01:00
Ben Noordhuis
ae17b8522d
Remove operator overloading ( #32 )
...
Part of https://github.com/quickjs-ng/quickjs/issues/17
2023-11-10 10:23:40 +01:00
Ben Noordhuis
e449cb08ef
Remove BigFloat ( #31 )
...
Part of https://github.com/quickjs-ng/quickjs/issues/17
2023-11-08 22:23:06 +01:00
Saúl Ibarra Corretgé
c1ed688610
Drop non-standard JSON extension
...
Ref: https://github.com/quickjs-ng/quickjs/issues/20
2023-11-08 22:14:25 +01:00
Ben Noordhuis
5d5b3cc21f
Remove BigDecimal ( #29 )
...
Part of https://github.com/quickjs-ng/quickjs/issues/17
2023-11-08 21:07:16 +01:00
Ben Noordhuis
0068db8a11
Avoid UB when checking if float fits in int32
2023-11-08 19:17:13 +01:00
Saúl Ibarra Corretgé
4f02ab8cfa
Fix use-after-free on error during module evaluation
...
E.g. if during evaluation of module A, we start loading module B and
an error occurs. This results in a call to js_free_modules() with
JS_FREE_MODULE_NOT_EVALUATED, and since module A isn't yet evaluated,
it gets freed prematurely.
To solve this we improve js_free_modules() to ensure `eval_mark` is not
set. Once js_evaluate_module() returns for module A, it will notice that
an exception occurred and call js_free_modules() with
JS_FREE_MODULE_NOT_EVALUATED. Since `eval_mark` has been cleared by then,
module A gets cleaned up as well.
Co-authored-by: Ole André Vadla Ravnås <oleavr@gmail.com>
2023-11-07 22:23:09 +01:00
Ben Noordhuis
a3a57febed
Implement Array.prototype.toReversed ( #19 )
2023-11-07 17:31:33 +01:00
Saúl Ibarra Corretgé
e2ae8746ca
Drop support for "use strip"
...
Ref: https://github.com/quickjs-ng/quickjs/issues/20
2023-11-07 00:29:11 +01:00
Saúl Ibarra Corretgé
1fb9a5010f
Drop support for "use math"
...
Ref: https://github.com/quickjs-ng/quickjs/issues/20
2023-11-06 23:07:31 +01:00
Ben Noordhuis
9b3b3084fa
Implement TypedArray.prototype.at ( #18 )
2023-11-06 00:05:44 +01:00
Ben Noordhuis
18eb603e0d
Implement Promise.withResolvers ( #14 )
2023-11-05 11:08:58 +01:00
Ben Noordhuis
99eb81e1a6
Implement Array.prototype.at ( #13 )
2023-11-05 11:08:46 +01:00
Ben Noordhuis
55018345ed
Implement String.prototype.at ( #12 )
2023-11-05 11:08:27 +01:00
Ben Noordhuis
e5bdada266
Remove unsafe sprintf() and strcat() calls
...
Prep work for enabling the sanitizers on macos CI since they are marked
as deprecated and cause the build to fail when -Werror is enabled.
2023-11-03 01:31:31 +01:00
Saúl Ibarra Corretgé
6d7fd42aae
Add JS_GetUint8Array API
...
Shorthand for getting the underlying buffer of a Uint8Array.
2023-11-01 23:06:31 +01:00
Saúl Ibarra Corretgé
b11a10471d
fixup!
2023-11-01 22:42:59 +01:00
Saúl Ibarra Corretgé
a9ac7a07ff
Add top-level await support
...
Original author: zamfofex <zamfofex@twdb.moe>
2023-11-01 22:42:59 +01:00
Saúl Ibarra Corretgé
f51616eac8
Don't build with Atomics support by default
...
It's not currently implemented for Windows which makes the bytecode
generated by qjsc not portable.
2023-11-01 21:39:12 +01:00
Ben Noordhuis
d6fbd6b744
Fix UB signed integer overflow
2023-11-01 09:31:30 +01:00
Ben Noordhuis
4a8372a709
Fix UB left shift of negative number
2023-11-01 09:31:30 +01:00
Ben Noordhuis
a9957cdcee
Fix UB nullptr passing to memcpy()
2023-11-01 09:31:30 +01:00
Ben Noordhuis
8217c69157
Fix UB shift into sign bit
2023-11-01 09:31:30 +01:00
Ben Noordhuis
f8b3a2e93c
Fix sloppy mode arguments uninitialized value use
...
MemorySanitizer complained about uninitialized reads in
the indexed property code path in JS_GetPropertyValue()
with JS_CLASS_MAPPED_ARGUMENTS objects.
2023-11-01 05:20:14 +01:00
Ben Noordhuis
67585d0421
Fix -Wimplicit-const-int-float-conversion warnings
...
Compare against 0x1p63 instead of INT64_MAX. Converting INT64_MAX to
double rounds it up to INT64_MAX+1.
It made code like `if (d <= INT64_MAX) v = (int64_t)d;` behave subtly
wrong when `d >= 0x1p63` because then `v = (int64_t)d` wraps around to
a negative value.
2023-11-01 05:20:14 +01:00
bellard
446099aa9e
added Object.hasOwn()
2022-03-06 18:54:27 +01:00
bellard
b9f58802dc
fixed invalid Array.prototype.push/unshift optimization
2022-03-06 18:53:03 +01:00
bellard
b5e62895c6
2021-03-27 release
2021-03-27 11:17:31 +01:00
bellard
b1f67dfc1a
2020-11-08 release
2020-11-08 14:30:56 +01:00
bellard
7c312df422
2020-09-06 release
2020-09-06 19:10:15 +02:00
bellard
8900766099
2020-07-05 release
2020-09-06 19:07:30 +02:00
bellard
1722758717
2020-04-12 release
2020-09-06 19:04:20 +02:00
bellard
383e2b06c8
2020-03-16 release
2020-09-06 19:02:03 +02:00
bellard
0e8fffd4de
2020-01-19 release
2020-09-06 18:57:11 +02:00
bellard
91459fb672
2020-01-05 release
2020-09-06 18:53:08 +02:00