From 7a5954ef26c49f53d40a516df60800a119fb9da7 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 19 Nov 2019 15:05:09 -0500 Subject: [PATCH 01/12] src: fix -Winconsistent-missing-override warning This commit addresses the following warning: ../src/node_api.cc:28:19: warning: 'mark_arraybuffer_as_untransferable' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] v8::Maybe mark_arraybuffer_as_untransferable( ^ ../src/js_native_api_v8.h:42:27: note: overridden virtual function is here virtual v8::Maybe mark_arraybuffer_as_untransferable( PR-URL: https://github.com/nodejs/node/pull/30549 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis Reviewed-By: Ruben Bridgewater Reviewed-By: Jiawen Geng Reviewed-By: David Carlier --- src/node_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_api.cc b/src/node_api.cc index 0f7981cd5605ae..5e467dded5bdb7 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -26,7 +26,7 @@ struct node_napi_env__ : public napi_env__ { } v8::Maybe mark_arraybuffer_as_untransferable( - v8::Local ab) const { + v8::Local ab) const override { return ab->SetPrivate( context(), node_env()->arraybuffer_untransferable_private_symbol(), From f0b2d875d96d942d6d22612986dceb225317fede Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 12 Feb 2020 23:51:54 +0200 Subject: [PATCH 02/12] module: 12.x self resolve flag as experimental modules PR-URL: https://github.com/nodejs/node/pull/31757 Reviewed-By: Geoffrey Booth Reviewed-By: Jan Krems Reviewed-By: Myles Borins --- lib/internal/modules/cjs/loader.js | 1 + test/es-module/test-esm-flagged-self.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/es-module/test-esm-flagged-self.js diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index f3d97781e2a652..ed433e1b8744ea 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -432,6 +432,7 @@ function resolveBasePath(basePath, exts, isMain, trailingSlash, request) { } function trySelf(parentPath, isMain, request) { + if (!experimentalModules) return false; const { data: pkg, path: basePath } = readPackageScope(parentPath) || {}; if (!pkg || pkg.exports === undefined) return false; if (typeof pkg.name !== 'string') return false; diff --git a/test/es-module/test-esm-flagged-self.js b/test/es-module/test-esm-flagged-self.js new file mode 100644 index 00000000000000..43a0c4f9684bf0 --- /dev/null +++ b/test/es-module/test-esm-flagged-self.js @@ -0,0 +1,16 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); +const path = require('path'); +const { createRequireFromPath } = require('module'); + +const fixturesRequire = + createRequireFromPath(path.resolve(__dirname, '../fixtures/_')); + +try { + fixturesRequire('pkgexports/resolve-self'); + assert(false); +} catch (e) { + assert.strictEqual(e.code, 'MODULE_NOT_FOUND'); +} From 43d02e20e0f37c3494cdf950fb9586f911df3d39 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 14 Feb 2020 16:28:58 +0100 Subject: [PATCH 03/12] src: keep main-thread Isolate attached to platform during Dispose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This works around a situation in which the V8 WASM code calls into the platform while the Isolate is being disposed. This goes against the V8 API constract for `v8::Platform`. In lieu of a proper fix, it should be okay to keep the Isolate registered; the race condition fixed by 25447d82d cannot occur for the `NodeMainInstance`’s Isolate, as it is the last one to exit in any given Node.js process. This partially reverts 25447d82d. Refs: https://github.com/nodejs/node/pull/30909 Refs: https://github.com/nodejs/node/issues/31752 PR-URL: https://github.com/nodejs/node/pull/31795 Reviewed-By: Denys Otrishko Reviewed-By: James M Snell --- src/node_main_instance.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc index 86a857299f6e90..97cea34dbb46be 100644 --- a/src/node_main_instance.cc +++ b/src/node_main_instance.cc @@ -99,8 +99,12 @@ NodeMainInstance::~NodeMainInstance() { if (!owns_isolate_) { return; } - platform_->UnregisterIsolate(isolate_); + // TODO(addaleax): Reverse the order of these calls. The fact that we first + // dispose the Isolate is a temporary workaround for + // https://github.com/nodejs/node/issues/31752 -- V8 should not be posting + // platform tasks during Dispose(), but it does in some WASM edge cases. isolate_->Dispose(); + platform_->UnregisterIsolate(isolate_); } int NodeMainInstance::Run() { From 6d432994e6c3d92c9f137f54728c45bef597e93f Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Thu, 13 Feb 2020 15:26:33 -0800 Subject: [PATCH 04/12] Revert "build: warn upon --use-largepages config option" This reverts commit f5cd6d73fdf8e56954214fd57933df37b5168c54. PR-URL: https://github.com/nodejs/node/pull/31782 Reviewed-By: James M Snell Reviewed-By: Richard Lau --- configure.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/configure.py b/configure.py index 6537a62d3954d8..6a01fa46378c3b 100755 --- a/configure.py +++ b/configure.py @@ -1060,13 +1060,6 @@ def configure_node(o): else: o['variables']['node_use_dtrace'] = 'false' - if options.node_use_large_pages or options.node_use_large_pages_script_lld: - warn('''The `--use-largepages` and `--use-largepages-script-lld` options - have no effect during build time. Support for mapping to large pages is - now a runtime option of Node.js. Run `node --use-largepages` or add - `--use-largepages` to the `NODE_OPTIONS` environment variable once - Node.js is built to enable mapping to large pages.''') - if options.no_ifaddrs: o['defines'] += ['SUNOS_NO_IFADDRS'] From 3d5beebc62d444145b2a2436ba53e998a149b9d7 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Thu, 13 Feb 2020 15:26:56 -0800 Subject: [PATCH 05/12] Revert "src: make large_pages node.cc include conditional" This reverts commit 5e232f5de92c2340536a5065782cad57e8fe64fb. PR-URL: https://github.com/nodejs/node/pull/31782 Reviewed-By: James M Snell Reviewed-By: Richard Lau --- src/node.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/node.cc b/src/node.cc index cadbd9a62db9e0..05c87c62d6db6c 100644 --- a/src/node.cc +++ b/src/node.cc @@ -64,9 +64,7 @@ #include "inspector/worker_inspector.h" // ParentInspectorHandle #endif -#ifdef NODE_ENABLE_LARGE_CODE_PAGES #include "large_pages/node_large_page.h" -#endif #ifdef NODE_REPORT #include "node_report.h" From a53eeca2a9c7cb009f9ea3524250064db20c31c9 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Thu, 13 Feb 2020 15:27:04 -0800 Subject: [PATCH 06/12] Revert "build: switch realpath to pwd" This reverts commit dea40f8c522d60b96665a1681bd4f6863a6e9f19. PR-URL: https://github.com/nodejs/node/pull/31782 Reviewed-By: James M Snell Reviewed-By: Richard Lau --- node.gypi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node.gypi b/node.gypi index 4ee7bad0104040..687da8b501ceff 100644 --- a/node.gypi +++ b/node.gypi @@ -312,7 +312,7 @@ 'llvm_version=="0.0"', { 'ldflags': [ '-Wl,-T', - ' Date: Thu, 13 Feb 2020 15:27:13 -0800 Subject: [PATCH 07/12] Revert "build: re-introduce --use-largepages as no-op" This reverts commit 5fcf542faa08e6f59428d60dbd385595597bcda8. PR-URL: https://github.com/nodejs/node/pull/31782 Reviewed-By: James M Snell Reviewed-By: Richard Lau --- configure.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/configure.py b/configure.py index 6a01fa46378c3b..210bd8ec279909 100755 --- a/configure.py +++ b/configure.py @@ -398,16 +398,6 @@ dest='with_etw', help='build with ETW (default is true on Windows)') -parser.add_option('--use-largepages', - action='store_true', - dest='node_use_large_pages', - help='This option has no effect. --use-largepages is now a runtime option.') - -parser.add_option('--use-largepages-script-lld', - action='store_true', - dest='node_use_large_pages_script_lld', - help='This option has no effect. --use-largepages is now a runtime option.') - intl_optgroup.add_option('--with-intl', action='store', dest='with_intl', From 065a32f064ac8927e4fcdee28ecb2b64370a4a6d Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Thu, 13 Feb 2020 15:27:47 -0800 Subject: [PATCH 08/12] Revert "src: make --use-largepages a runtime option" This reverts commit fcbd2d245ac917785cb59ff51e0f599a7886df6b. PR-URL: https://github.com/nodejs/node/pull/31782 Reviewed-By: James M Snell Reviewed-By: Richard Lau --- configure.py | 33 +++++++++++++++++++++++ doc/api/cli.md | 17 ------------ doc/node.1 | 10 ------- node.gyp | 5 ++-- node.gypi | 6 +++-- src/large_pages/node_large_page.cc | 19 ++++++------- src/node.cc | 30 +++++++-------------- src/node_options.cc | 9 ------- src/node_options.h | 1 - test/parallel/test-startup-large-pages.js | 29 -------------------- 10 files changed, 58 insertions(+), 101 deletions(-) delete mode 100644 test/parallel/test-startup-large-pages.js diff --git a/configure.py b/configure.py index 210bd8ec279909..14f5665e0299a2 100755 --- a/configure.py +++ b/configure.py @@ -398,6 +398,17 @@ dest='with_etw', help='build with ETW (default is true on Windows)') +parser.add_option('--use-largepages', + action='store_true', + dest='node_use_large_pages', + help='build with Large Pages support. This feature is supported only on Linux kernel' + + '>= 2.6.38 with Transparent Huge pages enabled and FreeBSD') + +parser.add_option('--use-largepages-script-lld', + action='store_true', + dest='node_use_large_pages_script_lld', + help='link against the LLVM ld linker script. Implies -fuse-ld=lld in the linker flags') + intl_optgroup.add_option('--with-intl', action='store', dest='with_intl', @@ -1050,6 +1061,28 @@ def configure_node(o): else: o['variables']['node_use_dtrace'] = 'false' + if options.node_use_large_pages and not flavor in ('linux', 'freebsd', 'mac'): + raise Exception( + 'Large pages are supported only on Linux, FreeBSD and MacOS Systems.') + if options.node_use_large_pages and flavor in ('linux', 'freebsd', 'mac'): + if options.shared or options.enable_static: + raise Exception( + 'Large pages are supported only while creating node executable.') + if target_arch!="x64": + raise Exception( + 'Large pages are supported only x64 platform.') + if flavor == 'mac': + info('macOS server with 32GB or more is recommended') + if flavor == 'linux': + # Example full version string: 2.6.32-696.28.1.el6.x86_64 + FULL_KERNEL_VERSION=os.uname()[2] + KERNEL_VERSION=FULL_KERNEL_VERSION.split('-')[0] + if KERNEL_VERSION < "2.6.38" and flavor == 'linux': + raise Exception( + 'Large pages need Linux kernel version >= 2.6.38') + o['variables']['node_use_large_pages'] = b(options.node_use_large_pages) + o['variables']['node_use_large_pages_script_lld'] = b(options.node_use_large_pages_script_lld) + if options.no_ifaddrs: o['defines'] += ['SUNOS_NO_IFADDRS'] diff --git a/doc/api/cli.md b/doc/api/cli.md index 979c1214f5c59e..7703d0b6bd99d2 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -881,22 +881,6 @@ environment variables. See `SSL_CERT_DIR` and `SSL_CERT_FILE`. -### `--use-largepages=mode` - - -Re-map the Node.js static code to large memory pages at startup. If supported on -the target system, this will cause the Node.js static code to be moved onto 2 -MiB pages instead of 4 KiB pages. - -The following values are valid for `mode`: -* `off`: No mapping will be attempted. This is the default. -* `on`: If supported by the OS, mapping will be attempted. Failure to map will - be ignored and a message will be printed to standard error. -* `silent`: If supported by the OS, mapping will be attempted. Failure to map - will be ignored and will not be reported. - ### `--v8-options` - -This symbol shall be used to install a listener for only monitoring `'error'` -events. Listeners installed using this symbol are called before the regular -`'error'` listeners are called. - -Installing a listener using this symbol does not change the behavior once an -`'error'` event is emitted, therefore the process will still crash if no -regular `'error'` listener is installed. - ### `emitter.addListener(eventName, listener)`