Skip to content

Commit 969992d

Browse files
Merge branch 'master' into atomic_strings_new
2 parents 3810cb3 + 2d97e80 commit 969992d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+10197
-583
lines changed

.github/workflows/check-pr.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ jobs:
4848
cd quickjs
4949
CFLAGS=$CC_OPT LDFLAGS=$LD_OPT $MAKE_UTILITY -j$(nproc) libquickjs.a
5050
51+
- name: Check out and build quickjs-ng
52+
run: |
53+
git clone https://github.com/quickjs-ng/quickjs quickjs-ng
54+
cd quickjs-ng
55+
git checkout v0.8.0
56+
CFLAGS="$CC_OPT -fPIC" LDFLAGS=$LD_OPT cmake -B build
57+
cmake --build build --target qjs -j $(nproc)
58+
5159
- name: Configure and make njs
5260
run: |
5361
./configure \
@@ -88,6 +96,20 @@ jobs:
8896
$MAKE_UTILITY test
8997
$MAKE_UTILITY clean
9098
99+
- name: Configure and make njs with quickjs-ng
100+
run: |
101+
./configure \
102+
--with-quickjs \
103+
--cc-opt="$CC_OPT -Iquickjs-ng" \
104+
--ld-opt="$LD_OPT -Lquickjs-ng/build" \
105+
|| cat build/autoconf.err
106+
$MAKE_UTILITY -j$(nproc)
107+
108+
- name: Test njs with quickjs-ng
109+
run: |
110+
$MAKE_UTILITY test
111+
$MAKE_UTILITY clean
112+
91113
- name: Configure and build nginx and njs modules
92114
run: |
93115
cd nginx-source
@@ -168,3 +190,62 @@ jobs:
168190
TEST_NGINX_VERBOSE: 1
169191
ASAN_OPTIONS: "detect_odr_violation=0:report_globals=0:fast_unwind_on_malloc=0"
170192
LSAN_OPTIONS: "suppressions=${{ github.workspace }}/lsan_suppressions.txt"
193+
194+
- name: Configure and build nginx and njs modules with quickjs-ng, asan, static modules
195+
run: |
196+
cd nginx-source
197+
$NGINX_CONFIGURE_CMD --with-cc-opt="$CC_OPT -I${{ github.workspace }}/quickjs-ng -fsanitize=address -DNJS_DEBUG_MEMORY -DNGX_DEBUG_PALLOC -DNGX_DEBUG_MALLOC" --with-ld-opt="$LD_OPT -L${{ github.workspace }}/quickjs-ng/build -fsanitize=address" --add-module=../nginx || cat objs/autoconf.err
198+
$MAKE_UTILITY -j$(nproc)
199+
200+
- name: Test njs modules, quickjs-ng, static modules
201+
run: |
202+
ulimit -c unlimited
203+
prove -v -j$(nproc) -Inginx-tests/lib --state=save nginx/t . || prove -v -Inginx-tests/lib --state=failed
204+
env:
205+
TEST_NGINX_BINARY: "${{ github.workspace }}/nginx-source/objs/nginx"
206+
TEST_NGINX_VERBOSE: 1
207+
ASAN_OPTIONS: "detect_odr_violation=0:report_globals=0"
208+
LSAN_OPTIONS: "suppressions=${{ github.workspace }}/lsan_suppressions.txt"
209+
210+
- name: Test njs modules (js_engine qjs), quickjs-ng, static modules
211+
run: |
212+
ulimit -c unlimited
213+
prove -v -j$(nproc) -Inginx-tests/lib --state=save nginx/t . || prove -v -Inginx-tests/lib --state=failed
214+
env:
215+
TEST_NGINX_BINARY: "${{ github.workspace }}/nginx-source/objs/nginx"
216+
TEST_NGINX_GLOBALS_HTTP: "js_engine qjs;"
217+
TEST_NGINX_GLOBALS_STREAM: "js_engine qjs;"
218+
TEST_NGINX_VERBOSE: 1
219+
ASAN_OPTIONS: "detect_odr_violation=0:report_globals=0"
220+
LSAN_OPTIONS: "suppressions=${{ github.workspace }}/lsan_suppressions.txt"
221+
222+
- name: Configure and build nginx and njs modules with quickjs-ng, asan, dynamic modules
223+
run: |
224+
cd nginx-source
225+
$NGINX_CONFIGURE_CMD --with-debug --with-cc-opt="$CC_OPT -I${{ github.workspace }}/quickjs-ng -fsanitize=address -DNJS_DEBUG_MEMORY -DNGX_DEBUG_PALLOC -DNGX_DEBUG_MALLOC" --with-ld-opt="$LD_OPT -L${{ github.workspace }}/quickjs-ng/build -fsanitize=address" --add-dynamic-module=../nginx || cat objs/autoconf.err
226+
$MAKE_UTILITY -j$(nproc) modules
227+
$MAKE_UTILITY -j$(nproc)
228+
229+
- name: Test njs modules, quickjs-ng, dynamic modules
230+
run: |
231+
ulimit -c unlimited
232+
prove -v -j$(nproc) -Inginx-tests/lib --state=save nginx/t . || prove -v -Inginx-tests/lib --state=failed
233+
env:
234+
TEST_NGINX_BINARY: "${{ github.workspace }}/nginx-source/objs/nginx"
235+
TEST_NGINX_GLOBALS: "load_module ${{ github.workspace }}/nginx-source/objs/ngx_stream_js_module.so; load_module ${{ github.workspace }}/nginx-source/objs/ngx_http_js_module.so;"
236+
TEST_NGINX_VERBOSE: 1
237+
ASAN_OPTIONS: "detect_odr_violation=0:report_globals=0:fast_unwind_on_malloc=0"
238+
LSAN_OPTIONS: "suppressions=${{ github.workspace }}/lsan_suppressions.txt"
239+
240+
- name: Test njs modules (js_engine qjs), quickjs-ng, dynamic modules
241+
run: |
242+
ulimit -c unlimited
243+
prove -v -j$(nproc) -Inginx-tests/lib --state=save nginx/t . || prove -v -Inginx-tests/lib --state=failed
244+
env:
245+
TEST_NGINX_BINARY: "${{ github.workspace }}/nginx-source/objs/nginx"
246+
TEST_NGINX_GLOBALS: "load_module ${{ github.workspace }}/nginx-source/objs/ngx_stream_js_module.so; load_module ${{ github.workspace }}/nginx-source/objs/ngx_http_js_module.so;"
247+
TEST_NGINX_GLOBALS_HTTP: "js_engine qjs;"
248+
TEST_NGINX_GLOBALS_STREAM: "js_engine qjs;"
249+
TEST_NGINX_VERBOSE: 1
250+
ASAN_OPTIONS: "detect_odr_violation=0:report_globals=0:fast_unwind_on_malloc=0"
251+
LSAN_OPTIONS: "suppressions=${{ github.workspace }}/lsan_suppressions.txt"

