From 44a5fe145759a2fa43247da2f40a55df23572944 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 3 Dec 2018 00:49:12 +0800 Subject: process: specialize building and storage of process.config Instead of treating config.gypi as a JavaScript file, specialize the processing in js2c and make the serialized result a real JSON string (with 'true' and 'false' converted to boolean values) so we don't have to use a custom deserializer during bootstrap. In addition, store the JSON string separately in NativeModuleLoader, and keep it separate from the map of the builtin source code, so we don't have to put it onto `NativeModule._source` and delete it later, though we still preserve it in `process.binding('natives')`, which we don't use anymore. This patch also makes the map of builtin source code and the config.gypi string available through side-effect-free getters in C++. PR-URL: https://github.com/nodejs/node/pull/24816 Reviewed-By: Gus Caplan --- lib/internal/bootstrap/loaders.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/internal/bootstrap/loaders.js') diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index dfe904857f..c6764cfe5a 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -167,10 +167,15 @@ function NativeModule(id) { this.loading = false; } -NativeModule._source = getInternalBinding('natives'); +const { + source, + compileFunction +} = internalBinding('native_module'); + +NativeModule._source = source; NativeModule._cache = {}; -const config = getInternalBinding('config'); +const config = internalBinding('config'); // Think of this as module.exports in this file even though it is not // written in CommonJS style. @@ -330,7 +335,6 @@ NativeModule.prototype.proxifyExports = function() { this.exports = new Proxy(this.exports, handler); }; -const { compileFunction } = getInternalBinding('native_module'); NativeModule.prototype.compile = function() { const id = this.id; -- cgit v1.2.3