Skip to content

Commit 88ec314

Browse files
authored
Revert "deps,lib,tools: remove jitless and lite modes"
Newer version of V8 no longer supports --allow-overwriting-for-next-flag and there's no way to override the preset flag now. Revert the commit to allow users to opt-in into the flags if still necessary. This reverts commit 7e39b87. Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: #66516 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent 95009e8 commit 88ec314

20 files changed

Lines changed: 98 additions & 142 deletions

‎BUILDING.md‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ and libc version. The table below lists the support tier for each supported
9898
combination. A list of [supported compile toolchains](#supported-toolchains) is
9999
also supplied for tier 1 platforms.
100100

101-
Node.js requires WebAssembly for built-in functionality, including `fetch()` and
102-
TypeScript support. JIT-less execution and V8 lite mode are not supported.
103-
104101
**For production applications, run Node.js on supported platforms only (Tier 1 or 2).**
105102

106103
Node.js does not support a platform version if a vendor has expired support

‎configure.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,14 @@
12241224
default=False,
12251225
help='compile V8 with debug checks and runtime debugging features enabled')
12261226

1227+
parser.add_argument('--v8-lite-mode',
1228+
action='store_true',
1229+
dest='v8_lite_mode',
1230+
default=False,
1231+
help='compile V8 in lite mode for constrained environments (lowers V8 '+
1232+
'memory footprint, but also implies no just-in-time compilation ' +
1233+
'support, thus much slower execution)')
1234+
12271235
parser.add_argument('--v8-enable-object-print',
12281236
action='store_true',
12291237
dest='v8_enable_object_print',
@@ -1310,10 +1318,6 @@
13101318

13111319
(options, args) = parser.parse_known_args()
13121320

1313-
# Reject the removed option before forwarding unknown arguments to GYP.
1314-
if any(arg.split('=', 1)[0] == '--v8-lite-mode' for arg in args):
1315-
parser.error('--v8-lite-mode is no longer supported; Node.js requires WebAssembly')
1316-
13171321
# Expand ~ in the install prefix now, it gets written to multiple files.
13181322
options.prefix = str(Path(options.prefix or '').expanduser())
13191323

@@ -2227,8 +2231,9 @@ def configure_library(lib, output, pkgname=None):
22272231
def configure_v8(o, configs):
22282232
set_configuration_variable(configs, 'v8_enable_v8_checks', release=0, debug=1)
22292233

2230-
o['variables']['v8_enable_webassembly'] = 1
2234+
o['variables']['v8_enable_webassembly'] = 0 if options.v8_lite_mode else 1
22312235
o['variables']['v8_enable_javascript_promise_hooks'] = 1
2236+
o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0
22322237
is_gdbjit_supported_arch = (
22332238
'x64' in o['variables']['target_arch'] or
22342239
'ia32' in o['variables']['target_arch'] or

‎doc/api/cli.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,19 @@ added: v0.7.7
21962196

21972197
Opens the REPL even if stdin does not appear to be a terminal.
21982198

2199+
### `--jitless`
2200+
2201+
<!-- YAML
2202+
added: v12.0.0
2203+
-->
2204+
2205+
> Stability: 1 - Experimental. This flag is inherited from V8 and is subject to
2206+
> change upstream.
2207+
2208+
Disable [runtime allocation of executable memory][jitless]. This may be
2209+
required on some platforms for security reasons. It can also reduce attack
2210+
surface on other platforms, but the performance impact may be severe.
2211+
21992212
### `--localstorage-file=file`
22002213

22012214
<!-- YAML
@@ -4398,6 +4411,7 @@ V8 options that are allowed are:
43984411
* `--enable-etw-stack-walking`
43994412
* `--expose-gc`
44004413
* `--interpreted-frames-native-stack`
4414+
* `--jitless`
44014415
* `--max-heap-size`
44024416
* `--max-old-space-size`
44034417
* `--max-semi-space-size`
@@ -4768,6 +4782,8 @@ documented here:
47684782

47694783
### `--interpreted-frames-native-stack`
47704784

4785+
### `--jitless`
4786+
47714787
### `--max-heap-size`
47724788

47734789
Specifies the maximum heap size (in megabytes) for the process.
@@ -4960,6 +4976,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
49604976
[environment_variables]: #environment-variables-1
49614977
[filtering tests by name]: test.md#filtering-tests-by-name
49624978
[global setup and teardown]: test.md#global-setup-and-teardown
4979+
[jitless]: https://v8.dev/blog/jitless
49634980
[libuv threadpool documentation]: https://docs.libuv.org/en/latest/threadpool.html
49644981
[module compile cache]: module.md#module-compile-cache
49654982
[preloading asynchronous module customization hooks]: module.md#registration-of-asynchronous-customization-hooks

‎doc/api/errors.md‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3645,6 +3645,14 @@ The WASI instance has already started.
36453645

36463646
The WASI instance has not been started.
36473647

3648+
<a id="ERR_WEBASSEMBLY_NOT_SUPPORTED"></a>
3649+
3650+
### `ERR_WEBASSEMBLY_NOT_SUPPORTED`
3651+
3652+
A feature requiring WebAssembly was used, but WebAssembly is not supported or
3653+
has been disabled in the current environment (for example, when running with
3654+
`--jitless`).
3655+
36483656
<a id="ERR_WEBASSEMBLY_RESPONSE"></a>
36493657

36503658
### `ERR_WEBASSEMBLY_RESPONSE`
@@ -4480,18 +4488,6 @@ The linker function returned a module for which linking has failed.
44804488

44814489
The module must be successfully linked before instantiation.
44824490

4483-
<a id="ERR_WEBASSEMBLY_NOT_SUPPORTED"></a>
4484-
4485-
### `ERR_WEBASSEMBLY_NOT_SUPPORTED`
4486-
4487-
<!-- YAML
4488-
removed: REPLACEME
4489-
-->
4490-
4491-
A feature requiring WebAssembly was used in an environment where WebAssembly
4492-
was unavailable. Node.js now requires WebAssembly and no longer supports
4493-
JIT-less execution.
4494-
44954491
<a id="ERR_WORKER_UNSUPPORTED_EXTENSION"></a>
44964492

44974493
### `ERR_WORKER_UNSUPPORTED_EXTENSION`

‎doc/node.1‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,11 @@ See V8 Inspector integration for Node.js for further explanation on Node.js debu
11751175
.It Fl i , Fl -interactive
11761176
Opens the REPL even if stdin does not appear to be a terminal.
11771177
.
1178+
.It Fl -jitless
1179+
Disable runtime allocation of executable memory. This may be
1180+
required on some platforms for security reasons. It can also reduce attack
1181+
surface on other platforms, but the performance impact may be severe.
1182+
.
11781183
.It Fl -localstorage-file Ns = Ns Ar file
11791184
The file used to store \fBlocalStorage\fR data. If the file does not exist, it is
11801185
created the first time \fBlocalStorage\fR is accessed. The same file may be shared
@@ -2523,6 +2528,8 @@ V8 options that are allowed are:
25232528
.It
25242529
\fB--interpreted-frames-native-stack\fR
25252530
.It
2531+
\fB--jitless\fR
2532+
.It
25262533
\fB--max-heap-size\fR
25272534
.It
25282535
\fB--max-old-space-size\fR

‎lib/eslint.config_partial.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ export default [
298298
name: 'URLSearchParams',
299299
message: "Use `const { URLSearchParams } = require('internal/url');` instead of the global.",
300300
},
301-
// WebAssembly is unavailable during snapshot building and must be
302-
// accessed lazily at runtime.
301+
// WebAssembly is not available in primordials because it can be
302+
// disabled with --jitless CLI flag.
303303
{
304304
name: 'WebAssembly',
305305
message: 'Use `const { WebAssembly } = globalThis;` instead of the global.',

‎lib/internal/errors.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,9 @@ E('ERR_VM_MODULE_NOT_MODULE',
19811981
'Provided module is not an instance of Module', Error);
19821982
E('ERR_VM_MODULE_STATUS', 'Module status %s', Error);
19831983
E('ERR_WASI_ALREADY_STARTED', 'WASI instance has already started', Error);
1984+
E('ERR_WEBASSEMBLY_NOT_SUPPORTED',
1985+
'WebAssembly is not supported in this environment, but is required for %s',
1986+
Error);
19841987
E('ERR_WEBASSEMBLY_RESPONSE', 'WebAssembly response %s', TypeError);
19851988
E('ERR_WORKER_HANDLE_NOT_TRANSFERABLE',
19861989
'%s cannot be transferred in its current state; it must be a freshly ' +

‎lib/internal/freeze_intrinsics.js‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,18 @@ module.exports = function() {
363363
ArrayPrototypePush(intrinsics, SharedArrayBuffer);
364364
}
365365

366-
ArrayPrototypePush(intrinsicPrototypes,
367-
WebAssembly.Module.prototype,
368-
WebAssembly.Instance.prototype,
369-
WebAssembly.Table.prototype,
370-
WebAssembly.Memory.prototype,
371-
WebAssembly.CompileError.prototype,
372-
WebAssembly.LinkError.prototype,
373-
WebAssembly.RuntimeError.prototype,
374-
);
375-
ArrayPrototypePush(intrinsics, WebAssembly);
366+
if (typeof WebAssembly !== 'undefined') {
367+
ArrayPrototypePush(intrinsicPrototypes,
368+
WebAssembly.Module.prototype,
369+
WebAssembly.Instance.prototype,
370+
WebAssembly.Table.prototype,
371+
WebAssembly.Memory.prototype,
372+
WebAssembly.CompileError.prototype,
373+
WebAssembly.LinkError.prototype,
374+
WebAssembly.RuntimeError.prototype,
375+
);
376+
ArrayPrototypePush(intrinsics, WebAssembly);
377+
}
376378

377379
if (typeof Intl !== 'undefined') {
378380
ArrayPrototypePush(intrinsicPrototypes,

‎lib/internal/util.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ const {
4545
SymbolPrototypeGetDescription,
4646
SymbolReplace,
4747
SymbolSplit,
48+
globalThis,
4849
} = primordials;
4950

5051
const {
5152
codes: {
5253
ERR_NO_CRYPTO,
5354
ERR_NO_TYPESCRIPT,
5455
ERR_UNKNOWN_SIGNAL,
56+
ERR_WEBASSEMBLY_NOT_SUPPORTED,
5557
},
5658
isErrorStackTraceLimitWritable,
5759
overrideStackTrace,
@@ -243,6 +245,8 @@ function assertCrypto() {
243245
function assertTypeScript() {
244246
if (noTypeScript)
245247
throw new ERR_NO_TYPESCRIPT();
248+
if (globalThis.WebAssembly === undefined)
249+
throw new ERR_WEBASSEMBLY_NOT_SUPPORTED('TypeScript');
246250
}
247251

248252
/**

‎src/node.cc‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@
4848
#include "node_version.h"
4949
#include "permission/env_permission.h"
5050

51-
#if defined(V8_JITLESS) || defined(V8_LITE_MODE)
52-
#error Node.js does not support interpreter-only V8 builds.
53-
#endif
54-
5551
#if HAVE_OPENSSL
5652
#include "ncrypto.h"
5753
#if OPENSSL_VERSION_MAJOR >= 3
@@ -1112,12 +1108,6 @@ static ExitCode InitializeNodeWithArgsInternal(
11121108

11131109
allow_env_sources.Finish();
11141110

1115-
// Node.js requires WebAssembly for built-in functionality. Override these
1116-
// modes after all option sources, before V8 applies their implications.
1117-
// Explicitly allow overriding even when contradiction checks are enabled.
1118-
V8::SetFlagsFromString("--allow-overwriting-for-next-flag --no-lite-mode "
1119-
"--allow-overwriting-for-next-flag --no-jitless");
1120-
11211111
// Every option source has now been parsed, so cross-source option
11221112
// constraints can finally be validated.
11231113
CheckGlobalBenchOptions(errors);

0 commit comments

Comments
 (0)