185 Commits

Author SHA1 Message Date
Fabrice Bellard
6ac04e1bf2 removed useless printf() (#257) 2025-03-31 18:00:27 +02:00
Fabrice Bellard
0d7aaed71c ensure that JS_IteratorNext() returns JS_UNDEFINED when done = TRUE (#394) 2025-03-31 13:37:37 +02:00
Fabrice Bellard
56c47f7d2a fixed exception handling in AsyncFromSyncIterator and async for of 2025-03-28 10:11:15 +01:00
Fabrice Bellard
67de495254 fixed typed array set operation when obj != receiver 2025-03-27 17:06:26 +01:00
Fabrice Bellard
b0c1a12196 fixed set_date_field() 2025-03-27 16:28:56 +01:00
Fabrice Bellard
e8cfe8fede removed memory leak in string padding (issue #274) 2025-03-27 14:43:25 +01:00
Fabrice Bellard
6cc02b4421 more use of js_new_string8 - inlined JS_NewString() (initial patch by Charlie Gordon) 2025-03-25 16:33:47 +01:00
Fabrice Bellard
156d981afe added string ropes for faster concatenation of long strings (issue #67) 2025-03-25 16:01:40 +01:00
Fabrice Bellard
d1bb520f29 reduced memory usage of Map hash table 2025-03-22 11:28:23 +01:00
Fabrice Bellard
49413985eb fixed hash_map_resize() - added Map/WeakMap in microbench 2025-03-22 10:54:21 +01:00
Fabrice Bellard
9f65ef1950 simplified and fixed backtrace_barrier (#306) 2025-03-20 13:37:07 +01:00
Fabrice Bellard
993660621a added new dtoa library to print and parse float64 numbers. It is necessary to fix corner cases (e.g. radix != 10) and to have correct behavior regardless of the libc implementation. 2025-03-19 19:07:57 +01:00
Fabrice Bellard
9f1864a268 msan fix (#389) 2025-03-19 14:27:01 +01:00
Fabrice Bellard
131408fa07 simplified js_bigint_from_float64() 2025-03-19 13:56:10 +01:00
Fabrice Bellard
6d6893bfa3 fixed BigInt hashing - removed -fno-bigint in qjsc and JS_AddIntrinsicBigInt() (BigInt is now considered as a base object) 2025-03-19 12:33:54 +01:00
Fabrice Bellard
5a16c0c1eb fixed JS_DumpValue() for BigInt 2025-03-19 11:59:47 +01:00
Fabrice Bellard
6de88859e7 more bignum cleanup 2025-03-19 11:43:31 +01:00
Fabrice Bellard
ee4cd4deac compilation fix 2025-03-18 18:45:21 +01:00
Fabrice Bellard
61e8b94428 removed bignum support and qjscalc - added optimized BigInt implementation 2025-03-18 18:29:10 +01:00
Fabrice Bellard
9bd10d8eb9 simplified the handling of closures 2025-03-13 17:44:55 +01:00
Fabrice Bellard
dfd9c93ab0 added missing stack overflow check in JSON.stringify() 2025-03-13 17:27:38 +01:00
Fabrice Bellard
25aaa77370 allow regexp interruption (e.g. with Ctrl-C in the REPL) 2025-03-13 17:17:51 +01:00
Fabrice Bellard
027f3cb5e4 fix crash when add_property() fails on build arguments (penneryu) 2025-03-13 16:30:02 +01:00
Fabrice Bellard
6474793e38 JS_SetPropertyInternal(): avoid recursing thru the prototypes if the property is found in a prototype 2025-03-13 16:04:38 +01:00
Fabrice Bellard
030333cff6 fixed date parsing in case there is more than nine initial digits (initial patch by nickva) 2025-03-13 15:52:53 +01:00
Pino Toscano
34894936d8 Use malloc_usable_size() on any OS based on GNU libc
malloc_usable_size() is a GNU extension in GNU libc; hence, use it
every time GNU libc is used, rather than only on Linux.
2024-07-21 10:24:01 +02:00
Kasper Isager Dalsgarð
5417ab0159
Fix JS_HasException() when null is thrown (#313)
Use `JS_UNINITIALIZED` instead of `JS_NULL` when no exception is pending, so `null` can be thrown and distinguished from no exception pending.
2024-07-17 13:58:08 +02:00
Dmitry Volyntsev
b3715f7cb1
Fix GC leak in js_proxy_get() (#302)
Fixes #277
2024-07-15 00:08:40 +02:00
Charlie Gordon
97be5a32af
Add js_resolve_proxy (#293)
- simplify `JS_IsArray` for proxy chains
- remove `js_proxy_isArray`
2024-05-09 14:14:50 +02:00
Kasper Isager Dalsgarð
f3f2f42717
Add JS_StrictEq(), JS_SameValue(), and JS_SameValueZero() (#264)
* add `JS_StrictEq()`, `JS_SameValue()`, and `JS_SameValueZero()` all accepting `JSValueConst`
* make `js_strict_eq` accept `JSValueConst`, remove uses of this function internally and replace them with
`js_strict_eq2` instead.
2024-05-09 13:07:40 +02:00
Kasper Isager Dalsgarð
6f9d05fd2b
Expose JS_SetUncatchableError() (#262)
* Expose `JS_SetUncatchableError()`

* Remove unnecessary `JS_SetUncatchableError` declaration
2024-05-09 12:45:47 +02:00
Kasper Isager Dalsgarð
db9dbd0a2b
Add JS_HasException() (#265) 2024-05-08 23:19:15 +02:00
Dmitry Volyntsev
6c43013140
Add JS_NewTypedArray() (#272) 2024-05-08 23:17:00 +02:00
Charlie Gordon
0c8fecab23
Improve class parser (#289)
- accept `class P { async = 1 }}`
- accept `class P { static = 1 }}` etc.
- Fixes #261
2024-05-05 19:54:47 +02:00
Richard Davison
d9c699f528
fix class method with name get (#258)
Co-authored-by: Richard Davison <ridaviso@amazon.com>
2024-05-05 18:46:30 +02:00
Charlie Gordon
7a2c6f42d4
Improve libunicode and libregexp headers (#288)
- move all `lre_xxx` functions to libunicode
- use flags table `lre_ctype_bits` instead of bitmaps
- simplify `lre_is_space`, `lre_js_is_ident_first` and `lre_js_is_ident_next`
- simplify `simple_next_token`, handle UTF-8 correctly
- simplify `is_let`, remove dead code
2024-05-05 17:47:40 +02:00
Charlie Gordon
3b45d155c7 Fix endianness handling in js_dataview_getValue / js_dataview_setValue 2024-03-23 13:19:04 +01:00
Charlie Gordon
653b2276cb Improve error handling
- detect and report invalid duplicate parameter names
- throw RangeError for too many function arguments
- throw RangeError for invalid string length
- prevent `-Wcast-function-type` warnings
2024-03-23 12:58:53 +01:00
Charlie Gordon
203fe2d539 Improve JSON.stringify
- changed error messages
- clarify `toJSON` method usage
- simplify boxed objects handling
- for ECMA conformity, BigInt objects need a toJSON method in the prototype chain
  including boxed objects
2024-03-23 12:43:45 +01:00
Charlie Gordon
ce6b6dcacd Use more explicit magic values for array methods 2024-03-23 09:52:23 +01:00
Charlie Gordon
c0e67c47cd Simplify redundant initializers for JS_NewBool() 2024-03-23 09:28:38 +01:00
Charlie Gordon
06651314f5 Fix compilation with -DCONFIG_BIGNUM
- disable BigDecimal convertion in `JS_ReadBigNum`
- fix some error messages
2024-03-22 11:23:33 +01:00
Charlie Gordon
65ecb0b0d6 Improve Date.parse, small fixes
- add `minimum_length` to enforce array length validation
- add `JS_NewDate()` API
- add `[Symbol.toStringTag]` property in the global object
- simplify `string_get_milliseconds`
- support more timezone abbrevs using `string_get_tzabbr` and array
2024-03-22 00:47:17 +01:00
Charlie Gordon
06c100c9bf Prevent UB on memcpy and floating point conversions
- add `memcpy_no_ub` that accepts null pointers for 0 count
- prevent 0 length allocation in `js_worker_postMessage`
- use safer test for `int` value in `JS_NewFloat64`,
  `JS_ToArrayLengthFree` and `js_typed_array_indexOf`
2024-03-03 14:05:40 +01:00
Charlie Gordon
35b7b3c379 Improve Date.parse
- accept many more alternative date/time formats
- add test cases in tests/test_builtin.js
- match month and timezone names case insensitively
- accept AM and PM markers
- recognize US timezone names
- skip parenthesized stuff
- fix almost all v8 test cases
2024-03-03 02:59:08 +01:00
Charlie Gordon
8d64731eb8 Improve Number.prototype.toString for radix other than 10
- fix the conversions for integers and exact fractions
- approximate approach for other cases.
- bypass floating point conversions for JS_TAG_INT values
- avoid divisions for base 10 integer conversions
2024-03-02 15:13:18 +01:00
Charlie Gordon
78db49cf95 Improve Date.parse
- rewrite Date.parse() with separate parsers
- return `NaN` for out of bounds field values as specified
- accept up to 9 decimals for millisecond fraction but truncate at 3
- accept many more alternative date/time formats
- add test cases in tests/test_builtin.js
2024-02-25 23:47:26 +01:00
Charlie Gordon
27928ce491 Fix Map hash bug
- `map_hash_key` must generate the same key for JS_INT and JS_FLOAT64
   with the same value
- add test cases in tests/test_builtin.js
2024-02-22 19:31:57 +01:00
Charlie Gordon
b70e764427 Rewrite set_date_fields to match the ECMA specification
- use `double` arithmetic where necessary to match the spec
- use `volatile` to ensure correct order of evaluation
  and prevent FMA code generation
- reject some border cases.
- avoid undefined behavior in `double` -> `int64_t` conversions
- improved tests/test_builtin.js `assert` function to compare
  values more reliably.
- added some tests in `test_date()`
- disable some of these tests on win32 and cygwin targets
2024-02-21 21:22:10 +01:00
Tyler Rockwood
b91a2aec67 Add C API function JS_GetClassID()
If you want to extend a built-in class you need it's class ID and there
is no robust way to get that without this accessor.

* add JS_INVALID_CLASS_ID constant for invalid class ID.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
2024-02-21 15:33:37 +01:00