Commit graph

188 commits

Author SHA1 Message Date
63e1762670 move polyfills
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / qemu-alpine (arm32v6) (push) Waiting to run
ci / qemu-alpine (arm32v7) (push) Waiting to run
ci / qemu-alpine (arm64v8) (push) Waiting to run
ci / qemu-alpine (i386) (push) Waiting to run
ci / qemu-alpine (s390x) (push) Waiting to run
2024-10-24 15:27:46 -05:00
a951ae64da add copyright deets
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / qemu-alpine (arm32v6) (push) Waiting to run
ci / qemu-alpine (arm32v7) (push) Waiting to run
ci / qemu-alpine (arm64v8) (push) Waiting to run
ci / qemu-alpine (i386) (push) Waiting to run
ci / qemu-alpine (s390x) (push) Waiting to run
2024-10-24 15:15:15 -05:00
5e8d81c2a6 add donejs edition denotation
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / qemu-alpine (arm32v6) (push) Waiting to run
ci / qemu-alpine (arm32v7) (push) Waiting to run
ci / qemu-alpine (arm64v8) (push) Waiting to run
ci / qemu-alpine (i386) (push) Waiting to run
ci / qemu-alpine (s390x) (push) Waiting to run
2024-10-24 15:12:35 -05:00
c6c98a254c flix global 2024-10-24 15:10:12 -05:00
b0cc1aa457 fix strings missing quotes
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / qemu-alpine (arm32v6) (push) Waiting to run
ci / qemu-alpine (arm32v7) (push) Waiting to run
ci / qemu-alpine (arm64v8) (push) Waiting to run
ci / qemu-alpine (i386) (push) Waiting to run
ci / qemu-alpine (s390x) (push) Waiting to run
2024-10-24 15:09:06 -05:00
250647fd99 add global alias to globalThis
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / qemu-alpine (arm32v6) (push) Waiting to run
ci / qemu-alpine (arm32v7) (push) Waiting to run
ci / qemu-alpine (arm64v8) (push) Waiting to run
ci / qemu-alpine (i386) (push) Waiting to run
ci / qemu-alpine (s390x) (push) Waiting to run
2024-10-24 15:08:34 -05:00
63376913de add require to global 2024-10-24 15:07:45 -05:00
b2d3293a97 whoopsie oopsie 2024-10-24 15:05:20 -05:00
6930c1ef9d fix require polyfill 2024-10-24 15:04:42 -05:00
18c24ca20e update license
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / qemu-alpine (arm32v6) (push) Waiting to run
ci / qemu-alpine (arm32v7) (push) Waiting to run
ci / qemu-alpine (arm64v8) (push) Waiting to run
ci / qemu-alpine (i386) (push) Waiting to run
ci / qemu-alpine (s390x) (push) Waiting to run
2024-10-24 14:33:46 -05:00
abf99613fb Forgot to mention in previous commit - added a hacky polyfill 2024-10-24 14:29:28 -05:00
51ec4ed20b revert to previous version
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / qemu-alpine (arm32v6) (push) Waiting to run
ci / qemu-alpine (arm32v7) (push) Waiting to run
ci / qemu-alpine (arm64v8) (push) Waiting to run
ci / qemu-alpine (i386) (push) Waiting to run
ci / qemu-alpine (s390x) (push) Waiting to run
2024-10-24 14:25:35 -05:00
Akos Kiss
6e2e68fd08 Fix termination in Worker test
Function names are case sensitive, `onMessage` is not the same as
`onmessage`.

