Skip to content

Commit 21d66d6

Browse files
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]>
1 parent ea47cc4 commit 21d66d6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/internal/bootstrap_node.js

Lines changed: 0 additions & 2 deletions
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');
@@ -211,7 +210,6 @@
211210

212211
function setupGlobalVariables() {
213212
global.process = process;
214-
global.global = global;
215213
const util = NativeModule.require('util');
216214

217215
// Deprecate GLOBAL and root

src/node.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ using v8::Locker;
118118
using v8::MaybeLocal;
119119
using v8::Message;
120120
using v8::Name;
121+
using v8::Null;
121122
using v8::Number;
122123
using v8::Object;
123124
using v8::ObjectTemplate;
@@ -3321,8 +3322,12 @@ void LoadEnvironment(Environment* env) {
33213322

33223323
env->SetMethod(env->process_object(), "_rawDebug", RawDebug);
33233324

3325+
// Expose the global object as a property on itself
3326+
// (Allows you to set stuff on `global` from anywhere in JavaScript.)
3327+
global->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "global"), global);
3328+
33243329
Local<Value> arg = env->process_object();
3325-
f->Call(global, 1, &arg);
3330+
f->Call(Null(env->isolate()), ARRAY_SIZE(&arg), &arg);
33263331
}
33273332

33283333
static void PrintHelp();

0 commit comments

Comments
 (0)