@@ -56,9 +56,11 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
56
56
return ;
57
57
}
58
58
59
- HandleScope handle_scope (env->isolate ());
59
+ Isolate* isolate = env->isolate ();
60
+
61
+ HandleScope handle_scope (isolate);
60
62
// If you hit this assertion, you forgot to enter the v8::Context first.
61
- CHECK_EQ (Environment::GetCurrent (env-> isolate () ), env);
63
+ CHECK_EQ (Environment::GetCurrent (isolate), env);
62
64
63
65
env->isolate ()->SetIdle (false );
64
66
@@ -83,7 +85,8 @@ void InternalCallbackScope::Close() {
83
85
if (closed_) return ;
84
86
closed_ = true ;
85
87
86
- auto idle = OnScopeLeave ([&]() { env_->isolate ()->SetIdle (true ); });
88
+ Isolate* isolate = env_->isolate ();
89
+ auto idle = OnScopeLeave ([&]() { isolate->SetIdle (true ); });
87
90
88
91
if (!env_->can_call_into_js ()) return ;
89
92
auto perform_stopping_check = [&]() {
@@ -113,8 +116,9 @@ void InternalCallbackScope::Close() {
113
116
114
117
auto weakref_cleanup = OnScopeLeave ([&]() { env_->RunWeakRefCleanup (); });
115
118
119
+ Local<Context> context = env_->context ();
116
120
if (!tick_info->has_tick_scheduled ()) {
117
- env_-> context () ->GetMicrotaskQueue ()->PerformCheckpoint (env_-> isolate () );
121
+ context->GetMicrotaskQueue ()->PerformCheckpoint (isolate);
118
122
119
123
perform_stopping_check ();
120
124
}
@@ -130,7 +134,7 @@ void InternalCallbackScope::Close() {
130
134
return ;
131
135
}
132
136
133
- HandleScope handle_scope (env_-> isolate () );
137
+ HandleScope handle_scope (isolate);
134
138
Local<Object> process = env_->process_object ();
135
139
136
140
if (!env_->can_call_into_js ()) return ;
@@ -141,7 +145,7 @@ void InternalCallbackScope::Close() {
141
145
// to initializes the tick callback during bootstrap.
142
146
CHECK (!tick_callback.IsEmpty ());
143
147
144
- if (tick_callback->Call (env_-> context () , process, 0 , nullptr ).IsEmpty ()) {
148
+ if (tick_callback->Call (context, process, 0 , nullptr ).IsEmpty ()) {
145
149
failed_ = true ;
146
150
}
147
151
perform_stopping_check ();
@@ -181,6 +185,7 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env,
181
185
182
186
MaybeLocal<Value> ret;
183
187
188
+ Local<Context> context = env->context ();
184
189
if (use_async_hooks_trampoline) {
185
190
MaybeStackBuffer<Local<Value>, 16 > args (3 + argc);
186
191
args[0 ] = v8::Number::New (env->isolate (), asyncContext.async_id );
@@ -189,9 +194,9 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env,
189
194
for (int i = 0 ; i < argc; i++) {
190
195
args[i + 3 ] = argv[i];
191
196
}
192
- ret = hook_cb->Call (env-> context () , recv, args.length (), &args[0 ]);
197
+ ret = hook_cb->Call (context, recv, args.length (), &args[0 ]);
193
198
} else {
194
- ret = callback->Call (env-> context () , recv, argc, argv);
199
+ ret = callback->Call (context, recv, argc, argv);
195
200
}
196
201
197
202
if (ret.IsEmpty ()) {
@@ -266,7 +271,7 @@ MaybeLocal<Value> MakeCallback(Isolate* isolate,
266
271
if (ret.IsEmpty () && env->async_callback_scope_depth () == 0 ) {
267
272
// This is only for legacy compatibility and we may want to look into
268
273
// removing/adjusting it.
269
- return Undefined (env-> isolate () );
274
+ return Undefined (isolate);
270
275
}
271
276
return ret;
272
277
}
@@ -285,11 +290,12 @@ MaybeLocal<Value> MakeSyncCallback(Isolate* isolate,
285
290
CHECK_NOT_NULL (env);
286
291
if (!env->can_call_into_js ()) return Local<Value>();
287
292
288
- Context::Scope context_scope (env->context ());
293
+ Local<Context> context = env->context ();
294
+ Context::Scope context_scope (context);
289
295
if (env->async_callback_scope_depth ()) {
290
296
// There's another MakeCallback() on the stack, piggy back on it.
291
297
// In particular, retain the current async_context.
292
- return callback->Call (env-> context () , recv, argc, argv);
298
+ return callback->Call (context, recv, argc, argv);
293
299
}
294
300
295
301
// This is a toplevel invocation and the caller (intentionally)
0 commit comments