Skip to content

Commit d4abca5

Browse files
Fishrock123Myles Borins
authored and
Myles Borins
committed
lib: remove bootstrap global context indirection
PR-URL: #5881 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Conflicts: lib/internal/bootstrap_node.js src/node.cc
1 parent 61167c3 commit d4abca5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/internal/bootstrap_node.js

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
'use strict';
99

1010
(function(process) {
11-
this.global = this;
1211

1312
function startup() {
1413
var EventEmitter = NativeModule.require('events');
@@ -200,7 +199,6 @@
200199

201200
function setupGlobalVariables() {
202201
global.process = process;
203-
global.global = global;
204202
global.GLOBAL = global;
205203
global.root = global;
206204
global.Buffer = NativeModule.require('buffer').Buffer;

src/node.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ using v8::Local;
117117
using v8::Locker;
118118
using v8::MaybeLocal;
119119
using v8::Message;
120+
using v8::Null;
120121
using v8::Number;
121122
using v8::Object;
122123
using v8::ObjectTemplate;
@@ -3257,8 +3258,12 @@ void LoadEnvironment(Environment* env) {
32573258

32583259
env->SetMethod(env->process_object(), "_rawDebug", RawDebug);
32593260

3261+
// Expose the global object as a property on itself
3262+
// (Allows you to set stuff on `global` from anywhere in JavaScript.)
3263+
global->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "global"), global);
3264+
32603265
Local<Value> arg = env->process_object();
3261-
f->Call(global, 1, &arg);
3266+
f->Call(Null(env->isolate()), 1, &arg);
32623267
}
32633268

32643269
static void PrintHelp();

0 commit comments

Comments
 (0)