Commit graph

375 commits

Author SHA1 Message Date
bellard
148a205b71 Fix UB in bf_set_ui()
Ref: https://github.com/bellard/quickjs/issues/131
2023-12-02 16:05:10 +01:00
Nick Vatamaniuc
6b3bed1740
Fix stack overflow in CVE-2023-31922 (#157)
isArray and proxy isArray can call each other indefinitely in a mutually
recursive loop.

Add a stack overflow check in the js_proxy_isArray function before calling
`JS_isArray(ctx, s->target)`.

Original issue: https://github.com/bellard/quickjs/issues/178
CVE: https://nvd.nist.gov/vuln/detail/CVE-2023-31922
2023-12-01 16:31:36 +01:00
Saúl Ibarra Corretgé
bf1facaea3 Always enable stack checking
Seems to work in Emscripten and it can be disabled with
JS_SetMaxStackSize(rt, 0).
2023-12-01 15:29:18 +01:00
Ben Noordhuis
a5b9e54151
Re-enable stack depth checks under ASan (#161)
The default 256 kb stack is too small to run some of the test262 tests
when ASAN is enabled.

Double it to 512 kb and ensure threads created by quickjs have big
enough stacks.
2023-11-30 22:18:23 +01:00
Saúl Ibarra Corretgé
0745c3a12b Add Emscripten target to CI
No testing, just making sure it compiles, and keeps on doing so.

Ref: https://github.com/quickjs-ng/quickjs/issues/75
2023-11-30 21:29:51 +01:00
Saúl Ibarra Corretgé
6f5cda46e7 Test Debug and Release on ClangCL 2023-11-30 09:28:39 +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
Ben Noordhuis
3f10651dc1
Prohibit freezing/sealing module namespace objects (#160) 2023-11-30 00:42:36 +01:00
Ben Noordhuis
b6b70e471c
Add os.cputime() (#159)
And use it in microbench to get slightly more accurate results.
2023-11-30 00:05:48 +01:00
Ben Noordhuis
a140e1cf2c
Make -DDUMP_BYTECODE=64 print executed bytecode (#158)
Basically a poor man's bytecode tracer.
2023-11-29 23:53:01 +01:00
Ben Noordhuis
39c8acd312 Replace JS_DupValue() calls with js_dup() 2023-11-29 23:38:01 +01:00
Ben Noordhuis
f1d6e9e5ff Replace JS_NewBool() calls with js_bool() 2023-11-29 23:38:01 +01:00
Ben Noordhuis
a28d1b822c Replace JS_NewUint32() calls with js_uint32() 2023-11-29 23:38:01 +01:00
Ben Noordhuis
087441559e Replace JS_NewFloat64() calls with js_float64() 2023-11-29 23:38:01 +01:00
Ben Noordhuis
46155806fc Replace JS_NewInt32() calls with js_int32() 2023-11-29 23:38:01 +01:00
Linus Groh
3b034b84d9
Fix null pointer arithmetic UB in libregexp (#136)
This is a patch I originally wrote for the Kiesel JS engine:
https://codeberg.org/kiesel-js/kiesel/src/branch/main/patches/libregexp.patch
2023-11-29 14:43:02 +01:00
Ben Noordhuis
f181b3e54f
Remove dead code (#155) 2023-11-29 10:13:13 +01:00
Marcin Kolny
699744562e Enable support for GCC compler v < 4.9
GCCv4.8 and lower doesn't ship with stdatomic implementation
(even though they don't define __STD_NO_ATOMICS__ for c11).
If the code is compiled with GCCv4.8 and older, we use builtin
GCC atomic operations instead.

The patch was initially proposed in quickjs's mailing group:
https://www.freelists.org/post/quickjs-devel/PATCH-support-for-older-gcc-versions-whitespace-changes-excluded
2023-11-29 09:22:27 +01:00
Divy Srivastava
6b78c7f3e1
Implement polymorphic inline caches (#120) 2023-11-29 09:12:02 +01:00
Ben Noordhuis
5c3077e091
Implement RegExp serialization (#153)
JS_WriteObject() and JS_ReadObject() now support RegExp objects.
2023-11-29 08:50:53 +01:00
Ben Noordhuis
a6e73ca73c
Handle serialization endianness transparently (#152)
Change JS_WriteObject() and JS_WriteObject2() to write little-endian
data and update JS_ReadObject() to byte-swap data when running on a
big-endian system.

Obsoletes the JS_WRITE_OBJ_BSWAP flag, it is now a no-op.

Fixes: https://github.com/quickjs-ng/quickjs/issues/125
2023-11-28 22:49:01 +01:00
Ben Noordhuis
0ecb2c86b5
Unbreak run-test262 (#151)
Commit 8be0358dd7 broke `run-test262 -c test262.conf -a`, the delayed
parsing of the config file overwrote the effect of the `-a` flag.
2023-11-28 22:42:22 +01:00
Saúl Ibarra Corretgé
5c136edbcf Implement WeakRef 2023-11-28 13:26:33 +01:00
Saúl Ibarra Corretgé
1df9615638 Generalize weakref handling logic 2023-11-28 13:26:33 +01:00
Saúl Ibarra Corretgé
331356625e Simplify CMake invocation 2023-11-28 09:30:45 +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é
0b920e7411 Fix make debug 2023-11-27 23:53:41 +01:00
Ben Noordhuis
8be0358dd7
Ignore testdir config when -d or -f is passed (#145)
Otherwise it runs the whole test262 suite even though I just want to run
a select few.
2023-11-27 00:59:30 +01:00
Ben Noordhuis
b5148b212e
Implement static class initializer blocks (#144)
Spec compliance bug: "await" is illegal inside initializer blocks
_except_ when used as an identifier in a function expression, like so:

    class C {
        static {
            var f = function await() {}
        }
    }

It is somewhat complicated to make the parser understand the distinction
and such code is probably rare or non-existent so I decided to leave
well enough alone for now.
2023-11-26 21:11:48 +01:00
Ben Noordhuis
51633afe56
Remove no-op OP_swap+OP_swap bytecode sequence (#143)
Observed in generated code for static initializers. We could in theory
track and correct it in js_parse_class() but doing it as a peephole
optimization is both easier and more general.
2023-11-26 16:54:43 +01:00
Saúl Ibarra Corretgé
fb1b1ced26
Set default visibility to hidden and export the public API (#140) 2023-11-26 01:41:32 +01:00
Ben Noordhuis
8df335a7b9
Expose class name to static initializers (#139)
Fixes: https://github.com/quickjs-ng/quickjs/issues/138
2023-11-26 01:09:18 +01:00
Saúl Ibarra Corretgé
d4c1244045 Ignore -Wimplicit-fallthrough 2023-11-26 00:08:48 +01:00
Saúl Ibarra Corretgé
d74b2e7ec1 Squelch a -Wcast-function-type warnings
Ref: https://github.com/quickjs-ng/quickjs/issues/131
2023-11-26 00:08:48 +01:00
Saúl Ibarra Corretgé
7776cc3b75 Fix getting array buffer when building Uint8Array 2023-11-25 00:42:44 +01:00
Saúl Ibarra Corretgé
27287519aa Fix implicit enum conversion
Ref: https://github.com/quickjs-ng/quickjs/issues/131
2023-11-25 00:00:45 +01:00
Saúl Ibarra Corretgé
8f2993bd68 Add APIs to build a Uint8Array from binary data directly 2023-11-24 23:05:39 +01:00
Saúl Ibarra Corretgé
268cde8270 Add API to build Date objects 2023-11-24 23:05:27 +01:00
Saúl Ibarra Corretgé
0bbb78ce5e Fix not making library include path public
This broke embedding the qjs library via CMake.
2023-11-24 23:05:12 +01:00
Fedor Indutny
ff5e8dc3f5 Fix repl autocompletion for regexp with flags
Fix: #74
2023-11-24 20:57:03 +01:00
Saúl Ibarra Corretgé
463df3adf6 Simplify code in CI 2023-11-24 15:44:35 +01:00
Saúl Ibarra Corretgé
72e542fbeb Add MinGW 32 CI target 2023-11-24 15:44:35 +01:00
Ben Noordhuis
22a3d80740 Implement Map.groupBy 2023-11-24 11:30:21 +01:00
Ben Noordhuis
3e54403b08 Implement Object.groupBy 2023-11-24 11:30:21 +01:00
Ben Noordhuis
52f7524932 Enable array-grouping test262 feature 2023-11-24 11:30:21 +01:00
Divy Srivastava
a8a5ecb095
Specialize bytecode for default ctor (#112) 2023-11-24 01:27:18 +01:00
Saúl Ibarra Corretgé
4e73bcf42d
Now working on version 0.2.0 2023-11-23 15:46:00 +01:00
Saúl Ibarra Corretgé
fd3d71b486
Set version 0.1.0 2023-11-23 14:44:54 +01:00
Saúl Ibarra Corretgé
af456e6c11 Add workflow for making releases 2023-11-23 14:43:56 +01:00
Saúl Ibarra Corretgé
5e4d45a9d4 Add -ng suffix to CLI output 2023-11-23 00:07:26 +01:00