Skip to content

Commit

Permalink
Upgrade to node v9.3.0 (electron#11507)
Browse files Browse the repository at this point in the history
* 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

nodejs/node#16565

* update libcc ref

* switch libcc to c62

* REVIEW: Address node api changes

- Always start the inspector agent for nodejs/node#17085
- Set the tracing controller for node nodejs/node#15538
- Isolate data creation now requires plaform nodejs/node#16700
  • Loading branch information
codebytere authored and sethlu committed May 3, 2018
1 parent 908926e commit c9a057c
Show file tree
Hide file tree
Showing 44 changed files with 137 additions and 98 deletions.
12 changes: 9 additions & 3 deletions atom/app/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<const char**>(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);
Expand All @@ -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);

Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1342,4 +1342,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_app, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_auto_updater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_auto_updater, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_auto_updater, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_browser_view, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_browser_view, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_browser_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1332,4 +1332,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_window, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_window, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_content_tracing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_content_tracing, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_debugger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_debugger, Initialize);
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_debugger, Initialize);
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_desktop_capturer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_desktop_capturer, Initialize);
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_dialog, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_download_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_download_item, Initialize);
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_global_shortcut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_global_shortcut, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_global_shortcut, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_menu, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_menu, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_net, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_net, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_notification.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_notification, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_notification, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_power_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_power_monitor, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_monitor, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_power_save_blocker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_power_save_blocker, Initialize);
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_save_blocker, Initialize);
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_protocol, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_render_process_preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_render_process_preferences,
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_screen, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_screen, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -839,4 +839,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_session, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_system_preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_system_preferences, Initialize);
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_system_preferences, Initialize);
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_tray, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2034,4 +2034,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_web_contents, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_web_view_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_web_view_manager, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_view_manager, Initialize)
4 changes: 2 additions & 2 deletions atom/browser/atom_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions atom/browser/javascript_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions atom/browser/javascript_environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace node {
class Environment;
class NodePlatform;
class MultiIsolatePlatform;
}

namespace atom {
Expand All @@ -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<v8::Context> context() const {
return v8::Local<v8::Context>::New(isolate_, context_);
Expand All @@ -33,7 +33,7 @@ class JavascriptEnvironment {
bool Initialize();

// Leaked on exit.
node::NodePlatform* platform_;
node::MultiIsolatePlatform* platform_;

bool initialized_;
gin::IsolateHolder isolate_holder_;
Expand Down
20 changes: 10 additions & 10 deletions atom/browser/node_debugger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<node::NodePlatform*>(platform), nullptr,
options);
DCHECK(env_->inspector_agent()->IsStarted());
}

} // namespace atom
4 changes: 2 additions & 2 deletions atom/browser/node_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace node {
class Environment;
class NodePlatform;
class MultiIsolatePlatform;
}

namespace atom {
Expand All @@ -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_;
Expand Down
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_asar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_asar, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_asar, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_clipboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_clipboard, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_clipboard, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_crash_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_crash_reporter, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_crash_reporter, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_native_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,4 +636,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_native_image, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_native_image, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_shell, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_shell, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_v8_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,

} // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_v8_util, Initialize)
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_v8_util, Initialize)
Loading

0 comments on commit c9a057c

Please sign in to comment.