CHANGES

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
Changes with njs 0.8.9 14 Jan 2025
2+
3+
nginx modules:
4+
5+
*) Bugfix: removed extra VM creation per server.
6+
Previously, when js_import was declared in http or stream blocks,
7+
an extra copy of the VM instance was created for each server
8+
block. This was not needed and consumed a lot of memory for
9+
configurations with many server blocks.
10+
11+
This issue was introduced in 9b674412 (0.8.6) and was partially
12+
fixed for location blocks only in 685b64f0 (0.8.7).
13+
14+
Core:
15+
16+
*) Feature: added fs module for QuickJS engine.
17+
18+
Changes with njs 0.8.8 10 Dec 2024
19+
20+
nginx modules:
21+
22+
*) Feature: implemented shared dictionary for QuickJS engine.
23+
24+
*) Improvement: js_preload_object is refactored.
25+
26+
*) Bugfix: fixed limit rated output.
27+
28+
*) Bugfix: optimized use of SSL contexts for
29+
js_fetch_trusted_certificate directive.
30+
31+
Core:
32+
33+
*) Feature: implemented process object for QuickJS engine.
34+
35+
*) Feature: implemented process.kill() method.
36+
37+
*) Bugfix: fixed tests with libxml2 2.13 and later.
38+
39+
*) Bugfix: fixed promise resolving when Promise is inherited.
40+
41+
*) Bugfix: fixed absolute scope in cloned VMs.
42+
143
Changes with njs 0.8.7 22 Oct 2024
244

345
nginx modules:

