Merge pull request #4927 from atom/node-5.9.1

Upgrade to Node v5.9.1
This commit is contained in:
Cheng Zhao 2016-03-27 21:35:20 +09:00
commit 4ebd24d128
9 changed files with 43 additions and 57 deletions

View file

@ -106,17 +106,21 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
node_debugger_.reset(new NodeDebugger(js_env_->isolate()));
// Create the global environment.
global_env = node_bindings_->CreateEnvironment(js_env_->context());
node::Environment* env =
node_bindings_->CreateEnvironment(js_env_->context());
// Make sure node can get correct environment when debugging.
if (node_debugger_->IsRunning())
global_env->AssignToContext(v8::Debug::GetDebugContext());
env->AssignToContext(v8::Debug::GetDebugContext());
// Add atom-shell extended APIs.
atom_bindings_->BindTo(js_env_->isolate(), global_env->process_object());
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
// Load everything.
node_bindings_->LoadEnvironment(global_env);
node_bindings_->LoadEnvironment(env);
// Wrap the uv loop with global env.
node_bindings_->set_uv_env(env);
}
void AtomBrowserMainParts::PreMainMessageLoopRun() {

View file

@ -129,9 +129,11 @@ void InitAsarSupport(v8::Isolate* isolate,
v8::Local<v8::Value> process,
v8::Local<v8::Value> require) {
// Evaluate asar_init.coffee.
const char* asar_init_native = reinterpret_cast<const char*>(
static_cast<const unsigned char*>(node::asar_init_native));
v8::Local<v8::Script> asar_init = v8::Script::Compile(v8::String::NewFromUtf8(
isolate,
node::asar_init_native,
asar_init_native,
v8::String::kNormalString,
sizeof(node::asar_init_native) -1));
v8::Local<v8::Value> result = asar_init->Run();
@ -141,9 +143,11 @@ void InitAsarSupport(v8::Isolate* isolate,
v8::Local<v8::Value>,
std::string)> init;
if (mate::ConvertFromV8(isolate, result, &init)) {
const char* asar_native = reinterpret_cast<const char*>(
static_cast<const unsigned char*>(node::asar_native));
init.Run(process,
require,
std::string(node::asar_native, sizeof(node::asar_native) - 1));
std::string(asar_native, sizeof(node::asar_native) - 1));
}
}

View file

@ -98,24 +98,8 @@ void AtomBindings::OnCallNextTick(uv_async_t* handle) {
self->pending_next_ticks_.begin();
it != self->pending_next_ticks_.end(); ++it) {
node::Environment* env = *it;
node::Environment::TickInfo* tick_info = env->tick_info();
v8::Context::Scope context_scope(env->context());
if (tick_info->in_tick())
continue;
if (tick_info->length() == 0) {
env->isolate()->RunMicrotasks();
}
if (tick_info->length() == 0) {
tick_info->set_index(0);
continue;
}
tick_info->set_in_tick(true);
env->tick_callback_function()->Call(env->process_object(), 0, NULL);
tick_info->set_in_tick(false);
node::Environment::AsyncCallbackScope callback_scope(env);
env->KickNextTick(&callback_scope);
}
self->pending_next_ticks_.clear();

View file

@ -106,8 +106,6 @@ base::FilePath GetResourcesPath(bool is_browser) {
} // namespace
node::Environment* global_env = nullptr;
NodeBindings::NodeBindings(bool is_browser)
: is_browser_(is_browser),
message_loop_(nullptr),
@ -214,10 +212,8 @@ void NodeBindings::RunMessageLoop() {
void NodeBindings::UvRunOnce() {
DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));
// By default the global env would be used unless user specified another one
// (this happens for renderer process, which wraps the uv loop with web page
// context).
node::Environment* env = uv_env() ? uv_env() : global_env;
node::Environment* env = uv_env();
CHECK(env);
// Use Locker in browser process.
mate::Locker locker(env->isolate());

