Skip to content

Commit

Permalink
src: move Environment::context out of strong properties
Browse files Browse the repository at this point in the history
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: #27430
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information
joyeecheung authored and targos committed May 4, 2019
1 parent df4246e commit 600048b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1106,10 +1106,13 @@ void AsyncRequest::set_stopped(bool flag) {
inline void Environment::set_ ## PropertyName(v8::Local<TypeName> 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<v8::Context> Environment::context() const {
return PersistentToLocal::Strong(context_);
}
} // namespace node

#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
Expand Down
11 changes: 7 additions & 4 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -1061,9 +1060,11 @@ class Environment : public MemoryRetainer {
inline v8::Local<TypeName> PropertyName() const; \
inline void set_ ## PropertyName(v8::Local<TypeName> value);
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
#undef V

inline v8::Local<v8::Context> context() const;

#if HAVE_INSPECTOR
inline inspector::Agent* inspector_agent() const {
return inspector_agent_.get();
Expand Down Expand Up @@ -1294,8 +1295,10 @@ class Environment : public MemoryRetainer {

#define V(PropertyName, TypeName) v8::Global<TypeName> PropertyName ## _;
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
#undef V

v8::Global<v8::Context> context_;
};

} // namespace node
Expand Down

0 comments on commit 600048b

Please sign in to comment.