Commit graph

658 commits

Author SHA1 Message Date
The Ghost of FOSS' Future
16152fc0ce
Update README.md 2025-01-06 14:56:06 -06:00
The Ghost of FOSS' Future
febcddc3f2
Update LICENSE 2025-01-06 14:27:42 -06:00
The Ghost of FOSS' Future
ea54439877
Update qjsc.c 2025-01-06 14:26:21 -06:00
The Ghost of FOSS' Future
44fa5dbf60
Update qjs.c 2025-01-06 14:25:39 -06:00
Ben Noordhuis
ac4cd17bb5
Track line and column numbers for expressions (#781)
Commit 73cc00e reduced the number of emitted source locations a great
deal but it resulted in at least one observable regression:

    export default async function f() {
         return "abc" + x
    }
    f() // ReferenceError should point to 2:20 but pointed to 1:1

Emit source locations for expressions again. Increases the average
number of source locations by about 15%. Non-scientifically tested
by counting source locations emitted when parsing the test suite
before and after.

No test because we currently cannot easily test stack traces coming
from module imports.

Fixes: https://github.com/quickjs-ng/quickjs/issues/779
2025-01-05 22:20:43 +01:00
Ben Noordhuis
5b609f15af
Optimize derived class construction (#753)
We were emitting gobs of inefficient bytecode that created an arguments
array on the stack, then applied it to the parent constructor.

Add a new opcode for initializing a derived class. Speeds up construction
by 500%, although sadly that is not visible in the web-tooling-benchmark,
only in micro-benchmarks.

Fixes: https://github.com/quickjs-ng/quickjs/issues/752
2025-01-05 22:01:37 +01:00
Ben Noordhuis
6e434008f5
Fix -Wunterminated-string-initialization warning (#787)
Unbreaks the Cygwin build.
2025-01-05 21:42:18 +01:00
gschwind
1b957f71e3
Fix JS_NewClassID comment (#784) 2025-01-05 20:46:21 +01:00
lai
b675a95bec Expose JS_HasException API (#785) 2025-01-05 11:08:37 +01:00
guest271314
9fc794001a
Update cli.md (#783) 2025-01-04 09:56:10 +01: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
Richard Davison
74fd4d7dc9
Add js_string_eq (#765)
Avoids checking equality when string lengths don't match.

Co-authored-by: Richard Davison <ridaviso@amazon.com>
2024-12-27 22:45:42 +01:00
Andrew Johnson
8d88f320fb
Fix compilation of quickjs-libc under emscripten (#773) 2024-12-27 16:37:34 +01:00
Saúl Ibarra Corretgé
482291286b Set version to 0.8.0 2024-12-23 22:45:13 +01:00
Saúl Ibarra Corretgé
e5915821be
Throw error when target executable cannot be found (#764) 2024-12-23 21:31:15 +01:00
Richard Davison
7f156b6ef9
Add typed array utility functions 2024-12-22 16:35:10 +01:00
Saúl Ibarra Corretgé
be2db73000 Use 1 MB as the default stack size
In addition:

- Move the WASI override to quickjs.c
- Allow it to be user defined

Ref: https://github.com/quickjs-ng/quickjs/issues/749#issuecomment-2540167690
2024-12-17 10:03:17 +01:00
KaruroChori
374915ad0c
Rename some internal symbols to avoid collisions 2024-12-15 11:01:16 +01:00
Saúl Ibarra Corretgé
7e292050a2 Drop checks for no longer used files 2024-12-13 09:46:57 +01:00
Cryse Hillmes
4b9d0ebdba Expose JS_IsUncatchableError API.
Very useful when handling errors.
2024-12-10 07:09:07 +01:00
Cryse Hillmes
6198fdf5d5 Update .gitignore for CMake and Visual Studio. 2024-12-10 06:46:11 +01:00
Saúl Ibarra Corretgé
53b641d4b3 Fixes timezone bias on Windows
`GetTimeZoneInformation`returns the bias in minutes already, so no need to adjust it.

Also handle the return code since it determines if the time zone is in the daylight saving range.

Ref: https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-gettimezoneinformation
Fixes: https://github.com/saghul/txiki.js/issues/325
2024-12-09 22:53:43 +01:00
Ben Noordhuis
66732e78ef
Fix break statement in presence of labels (#742)
In this snippet...

    for (;;) label: break

...the break statement jumped back to the start of the loop instead of
*out* of the loop.

Fixes: https://github.com/quickjs-ng/quickjs/issues/741
2024-12-04 23:56:52 +01:00
Oliver
ebc1a655b4
Fix linking with libm
Fixes using clang's MSVC ABI.

Fixes: https://github.com/quickjs-ng/quickjs/issues/728
2024-12-04 07:15:20 +01:00
Saúl Ibarra Corretgé
a41771f735 Update docs on standalone executables 2024-12-03 23:03:37 +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é
721766faa1 Fix exporting JS_GetModuleNamespace 2024-12-03 17:11:34 +01:00
Saúl Ibarra Corretgé
4968ef6e90 Add support for the "x" flag in std.open() 2024-12-03 14:59:50 +01:00
Saúl Ibarra Corretgé
92577d33ff Rename __argv to execArgv 2024-12-03 07:05:38 +01:00
Saúl Ibarra Corretgé
858fc361ff Use UCRT64 variant when making 64bit Windows releases
See: https://www.msys2.org/docs/environments/
2024-12-02 21:19:51 +01:00
Saúl Ibarra Corretgé
e77cfb67b8 Add "compile_module" and "eval_module" flags to std.evalScript
This is preparation for standalone binaries support, we need the ability
to compile source as a module and then evaluate it.
2024-12-02 21:18:08 +01:00
Saúl Ibarra Corretgé
517e9e274e Add ability to load file as Uint8Array in std.loadFile 2024-12-02 21:17:34 +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é
06cd3da2fd Add INSTALL_PREFIX helper variable to Makefile 2024-12-02 21:16:53 +01:00
Saúl Ibarra Corretgé
685a9bc171 Install qjsc as part of the install target
Fixes: https://github.com/quickjs-ng/quickjs/issues/730
2024-12-02 21:16:53 +01:00
Saúl Ibarra Corretgé
fd054b7231 Fix Date.prototype.set* when date is invalid
setYear required special handing since calling date.setYear(NaN) has
specific defined behavior.
2024-11-28 20:45:54 +01:00
Saúl Ibarra Corretgé
c351133dcc Implement Error.captureStackTrace 2024-11-26 12:13:42 +01:00
Ben Noordhuis
0b0b794605
Simplify close_lexical_var (#726)
Its implementation was borderline wrong: calling it with is_arg=TRUE
segfaults because it looks up the var ref index in the wrong array.

Fortunately, there is only one caller and it only passes FALSE.
2024-11-26 00:34:46 +01:00
Saúl Ibarra Corretgé
aca0a09509 Drop GCC 4.8 CI
The workaround to use an old Node version no longer works: https://github.com/actions/checkout/issues/1590
2024-11-25 22:18:05 +01:00
Saúl Ibarra Corretgé
bda14ec9e1 Simplify release CI
In addition, run the release CI, except the upload step on each PR, to
make sure things don't break and we find about them right when doing a
release.
2024-11-25 22:09:11 +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
Saúl Ibarra Corretgé
9631492534 Fix catching all exceptions from std.evalScript
In case of a syntax error, the function throws syncrnonously.

I'll admit I wondered when Promise.try would be useful... I guess I know
now!

Fixes: https://github.com/quickjs-ng/quickjs/issues/720#issuecomment-2495961142
2024-11-25 10:44:05 +01:00
Penner
61dae5d420 fix crash when add property maybe failed on build arguments 2024-11-25 07:59:23 +01:00
pancake
df44d66291
Do not depend on c99 for(int
NB: The project requires C11, but sicne this is the only occurrence of such kind, we let it slide. See the PR conversation.
2024-11-24 12:46:29 +01:00
Saúl Ibarra Corretgé
4ca6d9bba0
Don't share class functions across Set and Map
Map has groupBy and Set doesn't.

Fixes: https://github.com/quickjs-ng/quickjs/issues/714
2024-11-22 08:33:48 +01:00
Ben Noordhuis
81e50f3cae
Use closefrom() to close open file descriptors (#712)
Replace the naive close() loop in js_os_exec with closefrom().

On my system RLIMIT_NOFILE is set to 1 million and the delay from the
loop gets noticeable when I spawn many processes.

Use dlsym() to look up closefrom() because it's not available everywhere
(looking at you, musl.)

Fixes: https://github.com/quickjs-ng/quickjs/issues/711
2024-11-21 20:43:18 +01:00
Icemic
010777f259
Add quickjs-rusty to projects using NG 2024-11-21 14:23:15 +01:00
morn-0
769e78ff7d Remove unnecessary parameters
Enhanced msvc cross-compile compatibility
2024-11-20 15:52:52 +01:00
Saúl Ibarra Corretgé
ef15418807 Fix null deref in js_iterator_helper_next
Fixes: https://github.com/quickjs-ng/quickjs/issues/705
2024-11-19 19:21:34 +01:00
Saúl Ibarra Corretgé
0b9b6c1915
Simplify iterator helpers code, remove duplication 2024-11-18 23:43:39 +01:00