From 600048b1b767a6b34c78d2c8d3339cdb674e94d6 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sun, 21 Apr 2019 22:15:07 +0800 Subject: [PATCH] src: move Environment::context out of strong properties Rename `ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES` to `ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES`, and move `context` out of the list, so that the data can be iterated separately. PR-URL: https://github.com/nodejs/node/pull/27430 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis Reviewed-By: Refael Ackermann --- src/env-inl.h | 5 ++++- src/env.h | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) 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