diff --git a/src/env-inl.h b/src/env-inl.h index 36f8506bafb5a7..9e10cb24146c1a 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -1106,10 +1106,13 @@ void AsyncRequest::set_stopped(bool flag) { inline void Environment::set_ ## PropertyName(v8::Local value) { \ PropertyName ## _.Reset(isolate(), value); \ } - ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) + ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) #undef V + inline v8::Local Environment::context() const { + return PersistentToLocal::Strong(context_); + } } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/env.h b/src/env.h index 56abe129abf45e..c9dcdcea6b7d40 100644 --- a/src/env.h +++ b/src/env.h @@ -340,11 +340,10 @@ constexpr size_t kFsStatsBufferLength = kFsStatsFieldsNumber * 2; V(x_forwarded_string, "x-forwarded-for") \ V(zero_return_string, "ZERO_RETURN") -#define ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) \ +#define ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) \ V(as_callback_data_template, v8::FunctionTemplate) \ V(async_wrap_ctor_template, v8::FunctionTemplate) \ V(async_wrap_object_ctor_template, v8::FunctionTemplate) \ - V(context, v8::Context) \ V(fd_constructor_template, v8::ObjectTemplate) \ V(fdclose_constructor_template, v8::ObjectTemplate) \ V(filehandlereadwrap_template, v8::ObjectTemplate) \ @@ -1061,9 +1060,11 @@ class Environment : public MemoryRetainer { inline v8::Local PropertyName() const; \ inline void set_ ## PropertyName(v8::Local value); ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) - ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) + ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) #undef V + inline v8::Local context() const; + #if HAVE_INSPECTOR inline inspector::Agent* inspector_agent() const { return inspector_agent_.get(); @@ -1294,8 +1295,10 @@ class Environment : public MemoryRetainer { #define V(PropertyName, TypeName) v8::Global PropertyName ## _; ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) - ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) + ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) #undef V + + v8::Global context_; }; } // namespace node