From c9a057c5410079b0895022da3cc8d322c1594f40 Mon Sep 17 00:00:00 2001 From: shelley vohr Date: Sat, 6 Jan 2018 07:58:24 -0800 Subject: [PATCH] Upgrade to node v9.3.0 (#11507) * update submodule refs for node v9.3.0 * Define "llvm_version" for Node.js build * NODE_MODULE_CONTEXT_AWARE_BUILTIN -> NODE_BUILTIN_MODULE_CONTEXT_AWARE * update NodePlatform to MultiIsolatePlatform * fix linting error * update node ref * REVIEW: Explicitly register builtin modules https://github.com/nodejs/node/pull/16565 * update libcc ref * switch libcc to c62 * REVIEW: Address node api changes - Always start the inspector agent for https://github.com/nodejs/node/pull/17085 - Set the tracing controller for node https://github.com/nodejs/node/pull/15538 - Isolate data creation now requires plaform https://github.com/nodejs/node/pull/16700 --- atom/app/node_main.cc | 12 ++- atom/browser/api/atom_api_app.cc | 2 +- atom/browser/api/atom_api_auto_updater.cc | 2 +- atom/browser/api/atom_api_browser_view.cc | 2 +- atom/browser/api/atom_api_browser_window.cc | 2 +- atom/browser/api/atom_api_content_tracing.cc | 2 +- atom/browser/api/atom_api_debugger.cc | 2 +- atom/browser/api/atom_api_desktop_capturer.cc | 2 +- atom/browser/api/atom_api_dialog.cc | 2 +- atom/browser/api/atom_api_download_item.cc | 2 +- atom/browser/api/atom_api_global_shortcut.cc | 2 +- atom/browser/api/atom_api_menu.cc | 2 +- atom/browser/api/atom_api_net.cc | 2 +- atom/browser/api/atom_api_notification.cc | 2 +- atom/browser/api/atom_api_power_monitor.cc | 2 +- .../api/atom_api_power_save_blocker.cc | 2 +- atom/browser/api/atom_api_protocol.cc | 2 +- .../atom_api_render_process_preferences.cc | 2 +- atom/browser/api/atom_api_screen.cc | 2 +- atom/browser/api/atom_api_session.cc | 2 +- .../api/atom_api_system_preferences.cc | 2 +- atom/browser/api/atom_api_tray.cc | 2 +- atom/browser/api/atom_api_web_contents.cc | 2 +- atom/browser/api/atom_api_web_view_manager.cc | 2 +- atom/browser/atom_browser_main_parts.cc | 4 +- atom/browser/javascript_environment.cc | 7 +- atom/browser/javascript_environment.h | 6 +- atom/browser/node_debugger.cc | 20 ++-- atom/browser/node_debugger.h | 4 +- atom/common/api/atom_api_asar.cc | 2 +- atom/common/api/atom_api_clipboard.cc | 2 +- atom/common/api/atom_api_crash_reporter.cc | 2 +- atom/common/api/atom_api_native_image.cc | 2 +- atom/common/api/atom_api_shell.cc | 2 +- atom/common/api/atom_api_v8_util.cc | 2 +- atom/common/node_bindings.cc | 99 +++++++++++-------- atom/common/node_bindings.h | 6 +- atom/renderer/api/atom_api_renderer_ipc.cc | 2 +- atom/renderer/api/atom_api_web_frame.cc | 2 +- atom/renderer/atom_renderer_client.cc | 6 ++ .../atom_sandboxed_renderer_client.cc | 3 + common.gypi | 2 + vendor/libchromiumcontent | 2 +- vendor/node | 2 +- 44 files changed, 137 insertions(+), 98 deletions(-) diff --git a/atom/app/node_main.cc b/atom/app/node_main.cc index c0175d170d3ccf..8e0089ad95c0ab 100644 --- a/atom/app/node_main.cc +++ b/atom/app/node_main.cc @@ -12,6 +12,7 @@ #include "atom/common/api/atom_bindings.h" #include "atom/common/crash_reporter/crash_reporter.h" #include "atom/common/native_mate_converters/string16_converter.h" +#include "atom/common/node_bindings.h" #include "base/command_line.h" #include "base/feature_list.h" #include "base/task_scheduler/task_scheduler.h" @@ -50,14 +51,16 @@ int NodeMain(int argc, char *argv[]) { // Initialize gin::IsolateHolder. JavascriptEnvironment gin_env; + // Explicitly register electron's builtin modules. + NodeBindings::RegisterBuiltinModules(); + int exec_argc; const char** exec_argv; node::Init(&argc, const_cast(argv), &exec_argc, &exec_argv); - node::IsolateData isolate_data(gin_env.isolate(), loop); node::Environment* env = node::CreateEnvironment( - &isolate_data, gin_env.context(), argc, argv, - exec_argc, exec_argv); + node::CreateIsolateData(gin_env.isolate(), loop, gin_env.platform()), + gin_env.context(), argc, argv, exec_argc, exec_argv); // Enable support for v8 inspector. NodeDebugger node_debugger(env); @@ -79,6 +82,7 @@ int NodeMain(int argc, char *argv[]) { bool more; do { more = uv_run(env->event_loop(), UV_RUN_ONCE); + gin_env.platform()->DrainBackgroundTasks(env->isolate()); if (more == false) { node::EmitBeforeExit(env); @@ -92,6 +96,8 @@ int NodeMain(int argc, char *argv[]) { exit_code = node::EmitExit(env); node::RunAtExit(env); + gin_env.platform()->DrainBackgroundTasks(env->isolate()); + gin_env.platform()->CancelPendingDelayedTasks(env->isolate()); node::FreeEnvironment(env); } diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 0a912cd77c1a49..77112113569009 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -1342,4 +1342,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_app, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize) diff --git a/atom/browser/api/atom_api_auto_updater.cc b/atom/browser/api/atom_api_auto_updater.cc index 706931fe61eb42..88a58f6bca6b1c 100644 --- a/atom/browser/api/atom_api_auto_updater.cc +++ b/atom/browser/api/atom_api_auto_updater.cc @@ -150,4 +150,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_auto_updater, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_auto_updater, Initialize) diff --git a/atom/browser/api/atom_api_browser_view.cc b/atom/browser/api/atom_api_browser_view.cc index 4bd88a5a43c03c..c64054cdac2e47 100644 --- a/atom/browser/api/atom_api_browser_view.cc +++ b/atom/browser/api/atom_api_browser_view.cc @@ -162,4 +162,4 @@ void Initialize(v8::Local exports, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_browser_view, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_browser_view, Initialize) diff --git a/atom/browser/api/atom_api_browser_window.cc b/atom/browser/api/atom_api_browser_window.cc index 08e953539a9858..6a6e4f02c4433f 100644 --- a/atom/browser/api/atom_api_browser_window.cc +++ b/atom/browser/api/atom_api_browser_window.cc @@ -1332,4 +1332,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_window, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_window, Initialize) diff --git a/atom/browser/api/atom_api_content_tracing.cc b/atom/browser/api/atom_api_content_tracing.cc index 375196b28318b3..50b0c9799b8b4b 100644 --- a/atom/browser/api/atom_api_content_tracing.cc +++ b/atom/browser/api/atom_api_content_tracing.cc @@ -73,4 +73,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_content_tracing, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize) diff --git a/atom/browser/api/atom_api_debugger.cc b/atom/browser/api/atom_api_debugger.cc index da8b212be0244e..58c028e3d41907 100644 --- a/atom/browser/api/atom_api_debugger.cc +++ b/atom/browser/api/atom_api_debugger.cc @@ -178,4 +178,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_debugger, Initialize); +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_debugger, Initialize); diff --git a/atom/browser/api/atom_api_desktop_capturer.cc b/atom/browser/api/atom_api_desktop_capturer.cc index b5daaaee05f9b5..d27838ad22d64c 100644 --- a/atom/browser/api/atom_api_desktop_capturer.cc +++ b/atom/browser/api/atom_api_desktop_capturer.cc @@ -114,4 +114,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_desktop_capturer, Initialize); +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize); diff --git a/atom/browser/api/atom_api_dialog.cc b/atom/browser/api/atom_api_dialog.cc index f04af29d822340..ff02c5fa009f2e 100644 --- a/atom/browser/api/atom_api_dialog.cc +++ b/atom/browser/api/atom_api_dialog.cc @@ -140,4 +140,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_dialog, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize) diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index 3e5932cad0ffeb..491cc18538b2c4 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -236,4 +236,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_download_item, Initialize); +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize); diff --git a/atom/browser/api/atom_api_global_shortcut.cc b/atom/browser/api/atom_api_global_shortcut.cc index 039d708a7c1cc4..a33ba7e45e5645 100644 --- a/atom/browser/api/atom_api_global_shortcut.cc +++ b/atom/browser/api/atom_api_global_shortcut.cc @@ -98,4 +98,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_global_shortcut, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_global_shortcut, Initialize) diff --git a/atom/browser/api/atom_api_menu.cc b/atom/browser/api/atom_api_menu.cc index b27ee2ba789817..14a38c87019171 100644 --- a/atom/browser/api/atom_api_menu.cc +++ b/atom/browser/api/atom_api_menu.cc @@ -228,4 +228,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_menu, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_menu, Initialize) diff --git a/atom/browser/api/atom_api_net.cc b/atom/browser/api/atom_api_net.cc index 24008ed7aeed1d..77393c92565b33 100644 --- a/atom/browser/api/atom_api_net.cc +++ b/atom/browser/api/atom_api_net.cc @@ -58,4 +58,4 @@ void Initialize(v8::Local exports, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_net, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_net, Initialize) diff --git a/atom/browser/api/atom_api_notification.cc b/atom/browser/api/atom_api_notification.cc index daa46b96cbfd55..3eb99be4325700 100644 --- a/atom/browser/api/atom_api_notification.cc +++ b/atom/browser/api/atom_api_notification.cc @@ -270,4 +270,4 @@ void Initialize(v8::Local exports, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_notification, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_notification, Initialize) diff --git a/atom/browser/api/atom_api_power_monitor.cc b/atom/browser/api/atom_api_power_monitor.cc index 90f32393f1682b..fce749790b52e6 100644 --- a/atom/browser/api/atom_api_power_monitor.cc +++ b/atom/browser/api/atom_api_power_monitor.cc @@ -103,4 +103,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_power_monitor, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_monitor, Initialize) diff --git a/atom/browser/api/atom_api_power_save_blocker.cc b/atom/browser/api/atom_api_power_save_blocker.cc index f430e28c3baceb..37aef91af9c64e 100644 --- a/atom/browser/api/atom_api_power_save_blocker.cc +++ b/atom/browser/api/atom_api_power_save_blocker.cc @@ -133,4 +133,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_power_save_blocker, Initialize); +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_save_blocker, Initialize); diff --git a/atom/browser/api/atom_api_protocol.cc b/atom/browser/api/atom_api_protocol.cc index 6ea1d8b757757c..b904c88bfcc6e9 100644 --- a/atom/browser/api/atom_api_protocol.cc +++ b/atom/browser/api/atom_api_protocol.cc @@ -253,4 +253,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_protocol, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize) diff --git a/atom/browser/api/atom_api_render_process_preferences.cc b/atom/browser/api/atom_api_render_process_preferences.cc index 5786d694cfd5d8..d57a8e78a4165a 100644 --- a/atom/browser/api/atom_api_render_process_preferences.cc +++ b/atom/browser/api/atom_api_render_process_preferences.cc @@ -86,5 +86,5 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_render_process_preferences, +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences, Initialize) diff --git a/atom/browser/api/atom_api_screen.cc b/atom/browser/api/atom_api_screen.cc index a87d6d3598f8c4..2e94e05da35f3e 100644 --- a/atom/browser/api/atom_api_screen.cc +++ b/atom/browser/api/atom_api_screen.cc @@ -144,4 +144,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_screen, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_screen, Initialize) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 6e5c4b9cbe77c1..c9fc0837f5df98 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -839,4 +839,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_session, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize) diff --git a/atom/browser/api/atom_api_system_preferences.cc b/atom/browser/api/atom_api_system_preferences.cc index 82c3b2e1017f85..2b18d0f7974dab 100644 --- a/atom/browser/api/atom_api_system_preferences.cc +++ b/atom/browser/api/atom_api_system_preferences.cc @@ -96,4 +96,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_system_preferences, Initialize); +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_system_preferences, Initialize); diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index 27d186e0d03858..6a032e20279358 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -250,4 +250,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_tray, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index cca172f3ceccb9..6f5507c55398c5 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -2034,4 +2034,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_web_contents, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize) diff --git a/atom/browser/api/atom_api_web_view_manager.cc b/atom/browser/api/atom_api_web_view_manager.cc index d145fb15fb6e30..2a0cbd8a3ebf09 100644 --- a/atom/browser/api/atom_api_web_view_manager.cc +++ b/atom/browser/api/atom_api_web_view_manager.cc @@ -52,4 +52,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_web_view_manager, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_view_manager, Initialize) diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 86d50d3c78bda4..718d7d4f82babe 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -135,8 +135,8 @@ void AtomBrowserMainParts::PostEarlyInitialization() { node_bindings_->Initialize(); // Create the global environment. - node::Environment* env = - node_bindings_->CreateEnvironment(js_env_->context()); + node::Environment* env = node_bindings_->CreateEnvironment( + js_env_->context(), js_env_->platform()); node_env_.reset(new NodeEnvironment(env)); // Enable support for v8 inspector diff --git a/atom/browser/javascript_environment.cc b/atom/browser/javascript_environment.cc index a1e824cad31565..631beb4ff61a56 100644 --- a/atom/browser/javascript_environment.cc +++ b/atom/browser/javascript_environment.cc @@ -15,6 +15,7 @@ #include "gin/v8_initializer.h" #include "atom/common/node_includes.h" +#include "vendor/node/src/tracing/trace_event.h" namespace atom { @@ -48,10 +49,10 @@ bool JavascriptEnvironment::Initialize() { // The V8Platform of gin relies on Chromium's task schedule, which has not // been started at this point, so we have to rely on Node's V8Platform. platform_ = node::CreatePlatform( - base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0), - uv_default_loop(), nullptr); + base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0), nullptr); v8::V8::InitializePlatform(platform_); - + node::tracing::TraceEventHelper::SetTracingController( + new v8::TracingController()); gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, gin::IsolateHolder::kStableV8Extras, gin::ArrayBufferAllocator::SharedInstance(), diff --git a/atom/browser/javascript_environment.h b/atom/browser/javascript_environment.h index 0754df212c8777..69872e454aa4af 100644 --- a/atom/browser/javascript_environment.h +++ b/atom/browser/javascript_environment.h @@ -10,7 +10,7 @@ namespace node { class Environment; -class NodePlatform; +class MultiIsolatePlatform; } namespace atom { @@ -23,7 +23,7 @@ class JavascriptEnvironment { void OnMessageLoopCreated(); void OnMessageLoopDestroying(); - node::NodePlatform* platform() const { return platform_; } + node::MultiIsolatePlatform* platform() const { return platform_; } v8::Isolate* isolate() const { return isolate_; } v8::Local context() const { return v8::Local::New(isolate_, context_); @@ -33,7 +33,7 @@ class JavascriptEnvironment { bool Initialize(); // Leaked on exit. - node::NodePlatform* platform_; + node::MultiIsolatePlatform* platform_; bool initialized_; gin::IsolateHolder isolate_holder_; diff --git a/atom/browser/node_debugger.cc b/atom/browser/node_debugger.cc index 27d2ce7999160e..191531d5bf3b9e 100644 --- a/atom/browser/node_debugger.cc +++ b/atom/browser/node_debugger.cc @@ -20,7 +20,7 @@ NodeDebugger::NodeDebugger(node::Environment* env) NodeDebugger::~NodeDebugger() { } -void NodeDebugger::Start(node::NodePlatform* platform) { +void NodeDebugger::Start(node::MultiIsolatePlatform* platform) { auto inspector = env_->inspector_agent(); if (inspector == nullptr) return; @@ -34,16 +34,16 @@ void NodeDebugger::Start(node::NodePlatform* platform) { #endif } - if (options.inspector_enabled()) { - // Set process._debugWaitConnect if --inspect-brk was specified to stop - // the debugger on the first line - if (options.wait_for_connect()) { - mate::Dictionary process(env_->isolate(), env_->process_object()); - process.Set("_breakFirstLine", true); - } - - inspector->Start(platform, nullptr, options); + // Set process._debugWaitConnect if --inspect-brk was specified to stop + // the debugger on the first line + if (options.wait_for_connect()) { + mate::Dictionary process(env_->isolate(), env_->process_object()); + process.Set("_breakFirstLine", true); } + + inspector->Start(static_cast(platform), nullptr, + options); + DCHECK(env_->inspector_agent()->IsStarted()); } } // namespace atom diff --git a/atom/browser/node_debugger.h b/atom/browser/node_debugger.h index cb176c77764889..f62eeadac55b51 100644 --- a/atom/browser/node_debugger.h +++ b/atom/browser/node_debugger.h @@ -9,7 +9,7 @@ namespace node { class Environment; -class NodePlatform; +class MultiIsolatePlatform; } namespace atom { @@ -20,7 +20,7 @@ class NodeDebugger { explicit NodeDebugger(node::Environment* env); ~NodeDebugger(); - void Start(node::NodePlatform* platform); + void Start(node::MultiIsolatePlatform* platform); private: node::Environment* env_; diff --git a/atom/common/api/atom_api_asar.cc b/atom/common/api/atom_api_asar.cc index ef27850370ff99..c9c355e42350e5 100644 --- a/atom/common/api/atom_api_asar.cc +++ b/atom/common/api/atom_api_asar.cc @@ -163,4 +163,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_asar, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_asar, Initialize) diff --git a/atom/common/api/atom_api_clipboard.cc b/atom/common/api/atom_api_clipboard.cc index 66b88374e4f98c..47c85650a84ebc 100644 --- a/atom/common/api/atom_api_clipboard.cc +++ b/atom/common/api/atom_api_clipboard.cc @@ -255,4 +255,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_clipboard, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_clipboard, Initialize) diff --git a/atom/common/api/atom_api_crash_reporter.cc b/atom/common/api/atom_api_crash_reporter.cc index 9042f0917942ba..78ef525f911877 100644 --- a/atom/common/api/atom_api_crash_reporter.cc +++ b/atom/common/api/atom_api_crash_reporter.cc @@ -61,4 +61,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_crash_reporter, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_crash_reporter, Initialize) diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index a8f865c63ea6c1..ed736dabd00f3c 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -636,4 +636,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_native_image, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_native_image, Initialize) diff --git a/atom/common/api/atom_api_shell.cc b/atom/common/api/atom_api_shell.cc index 39e6aea7baf821..231d2ea9cbef6e 100644 --- a/atom/common/api/atom_api_shell.cc +++ b/atom/common/api/atom_api_shell.cc @@ -151,4 +151,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_shell, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_shell, Initialize) diff --git a/atom/common/api/atom_api_v8_util.cc b/atom/common/api/atom_api_v8_util.cc index a01ca8f84d917f..f7edfd28cb3f52 100644 --- a/atom/common/api/atom_api_v8_util.cc +++ b/atom/common/api/atom_api_v8_util.cc @@ -123,4 +123,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_v8_util, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_v8_util, Initialize) diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index 90e76e7870fd9c..a69f5bcf7e3e03 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -27,45 +27,48 @@ #include "atom/common/node_includes.h" -// Force all builtin modules to be referenced so they can actually run their -// DSO constructors, see http://git.io/DRIqCg. -#define REFERENCE_MODULE(name) \ - extern "C" void _register_ ## name(void); \ - void (*fp_register_ ## name)(void) = _register_ ## name -// Electron's builtin modules. -REFERENCE_MODULE(atom_browser_app); -REFERENCE_MODULE(atom_browser_auto_updater); -REFERENCE_MODULE(atom_browser_browser_view); -REFERENCE_MODULE(atom_browser_content_tracing); -REFERENCE_MODULE(atom_browser_debugger); -REFERENCE_MODULE(atom_browser_desktop_capturer); -REFERENCE_MODULE(atom_browser_dialog); -REFERENCE_MODULE(atom_browser_download_item); -REFERENCE_MODULE(atom_browser_global_shortcut); -REFERENCE_MODULE(atom_browser_in_app_purchase); -REFERENCE_MODULE(atom_browser_menu); -REFERENCE_MODULE(atom_browser_net); -REFERENCE_MODULE(atom_browser_power_monitor); -REFERENCE_MODULE(atom_browser_power_save_blocker); -REFERENCE_MODULE(atom_browser_protocol); -REFERENCE_MODULE(atom_browser_render_process_preferences); -REFERENCE_MODULE(atom_browser_session); -REFERENCE_MODULE(atom_browser_system_preferences); -REFERENCE_MODULE(atom_browser_tray); -REFERENCE_MODULE(atom_browser_web_contents); -REFERENCE_MODULE(atom_browser_web_view_manager); -REFERENCE_MODULE(atom_browser_window); -REFERENCE_MODULE(atom_common_asar); -REFERENCE_MODULE(atom_common_clipboard); -REFERENCE_MODULE(atom_common_crash_reporter); -REFERENCE_MODULE(atom_common_native_image); -REFERENCE_MODULE(atom_common_notification); -REFERENCE_MODULE(atom_common_screen); -REFERENCE_MODULE(atom_common_shell); -REFERENCE_MODULE(atom_common_v8_util); -REFERENCE_MODULE(atom_renderer_ipc); -REFERENCE_MODULE(atom_renderer_web_frame); -#undef REFERENCE_MODULE +#define ELECTRON_BUILTIN_MODULES(V) \ + V(atom_browser_app) \ + V(atom_browser_auto_updater) \ + V(atom_browser_browser_view) \ + V(atom_browser_content_tracing) \ + V(atom_browser_debugger) \ + V(atom_browser_desktop_capturer) \ + V(atom_browser_dialog) \ + V(atom_browser_download_item) \ + V(atom_browser_global_shortcut) \ + V(atom_browser_in_app_purchase) \ + V(atom_browser_menu) \ + V(atom_browser_net) \ + V(atom_browser_power_monitor) \ + V(atom_browser_power_save_blocker) \ + V(atom_browser_protocol) \ + V(atom_browser_render_process_preferences) \ + V(atom_browser_session) \ + V(atom_browser_system_preferences) \ + V(atom_browser_tray) \ + V(atom_browser_web_contents) \ + V(atom_browser_web_view_manager) \ + V(atom_browser_window) \ + V(atom_common_asar) \ + V(atom_common_clipboard) \ + V(atom_common_crash_reporter) \ + V(atom_common_native_image) \ + V(atom_common_notification) \ + V(atom_common_screen) \ + V(atom_common_shell) \ + V(atom_common_v8_util) \ + V(atom_renderer_ipc) \ + V(atom_renderer_web_frame) + +// This is used to load built-in modules. Instead of using +// __attribute__((constructor)), we call the _register_ +// function for each built-in modules explicitly. This is only +// forward declaration. The definitions are in each module's +// implementation when calling the NODE_BUILTIN_MODULE_CONTEXT_AWARE. +#define V(modname) void _register_##modname(); +ELECTRON_BUILTIN_MODULES(V) +#undef V namespace { @@ -155,6 +158,12 @@ NodeBindings::~NodeBindings() { stop_and_close_uv_loop(uv_loop_); } +void NodeBindings::RegisterBuiltinModules() { +#define V(modname) _register_##modname(); + ELECTRON_BUILTIN_MODULES(V) +#undef V +} + void NodeBindings::Initialize() { // Open node's error reporting system for browser process. node::g_standalone_mode = browser_env_ == BROWSER; @@ -166,6 +175,9 @@ void NodeBindings::Initialize() { AtomCommandLine::InitializeFromCommandLine(); #endif + // Explicitly register electron's builtin modules. + RegisterBuiltinModules(); + // Init node. // (we assume node::Init would not modify the parameters under embedded mode). node::Init(nullptr, nullptr, nullptr, nullptr); @@ -180,6 +192,7 @@ void NodeBindings::Initialize() { } node::Environment* NodeBindings::CreateEnvironment( +<<<<<<< c1acc6cb5c9591122cecfcf3910c73d62d28eaf7 v8::Handle context) { #if defined(OS_WIN) auto& atom_args = AtomCommandLine::argv(); @@ -187,6 +200,10 @@ node::Environment* NodeBindings::CreateEnvironment( std::transform(atom_args.cbegin(), atom_args.cend(), args.begin(), [](auto& a) { return base::WideToUTF8(a); }); #else +======= + v8::Handle context, + node::MultiIsolatePlatform* platform) { +>>>>>>> Upgrade to node v9.3.0 (#11507) auto args = AtomCommandLine::argv(); #endif @@ -212,8 +229,8 @@ node::Environment* NodeBindings::CreateEnvironment( std::unique_ptr c_argv = StringVectorToArgArray(args); node::Environment* env = node::CreateEnvironment( - new node::IsolateData(context->GetIsolate(), uv_loop_), context, - args.size(), c_argv.get(), 0, nullptr); + node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform), + context, args.size(), c_argv.get(), 0, nullptr); if (browser_env_ == BROWSER) { // SetAutorunMicrotasks is no longer called in node::CreateEnvironment diff --git a/atom/common/node_bindings.h b/atom/common/node_bindings.h index 4be779e68a0179..8f0fdbe5761187 100644 --- a/atom/common/node_bindings.h +++ b/atom/common/node_bindings.h @@ -17,6 +17,7 @@ class MessageLoop; namespace node { class Environment; +class MultiIsolatePlatform; } namespace atom { @@ -30,6 +31,7 @@ class NodeBindings { }; static NodeBindings* Create(BrowserEnvironment browser_env); + static void RegisterBuiltinModules(); virtual ~NodeBindings(); @@ -37,7 +39,9 @@ class NodeBindings { void Initialize(); // Create the environment and load node.js. - node::Environment* CreateEnvironment(v8::Handle context); + node::Environment* CreateEnvironment( + v8::Handle context, + node::MultiIsolatePlatform* platform = nullptr); // Load node.js in the environment. void LoadEnvironment(node::Environment* env); diff --git a/atom/renderer/api/atom_api_renderer_ipc.cc b/atom/renderer/api/atom_api_renderer_ipc.cc index 7bee1411ba1c2f..2bb35992ff9aa2 100644 --- a/atom/renderer/api/atom_api_renderer_ipc.cc +++ b/atom/renderer/api/atom_api_renderer_ipc.cc @@ -76,4 +76,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace atom -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_ipc, atom::api::Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_renderer_ipc, atom::api::Initialize) diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index 2fe9c68c5d7d1a..c0aeb397c08e3c 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -518,4 +518,4 @@ void Initialize(v8::Local exports, v8::Local unused, } // namespace -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_web_frame, Initialize) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_renderer_web_frame, Initialize) diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 82ba9d02435000..937e422a0d21b5 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -25,6 +25,7 @@ #include "atom/common/node_includes.h" #include "atom_natives.h" // NOLINT: This file is generated with js2c +#include "vendor/node/src/tracing/trace_event.h" namespace atom { @@ -95,6 +96,11 @@ void AtomRendererClient::DidCreateScriptContext( node_bindings_->PrepareMessageLoop(); } + // Setup node tracing controller. + if (!node::tracing::TraceEventHelper::GetTracingController()) + node::tracing::TraceEventHelper::SetTracingController( + new v8::TracingController()); + // Setup node environment for each window. node::Environment* env = node_bindings_->CreateEnvironment(context); diff --git a/atom/renderer/atom_sandboxed_renderer_client.cc b/atom/renderer/atom_sandboxed_renderer_client.cc index 07d20bda8b00b1..33f9c6940b6aaf 100644 --- a/atom/renderer/atom_sandboxed_renderer_client.cc +++ b/atom/renderer/atom_sandboxed_renderer_client.cc @@ -11,6 +11,7 @@ #include "atom/common/native_mate_converters/string16_converter.h" #include "atom/common/native_mate_converters/v8_value_converter.h" #include "atom/common/native_mate_converters/value_converter.h" +#include "atom/common/node_bindings.h" #include "atom/common/options_switches.h" #include "atom/renderer/api/atom_api_renderer_ipc.h" #include "atom/renderer/atom_render_view_observer.h" @@ -136,6 +137,8 @@ class AtomSandboxedRenderViewObserver : public AtomRenderViewObserver { AtomSandboxedRendererClient::AtomSandboxedRendererClient() { + // Explicitly register electron's builtin modules. + NodeBindings::RegisterBuiltinModules(); } AtomSandboxedRendererClient::~AtomSandboxedRendererClient() { diff --git a/common.gypi b/common.gypi index 233e21047718c9..2209914148e83d 100644 --- a/common.gypi +++ b/common.gypi @@ -13,6 +13,8 @@ 'component%': 'static_library', 'debug_http2': 'false', 'debug_nghttp2': 'false', + # XXX(alexeykuzmin): Must match the clang version we use. See `clang -v`. + 'llvm_version': '6.0', 'python': 'python', 'openssl_fips': '', 'openssl_no_asm': 1, diff --git a/vendor/libchromiumcontent b/vendor/libchromiumcontent index 86a86703137e54..f8ff573e503dea 160000 --- a/vendor/libchromiumcontent +++ b/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 86a86703137e54b0299bd76421093fdfdb94c531 +Subproject commit f8ff573e503dea08f8ef05a2773bf3b0aa8dfdb1 diff --git a/vendor/node b/vendor/node index 618ed0431bbd1a..7fe5e2f60f6f40 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 618ed0431bbd1a96fc88d2b6b36ad3086d418ffd +Subproject commit 7fe5e2f60f6f40363ec0d77fd17b241208663534