Skip to content

Commit 600048b

Browse files
joyeecheungtargos
authored andcommitted
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: #27430 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent df4246e commit 600048b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/env-inl.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1106,10 +1106,13 @@ void AsyncRequest::set_stopped(bool flag) {
11061106
inline void Environment::set_ ## PropertyName(v8::Local<TypeName> value) { \
11071107
PropertyName ## _.Reset(isolate(), value); \
11081108
}
1109-
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
1109+
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
11101110
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
11111111
#undef V
11121112

1113+
inline v8::Local<v8::Context> Environment::context() const {
1114+
return PersistentToLocal::Strong(context_);
1115+
}
11131116
} // namespace node
11141117

11151118
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

src/env.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,10 @@ constexpr size_t kFsStatsBufferLength = kFsStatsFieldsNumber * 2;
340340
V(x_forwarded_string, "x-forwarded-for") \
341341
V(zero_return_string, "ZERO_RETURN")
342342

343-
#define ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) \
343+
#define ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) \
344344
V(as_callback_data_template, v8::FunctionTemplate) \
345345
V(async_wrap_ctor_template, v8::FunctionTemplate) \
346346
V(async_wrap_object_ctor_template, v8::FunctionTemplate) \
347-
V(context, v8::Context) \
348347
V(fd_constructor_template, v8::ObjectTemplate) \
349348
V(fdclose_constructor_template, v8::ObjectTemplate) \
350349
V(filehandlereadwrap_template, v8::ObjectTemplate) \
@@ -1061,9 +1060,11 @@ class Environment : public MemoryRetainer {
10611060
inline v8::Local<TypeName> PropertyName() const; \
10621061
inline void set_ ## PropertyName(v8::Local<TypeName> value);
10631062
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1064-
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
1063+
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
10651064
#undef V
10661065

1066+
inline v8::Local<v8::Context> context() const;
1067+
10671068
#if HAVE_INSPECTOR
10681069
inline inspector::Agent* inspector_agent() const {
10691070
return inspector_agent_.get();
@@ -1294,8 +1295,10 @@ class Environment : public MemoryRetainer {
12941295

12951296
#define V(PropertyName, TypeName) v8::Global<TypeName> PropertyName ## _;
12961297
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1297-
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
1298+
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
12981299
#undef V
1300+
1301+
v8::Global<v8::Context> context_;
12991302
};
13001303

13011304
} // namespace node

0 commit comments

Comments
 (0)