Commit Graph

140 Commits

Author SHA1 Message Date
Charlie Gordon
a78d2cbf7c Improve repl regexp handling
- handle regexp with flags in repl completion
- group config_jscalc customisations
2024-03-02 14:36:44 +01:00
Charlie Gordon
8180d3dd87 Improve microbench.js
- ensure handler behavior does not depend on n argument
- load and save reference file in node.js
- add -s filename option to name the output reference file
- add targets in Makefile for tests and bencharks using node.js
- fix incorrect timings when not using high resolution timer
- use performance timer in node.js
- output performance factor instead of percentage
- use smaller threshold by default
- add benchmarks for:
    date_parse(), prop_update(), prop_clone(), array_slice()
    global_func_call(),
2024-02-26 00:14:31 +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
6428ce0c8b show readable representation of Date objects in repl 2024-02-25 22:53:29 +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
Charlie Gordon
12c91df577 Improve surrogate handling readability
- add inline function to test and convert surrogates
  is_surrogate(c), is_hi_surrogate(c), is_lo_surrogate(c),
  get_hi_surrogate(c), get_lo_surrogate(c), from_surrogate(hi, lo)
- use names for BC header offsets and lengths in libregexp.c
- remove strict aliasing violations in `lre_exec_backtrack()`
- pass all context variables to XXX_CHAR macros in `lre_exec_backtrack()`
2024-02-20 00:22:32 +01:00
Charlie Gordon
8d932deb49 Rename regex flag and field utf16 -> unicode
- rename is_utf16 structure member to is_unicode
- rename flag LRE_FLAG_UTF16 as LRE_FLAG_UNICODE
2024-02-19 16:30:08 +01:00
Charlie Gordon
97ae6f39e6 Add benchmarks target
- assuming quickjs-benchmarks is cloned in the parent directory,
- compile quickjs-benchmarks targets and run the benchmarks
2024-02-19 01:13:07 +01:00
Charlie Gordon
c24a865a29 Improve run-test262
- add -t to show timings
- add -C to select compact progress meter
- default to compact progress meter if not attached to console
- set agent stack size to 2MB
- compute module filename relative to current path
- ignore `testdir` for -d and -f options
- return non zero status on errors changes
2024-02-18 15:00:04 +01:00
Charlie Gordon
bbf36d5b84 Fix big endian serialization
Big endian serialization was broken because:
- it partially relied on `WORDS_ENDIAN` (unconditionally undef'd in cutils.h)
- endianness was not handled at all in the bc reader.

Modifications:
- remove `WORDS_ENDIAN`
- use `bc_put_u32()` / `bc_put_u64()` in `JS_WriteBigInt()`
- use `bc_get_u32()` / `bc_get_u64()` in `JS_ReadBigInt()`
- handle host endianness in `bc_get_u16()`, `bc_get_u32()`, `bc_get_u64()` and
  `JS_ReadFunctionBytecode()`

- handle optional littleEndian argument as specified in
  `js_dataview_getValue()` and `js_dataview_setValue()`
2024-02-18 08:29:04 +01:00
Charlie Gordon
530ba6a631 handle missing test262 gracefully 2024-02-17 22:57:57 +01:00
Charlie Gordon
0a361b7c0f handle missing test262 gracefully 2024-02-17 22:56:54 +01:00
Charlie Gordon
74bdb4967c Improve tests
- split test_bigfloat.js from test_bignum.js
- make test_date() compatible with node
- document Date constructor string argument format:
  should add test cases for invalid strings
- test_argument_scope(): only test this syntax error in strict mode:
  `var f = function(a = eval("var arguments")) {};`
2024-02-17 21:54:19 +01:00
Charlie Gordon
85fb2caeae Fix UB signed integer overflow in js_math_imul
- Use uint32_t arithmetics and Standard conformant conversion to
  avoid UB in js_math_imul.
- add builtin tests
- use specific object directories for SAN targets
2024-02-17 21:15:29 +01:00
Ben Noordhuis
8df4327559 Fix UB left shift of negative number 2024-02-17 17:36:50 +01:00
Ben Noordhuis
3bb2ca360e Remove unnecessary ssize_t posix-ism
ssize_t is not always available and the cast it was used in wasn't
necessary in the first place, the value already has the right type.

Note that the field malloc_limit is an int64_t in JSMemoryUsage whereas it
is a size_t in JSMallocState.
2024-02-16 10:25:29 +01:00
Charlie Gordon
c06af876f6 Improve string concatenation hack
- add more cases of in place string concatenation
  this temporary hack improves the microbench timing by 30% but
  has little impact on the test262 timings.
2024-02-15 10:30:04 +01:00
Charlie Gordon
8e21b96738 pass node-js command line arguments to microbench 2024-02-15 09:59:50 +01:00
Charlie Gordon
95e0aa0526 Reverse e140122202
- remove temporary fix for MemorySanitizer:
  setting p->u.array.count to 0 silenced a warning in JS_GetPropertyValue on a
  hacky test agains the length of fast_array object.
  This hack was removed by commit c3635861f6.
2024-02-13 09:45:58 +01:00
Charlie Gordon
1fe04149e9 Fix test262 error
- force evaluation order in `set_date_fields`
- fix evaluation error in test262/test/built-ins/Date/UTC/fp-evaluation-order.js:19:
  unexpected error: Test262Error: precision in MakeDate Expected SameValue(«34448384», «34447360») to be true
2024-02-12 18:37:37 +01:00
Charlie Gordon
ef4e7b23f4 Fix compiler warnings 2024-02-12 18:35:27 +01:00
Charlie Gordon
92e339d14f Simplify and clarify URL quoting js_std_urlGet 2024-02-12 18:34:52 +01:00
Nick Vatamaniuc
636c946531
FreeBSD QuickJS Patch (#203) 2024-02-12 11:28:00 +01:00
Felix S
ae6fa8d3d2
Fix shell injection bug in std.urlGet (#61) 2024-02-12 11:20:25 +01:00
Sam
693449e34e
add gitignore for build objects (#84)
Signed-off-by: Samuel Hellawell <sshellawell@gmail.com>
Co-authored-by: Charlie Gordon <github@chqrlie.org>
2024-02-12 10:28:38 +01:00
Ben Noordhuis
e140122202 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.
2024-02-11 23:54:19 +01:00
Ben Noordhuis
6dbf01bb1f 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.
2024-02-11 21:58:14 +01:00
Charlie Gordon
6535064577 Fix undefined behavior (UBSAN) 2024-02-11 21:32:36 +01:00
Saúl Ibarra Corretgé
e53d622359 Fix UB in js_dtoa1 2024-02-11 20:59:17 +01:00
Ben Noordhuis
fd6e039770 Add UndefinedBehaviorSanitizer support 2024-02-11 20:37:24 +01:00
Ben Noordhuis
325ca194b7 Add MemorySanitizer support 2024-02-11 20:27:34 +01:00
Ben Noordhuis
626e0d4e60 Unbroke tests/test_test_bjson.js 2024-02-11 18:38:47 +01:00
Ben Noordhuis
2e1013429a Add more tests
- add regexp tests in tests/microbench.js
- add bjson_test_regexp in tests/test_test_bjson.js
2024-02-11 16:20:39 +01:00
Charlie Gordon
48deab1aeb Fix runtime bugs
- fix string leak in `js_printf_internal` on errors
- read `errno` before potential side effects in `js_os_stat`
2024-02-11 12:49:40 +01:00
Charlie Gordon
c9e6c56c70 Improve microbench
- remove import statements (invoke with qjs --std)
- fix compatibility issues with node
- add more loop styles
- add more string concatenation tests
- use === and !=== where appropriate
- fix sort timing log
- add `-r ref_file` command line option to specify reference file
- add .gitignore file with target file patterns
2024-02-11 12:11:53 +01:00
Charlie Gordon
2c793e5097 Fix test262o error
- excude test262o/test/suite/ch15/15.5/15.5.4/15.5.4.9/15.5.4.9_CE.js:
  Test262 Error: String.prototype.localeCompare considers ö (\u006f\u0308) = ö (\u00f6).
2024-02-10 20:54:29 +01:00
Charlie Gordon
37bd4ae62d Strip trailing spaces 2024-02-10 16:19:17 +01:00
Fabrice Bellard
6f480abbc8 avoid using INT64_MAX in double comparisons because it cannot be exactly represented as a double (bnoordhuis) 2024-02-03 15:48:57 +01:00
Fabrice Bellard
1ed38eef33 fixed MingW64 install on Windows (absop) (github issue #230) 2024-02-03 15:48:09 +01:00
Fabrice Bellard
00967aac24 fixed Promise return in the REPL by using a wrapper object in async std.evalScript() (github issue #231) 2024-02-03 15:47:42 +01:00
Fabrice Bellard
c6cc6a9a5e export JS_GetModuleNamespace (github issue #34) 2024-01-27 13:27:32 +01:00
Fabrice Bellard
cd666a851f simplified and fixed arrow function parsing (github issue #226) 2024-01-27 13:12:54 +01:00
Fabrice Bellard
090685a8c2 update test results 2024-01-27 13:12:37 +01:00
Fabrice Bellard
67723c93e4 fixed js_std_await() in case 'obj' is not a promise (github issue #222) 2024-01-22 18:03:35 +01:00
Fabrice Bellard
9e561d5c2e fixed and simplified setTimeout() by using an integer timer handle (github issue #218) 2024-01-19 10:20:34 +01:00
Fabrice Bellard
84058766e9 added js_std_await() and use it to wait for the evaluation of a module (github issue #219) 2024-01-19 10:19:58 +01:00
Fabrice Bellard
d6c7d169de update Changelog 2024-01-19 10:18:32 +01:00
Fabrice Bellard
3f81070e57 new release 2024-01-13 11:16:02 +01:00