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 --- src/node_binding.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/node_binding.cc') diff --git a/src/node_binding.cc b/src/node_binding.cc index 6d70d0a501e..bdfb74e2744 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -412,6 +412,13 @@ void GetInternalBinding(const FunctionCallbackInfo& args) { DefineConstants(env->isolate(), exports); } else if (!strcmp(*module_v, "natives")) { exports = per_process_loader.GetSourceObject(env->context()); + // Legacy feature: process.binding('natives').config contains stringified + // config.gypi + CHECK(exports + ->Set(env->context(), + env->config_string(), + per_process_loader.GetConfigString(env->isolate())) + .FromJust()); } else { return ThrowIfNoSuchModule(env, *module_v); } -- cgit v1.2.3