From d4abca5b271d80ccf88c3d6428c36aaf2bc69dea Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Wed, 23 Mar 2016 18:09:10 -0400 Subject: [PATCH] lib: remove bootstrap global context indirection PR-URL: https://github.com/nodejs/node/pull/5881 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Conflicts: lib/internal/bootstrap_node.js src/node.cc --- lib/internal/bootstrap_node.js | 2 -- src/node.cc | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index 3edfed94548d23..c3cb24d3485e53 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -8,7 +8,6 @@ 'use strict'; (function(process) { - this.global = this; function startup() { var EventEmitter = NativeModule.require('events'); @@ -200,7 +199,6 @@ function setupGlobalVariables() { global.process = process; - global.global = global; global.GLOBAL = global; global.root = global; global.Buffer = NativeModule.require('buffer').Buffer; diff --git a/src/node.cc b/src/node.cc index e5a62c6bc37035..42e24a718c5475 100644 --- a/src/node.cc +++ b/src/node.cc @@ -117,6 +117,7 @@ using v8::Local; using v8::Locker; using v8::MaybeLocal; using v8::Message; +using v8::Null; using v8::Number; using v8::Object; using v8::ObjectTemplate; @@ -3257,8 +3258,12 @@ void LoadEnvironment(Environment* env) { env->SetMethod(env->process_object(), "_rawDebug", RawDebug); + // Expose the global object as a property on itself + // (Allows you to set stuff on `global` from anywhere in JavaScript.) + global->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "global"), global); + Local arg = env->process_object(); - f->Call(global, 1, &arg); + f->Call(Null(env->isolate()), 1, &arg); } static void PrintHelp();