Skip to content

Commit e1347b4

Browse files
andrewdotnMylesBorins
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 6f9f2c5 commit e1347b4

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

doc/api/cli.md

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

171171
Enable experimental JSON support for the ES Module loader.
172172

173+
### `--experimental-loader=module`
174+
<!-- YAML
175+
added: v9.0.0
176+
-->
177+
178+
Specify the `module` of a custom [experimental ECMAScript Module loader][].
179+
`module` may be either a path to a file, or an ECMAScript Module name.
180+
173181
### `--experimental-modules`
174182
<!-- YAML
175183
added: v8.5.0
@@ -405,14 +413,6 @@ Specify ways of the inspector web socket url exposure.
405413
By default inspector websocket url is available in stderr and under `/json/list`
406414
endpoint on `http://host:port/json/list`.
407415

408-
### `--experimental-loader=module`
409-
<!-- YAML
410-
added: v9.0.0
411-
-->
412-
413-
Specify the `module` of a custom [experimental ECMAScript Module loader][].
414-
`module` may be either a path to a file, or an ECMAScript Module name.
415-
416416
### `--insecure-http-parser`
417417
<!-- YAML
418418
added: v13.4.0
@@ -423,6 +423,18 @@ interoperability with non-conformant HTTP implementations. It may also allow
423423
request smuggling and other HTTP attacks that rely on invalid headers being
424424
accepted. Avoid using this option.
425425

426+
### `--jitless`
427+
<!-- YAML
428+
added: v12.0.0
429+
-->
430+
431+
Disable [runtime allocation of executable memory][jitless]. This may be
432+
required on some platforms for security reasons. It can also reduce attack
433+
surface on other platforms, but the performance impact may be severe.
434+
435+
This flag is inherited from V8 and is subject to change upstream. It may
436+
disappear in a non-semver-major release.
437+
426438
### `--max-http-header-size=size`
427439
<!-- YAML
428440
added: v11.6.0
@@ -1156,6 +1168,7 @@ V8 options that are allowed are:
11561168
* `--abort-on-uncaught-exception`
11571169
* `--disallow-code-generation-from-strings`
11581170
* `--interpreted-frames-native-stack`
1171+
* `--jitless`
11591172
* `--max-old-space-size`
11601173
* `--perf-basic-prof-only-functions`
11611174
* `--perf-basic-prof`
@@ -1391,5 +1404,6 @@ greater than `4` (its current default value). For more information, see the
13911404
[debugging security implications]: https://nodejs.org/en/docs/guides/debugging-getting-started/#security-implications
13921405
[emit_warning]: process.html#process_process_emitwarning_warning_type_code_ctor
13931406
[experimental ECMAScript Module loader]: esm.html#esm_experimental_loaders
1407+
[jitless]: https://v8.dev/blog/jitless
13941408
[libuv threadpool documentation]: http://docs.libuv.org/en/latest/threadpool.html
13951409
[remote code execution]: https://www.owasp.org/index.php/Code_Injection

doc/node.1

+14-5
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ Enable experimental ES modules support for import.meta.resolve().
119119
.It Fl -experimental-json-modules
120120
Enable experimental JSON interop support for the ES Module loader.
121121
.
122+
.It Fl -experimental-loader Ns = Ns Ar module
123+
Specify the
124+
.Ar module
125+
to use as a custom module loader.
126+
.
122127
.It Fl -experimental-modules
123128
Enable experimental latest experimental modules features.
124129
.
@@ -220,17 +225,21 @@ Default is
220225
V8 Inspector integration allows attaching Chrome DevTools and IDEs to Node.js instances for debugging and profiling.
221226
It uses the Chrome DevTools Protocol.
222227
.
223-
.It Fl -experimental-loader Ns = Ns Ar module
224-
Specify the
225-
.Ar module
226-
to use as a custom module loader.
227-
.
228228
.It Fl -insecure-http-parser
229229
Use an insecure HTTP parser that accepts invalid HTTP headers. This may allow
230230
interoperability with non-conformant HTTP implementations. It may also allow
231231
request smuggling and other HTTP attacks that rely on invalid headers being
232232
accepted. Avoid using this option.
233233
.
234+
.It Fl -jitless
235+
Disable runtime allocation of executable memory. This may be required on
236+
some platforms for security reasons. It can also reduce attack surface on
237+
other platforms, but the performance impact may be severe.
238+
.
239+
.Pp
240+
This flag is inherited from V8 and is subject to change upstream. It may
241+
disappear in a non-semver-major release.
242+
.
234243
.It Fl -max-http-header-size Ns = Ns Ar size
235244
Specify the maximum size of HTTP headers in bytes. Defaults to 8KB.
236245
.

src/node_options.cc

+4
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,10 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
616616
"disallow eval and friends",
617617
V8Option{},
618618
kAllowedInEnvironment);
619+
AddOption("--jitless",
620+
"disable runtime allocation of executable memory",
621+
V8Option{},
622+
kAllowedInEnvironment);
619623

620624
#ifdef NODE_REPORT
621625
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)