From 60d3a5e00982b20c4be3bc6f72c29f5004cec653 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 9 Jan 2019 00:00:33 +0800 Subject: [PATCH 1/7] src: move process object creation into node_process_object.cc Changes `SetupProcessObject` to `CreateProessObject` which creates the process object from scratch and return it to `Environment::Start` to be stored in the Environment object. --- node.gyp | 3 +- src/env.cc | 11 +- src/node.cc | 226 ---------------- src/node_internals.h | 7 +- ...ode_process.cc => node_process_methods.cc} | 0 src/node_process_object.cc | 255 ++++++++++++++++++ 6 files changed, 262 insertions(+), 240 deletions(-) rename src/{node_process.cc => node_process_methods.cc} (100%) create mode 100644 src/node_process_object.cc diff --git a/node.gyp b/node.gyp index a0baf052be74d9..36a6ea92dc3f07 100644 --- a/node.gyp +++ b/node.gyp @@ -370,7 +370,8 @@ 'src/node_perf.cc', 'src/node_platform.cc', 'src/node_postmortem_metadata.cc', - 'src/node_process.cc', + 'src/node_process_methods.cc', + 'src/node_process_object.cc', 'src/node_serdes.cc', 'src/node_stat_watcher.cc', 'src/node_symbols.cc', diff --git a/src/env.cc b/src/env.cc index 068809e00a6b15..19cc16fcfac271 100644 --- a/src/env.cc +++ b/src/env.cc @@ -22,7 +22,6 @@ using v8::Context; using v8::EmbedderGraph; using v8::External; using v8::Function; -using v8::FunctionTemplate; using v8::HandleScope; using v8::Integer; using v8::Isolate; @@ -339,17 +338,9 @@ void Environment::Start(const std::vector& args, StartProfilerIdleNotifier(); } - auto process_template = FunctionTemplate::New(isolate()); - process_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate(), "process")); - - auto process_object = process_template->GetFunction(context()) - .ToLocalChecked() - ->NewInstance(context()) - .ToLocalChecked(); + Local process_object = CreateProcessObject(this, args, exec_args); set_process_object(process_object); - SetupProcessObject(this, args, exec_args); - static uv_once_t init_once = UV_ONCE_INIT; uv_once(&init_once, InitThreadLocalOnce); uv_key_set(&thread_local_env, this); diff --git a/src/node.cc b/src/node.cc index 3a1a6a9d6c2712..a4c50696ec7066 100644 --- a/src/node.cc +++ b/src/node.cc @@ -124,14 +124,12 @@ using v8::MaybeLocal; using v8::Message; using v8::MicrotasksPolicy; using v8::NewStringType; -using v8::None; using v8::Nothing; using v8::Object; using v8::ObjectTemplate; using v8::Script; using v8::ScriptOrigin; using v8::SealHandleScope; -using v8::SideEffectType; using v8::String; using v8::TracingController; using v8::Undefined; @@ -686,230 +684,6 @@ static void OnMessage(Local message, Local error) { } } -void SetupProcessObject(Environment* env, - const std::vector& args, - const std::vector& exec_args) { - Isolate* isolate = env->isolate(); - HandleScope scope(isolate); - Local context = env->context(); - - Local process = env->process_object(); - - auto title_string = FIXED_ONE_BYTE_STRING(env->isolate(), "title"); - CHECK(process->SetAccessor( - env->context(), - title_string, - ProcessTitleGetter, - env->is_main_thread() ? ProcessTitleSetter : nullptr, - env->as_external(), - DEFAULT, - None, - SideEffectType::kHasNoSideEffect).FromJust()); - - // process.version - READONLY_PROPERTY(process, - "version", - FIXED_ONE_BYTE_STRING(env->isolate(), NODE_VERSION)); - - // process.versions - Local versions = Object::New(env->isolate()); - READONLY_PROPERTY(process, "versions", versions); - -#define V(key) \ - if (!per_process::metadata.versions.key.empty()) { \ - READONLY_STRING_PROPERTY( \ - versions, #key, per_process::metadata.versions.key); \ - } - NODE_VERSIONS_KEYS(V) -#undef V - - // process.arch - READONLY_STRING_PROPERTY(process, "arch", per_process::metadata.arch); - - // process.platform - READONLY_STRING_PROPERTY(process, "platform", per_process::metadata.platform); - - // process.release - Local release = Object::New(env->isolate()); - READONLY_PROPERTY(process, "release", release); - READONLY_STRING_PROPERTY(release, "name", per_process::metadata.release.name); -#if NODE_VERSION_IS_LTS - READONLY_STRING_PROPERTY(release, "lts", per_process::metadata.release.lts); -#endif // NODE_VERSION_IS_LTS - -#ifdef NODE_HAS_RELEASE_URLS - READONLY_STRING_PROPERTY( - release, "sourceUrl", per_process::metadata.release.source_url); - READONLY_STRING_PROPERTY( - release, "headersUrl", per_process::metadata.release.headers_url); -#ifdef _WIN32 - READONLY_STRING_PROPERTY( - release, "libUrl", per_process::metadata.release.lib_url); -#endif // _WIN32 -#endif // NODE_HAS_RELEASE_URLS - - // process.argv - process->Set(env->context(), - FIXED_ONE_BYTE_STRING(env->isolate(), "argv"), - ToV8Value(env->context(), args).ToLocalChecked()).FromJust(); - - // process.execArgv - process->Set(env->context(), - FIXED_ONE_BYTE_STRING(env->isolate(), "execArgv"), - ToV8Value(env->context(), exec_args) - .ToLocalChecked()).FromJust(); - - // create process.env - process - ->Set(env->context(), - FIXED_ONE_BYTE_STRING(env->isolate(), "env"), - CreateEnvVarProxy(context, isolate, env->as_external())) - .FromJust(); - - READONLY_PROPERTY(process, "pid", - Integer::New(env->isolate(), uv_os_getpid())); - - CHECK(process->SetAccessor(env->context(), - FIXED_ONE_BYTE_STRING(env->isolate(), "ppid"), - GetParentProcessId).FromJust()); - - // -e, --eval - // TODO(addaleax): Remove this. - if (env->options()->has_eval_string) { - READONLY_PROPERTY(process, - "_eval", - String::NewFromUtf8( - env->isolate(), - env->options()->eval_string.c_str(), - NewStringType::kNormal).ToLocalChecked()); - } - - // -p, --print - // TODO(addaleax): Remove this. - if (env->options()->print_eval) { - READONLY_PROPERTY(process, "_print_eval", True(env->isolate())); - } - - // -c, --check - // TODO(addaleax): Remove this. - if (env->options()->syntax_check_only) { - READONLY_PROPERTY(process, "_syntax_check_only", True(env->isolate())); - } - - // -i, --interactive - // TODO(addaleax): Remove this. - if (env->options()->force_repl) { - READONLY_PROPERTY(process, "_forceRepl", True(env->isolate())); - } - - // -r, --require - // TODO(addaleax): Remove this. - const std::vector& preload_modules = - env->options()->preload_modules; - if (!preload_modules.empty()) { - READONLY_PROPERTY(process, - "_preload_modules", - ToV8Value(env->context(), preload_modules) - .ToLocalChecked()); - } - - // --no-deprecation - if (env->options()->no_deprecation) { - READONLY_PROPERTY(process, "noDeprecation", True(env->isolate())); - } - - // --no-warnings - if (env->options()->no_warnings) { - READONLY_PROPERTY(process, "noProcessWarnings", True(env->isolate())); - } - - // --trace-warnings - if (env->options()->trace_warnings) { - READONLY_PROPERTY(process, "traceProcessWarnings", True(env->isolate())); - } - - // --throw-deprecation - if (env->options()->throw_deprecation) { - READONLY_PROPERTY(process, "throwDeprecation", True(env->isolate())); - } - -#ifdef NODE_NO_BROWSER_GLOBALS - // configure --no-browser-globals - READONLY_PROPERTY(process, "_noBrowserGlobals", True(env->isolate())); -#endif // NODE_NO_BROWSER_GLOBALS - - // --prof-process - // TODO(addaleax): Remove this. - if (env->options()->prof_process) { - READONLY_PROPERTY(process, "profProcess", True(env->isolate())); - } - - // --trace-deprecation - if (env->options()->trace_deprecation) { - READONLY_PROPERTY(process, "traceDeprecation", True(env->isolate())); - } - - // TODO(refack): move the following 4 to `node_config` - // --inspect-brk - if (env->options()->debug_options().wait_for_connect()) { - READONLY_DONT_ENUM_PROPERTY(process, - "_breakFirstLine", True(env->isolate())); - } - - if (env->options()->debug_options().break_node_first_line) { - READONLY_DONT_ENUM_PROPERTY(process, - "_breakNodeFirstLine", True(env->isolate())); - } - - // --inspect --debug-brk - if (env->options()->debug_options().deprecated_invocation()) { - READONLY_DONT_ENUM_PROPERTY(process, - "_deprecatedDebugBrk", True(env->isolate())); - } - - // --debug or, --debug-brk without --inspect - if (env->options()->debug_options().invalid_invocation()) { - READONLY_DONT_ENUM_PROPERTY(process, - "_invalidDebug", True(env->isolate())); - } - - // --security-revert flags -#define V(code, _, __) \ - do { \ - if (IsReverted(SECURITY_REVERT_ ## code)) { \ - READONLY_PROPERTY(process, "REVERT_" #code, True(env->isolate())); \ - } \ - } while (0); - SECURITY_REVERSIONS(V) -#undef V - - { - size_t exec_path_len = 2 * PATH_MAX; - std::vector exec_path(exec_path_len); - Local exec_path_value; - if (uv_exepath(exec_path.data(), &exec_path_len) == 0) { - exec_path_value = String::NewFromUtf8(env->isolate(), - exec_path.data(), - NewStringType::kInternalized, - exec_path_len).ToLocalChecked(); - } else { - exec_path_value = String::NewFromUtf8(env->isolate(), args[0].c_str(), - NewStringType::kInternalized).ToLocalChecked(); - } - process->Set(env->context(), - FIXED_ONE_BYTE_STRING(env->isolate(), "execPath"), - exec_path_value).FromJust(); - } - - auto debug_port_string = FIXED_ONE_BYTE_STRING(env->isolate(), "debugPort"); - CHECK(process->SetAccessor(env->context(), - debug_port_string, - DebugPortGetter, - env->is_main_thread() ? DebugPortSetter : nullptr, - env->as_external()).FromJust()); -} - - void SignalExit(int signo) { uv_tty_reset_mode(); #ifdef __FreeBSD__ diff --git a/src/node_internals.h b/src/node_internals.h index f9ef31eea5aa85..8ffa290caae822 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -185,9 +185,10 @@ v8::Maybe ProcessEmitDeprecationWarning(Environment* env, const char* warning, const char* deprecation_code); -void SetupProcessObject(Environment* env, - const std::vector& args, - const std::vector& exec_args); +v8::Local CreateProcessObject( + Environment* env, + const std::vector& args, + const std::vector& exec_args); enum Endianness { kLittleEndian, // _Not_ LITTLE_ENDIAN, clashes with endian.h. diff --git a/src/node_process.cc b/src/node_process_methods.cc similarity index 100% rename from src/node_process.cc rename to src/node_process_methods.cc diff --git a/src/node_process_object.cc b/src/node_process_object.cc new file mode 100644 index 00000000000000..68c27fa3f69fd5 --- /dev/null +++ b/src/node_process_object.cc @@ -0,0 +1,255 @@ +#include "env-inl.h" +#include "node_internals.h" +#include "node_metadata.h" +#include "node_revert.h" +#include "util-inl.h" + +namespace node { +using v8::Context; +using v8::DEFAULT; +using v8::EscapableHandleScope; +using v8::Function; +using v8::FunctionTemplate; +using v8::HandleScope; +using v8::Integer; +using v8::Isolate; +using v8::Just; +using v8::Local; +using v8::NewStringType; +using v8::None; +using v8::Object; +using v8::SideEffectType; +using v8::String; +using v8::Value; + +Local CreateProcessObject(Environment* env, + const std::vector& args, + const std::vector& exec_args) { + Isolate* isolate = env->isolate(); + EscapableHandleScope scope(isolate); + Local context = env->context(); + + Local process_template = FunctionTemplate::New(isolate); + process_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "process")); + Local process = process_template->GetFunction(context) + .ToLocalChecked() + ->NewInstance(context) + .ToLocalChecked(); + + auto title_string = FIXED_ONE_BYTE_STRING(env->isolate(), "title"); + CHECK(process->SetAccessor( + env->context(), + title_string, + ProcessTitleGetter, + env->is_main_thread() ? ProcessTitleSetter : nullptr, + env->as_external(), + DEFAULT, + None, + SideEffectType::kHasNoSideEffect).FromJust()); + + // process.version + READONLY_PROPERTY(process, + "version", + FIXED_ONE_BYTE_STRING(env->isolate(), NODE_VERSION)); + + // process.versions + Local versions = Object::New(env->isolate()); + READONLY_PROPERTY(process, "versions", versions); + +#define V(key) \ + if (!per_process::metadata.versions.key.empty()) { \ + READONLY_STRING_PROPERTY( \ + versions, #key, per_process::metadata.versions.key); \ + } + NODE_VERSIONS_KEYS(V) +#undef V + + // process.arch + READONLY_STRING_PROPERTY(process, "arch", per_process::metadata.arch); + + // process.platform + READONLY_STRING_PROPERTY(process, "platform", per_process::metadata.platform); + + // process.release + Local release = Object::New(env->isolate()); + READONLY_PROPERTY(process, "release", release); + READONLY_STRING_PROPERTY(release, "name", per_process::metadata.release.name); +#if NODE_VERSION_IS_LTS + READONLY_STRING_PROPERTY(release, "lts", per_process::metadata.release.lts); +#endif // NODE_VERSION_IS_LTS + +#ifdef NODE_HAS_RELEASE_URLS + READONLY_STRING_PROPERTY( + release, "sourceUrl", per_process::metadata.release.source_url); + READONLY_STRING_PROPERTY( + release, "headersUrl", per_process::metadata.release.headers_url); +#ifdef _WIN32 + READONLY_STRING_PROPERTY( + release, "libUrl", per_process::metadata.release.lib_url); +#endif // _WIN32 +#endif // NODE_HAS_RELEASE_URLS + + // process.argv + process->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "argv"), + ToV8Value(env->context(), args).ToLocalChecked()).FromJust(); + + // process.execArgv + process->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "execArgv"), + ToV8Value(env->context(), exec_args) + .ToLocalChecked()).FromJust(); + + // create process.env + process + ->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "env"), + CreateEnvVarProxy(context, isolate, env->as_external())) + .FromJust(); + + READONLY_PROPERTY(process, "pid", + Integer::New(env->isolate(), uv_os_getpid())); + + CHECK(process->SetAccessor(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "ppid"), + GetParentProcessId).FromJust()); + + // -e, --eval + // TODO(addaleax): Remove this. + if (env->options()->has_eval_string) { + READONLY_PROPERTY(process, + "_eval", + String::NewFromUtf8( + env->isolate(), + env->options()->eval_string.c_str(), + NewStringType::kNormal).ToLocalChecked()); + } + + // -p, --print + // TODO(addaleax): Remove this. + if (env->options()->print_eval) { + READONLY_PROPERTY(process, "_print_eval", True(env->isolate())); + } + + // -c, --check + // TODO(addaleax): Remove this. + if (env->options()->syntax_check_only) { + READONLY_PROPERTY(process, "_syntax_check_only", True(env->isolate())); + } + + // -i, --interactive + // TODO(addaleax): Remove this. + if (env->options()->force_repl) { + READONLY_PROPERTY(process, "_forceRepl", True(env->isolate())); + } + + // -r, --require + // TODO(addaleax): Remove this. + const std::vector& preload_modules = + env->options()->preload_modules; + if (!preload_modules.empty()) { + READONLY_PROPERTY(process, + "_preload_modules", + ToV8Value(env->context(), preload_modules) + .ToLocalChecked()); + } + + // --no-deprecation + if (env->options()->no_deprecation) { + READONLY_PROPERTY(process, "noDeprecation", True(env->isolate())); + } + + // --no-warnings + if (env->options()->no_warnings) { + READONLY_PROPERTY(process, "noProcessWarnings", True(env->isolate())); + } + + // --trace-warnings + if (env->options()->trace_warnings) { + READONLY_PROPERTY(process, "traceProcessWarnings", True(env->isolate())); + } + + // --throw-deprecation + if (env->options()->throw_deprecation) { + READONLY_PROPERTY(process, "throwDeprecation", True(env->isolate())); + } + +#ifdef NODE_NO_BROWSER_GLOBALS + // configure --no-browser-globals + READONLY_PROPERTY(process, "_noBrowserGlobals", True(env->isolate())); +#endif // NODE_NO_BROWSER_GLOBALS + + // --prof-process + // TODO(addaleax): Remove this. + if (env->options()->prof_process) { + READONLY_PROPERTY(process, "profProcess", True(env->isolate())); + } + + // --trace-deprecation + if (env->options()->trace_deprecation) { + READONLY_PROPERTY(process, "traceDeprecation", True(env->isolate())); + } + + // TODO(refack): move the following 4 to `node_config` + // --inspect-brk + if (env->options()->debug_options().wait_for_connect()) { + READONLY_DONT_ENUM_PROPERTY(process, + "_breakFirstLine", True(env->isolate())); + } + + if (env->options()->debug_options().break_node_first_line) { + READONLY_DONT_ENUM_PROPERTY(process, + "_breakNodeFirstLine", True(env->isolate())); + } + + // --inspect --debug-brk + if (env->options()->debug_options().deprecated_invocation()) { + READONLY_DONT_ENUM_PROPERTY(process, + "_deprecatedDebugBrk", True(env->isolate())); + } + + // --debug or, --debug-brk without --inspect + if (env->options()->debug_options().invalid_invocation()) { + READONLY_DONT_ENUM_PROPERTY(process, + "_invalidDebug", True(env->isolate())); + } + + // --security-revert flags +#define V(code, _, __) \ + do { \ + if (IsReverted(SECURITY_REVERT_ ## code)) { \ + READONLY_PROPERTY(process, "REVERT_" #code, True(env->isolate())); \ + } \ + } while (0); + SECURITY_REVERSIONS(V) +#undef V + + { + size_t exec_path_len = 2 * PATH_MAX; + std::vector exec_path(exec_path_len); + Local exec_path_value; + if (uv_exepath(exec_path.data(), &exec_path_len) == 0) { + exec_path_value = String::NewFromUtf8(env->isolate(), + exec_path.data(), + NewStringType::kInternalized, + exec_path_len).ToLocalChecked(); + } else { + exec_path_value = String::NewFromUtf8(env->isolate(), args[0].c_str(), + NewStringType::kInternalized).ToLocalChecked(); + } + process->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "execPath"), + exec_path_value).FromJust(); + } + + auto debug_port_string = FIXED_ONE_BYTE_STRING(env->isolate(), "debugPort"); + CHECK(process->SetAccessor(env->context(), + debug_port_string, + DebugPortGetter, + env->is_main_thread() ? DebugPortSetter : nullptr, + env->as_external()).FromJust()); + + return scope.Escape(process); +} + +} // namespace node From a28145ba22879160cfe6c453e4828ded56706c50 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 31 Dec 2018 23:18:08 +0800 Subject: [PATCH 2/7] src: declare process-related C++ methods in node_process.h Instead of in node_internals.h. Also move process property accessors that are not reused into node_process_object.cc and make them static. --- node.gyp | 1 + src/env.cc | 1 + src/inspector_agent.cc | 1 + src/node.cc | 9 +++--- src/node_crypto.cc | 9 +++--- src/node_env_var.cc | 2 +- src/node_file.cc | 4 ++- src/node_internals.h | 31 --------------------- src/node_messaging.cc | 11 ++++---- src/node_process.h | 32 +++++++++++++++++++++ src/node_process_methods.cc | 52 ++++------------------------------- src/node_process_object.cc | 55 +++++++++++++++++++++++++++++++++++-- src/signal_wrap.cc | 1 + src/uv.cc | 3 +- 14 files changed, 115 insertions(+), 97 deletions(-) create mode 100644 src/node_process.h diff --git a/node.gyp b/node.gyp index 36a6ea92dc3f07..0db34a873efa28 100644 --- a/node.gyp +++ b/node.gyp @@ -449,6 +449,7 @@ 'src/node_perf_common.h', 'src/node_persistent.h', 'src/node_platform.h', + 'src/node_process.h', 'src/node_revert.h', 'src/node_root_certs.h', 'src/node_stat_watcher.h', diff --git a/src/env.cc b/src/env.cc index 19cc16fcfac271..d2d5d5bf35d8e6 100644 --- a/src/env.cc +++ b/src/env.cc @@ -7,6 +7,7 @@ #include "node_native_module.h" #include "node_options-inl.h" #include "node_platform.h" +#include "node_process.h" #include "node_worker.h" #include "tracing/agent.h" #include "tracing/traced_value.h" diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 8710b8569072a1..d9a252bbe88140 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -9,6 +9,7 @@ #include "node/inspector/protocol/Protocol.h" #include "node_errors.h" #include "node_internals.h" +#include "node_process.h" #include "node_url.h" #include "v8-inspector.h" #include "v8-platform.h" diff --git a/src/node.cc b/src/node.cc index a4c50696ec7066..a797bfde4743ef 100644 --- a/src/node.cc +++ b/src/node.cc @@ -30,6 +30,7 @@ #include "node_options-inl.h" #include "node_perf.h" #include "node_platform.h" +#include "node_process.h" #include "node_revert.h" #include "node_version.h" #include "tracing/traced_value.h" @@ -582,9 +583,9 @@ void Exit(const FunctionCallbackInfo& args) { } static Maybe ProcessEmitWarningGeneric(Environment* env, - const char* warning, - const char* type = nullptr, - const char* code = nullptr) { + const char* warning, + const char* type = nullptr, + const char* code = nullptr) { HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); @@ -742,12 +743,10 @@ void RunBootstrapping(Environment* env) { // Setting global properties for the bootstrappers to use: // - global - // - process._rawDebug // Expose the global object as a property on itself // (Allows you to set stuff on `global` from anywhere in JavaScript.) global->Set(context, FIXED_ONE_BYTE_STRING(env->isolate(), "global"), global) .FromJust(); - env->SetMethod(process, "_rawDebug", RawDebug); // Create binding loaders std::vector> loaders_params = { diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 75a687801fbec7..296b15de5bee38 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -19,16 +19,17 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +#include "node_crypto.h" #include "node.h" #include "node_buffer.h" -#include "node_errors.h" #include "node_constants.h" -#include "node_crypto.h" #include "node_crypto_bio.h" -#include "node_crypto_groups.h" #include "node_crypto_clienthello-inl.h" -#include "node_mutex.h" +#include "node_crypto_groups.h" +#include "node_errors.h" #include "node_internals.h" +#include "node_mutex.h" +#include "node_process.h" #include "tls_wrap.h" // TLSWrap #include "async_wrap-inl.h" diff --git a/src/node_env_var.cc b/src/node_env_var.cc index 8cbfa22973c65d..e88fac2fc8b1f1 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -1,5 +1,5 @@ -#include "node_internals.h" #include "node_errors.h" +#include "node_process.h" #ifdef __APPLE__ #include diff --git a/src/node_file.cc b/src/node_file.cc index b66c0fe6d20915..8757f6bf0d8921 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -19,11 +19,13 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +#include "node_file.h" #include "aliased_buffer.h" #include "node_buffer.h" #include "node_internals.h" +#include "node_process.h" #include "node_stat_watcher.h" -#include "node_file.h" + #include "tracing/trace_event.h" #include "req_wrap-inl.h" diff --git a/src/node_internals.h b/src/node_internals.h index 8ffa290caae822..0622d71e4ccb6e 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -123,10 +123,6 @@ void RegisterSignalHandler(int signal, bool reset_handler = false); #endif -v8::Local CreateEnvVarProxy(v8::Local context, - v8::Isolate* isolate, - v8::Local data); - std::string GetHumanReadableProcessName(); void GetHumanReadableProcessName(char (*name)[1024]); @@ -180,16 +176,6 @@ namespace task_queue { void PromiseRejectCallback(v8::PromiseRejectMessage message); } // namespace task_queue -v8::Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...); -v8::Maybe ProcessEmitDeprecationWarning(Environment* env, - const char* warning, - const char* deprecation_code); - -v8::Local CreateProcessObject( - Environment* env, - const std::vector& args, - const std::vector& exec_args); - enum Endianness { kLittleEndian, // _Not_ LITTLE_ENDIAN, clashes with endian.h. kBigEndian @@ -696,23 +682,6 @@ static inline const char* errno_string(int errorno) { // Functions defined in node.cc that are exposed via the bootstrapper object -void RawDebug(const v8::FunctionCallbackInfo& args); - -void DebugPortGetter(v8::Local property, - const v8::PropertyCallbackInfo& info); -void DebugPortSetter(v8::Local property, - v8::Local value, - const v8::PropertyCallbackInfo& info); - -void GetParentProcessId(v8::Local property, - const v8::PropertyCallbackInfo& info); - -void ProcessTitleGetter(v8::Local property, - const v8::PropertyCallbackInfo& info); -void ProcessTitleSetter(v8::Local property, - v8::Local value, - const v8::PropertyCallbackInfo& info); - #if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__) #define NODE_IMPLEMENTS_POSIX_CREDENTIALS 1 #endif // __POSIX__ && !defined(__ANDROID__) && !defined(__CloudABI__) diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 6036648dd4c527..a538839bcc6fcb 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -1,12 +1,13 @@ -#include "debug_utils.h" #include "node_messaging.h" -#include "node_internals.h" +#include "async_wrap-inl.h" +#include "async_wrap.h" +#include "debug_utils.h" #include "node_buffer.h" #include "node_errors.h" -#include "util.h" +#include "node_internals.h" +#include "node_process.h" #include "util-inl.h" -#include "async_wrap.h" -#include "async_wrap-inl.h" +#include "util.h" using v8::Array; using v8::ArrayBuffer; diff --git a/src/node_process.h b/src/node_process.h new file mode 100644 index 00000000000000..35667ca1b9de40 --- /dev/null +++ b/src/node_process.h @@ -0,0 +1,32 @@ +#ifndef SRC_NODE_PROCESS_H_ +#define SRC_NODE_PROCESS_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#include "v8.h" + +namespace node { + +v8::Local CreateEnvVarProxy(v8::Local context, + v8::Isolate* isolate, + v8::Local data); + +// Most of the time, it's best to use `console.error` to write +// to the process.stderr stream. However, in some cases, such as +// when debugging the stream.Writable class or the process.nextTick +// function, it is useful to bypass JavaScript entirely. +void RawDebug(const v8::FunctionCallbackInfo& args); + +v8::Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...); +v8::Maybe ProcessEmitDeprecationWarning(Environment* env, + const char* warning, + const char* deprecation_code); + +v8::Local CreateProcessObject( + Environment* env, + const std::vector& args, + const std::vector& exec_args); + +} // namespace node +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS +#endif // SRC_NODE_PROCESS_H_ diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index 69f08a219b67e6..c9abe19b7e0b68 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -1,9 +1,10 @@ -#include "node.h" -#include "node_internals.h" -#include "node_errors.h" -#include "base_object.h" #include "base_object-inl.h" +#include "base_object.h" #include "env-inl.h" +#include "node.h" +#include "node_errors.h" +#include "node_internals.h" +#include "node_process.h" #include "util-inl.h" #include "uv.h" #include "v8.h" @@ -44,7 +45,6 @@ using v8::Local; using v8::Name; using v8::NewStringType; using v8::Object; -using v8::PropertyCallbackInfo; using v8::String; using v8::Uint32; using v8::Uint32Array; @@ -197,10 +197,6 @@ static void MemoryUsage(const FunctionCallbackInfo& args) { fields[3] = v8_heap_stats.external_memory(); } -// Most of the time, it's best to use `console.error` to write -// to the process.stderr stream. However, in some cases, such as -// when debugging the stream.Writable class or the process.nextTick -// function, it is useful to bypass JavaScript entirely. void RawDebug(const FunctionCallbackInfo& args) { CHECK(args.Length() == 1 && args[0]->IsString() && "must be called with a single string"); @@ -246,28 +242,6 @@ static void Uptime(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(uptime / 1000); } -void ProcessTitleGetter(Local property, - const PropertyCallbackInfo& info) { - char buffer[512]; - uv_get_process_title(buffer, sizeof(buffer)); - info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), buffer, - NewStringType::kNormal).ToLocalChecked()); -} - -void ProcessTitleSetter(Local property, - Local value, - const PropertyCallbackInfo& info) { - node::Utf8Value title(info.GetIsolate(), value); - TRACE_EVENT_METADATA1("__metadata", "process_name", "name", - TRACE_STR_COPY(*title)); - uv_set_process_title(*title); -} - -void GetParentProcessId(Local property, - const PropertyCallbackInfo& info) { - info.GetReturnValue().Set(uv_os_getppid()); -} - static void GetActiveRequests(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); @@ -297,22 +271,6 @@ void GetActiveHandles(const FunctionCallbackInfo& args) { Array::New(env->isolate(), handle_v.data(), handle_v.size())); } -void DebugPortGetter(Local property, - const PropertyCallbackInfo& info) { - Environment* env = Environment::GetCurrent(info); - int port = env->inspector_host_port()->port(); - info.GetReturnValue().Set(port); -} - - -void DebugPortSetter(Local property, - Local value, - const PropertyCallbackInfo& info) { - Environment* env = Environment::GetCurrent(info); - int32_t port = value->Int32Value(env->context()).FromMaybe(0); - env->inspector_host_port()->set_port(static_cast(port)); -} - #ifdef __POSIX__ static void DebugProcess(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); diff --git a/src/node_process_object.cc b/src/node_process_object.cc index 68c27fa3f69fd5..4fc6f861612daf 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -1,6 +1,7 @@ #include "env-inl.h" #include "node_internals.h" #include "node_metadata.h" +#include "node_process.h" #include "node_revert.h" #include "util-inl.h" @@ -15,13 +16,53 @@ using v8::Integer; using v8::Isolate; using v8::Just; using v8::Local; +using v8::Name; using v8::NewStringType; using v8::None; using v8::Object; +using v8::PropertyCallbackInfo; using v8::SideEffectType; using v8::String; using v8::Value; +static void ProcessTitleGetter(Local property, + const PropertyCallbackInfo& info) { + char buffer[512]; + uv_get_process_title(buffer, sizeof(buffer)); + info.GetReturnValue().Set( + String::NewFromUtf8(info.GetIsolate(), buffer, NewStringType::kNormal) + .ToLocalChecked()); +} + +static void ProcessTitleSetter(Local property, + Local value, + const PropertyCallbackInfo& info) { + node::Utf8Value title(info.GetIsolate(), value); + TRACE_EVENT_METADATA1( + "__metadata", "process_name", "name", TRACE_STR_COPY(*title)); + uv_set_process_title(*title); +} + +static void DebugPortGetter(Local property, + const PropertyCallbackInfo& info) { + Environment* env = Environment::GetCurrent(info); + int port = env->inspector_host_port()->port(); + info.GetReturnValue().Set(port); +} + +static void DebugPortSetter(Local property, + Local value, + const PropertyCallbackInfo& info) { + Environment* env = Environment::GetCurrent(info); + int32_t port = value->Int32Value(env->context()).FromMaybe(0); + env->inspector_host_port()->set_port(static_cast(port)); +} + +static void GetParentProcessId(Local property, + const PropertyCallbackInfo& info) { + info.GetReturnValue().Set(uv_os_getppid()); +} + Local CreateProcessObject(Environment* env, const std::vector& args, const std::vector& exec_args) { @@ -36,6 +77,7 @@ Local CreateProcessObject(Environment* env, ->NewInstance(context) .ToLocalChecked(); + // process.title auto title_string = FIXED_ONE_BYTE_STRING(env->isolate(), "title"); CHECK(process->SetAccessor( env->context(), @@ -100,7 +142,7 @@ Local CreateProcessObject(Environment* env, ToV8Value(env->context(), exec_args) .ToLocalChecked()).FromJust(); - // create process.env + // process.env process ->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "env"), @@ -114,6 +156,9 @@ Local CreateProcessObject(Environment* env, FIXED_ONE_BYTE_STRING(env->isolate(), "ppid"), GetParentProcessId).FromJust()); + // TODO(joyeecheung): the following process properties that are set using + // parsed CLI flags should be migrated to `internal/options` in JS land. + // -e, --eval // TODO(addaleax): Remove this. if (env->options()->has_eval_string) { @@ -190,13 +235,13 @@ Local CreateProcessObject(Environment* env, READONLY_PROPERTY(process, "traceDeprecation", True(env->isolate())); } - // TODO(refack): move the following 4 to `node_config` // --inspect-brk if (env->options()->debug_options().wait_for_connect()) { READONLY_DONT_ENUM_PROPERTY(process, "_breakFirstLine", True(env->isolate())); } + // --inspect-brk-node if (env->options()->debug_options().break_node_first_line) { READONLY_DONT_ENUM_PROPERTY(process, "_breakNodeFirstLine", True(env->isolate())); @@ -224,6 +269,7 @@ Local CreateProcessObject(Environment* env, SECURITY_REVERSIONS(V) #undef V + // process.execPath { size_t exec_path_len = 2 * PATH_MAX; std::vector exec_path(exec_path_len); @@ -242,6 +288,7 @@ Local CreateProcessObject(Environment* env, exec_path_value).FromJust(); } + // process.debugPort auto debug_port_string = FIXED_ONE_BYTE_STRING(env->isolate(), "debugPort"); CHECK(process->SetAccessor(env->context(), debug_port_string, @@ -249,6 +296,10 @@ Local CreateProcessObject(Environment* env, env->is_main_thread() ? DebugPortSetter : nullptr, env->as_external()).FromJust()); + // process._rawDebug: may be overwritten later in JS land, but should be + // availbale from the begining for debugging purposes + env->SetMethod(process, "_rawDebug", RawDebug); + return scope.Escape(process); } diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc index 93f86f5d790aa7..ca08342ec63bb1 100644 --- a/src/signal_wrap.cc +++ b/src/signal_wrap.cc @@ -22,6 +22,7 @@ #include "async_wrap-inl.h" #include "env-inl.h" #include "handle_wrap.h" +#include "node_process.h" #include "util-inl.h" #include "v8.h" diff --git a/src/uv.cc b/src/uv.cc index a7d0b1012ce2f4..5422b0d2403d39 100644 --- a/src/uv.cc +++ b/src/uv.cc @@ -20,9 +20,10 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. #include "uv.h" +#include "env-inl.h" #include "node.h" #include "node_internals.h" -#include "env-inl.h" +#include "node_process.h" namespace node { From 5e1b8a27eb3f9d20405b098f3f2a0f4bcfdee3ee Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 31 Dec 2018 22:59:40 +0800 Subject: [PATCH 3/7] process: move C++ process events into node_process_events.cc Move the C++ `process.emit` and `process.emitWarning` methods from `node.cc` into into `node_process_events.cc`, and reuse the implementation in other places that need to do `process.emit` in C++. --- node.gyp | 1 + src/inspector_agent.cc | 17 +----- src/node.cc | 104 +++---------------------------------- src/node_process.h | 9 ++++ src/node_process_events.cc | 103 ++++++++++++++++++++++++++++++++++++ 5 files changed, 122 insertions(+), 112 deletions(-) create mode 100644 src/node_process_events.cc diff --git a/node.gyp b/node.gyp index 0db34a873efa28..c7bc857b1530f1 100644 --- a/node.gyp +++ b/node.gyp @@ -370,6 +370,7 @@ 'src/node_perf.cc', 'src/node_platform.cc', 'src/node_postmortem_metadata.cc', + 'src/node_process_events.cc', 'src/node_process_methods.cc', 'src/node_process_object.cc', 'src/node_serdes.cc', diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index d9a252bbe88140..a53c58337e900b 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -370,26 +370,13 @@ class SameThreadInspectorSession : public InspectorSession { void NotifyClusterWorkersDebugEnabled(Environment* env) { Isolate* isolate = env->isolate(); HandleScope handle_scope(isolate); - auto context = env->context(); + Local context = env->context(); // Send message to enable debug in cluster workers - Local process_object = env->process_object(); - Local emit_fn = - process_object->Get(context, FIXED_ONE_BYTE_STRING(isolate, "emit")) - .ToLocalChecked(); - // In case the thread started early during the startup - if (!emit_fn->IsFunction()) - return; - Local message = Object::New(isolate); message->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cmd"), FIXED_ONE_BYTE_STRING(isolate, "NODE_DEBUG_ENABLED")).FromJust(); - Local argv[] = { - FIXED_ONE_BYTE_STRING(isolate, "internalMessage"), - message - }; - MakeCallback(env->isolate(), process_object, emit_fn.As(), - arraysize(argv), argv, {0, 0}); + ProcessEmit(env, "internalMessage", message); } #ifdef _WIN32 diff --git a/src/node.cc b/src/node.cc index a797bfde4743ef..4ae2e0b3d5e13e 100644 --- a/src/node.cc +++ b/src/node.cc @@ -125,7 +125,6 @@ using v8::MaybeLocal; using v8::Message; using v8::MicrotasksPolicy; using v8::NewStringType; -using v8::Nothing; using v8::Object; using v8::ObjectTemplate; using v8::Script; @@ -582,82 +581,6 @@ void Exit(const FunctionCallbackInfo& args) { env->Exit(code); } -static Maybe ProcessEmitWarningGeneric(Environment* env, - const char* warning, - const char* type = nullptr, - const char* code = nullptr) { - HandleScope handle_scope(env->isolate()); - Context::Scope context_scope(env->context()); - - Local process = env->process_object(); - Local emit_warning; - if (!process->Get(env->context(), - env->emit_warning_string()).ToLocal(&emit_warning)) { - return Nothing(); - } - - if (!emit_warning->IsFunction()) return Just(false); - - int argc = 0; - Local args[3]; // warning, type, code - - // The caller has to be able to handle a failure anyway, so we might as well - // do proper error checking for string creation. - if (!String::NewFromUtf8(env->isolate(), - warning, - NewStringType::kNormal).ToLocal(&args[argc++])) { - return Nothing(); - } - if (type != nullptr) { - if (!String::NewFromOneByte(env->isolate(), - reinterpret_cast(type), - NewStringType::kNormal) - .ToLocal(&args[argc++])) { - return Nothing(); - } - if (code != nullptr && - !String::NewFromOneByte(env->isolate(), - reinterpret_cast(code), - NewStringType::kNormal) - .ToLocal(&args[argc++])) { - return Nothing(); - } - } - - // MakeCallback() unneeded because emitWarning is internal code, it calls - // process.emit('warning', ...), but does so on the nextTick. - if (emit_warning.As()->Call(env->context(), - process, - argc, - args).IsEmpty()) { - return Nothing(); - } - return Just(true); -} - - -// Call process.emitWarning(str), fmt is a snprintf() format string -Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...) { - char warning[1024]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(warning, sizeof(warning), fmt, ap); - va_end(ap); - - return ProcessEmitWarningGeneric(env, warning); -} - - -Maybe ProcessEmitDeprecationWarning(Environment* env, - const char* warning, - const char* deprecation_code) { - return ProcessEmitWarningGeneric(env, - warning, - "DeprecationWarning", - deprecation_code); -} - static void OnMessage(Local message, Local error) { Isolate* isolate = message->GetIsolate(); switch (message->ErrorLevel()) { @@ -1163,19 +1086,14 @@ void RunBeforeExit(Environment* env) { void EmitBeforeExit(Environment* env) { HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); - Local process_object = env->process_object(); - Local exit_code = env->exit_code_string(); - Local args[] = { - FIXED_ONE_BYTE_STRING(env->isolate(), "beforeExit"), - process_object->Get(env->context(), exit_code).ToLocalChecked() - ->ToInteger(env->context()).ToLocalChecked() - }; - MakeCallback(env->isolate(), - process_object, "emit", arraysize(args), args, - {0, 0}).ToLocalChecked(); + Local exit_code = env->process_object() + ->Get(env->context(), env->exit_code_string()) + .ToLocalChecked() + ->ToInteger(env->context()) + .ToLocalChecked(); + ProcessEmit(env, "beforeExit", exit_code).ToLocalChecked(); } - int EmitExit(Environment* env) { // process.emit('exit') HandleScope handle_scope(env->isolate()); @@ -1188,15 +1106,7 @@ int EmitExit(Environment* env) { Local exit_code = env->exit_code_string(); int code = process_object->Get(env->context(), exit_code).ToLocalChecked() ->Int32Value(env->context()).ToChecked(); - - Local args[] = { - FIXED_ONE_BYTE_STRING(env->isolate(), "exit"), - Integer::New(env->isolate(), code) - }; - - MakeCallback(env->isolate(), - process_object, "emit", arraysize(args), args, - {0, 0}).ToLocalChecked(); + ProcessEmit(env, "exit", Integer::New(env->isolate(), code)); // Reload exit code, it may be changed by `emit('exit')` return process_object->Get(env->context(), exit_code).ToLocalChecked() diff --git a/src/node_process.h b/src/node_process.h index 35667ca1b9de40..865223c1634010 100644 --- a/src/node_process.h +++ b/src/node_process.h @@ -17,6 +17,15 @@ v8::Local CreateEnvVarProxy(v8::Local context, // function, it is useful to bypass JavaScript entirely. void RawDebug(const v8::FunctionCallbackInfo& args); +v8::MaybeLocal ProcessEmit(Environment* env, + const char* event, + v8::Local message); + +v8::Maybe ProcessEmitWarningGeneric(Environment* env, + const char* warning, + const char* type = nullptr, + const char* code = nullptr); + v8::Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...); v8::Maybe ProcessEmitDeprecationWarning(Environment* env, const char* warning, diff --git a/src/node_process_events.cc b/src/node_process_events.cc new file mode 100644 index 00000000000000..d9c87173abe317 --- /dev/null +++ b/src/node_process_events.cc @@ -0,0 +1,103 @@ +#include + +#include "env.h" +#include "node_internals.h" +#include "node_process.h" + +namespace node { +using v8::Context; +using v8::Function; +using v8::HandleScope; +using v8::Isolate; +using v8::Just; +using v8::Local; +using v8::Maybe; +using v8::MaybeLocal; +using v8::NewStringType; +using v8::Nothing; +using v8::Object; +using v8::String; +using v8::Value; + +MaybeLocal ProcessEmit(Environment* env, + const char* event, + Local message) { + // Send message to enable debug in cluster workers + Local process = env->process_object(); + Isolate* isolate = env->isolate(); + Local argv[] = {OneByteString(isolate, event), message}; + + return MakeCallback(isolate, process, "emit", arraysize(argv), argv, {0, 0}); +} + +Maybe ProcessEmitWarningGeneric(Environment* env, + const char* warning, + const char* type, + const char* code) { + HandleScope handle_scope(env->isolate()); + Context::Scope context_scope(env->context()); + + Local process = env->process_object(); + Local emit_warning; + if (!process->Get(env->context(), env->emit_warning_string()) + .ToLocal(&emit_warning)) { + return Nothing(); + } + + if (!emit_warning->IsFunction()) return Just(false); + + int argc = 0; + Local args[3]; // warning, type, code + + // The caller has to be able to handle a failure anyway, so we might as well + // do proper error checking for string creation. + if (!String::NewFromUtf8(env->isolate(), warning, NewStringType::kNormal) + .ToLocal(&args[argc++])) { + return Nothing(); + } + if (type != nullptr) { + if (!String::NewFromOneByte(env->isolate(), + reinterpret_cast(type), + NewStringType::kNormal) + .ToLocal(&args[argc++])) { + return Nothing(); + } + if (code != nullptr && + !String::NewFromOneByte(env->isolate(), + reinterpret_cast(code), + NewStringType::kNormal) + .ToLocal(&args[argc++])) { + return Nothing(); + } + } + + // MakeCallback() unneeded because emitWarning is internal code, it calls + // process.emit('warning', ...), but does so on the nextTick. + if (emit_warning.As() + ->Call(env->context(), process, argc, args) + .IsEmpty()) { + return Nothing(); + } + return Just(true); +} + +// Call process.emitWarning(str), fmt is a snprintf() format string +Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...) { + char warning[1024]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(warning, sizeof(warning), fmt, ap); + va_end(ap); + + return ProcessEmitWarningGeneric(env, warning); +} + +Maybe ProcessEmitDeprecationWarning(Environment* env, + const char* warning, + const char* deprecation_code) { + return ProcessEmitWarningGeneric( + env, warning, "DeprecationWarning", deprecation_code); +} + +} // namespace node From ff4e9def0ae572c919b4f29820f3b8dfab0a668a Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 9 Jan 2019 22:59:35 +0800 Subject: [PATCH 4/7] fixup! src: move process object creation into node_process_object.cc --- src/node_process_object.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node_process_object.cc b/src/node_process_object.cc index 4fc6f861612daf..dccf19c92e3f93 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -1,3 +1,5 @@ +#include // PATH_MAX + #include "env-inl.h" #include "node_internals.h" #include "node_metadata.h" From cc8d7e3f78ca7e4fa3a7943750de5020d65bb58d Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 9 Jan 2019 23:01:28 +0800 Subject: [PATCH 5/7] fixup! src: declare process-related C++ methods in node_process.h --- src/node_env_var.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node_env_var.cc b/src/node_env_var.cc index e88fac2fc8b1f1..d1ebb064e2417e 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -1,4 +1,5 @@ #include "node_errors.h" +#include "node_internals.h" #include "node_process.h" #ifdef __APPLE__ From cdd42e7a12038d460b1c79e665b83ad3ba451f59 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 9 Jan 2019 23:52:13 +0800 Subject: [PATCH 6/7] fixup! src: move process object creation into node_process_object.cc --- src/node_process_object.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node_process_object.cc b/src/node_process_object.cc index dccf19c92e3f93..980b5002b69b0b 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -2,6 +2,7 @@ #include "env-inl.h" #include "node_internals.h" +#include "node_options-inl.h" #include "node_metadata.h" #include "node_process.h" #include "node_revert.h" From b05ae4e8d235336badc1d516deb260a20d6a3596 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 10 Jan 2019 00:04:58 +0800 Subject: [PATCH 7/7] fixup! process: move C++ process events into node_process_events.cc --- src/node.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/node.cc b/src/node.cc index 4ae2e0b3d5e13e..17cc10a7e6d153 100644 --- a/src/node.cc +++ b/src/node.cc @@ -124,7 +124,6 @@ using v8::Maybe; using v8::MaybeLocal; using v8::Message; using v8::MicrotasksPolicy; -using v8::NewStringType; using v8::Object; using v8::ObjectTemplate; using v8::Script;