@@ -209,7 +209,8 @@ MaybeLocal<Context> ContextifyContext::CreateV8Context(
209
209
return MaybeLocal<Context>();
210
210
}
211
211
212
- ctx->SetSecurityToken (env->context ()->GetSecurityToken ());
212
+ Local<Context> context = env->context ();
213
+ ctx->SetSecurityToken (context->GetSecurityToken ());
213
214
214
215
// We need to tie the lifetime of the sandbox object with the lifetime of
215
216
// newly created context. We do this by making them hold references to each
@@ -218,7 +219,7 @@ MaybeLocal<Context> ContextifyContext::CreateV8Context(
218
219
// directly in an Object, we instead hold onto the new context's global
219
220
// object instead (which then has a reference to the context).
220
221
ctx->SetEmbedderData (ContextEmbedderIndex::kSandboxObject , sandbox_obj);
221
- sandbox_obj->SetPrivate (env-> context () ,
222
+ sandbox_obj->SetPrivate (context,
222
223
env->contextify_global_private_symbol (),
223
224
ctx->Global ());
224
225
@@ -393,16 +394,17 @@ void ContextifyContext::PropertySetterCallback(
393
394
if (ctx->context_ .IsEmpty ())
394
395
return ;
395
396
397
+ Local<Context> context = ctx->context ();
396
398
auto attributes = PropertyAttribute::None;
397
399
bool is_declared_on_global_proxy = ctx->global_proxy ()
398
- ->GetRealNamedPropertyAttributes (ctx-> context () , property)
400
+ ->GetRealNamedPropertyAttributes (context, property)
399
401
.To (&attributes);
400
402
bool read_only =
401
403
static_cast <int >(attributes) &
402
404
static_cast <int >(PropertyAttribute::ReadOnly);
403
405
404
406
bool is_declared_on_sandbox = ctx->sandbox ()
405
- ->GetRealNamedPropertyAttributes (ctx-> context () , property)
407
+ ->GetRealNamedPropertyAttributes (context, property)
406
408
.To (&attributes);
407
409
read_only = read_only ||
408
410
(static_cast <int >(attributes) &
@@ -440,7 +442,7 @@ void ContextifyContext::PropertySetterCallback(
440
442
args.GetReturnValue ().Set (false );
441
443
}
442
444
443
- USE (ctx->sandbox ()->Set (ctx-> context () , property, value));
445
+ USE (ctx->sandbox ()->Set (context, property, value));
444
446
}
445
447
446
448
// static
@@ -481,7 +483,7 @@ void ContextifyContext::PropertyDefinerCallback(
481
483
482
484
auto attributes = PropertyAttribute::None;
483
485
bool is_declared =
484
- ctx->global_proxy ()->GetRealNamedPropertyAttributes (ctx-> context () ,
486
+ ctx->global_proxy ()->GetRealNamedPropertyAttributes (context,
485
487
property)
486
488
.To (&attributes);
487
489
bool read_only =
@@ -655,8 +657,10 @@ void ContextifyScript::Init(Environment* env, Local<Object> target) {
655
657
env->SetProtoMethod (script_tmpl, " runInContext" , RunInContext);
656
658
env->SetProtoMethod (script_tmpl, " runInThisContext" , RunInThisContext);
657
659
658
- target->Set (env->context (), class_name,
659
- script_tmpl->GetFunction (env->context ()).ToLocalChecked ()).Check ();
660
+ Local<Context> context = env->context ();
661
+
662
+ target->Set (context, class_name,
663
+ script_tmpl->GetFunction (context).ToLocalChecked ()).Check ();
660
664
env->set_script_context_constructor_template (script_tmpl);
661
665
}
662
666
@@ -776,9 +780,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
776
780
}
777
781
contextify_script->script_ .Reset (isolate, v8_script.ToLocalChecked ());
778
782
783
+ Local<Context> env_context = env->context ();
779
784
if (compile_options == ScriptCompiler::kConsumeCodeCache ) {
780
785
args.This ()->Set (
781
- env-> context () ,
786
+ env_context ,
782
787
env->cached_data_rejected_string (),
783
788
Boolean::New (isolate, source.GetCachedData ()->rejected )).Check ();
784
789
} else if (produce_cached_data) {
@@ -790,12 +795,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
790
795
env,
791
796
reinterpret_cast <const char *>(cached_data->data ),
792
797
cached_data->length );
793
- args.This ()->Set (env-> context () ,
798
+ args.This ()->Set (env_context ,
794
799
env->cached_data_string (),
795
800
buf.ToLocalChecked ()).Check ();
796
801
}
797
802
args.This ()->Set (
798
- env-> context () ,
803
+ env_context ,
799
804
env->cached_data_produced_string (),
800
805
Boolean::New (isolate, cached_data_produced)).Check ();
801
806
}
@@ -885,7 +890,8 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) {
885
890
ContextifyContext::ContextFromContextifiedSandbox (env, sandbox);
886
891
CHECK_NOT_NULL (contextify_context);
887
892
888
- if (contextify_context->context ().IsEmpty ())
893
+ Local<Context> context = contextify_context->context ();
894
+ if (context.IsEmpty ())
889
895
return ;
890
896
891
897
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0 (
@@ -904,7 +910,7 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) {
904
910
bool break_on_first_line = args[4 ]->IsTrue ();
905
911
906
912
// Do the eval within the context
907
- Context::Scope context_scope (contextify_context-> context () );
913
+ Context::Scope context_scope (context);
908
914
EvalMachine (contextify_context->env (),
909
915
timeout,
910
916
display_errors,
0 commit comments