diff --git a/atom/app/node_main.cc b/atom/app/node_main.cc index e8487bf1dd5c..af8974fb29b7 100644 --- a/atom/app/node_main.cc +++ b/atom/app/node_main.cc @@ -48,8 +48,9 @@ int NodeMain(int argc, char *argv[]) { 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( - gin_env.isolate(), loop, gin_env.context(), argc, argv, + &isolate_data, gin_env.context(), argc, argv, exec_argc, exec_argv); // Start our custom debugger implementation. diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 1507a976fdb9..8b1616cf22e6 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -129,9 +129,13 @@ void AtomBrowserMainParts::PostEarlyInitialization() { // Support the "--debug" switch. node_debugger_.reset(new NodeDebugger(js_env_->isolate())); + isolate_data_.reset( + new node::IsolateData(js_env_->isolate(), uv_default_loop())); + // Create the global environment. node::Environment* env = - node_bindings_->CreateEnvironment(js_env_->context()); + node_bindings_->CreateEnvironment(isolate_data_.get(), + js_env_->context()); // Make sure node can get correct environment when debugging. if (node_debugger_->IsRunning()) diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index 0d8619f6865a..071a7a898f07 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -15,6 +15,10 @@ class BrowserProcess; +namespace node { +class IsolateData; +} + namespace atom { class AtomBindings; @@ -82,6 +86,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { std::unique_ptr node_bindings_; std::unique_ptr atom_bindings_; std::unique_ptr node_debugger_; + std::unique_ptr isolate_data_; base::Timer gc_timer_; diff --git a/atom/common/api/atom_api_asar.cc b/atom/common/api/atom_api_asar.cc index dc421f0a0a26..e94099bacf6b 100644 --- a/atom/common/api/atom_api_asar.cc +++ b/atom/common/api/atom_api_asar.cc @@ -132,12 +132,12 @@ void InitAsarSupport(v8::Isolate* isolate, v8::Local require) { // Evaluate asar_init.coffee. const char* asar_init_native = reinterpret_cast( - static_cast(node::asar_init_native)); + static_cast(node::asar_init_data)); v8::Local asar_init = v8::Script::Compile(v8::String::NewFromUtf8( isolate, asar_init_native, v8::String::kNormalString, - sizeof(node::asar_init_native) -1)); + sizeof(node::asar_init_data) -1)); v8::Local result = asar_init->Run(); // Initialize asar support. @@ -146,10 +146,10 @@ void InitAsarSupport(v8::Isolate* isolate, std::string)> init; if (mate::ConvertFromV8(isolate, result, &init)) { const char* asar_native = reinterpret_cast( - static_cast(node::asar_native)); + static_cast(node::asar_data)); init.Run(process, require, - std::string(asar_native, sizeof(node::asar_native) - 1)); + std::string(asar_native, sizeof(node::asar_data) - 1)); } } diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index 40f53520e8b1..8e2cb097938a 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -144,7 +144,7 @@ void NodeBindings::Initialize() { } node::Environment* NodeBindings::CreateEnvironment( - v8::Handle context) { + node::IsolateData* isolate_data, v8::Handle context) { auto args = AtomCommandLine::argv(); // Feed node the path to initialization script. @@ -160,7 +160,7 @@ node::Environment* NodeBindings::CreateEnvironment( std::unique_ptr c_argv = StringVectorToArgArray(args); node::Environment* env = node::CreateEnvironment( - context->GetIsolate(), uv_default_loop(), context, + isolate_data, context, args.size(), c_argv.get(), 0, nullptr); // Node uses the deprecated SetAutorunMicrotasks(false) mode, we should switch diff --git a/atom/common/node_bindings.h b/atom/common/node_bindings.h index 4866ba25f060..7cf310783966 100644 --- a/atom/common/node_bindings.h +++ b/atom/common/node_bindings.h @@ -16,6 +16,7 @@ class MessageLoop; namespace node { class Environment; +class IsolateData; } namespace atom { @@ -30,7 +31,8 @@ class NodeBindings { void Initialize(); // Create the environment and load node.js. - node::Environment* CreateEnvironment(v8::Handle context); + node::Environment* CreateEnvironment(node::IsolateData* isolate_data, + v8::Handle context); // Load node.js in the environment. void LoadEnvironment(node::Environment* env); diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index fdbbdf9e3687..7fa59c4f3441 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -103,8 +103,8 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver { // Wrap the bundle into a function that receives the binding object as // an argument. - std::string bundle(node::isolated_bundle_native, - node::isolated_bundle_native + sizeof(node::isolated_bundle_native)); + std::string bundle(node::isolated_bundle_data, + node::isolated_bundle_data + sizeof(node::isolated_bundle_data)); std::string wrapper = "(function (binding) {\n" + bundle + "\n})"; auto script = v8::Script::Compile( mate::ConvertToV8(isolate, wrapper)->ToString()); @@ -349,10 +349,13 @@ void AtomRendererClient::DidCreateScriptContext( if (first_time) { node_bindings_->Initialize(); node_bindings_->PrepareMessageLoop(); + isolate_data_.reset(new node::IsolateData(context->GetIsolate(), + uv_default_loop())); } // Setup node environment for each window. - node::Environment* env = node_bindings_->CreateEnvironment(context); + node::Environment* env = + node_bindings_->CreateEnvironment(isolate_data_.get(), context); // Add Electron extended APIs. atom_bindings_->BindTo(env->isolate(), env->process_object()); diff --git a/atom/renderer/atom_renderer_client.h b/atom/renderer/atom_renderer_client.h index a693262fed1b..47d241ada53a 100644 --- a/atom/renderer/atom_renderer_client.h +++ b/atom/renderer/atom_renderer_client.h @@ -10,6 +10,10 @@ #include "content/public/renderer/content_renderer_client.h" +namespace node { +class IsolateData; +} + namespace atom { class AtomBindings; @@ -69,6 +73,7 @@ class AtomRendererClient : public content::ContentRendererClient { std::unique_ptr node_bindings_; std::unique_ptr atom_bindings_; std::unique_ptr preferences_manager_; + std::unique_ptr isolate_data_; bool isolated_world_; DISALLOW_COPY_AND_ASSIGN(AtomRendererClient); diff --git a/atom/renderer/atom_sandboxed_renderer_client.cc b/atom/renderer/atom_sandboxed_renderer_client.cc index 892930cf5004..d1de0e17cd39 100644 --- a/atom/renderer/atom_sandboxed_renderer_client.cc +++ b/atom/renderer/atom_sandboxed_renderer_client.cc @@ -144,8 +144,8 @@ void AtomSandboxedRendererClient::DidCreateScriptContext( v8::Context::Scope context_scope(context); // Wrap the bundle into a function that receives the binding object and the // preload script path as arguments. - std::string preload_bundle_native(node::preload_bundle_native, - node::preload_bundle_native + sizeof(node::preload_bundle_native)); + std::string preload_bundle_native(node::preload_bundle_data, + node::preload_bundle_data + sizeof(node::preload_bundle_data)); std::stringstream ss; ss << "(function(binding, preloadPath) {\n"; ss << preload_bundle_native << "\n"; diff --git a/vendor/node b/vendor/node index 811cfe3fcd36..b1069b6dd532 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 811cfe3fcd360179d3dd436e3d80e1b045adf633 +Subproject commit b1069b6dd5321a6e5cf2f7fea68a85ac4a2df24b