Related to #98
2024-07-27 23:40:48 +02:00
Pino Toscano
012451d5f3 Define a fallback PATH_MAX if not available
PATH_MAX is optional in POSIX, and it is not available on GNU/Hurd.
While it could be possible to not rely on PATH_MAX, for now provide a
fallback definition (which should be safe enough) to get quickjs built
on GNU/Hurd.
2024-07-21 10:24:01 +02:00
Pino Toscano
8624b5c6f0 Use ftello() & fseeko() on any OS based on GNU libc
Strictly speaking, they are available in POSIX.1-2008 [1][2], so they
could be used on more platforms/OSes. To be cautious, enable them when
using GNU libc, since they have been available with that libc for a
very long time.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftell.html
[2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/fseek.html
2024-07-21 10:24:01 +02: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
Fabrice Bellard
36911f0d3a regexp: fix non greedy quantizers with zero length matches 2024-05-30 16:41:37 +02:00
Fabrice Bellard
d86aaf0b8f updated test262.patch 2024-05-30 15:49:31 +02:00
Fabrice Bellard
adec734346 fixed test of test262 directory 2024-05-30 15:36:20 +02:00
Charlie Gordon
d378a9f3a5
Improve js_os_exec (#295)
- use $(shell) make command to test if closefrom() is available
- use closefrom() if available in js_os_exec()
- limit the fallback loop to 1024 handles to avoid costly loop on linux alpine.
PR inspired by @nicolas-duteil-nova
2024-05-10 01:57:55 +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
Renáta Hodován
d53aafe0f3
Add the missing fuzz_common.c (#292) 2024-05-09 12:36:12 +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
Renáta Hodován
01454caf78
OSS-Fuzz targets improvements (#267)
* Move fuzz target sources from the oss-fuzz repository here

* Add support to build libFuzzer targets
* Simplify the fuzz_eval and fuzz_compile targets

The use of JS_NewContext instead of JS_NewContextRaw spares to call
JS_AddIntrinsic<XYZ> functions from the fuzz target, since the public
JS_NewContext API does exactly the same.

* Simplify the fuzz_regexp target

fuzz_regexp doesn't need to be dependant on libquickjs since the
runtime and the context - that were provided by libquickjs - were
only created to call two simple functions implemented in libquickjs
which could be mimicked by the fuzzer.
The removal of runtime and context objects implicated further
simplifications, like the omission of their one-time creation.
Finally, writing the result of the regexp operations into a file
is also superfluous, since it's not used by anybody.

* Recreate and destroy JS runtime and context in fuzz_eval and fuzz_compile targets

Before this patch, the test executions were not independent,
since all the executed tests used the same JavaScript runtime and
context, causing irreproducible failure reports.

* Enable bignumber support in eval and compile targets

Big numbers are used by the input corpus, but the targets were not
able to interpret them since they were not compiled into them.
This change improved the inital coverage of the fuzz_eval target with
21% and the coverage of the fuzz_compile target with 25% when using
the official corpus.

* Ensure std and os modules are available in the fuzz_eval and fuzz_compile targets
* Add fuzzer dictionary with builtin and variable names. Furthermore, added a JS script that collects all the builtin
names from the executing engine. 
* Move common fuzzer code into one place
* Enable to define the LIB_FUZZING_ENGINE variable to ease the oss-fuzz integration
* Add README to fuzzers
2024-05-08 18:19:48 +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
1402478d8d
Improve unicode table handling (#286)
- Document table and index formats
- Add size statistics
- Fix UBSAN issue in `get_le24()`

Fixes #285
2024-05-05 12:10:24 +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
6a89d7c270
Add CI targets, fix test_std.js (#247)
This switches the exec test to `SIGTERM` rather than `SIGQUIT` since the
latter didn’t seem to work in QEMU, and the distinction doesn’t really
matter for this test.

This also makes the `isatty()` check smarter by checking whether `STDIN`
is, in fact, a terminal.

Added qemu-alpine targets i386, arm32v6, arm32v7, arm64v8, s390x

Co-authored-by: Felipe Gasper <felipe@felipegasper.com>
2024-03-03 21:57:38 +01:00
Kanstantsin Sokal
ebe7496d14
Fix build: use LRE_BOOL in libunicode.h (#244) 2024-03-03 15:36:00 +01:00
Charlie Gordon
1a5333bcb3 prevent 0 length allocation in js_worker_postMessage 2024-03-03 14:42:01 +01:00
Ben Noordhuis
e17cb9fc7a Add github CI tests
- disable `isatty()` test in `test_os()`
- add `.github/workflows/ci.yml` with 8 targets
2024-03-03 14:14:23 +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
3dd93eb4e4
fix microbench when microbench.txt is missing (#246) 2024-03-03 03:38:49 +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
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