LICENSE

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/*
2-
* Copyright (C) 2015-2024 NGINX, Inc.
2+
* Copyright (C) 2015-2019 NGINX, Inc.
3+
* Copyright (C) 2019-2025 F5, Inc.
34
* Copyright (C) 2015-2021 Igor Sysoev
4-
* Copyright (C) 2017-2024 Dmitry Volyntsev
5+
* Copyright (C) 2017-2025 Dmitry Volyntsev
56
* Copyright (C) 2019-2022 Alexander Borisov
6-
* Copyright (C) 2022-2024 Vadim Zhestikov
7+
* Copyright (C) 2022-2025 Vadim Zhestikov
78
* All rights reserved.
89
*
910
* Redistribution and use in source and binary forms, with or without

auto/qjs_modules

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ njs_module_srcs=src/qjs_buffer.c
77

88
. auto/qjs_module
99

10+
njs_module_name=qjs_fs_module
11+
njs_module_incs=
12+
njs_module_srcs=external/qjs_fs_module.c
13+
14+
. auto/qjs_module
15+
16+
if [ $NJS_OPENSSL = YES -a $NJS_HAVE_OPENSSL = YES ]; then
17+
njs_module_name=qjs_webcrypto_module
18+
njs_module_incs=
19+
njs_module_srcs=external/qjs_webcrypto_module.c
20+
21+
. auto/qjs_module
22+
fi
23+
1024
if [ $NJS_ZLIB = YES -a $NJS_HAVE_ZLIB = YES ]; then
1125
njs_module_name=qjs_zlib_module
1226
njs_module_incs=

auto/quickjs

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,19 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
5353
. auto/feature
5454
fi
5555

56+
if [ $njs_found = no ]; then
57+
njs_feature="QuickJS-NG library -lqjs"
58+
njs_feature_incs=""
59+
njs_feature_libs="-lqjs -lm -ldl -lpthread"
60+
61+
. auto/feature
62+
fi
63+
64+
5665
if [ $njs_found = yes ]; then
5766

5867
njs_feature="QuickJS JS_GetClassID()"
68+
njs_feature_name=NJS_HAVE_QUICKJS_GET_CLASS_ID
5969
njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
6070
#pragma GCC diagnostic push
6171
#pragma GCC diagnostic ignored \"-Wcast-function-type\"
@@ -64,7 +74,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
6474
#include <quickjs.h>
6575

6676
int main() {
67-
(void) JS_GetClassID;
77+
(void) JS_GetClassID(JS_UNDEFINED);
6878
return 0;
6979
}"
7080

@@ -78,6 +88,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
7888
fi
7989

8090
njs_feature="QuickJS JS_NewTypedArray()"
91+
njs_feature_name=NJS_HAVE_QUICKJS_NEW_TYPED_ARRAY
8192
njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
8293
#pragma GCC diagnostic push
8394
#pragma GCC diagnostic ignored \"-Wcast-function-type\"
@@ -86,15 +97,66 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
8697
#include <quickjs.h>
8798

8899
int main() {
89-
(void) JS_NewTypedArray;
100+
JSValue ta, argv;
101+
JSRuntime *rt;
102+
JSContext *ctx;
103+
104+
rt = JS_NewRuntime();
105+
ctx = JS_NewContext(rt);
106+
argv = JS_NewInt64(ctx, 1);
107+
ta = JS_NewTypedArray(ctx, 1, &argv,
108+
JS_TYPED_ARRAY_UINT8);
109+
JS_FreeValue(ctx, ta);
110+
JS_FreeContext(ctx);
111+
JS_FreeRuntime(rt);
90112
return 0;
91113
}"
92114

93115
. auto/feature
94116

95-
if [ $njs_found = yes ]; then
96-
njs_define=NJS_HAVE_QUICKJS_NEW_TYPED_ARRAY . auto/define
97-
fi
117+
njs_feature="QuickJS JS_IsSameValue()"
118+
njs_feature_name=NJS_HAVE_QUICKJS_IS_SAME_VALUE
119+
njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
120+
#pragma GCC diagnostic push
121+
#pragma GCC diagnostic ignored \"-Wcast-function-type\"
122+
#endif
123+
124+
#include <quickjs.h>
125+
126+
int main() {
127+
JSRuntime *rt;
128+
JSContext *ctx;
129+
130+
rt = JS_NewRuntime();
131+
ctx = JS_NewContext(rt);
132+
(void) JS_IsSameValue(ctx, JS_UNDEFINED, JS_UNDEFINED);
133+
JS_FreeContext(ctx);
134+
JS_FreeRuntime(rt);
135+
return 0;
136+
}"
137+
138+
. auto/feature
139+
140+
njs_feature="QuickJS version"
141+
njs_feature_name=NJS_QUICKJS_VERSION
142+
njs_feature_run=value
143+
njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
144+
#pragma GCC diagnostic push
145+
#pragma GCC diagnostic ignored \"-Wcast-function-type\"
146+
#endif
147+
148+
#include <quickjs.h>
149+
150+
int main() {
151+
#if defined(QJS_VERSION_MAJOR)
152+
printf(\"\\\"%s\\\"\", JS_GetVersion());
153+
#else
154+
printf(\"\\\"Unknown\\\"\");
155+
#endif
156+
return 0;
157+
}"
158+
159+
. auto/feature
98160

99161
NJS_HAVE_QUICKJS=YES
100162
NJS_QUICKJS_LIB="$njs_feature_libs"

0 commit comments

Comments
 (0)