Skip to content

Commit ce67ca8

Browse files
andrewdotncodebytere
authored andcommitted
cli: allow --jitless V8 flag in NODE_OPTIONS
This work is modeled on #30094 which allowed `--disallow-code-generation-from-strings` in `NODE_OPTIONS`. The `--jitless` v8 option has been supported since 12.0.0. As a v8 option, node automatically picks it up, but there have been a few issues that were resolved by simply telling users about the option: #26758, This PR: - allows `--jitless` in `NODE_OPTIONS` - documents `--jitless` - moves `--experimental-loader=module` to locally restore alphabetical order in option documentation Refs: #30094 Refs: #26758 Refs: #28800 PR-URL: #32100 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Shelley Vohr <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent e5dc2fb commit ce67ca8

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

doc/api/cli.md

+22-8
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ added: v12.9.0
163163

164164
Enable experimental JSON support for the ES Module loader.
165165

166+
### `--experimental-loader=module`
167+
<!-- YAML
168+
added: v9.0.0
169+
-->
170+
171+
Specify the `module` of a custom [experimental ECMAScript Module loader][].
172+
`module` may be either a path to a file, or an ECMAScript Module name.
173+
166174
### `--experimental-modules`
167175
<!-- YAML
168176
added: v8.5.0
@@ -421,14 +429,6 @@ Specify ways of the inspector web socket url exposure.
421429
By default inspector websocket url is available in stderr and under `/json/list`
422430
endpoint on `http://host:port/json/list`.
423431

424-
### `--experimental-loader=module`
425-
<!-- YAML
426-
added: v9.0.0
427-
-->
428-
429-
Specify the `module` of a custom [experimental ECMAScript Module loader][].
430-
`module` may be either a path to a file, or an ECMAScript Module name.
431-
432432
### `--insecure-http-parser`
433433
<!-- YAML
434434
added: v12.15.0
@@ -439,6 +439,18 @@ interoperability with non-conformant HTTP implementations. It may also allow
439439
request smuggling and other HTTP attacks that rely on invalid headers being
440440
accepted. Avoid using this option.
441441

442+
### `--jitless`
443+
<!-- YAML
444+
added: v12.0.0
445+
-->
446+
447+
Disable [runtime allocation of executable memory][jitless]. This may be
448+
required on some platforms for security reasons. It can also reduce attack
449+
surface on other platforms, but the performance impact may be severe.
450+
451+
This flag is inherited from V8 and is subject to change upstream. It may
452+
disappear in a non-semver-major release.
453+
442454
### `--max-http-header-size=size`
443455
<!-- YAML
444456
added: v11.6.0
@@ -1147,6 +1159,7 @@ V8 options that are allowed are:
11471159
* `--abort-on-uncaught-exception`
11481160
* `--disallow-code-generation-from-strings`
11491161
* `--interpreted-frames-native-stack`
1162+
* `--jitless`
11501163
* `--max-old-space-size`
11511164
* `--perf-basic-prof-only-functions`
11521165
* `--perf-basic-prof`
@@ -1382,5 +1395,6 @@ greater than `4` (its current default value). For more information, see the
13821395
[debugging security implications]: https://nodejs.org/en/docs/guides/debugging-getting-started/#security-implications
13831396
[emit_warning]: process.html#process_process_emitwarning_warning_type_code_ctor
13841397
[experimental ECMAScript Module loader]: esm.html#esm_experimental_loaders
1398+
[jitless]: https://v8.dev/blog/jitless
13851399
[libuv threadpool documentation]: http://docs.libuv.org/en/latest/threadpool.html
13861400
[remote code execution]: https://www.owasp.org/index.php/Code_Injection

doc/node.1

+14
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ Enable experimental Source Map V3 support for stack traces.
116116
.It Fl -experimental-json-modules
117117
Enable experimental JSON interop support for the ES Module loader.
118118
.
119+
.It Fl -experimental-loader Ns = Ns Ar module
120+
Specify the
121+
.Ar module
122+
to use as a custom module loader.
123+
.
119124
.It Fl -experimental-modules
120125
Enable experimental ES module support and caching modules.
121126
.
@@ -238,6 +243,15 @@ interoperability with non-conformant HTTP implementations. It may also allow
238243
request smuggling and other HTTP attacks that rely on invalid headers being
239244
accepted. Avoid using this option.
240245
.
246+
.It Fl -jitless
247+
Disable runtime allocation of executable memory. This may be required on
248+
some platforms for security reasons. It can also reduce attack surface on
249+
other platforms, but the performance impact may be severe.
250+
.
251+
.Pp
252+
This flag is inherited from V8 and is subject to change upstream. It may
253+
disappear in a non-semver-major release.
254+
.
241255
.It Fl -max-http-header-size Ns = Ns Ar size
242256
Specify the maximum size of HTTP headers in bytes. Defaults to 8KB.
243257
.

src/node_options.cc

+4
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,10 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
643643
"disallow eval and friends",
644644
V8Option{},
645645
kAllowedInEnvironment);
646+
AddOption("--jitless",
647+
"disable runtime allocation of executable memory",
648+
V8Option{},
649+
kAllowedInEnvironment);
646650

647651
#ifdef NODE_REPORT
648652
AddOption("--report-uncaught-exception",

test/parallel/test-cli-node-options.js

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ if (common.hasCrypto) {
6767
// V8 options
6868
expect('--abort_on-uncaught_exception', 'B\n');
6969
expect('--disallow-code-generation-from-strings', 'B\n');
70+
expect('--jitless', 'B\n');
7071
expect('--max-old-space-size=0', 'B\n');
7172
expect('--stack-trace-limit=100',
7273
/(\s*at f \(\[(eval|worker eval)\]:1:\d*\)\r?\n)/,

0 commit comments

Comments
 (0)