Skip to content

Commit aec2226

Browse files
andrewdotnMylesBorins
authored andcommittedApr 1, 2020
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 Backport-PR-URL: #32594 PR-URL: #32100 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 4ee41c5 commit aec2226

File tree

4 files changed

+42
-14
lines changed

4 files changed

+42
-14
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-6
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
.
@@ -226,18 +231,21 @@ Default is
226231
V8 Inspector integration allows attaching Chrome DevTools and IDEs to Node.js instances for debugging and profiling.
227232
It uses the Chrome DevTools Protocol.
228233
.
229-
.It Fl -experimental-loader Ns = Ns Ar module
230-
Specify the
231-
.Ar module
232-
as a custom loader, to load
233-
.Fl -experimental-modules .
234-
.
235234
.It Fl -insecure-http-parser
236235
Use an insecure HTTP parser that accepts invalid HTTP headers. This may allow
237236
interoperability with non-conformant HTTP implementations. It may also allow
238237
request smuggling and other HTTP attacks that rely on invalid headers being
239238
accepted. Avoid using this option.
240239
.
240+
.It Fl -jitless
241+
Disable runtime allocation of executable memory. This may be required on
242+
some platforms for security reasons. It can also reduce attack surface on
243+
other platforms, but the performance impact may be severe.
244+
.
245+
.Pp
246+
This flag is inherited from V8 and is subject to change upstream. It may
247+
disappear in a non-semver-major release.
248+
.
241249
.It Fl -max-http-header-size Ns = Ns Ar size
242250
Specify the maximum size of HTTP headers in bytes. Defaults to 8KB.
243251
.

‎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

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

0 commit comments

Comments
 (0)
Please sign in to comment.