Skip to content

Commit 976e5a5

Browse files
committed
src: per-isolate eternal templates
1 parent a8f6c56 commit 976e5a5

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/env-inl.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -891,14 +891,23 @@ void Environment::set_process_exit_handler(
891891
#undef VY
892892
#undef VP
893893

894-
#define V(PropertyName, TypeName) \
895-
inline v8::Local<TypeName> Environment::PropertyName() const { \
896-
return PersistentToLocal::Strong(PropertyName ## _); \
897-
} \
898-
inline void Environment::set_ ## PropertyName(v8::Local<TypeName> value) { \
899-
PropertyName ## _.Reset(isolate(), value); \
894+
#define V(PropertyName, TypeName) \
895+
inline v8::Local<TypeName> Environment::PropertyName() const { \
896+
return PropertyName##_.Get(isolate_); \
897+
} \
898+
inline void Environment::set_##PropertyName(v8::Local<TypeName> value) { \
899+
PropertyName##_.Set(isolate(), value); \
900+
}
901+
PER_ISOLATE_TEMPLATES(V)
902+
#undef V
903+
904+
#define V(PropertyName, TypeName) \
905+
inline v8::Local<TypeName> Environment::PropertyName() const { \
906+
return PersistentToLocal::Strong(PropertyName##_); \
907+
} \
908+
inline void Environment::set_##PropertyName(v8::Local<TypeName> value) { \
909+
PropertyName##_.Reset(isolate(), value); \
900910
}
901-
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
902911
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
903912
#undef V
904913

src/env.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,7 +1760,7 @@ EnvSerializeInfo Environment::Serialize(SnapshotCreator* creator) {
17601760
} \
17611761
id++; \
17621762
} while (0);
1763-
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
1763+
PER_ISOLATE_TEMPLATES(V)
17641764
#undef V
17651765

17661766
id = 0;
@@ -1894,7 +1894,7 @@ void Environment::DeserializeProperties(const EnvSerializeInfo* info) {
18941894
id++;
18951895
#define V(PropertyName, TypeName) SetProperty(PropertyName, TypeName, \
18961896
templates, template, isolate_)
1897-
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V);
1897+
PER_ISOLATE_TEMPLATES(V);
18981898
#undef V
18991899

19001900
i = 0; // index to the array

src/env.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ class NoArrayBufferZeroFillScope {
469469
V(x_forwarded_string, "x-forwarded-for") \
470470
V(zero_return_string, "ZERO_RETURN")
471471

472-
#define ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) \
472+
#define PER_ISOLATE_TEMPLATES(V) \
473473
V(async_wrap_ctor_template, v8::FunctionTemplate) \
474474
V(async_wrap_object_ctor_template, v8::FunctionTemplate) \
475475
V(base_object_ctor_template, v8::FunctionTemplate) \
@@ -1357,8 +1357,8 @@ class Environment : public MemoryRetainer {
13571357
#define V(PropertyName, TypeName) \
13581358
inline v8::Local<TypeName> PropertyName() const; \
13591359
inline void set_ ## PropertyName(v8::Local<TypeName> value);
1360+
PER_ISOLATE_TEMPLATES(V)
13601361
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1361-
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
13621362
#undef V
13631363

13641364
inline v8::Local<v8::Context> context() const;
@@ -1649,9 +1649,11 @@ class Environment : public MemoryRetainer {
16491649
template <typename T>
16501650
void ForEachBaseObject(T&& iterator);
16511651

1652+
#define V(PropertyName, TypeName) v8::Eternal<TypeName> PropertyName##_;
1653+
PER_ISOLATE_TEMPLATES(V)
1654+
#undef V
16521655
#define V(PropertyName, TypeName) v8::Global<TypeName> PropertyName ## _;
16531656
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1654-
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
16551657
#undef V
16561658

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

0 commit comments

Comments
 (0)