Skip to content

Commit 88ee01d

Browse files
committed
src: per-isolate eternal templates
1 parent 57d6228 commit 88ee01d

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/env-inl.h

+16-7
Original file line numberDiff line numberDiff line change
@@ -1280,14 +1280,23 @@ void Environment::set_process_exit_handler(
12801280
#undef VY
12811281
#undef VP
12821282

1283-
#define V(PropertyName, TypeName) \
1284-
inline v8::Local<TypeName> Environment::PropertyName() const { \
1285-
return PersistentToLocal::Strong(PropertyName ## _); \
1286-
} \
1287-
inline void Environment::set_ ## PropertyName(v8::Local<TypeName> value) { \
1288-
PropertyName ## _.Reset(isolate(), value); \
1283+
#define V(PropertyName, TypeName) \
1284+
inline v8::Local<TypeName> Environment::PropertyName() const { \
1285+
return PropertyName##_.Get(isolate_); \
1286+
} \
1287+
inline void Environment::set_##PropertyName(v8::Local<TypeName> value) { \
1288+
PropertyName##_.Set(isolate(), value); \
1289+
}
1290+
PER_ISOLATE_TEMPLATES(V)
1291+
#undef V
1292+
1293+
#define V(PropertyName, TypeName) \
1294+
inline v8::Local<TypeName> Environment::PropertyName() const { \
1295+
return PersistentToLocal::Strong(PropertyName##_); \
1296+
} \
1297+
inline void Environment::set_##PropertyName(v8::Local<TypeName> value) { \
1298+
PropertyName##_.Reset(isolate(), value); \
12891299
}
1290-
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
12911300
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
12921301
#undef V
12931302

src/env.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ EnvSerializeInfo Environment::Serialize(SnapshotCreator* creator) {
13691369
} \
13701370
id++; \
13711371
} while (0);
1372-
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
1372+
PER_ISOLATE_TEMPLATES(V)
13731373
#undef V
13741374

13751375
id = 0;
@@ -1503,7 +1503,7 @@ void Environment::DeserializeProperties(const EnvSerializeInfo* info) {
15031503
id++;
15041504
#define V(PropertyName, TypeName) SetProperty(PropertyName, TypeName, \
15051505
templates, template, isolate_)
1506-
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V);
1506+
PER_ISOLATE_TEMPLATES(V);
15071507
#undef V
15081508

15091509
i = 0; // index to the array

src/env.h

+5-3
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) \
@@ -1359,8 +1359,8 @@ class Environment : public MemoryRetainer {
13591359
#define V(PropertyName, TypeName) \
13601360
inline v8::Local<TypeName> PropertyName() const; \
13611361
inline void set_ ## PropertyName(v8::Local<TypeName> value);
1362+
PER_ISOLATE_TEMPLATES(V)
13621363
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1363-
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
13641364
#undef V
13651365

13661366
inline v8::Local<v8::Context> context() const;
@@ -1652,9 +1652,11 @@ class Environment : public MemoryRetainer {
16521652
template <typename T>
16531653
void ForEachBaseObject(T&& iterator);
16541654

1655+
#define V(PropertyName, TypeName) v8::Eternal<TypeName> PropertyName##_;
1656+
PER_ISOLATE_TEMPLATES(V)
1657+
#undef V
16551658
#define V(PropertyName, TypeName) v8::Global<TypeName> PropertyName ## _;
16561659
ENVIRONMENT_STRONG_PERSISTENT_VALUES(V)
1657-
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V)
16581660
#undef V
16591661

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

0 commit comments

Comments
 (0)