Commit graph

55 commits

Author SHA1 Message Date
The Ghost of FOSS' Future
c8d48b3937
Merge branch 'quickjs-ng:master' into master 2025-01-08 22:45:11 +00:00
Saúl Ibarra Corretgé
97ea19dc81 Simplify exiting interpreter with exception
- Avoid keeping the exception object around
- Avoid passing the responsibility of freeing the exeption object to the
  caller
2025-01-08 21:37:49 +01:00
Saúl Ibarra Corretgé
4b8057d512 Exit qjs on unhandled promise rejections
Fixes: https://github.com/quickjs-ng/quickjs/issues/790
2025-01-07 21:27:17 +01:00
The Ghost of FOSS' Future
710866995b
add more polyfills 2025-01-06 19:28:30 -06:00
The Ghost of FOSS' Future
5d1cb14683
move globals back 2025-01-06 15:55:44 -06:00
The Ghost of FOSS' Future
f9809db69a
Add files via upload 2025-01-06 15:50:00 -06:00
The Ghost of FOSS' Future
4d17eb56ad
Update qjs.c 2025-01-06 15:31:15 -06:00
The Ghost of FOSS' Future
36c5ea0dae
moves repl polyfills to repl script 2025-01-06 15:24:12 -06:00
The Ghost of FOSS' Future
44fa5dbf60
Update qjs.c 2025-01-06 14:25:39 -06:00
Ben Noordhuis
99c02eb451
Update stack limit in ASan builds (#778)
Otherwise recursive calls keep going until they trip ASan checks.

Remove the `__ASAN__` and `__UBSAN__` defines; no longer necessary.

Remove `globalThis.__running_with_sanitizer__` from qjs; likewise.

Fixes: https://github.com/quickjs-ng/quickjs/issues/671
Fixes: https://github.com/quickjs-ng/quickjs/issues/775
Fixes: https://github.com/quickjs-ng/quickjs/issues/776
2024-12-30 11:29:22 +01:00
KaruroChori
374915ad0c
Rename some internal symbols to avoid collisions 2024-12-15 11:01:16 +01:00
Saúl Ibarra Corretgé
ce03c998c4
Add ability to create standalone binaries with qjs
Ref: https://github.com/quickjs-ng/quickjs/issues/438
Closes: https://github.com/quickjs-ng/quickjs/pull/441
2024-12-03 22:59:11 +01:00
Saúl Ibarra Corretgé
92577d33ff Rename __argv to execArgv 2024-12-03 07:05:38 +01:00
Saúl Ibarra Corretgé
5cfb0ec260 Expose raw argv in CLI
`scriptArgs` only contains arguments that the CLI didn't parse, the
script might want to dig into all the arguments.
2024-12-02 21:17:16 +01:00
Saúl Ibarra Corretgé
f7f70fc579 Fix leak when interpreter exits due to exception
Fixes: https://github.com/quickjs-ng/quickjs/issues/720
2024-11-25 11:07:07 +01:00
Ben Noordhuis
df81c9940f
Make qjs --std switch include bjson module (#640) 2024-10-29 22:56:00 +01:00
Saúl Ibarra Corretgé
0c8aeb1d50 Eval CLI included files as scripts
After 8cd59bf7c4 any file included by qjs
with -I that would parse as a module is eval'd as so, which is usually
not the intent, but rather to define some global functions.
2024-10-24 22:25:13 +02:00
Saúl Ibarra Corretgé
cc11a829e8
Prefix stdlib modules with "qjs:"
Fixes: https://github.com/quickjs-ng/quickjs/issues/616
2024-10-24 22:24:03 +02:00
Saúl Ibarra Corretgé
1defa63c73
Add version to navigator.userAgent (#542)
A la Deno and Bun.
2024-09-24 18:28:14 +02:00
Saúl Ibarra Corretgé
6ce2dcc938 Add ability to compile the CLI with mimalloc
Some (unscientific) benchmark results:

| Benchmark (Higher scores are better)  | QuickJS           | QuickJS (mimalloc) |
|---------------------------------------|-------------------|--------------------|
| Richards                              | 1217              | 1229               |
| DeltaBlue                             | 1192              | 1297               |
| Crypto                                | 1195              | 1191               |
| RayTrace                              | 1477              | 2186               |
| EarleyBoyer                           | 2441              | 3246               |
| RegExp                                | 275               | 315                |
| Splay                                 | 2461              | 3765               |
| NavierStokes                          | 2156              | 2119               |
| Score                                 | 1318              | 1553               |

Running the V8 benchmark suite (version 7) on an M1 MacBook Pro.

Fixes: https://github.com/quickjs-ng/quickjs/issues/142
2024-09-20 09:49:01 +02:00
Saúl Ibarra Corretgé
cfeeff91db Refactor JSMallocFunctions to simplify the implementation
Rather than having the user take care of JSMallocState, take care of the
bookkeeping internally (and make JSMallocState non-public since it's no
longer necessary) and keep the allocation functions to the bare minimum.

This has the advantage that using a different allocator is just a few
lines of code, and there is no need to copy the default implementation
just to moficy the call to the allocation function.

Fixes: https://github.com/quickjs-ng/quickjs/issues/285
2024-09-19 20:49:09 +02:00
Saúl Ibarra Corretgé
fb70e0994b Simplify realloc
Call to our free wrapper when size is 0.
2024-09-11 22:09:27 +02:00
Saúl Ibarra Corretgé
5a41aaa6a3 Use calloc rather than malloc + memset 2024-09-11 22:09:27 +02:00
Saúl Ibarra Corretgé
7ad980704c Report async failures via exit code
Fixes: https://github.com/quickjs-ng/quickjs/issues/340
2024-09-10 21:42:01 +02:00
Saúl Ibarra Corretgé
54afb19745 Make the timeout test more resilient
Since we don't keep timers sorted by deadline but by insertion order,
the test is flaky in slow environments (GHA seemingly). Increase the
timeouts to give it a bigger chance of success.

ASan / UBSan builds are notoriously slow, so skip the test in those.
2024-09-09 22:42:51 +02:00
Saúl Ibarra Corretgé
da591954a8 Add ability to specify dump flags with an env variable
Useful for CI for example.
2024-09-06 23:52:54 +02:00
Saúl Ibarra Corretgé
b5d2210096 Document -D/--dump-flags in CLI output 2024-09-06 23:19:11 +02:00
Ben Noordhuis
5a50ce3b08
Export bjson module (#478)
I find it convenient to have access to JS_ReadObject and JS_WriteObject
from JS land. That's precisely the functionality that tests/bjson.c
provides, ergo, move it into quickjs-libc.c
2024-08-11 11:04:08 +02:00
Tom Lienard
d3da56b630 Sync TLA implementation with upstream
Fixes: https://github.com/quickjs-ng/quickjs/issues/339
2024-06-07 15:46:44 +02:00
Saúl Ibarra Corretgé
6cb1301305 Accept "kmg" suffixes for memory limits
Switch the default in the CLI to kilobytes too.
2024-05-06 11:22:16 +02:00
Saúl Ibarra Corretgé
e5ae6cf106 Fix handling of memory limit
Default to 0, which is "disabled", just like the stack limit.
2024-05-06 11:22:16 +02:00
Saúl Ibarra Corretgé
2050bc782a Fix CLI memory stats output 2024-05-05 19:12:42 +02:00
Charlie Gordon
16e7661fa0
Improve dump option support (#344)
- DUMP_XXX defined as nothing or 0 produces unconditional output
- DUMP_XXX defined as a bitmask produces conditional output based
    on command line option -d<bitmask>
- add `JS_SetDumpFlags()` to select active dump options
- accept -d[<hex mask>] and --dump[=<hex mask>] to specify active
    dump options, generalize command line option handling
- improve DUMP_READ_OBJECT output, fix indentation issue
2024-04-14 02:00:19 +02:00
Ben Noordhuis
4b138c8923
Run V8 spec conformance test suite (#243)
The shell script runs the tests and diffs stdout against v8.txt.
Lines added/removed means tests were broken/fixed.

Future work is to a) fix failing tests, and b) enable more tests.

A number are disabled for various reasons and mjsunit subdirectories are
currently skipped. Need to decide on a case-by-case basis what is and
isn't relevant to us.

At the moment about 430 tests are run of which approx. 80% pass.
2024-01-02 07:47:40 +01:00
Saúl Ibarra Corretgé
030a0ddf3f Add navigator.userAgent to qjs CLI 2023-12-11 22:46:01 +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
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
Saúl Ibarra Corretgé
00d104e519 Add clang64 MinGW environment to CI
run-test262 required pthreads, so let's add that. In addition, in MinGW,
clock_gettime is implemented in the pthreads library, so we want to link
it too.

This doesn't get us anywhere closer to building with ClangCL on Windows,
but hey, another target that required some tweaking...
2023-11-28 09:11:27 +01:00
Saúl Ibarra Corretgé
5e4d45a9d4 Add -ng suffix to CLI output 2023-11-23 00:07:26 +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
Saúl Ibarra Corretgé
afee50e89e Fix compilation warning
~~~
/home/runner/work/quickjs/quickjs/qjs.c:506:28: error: ‘best[3]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  506 |                 if (i == 0 || best[j] > ms)
      |                     ~~~~~~~^~~~~~~~~~~~~~~
/home/runner/work/quickjs/quickjs/qjs.c:506:28: error: ‘best[2]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
/home/runner/work/quickjs/quickjs/qjs.c:506:28: error: ‘best[1]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
~~~
2023-11-11 18:33:51 +01:00
Saúl Ibarra Corretgé
55e845c5dd Add JS_GetVersion 2023-11-10 16:48:49 +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
Ben Noordhuis
5d5b3cc21f
Remove BigDecimal (#29)
Part of https://github.com/quickjs-ng/quickjs/issues/17
2023-11-08 21:07:16 +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
Saúl Ibarra Corretgé
79f3bbc215 Fix build when bignum extensions are not enabled 2023-11-02 09:36:35 +01:00