View file

@ -28,11 +28,4 @@
#include "vendor/node/src/node_buffer.h"
#include "vendor/node/src/node_internals.h"
namespace atom {
// Defined in node_bindings.cc.
// For renderer it's created in atom_renderer_client.cc.
// For browser it's created in atom_browser_main_parts.cc.
extern node::Environment* global_env;
}
#endif // ATOM_COMMON_NODE_INCLUDES_H_

View file

@ -90,18 +90,6 @@ void AtomRendererClient::WebKitInitialized() {
blink::WebCustomElement::addEmbedderCustomElementName("browserplugin");
OverrideNodeArrayBuffer();
node_bindings_->Initialize();
node_bindings_->PrepareMessageLoop();
DCHECK(!global_env);
// Create a default empty environment which would be used when we need to
// run V8 code out of a window context (like running a uv callback).
v8::Isolate* isolate = blink::mainThreadIsolate();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
global_env = node::Environment::New(context, uv_default_loop());
}
void AtomRendererClient::RenderThreadStarted() {
@ -160,8 +148,14 @@ bool AtomRendererClient::OverrideCreatePlugin(
void AtomRendererClient::DidCreateScriptContext(
v8::Handle<v8::Context> context) {
// Give the node loop a run to make sure everything is ready.
node_bindings_->RunMessageLoop();
// Whether the node binding has been initialized.
bool first_time = node_bindings_->uv_env() == nullptr;
// Prepare the node bindings.
if (first_time) {
node_bindings_->Initialize();
node_bindings_->PrepareMessageLoop();
}
// Setup node environment for each window.
node::Environment* env = node_bindings_->CreateEnvironment(context);
@ -169,12 +163,16 @@ void AtomRendererClient::DidCreateScriptContext(
// Add atom-shell extended APIs.
atom_bindings_->BindTo(env->isolate(), env->process_object());
// Make uv loop being wrapped by window context.
if (node_bindings_->uv_env() == nullptr)
node_bindings_->set_uv_env(env);
// Load everything.
node_bindings_->LoadEnvironment(env);
if (first_time) {
// Make uv loop being wrapped by window context.
node_bindings_->set_uv_env(env);
// Give the node loop a run to make sure everything is ready.
node_bindings_->RunMessageLoop();
}
}
void AtomRendererClient::WillReleaseScriptContext(

View file

@ -230,6 +230,7 @@
'msvs_cygwin_shell': 0, # Strangely setting it to 1 would make building under cygwin fail.
'msvs_disabled_warnings': [
4005, # (node.h) macro redefinition
4091, # (node_extern.h) '__declspec(dllimport)' : ignored on left of 'node::Environment' when no variable is declared
4189, # local variable is initialized but not referenced
4201, # (uv.h) nameless struct/union
4267, # conversion from 'size_t' to 'int', possible loss of data

View file

@ -9,6 +9,12 @@
// Make graceful-fs work with asar.
var source = process.binding('natives');
source['original-fs'] = source.fs;
return source['fs'] = "var src = '(function (exports, require, module, __filename, __dirname) { ' +\n process.binding('natives')['original-fs'] +\n ' });';\nvar vm = require('vm');\nvar fn = vm.runInThisContext(src, { filename: 'fs.js' });\nfn(exports, require, module);\nvar asar = require('ATOM_SHELL_ASAR');\nasar.wrapFsWithAsar(exports);";
return source['fs'] = `
var nativeModule = new process.NativeModule('original-fs');
nativeModule.cache();
nativeModule.compile();
var asar = require('ATOM_SHELL_ASAR');
asar.wrapFsWithAsar(nativeModule.exports);
module.exports = nativeModule.exports`;
};
})();

2
vendor/node vendored

@ -1 +1 @@
Subproject commit a507a3c3816d6ac085ed46250c489a3d76ab8b3c
Subproject commit d8e7d3e76cb3c6e709449d181ddc2af8c4859303