From 88ee01db8dace8d7f48201a9066b846c46ea662c Mon Sep 17 00:00:00 2001 From: legendecas Date: Tue, 12 Jul 2022 23:34:10 +0800 Subject: [PATCH] src: per-isolate eternal templates --- src/env-inl.h | 23 ++++++++++++++++------- src/env.cc | 4 ++-- src/env.h | 8 +++++--- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index fdc4f1f7ba4c169..99dc445ee01121f 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -1280,14 +1280,23 @@ void Environment::set_process_exit_handler( #undef VY #undef VP -#define V(PropertyName, TypeName) \ - inline v8::Local Environment::PropertyName() const { \ - return PersistentToLocal::Strong(PropertyName ## _); \ - } \ - inline void Environment::set_ ## PropertyName(v8::Local value) { \ - PropertyName ## _.Reset(isolate(), value); \ +#define V(PropertyName, TypeName) \ + inline v8::Local Environment::PropertyName() const { \ + return PropertyName##_.Get(isolate_); \ + } \ + inline void Environment::set_##PropertyName(v8::Local value) { \ + PropertyName##_.Set(isolate(), value); \ + } + PER_ISOLATE_TEMPLATES(V) +#undef V + +#define V(PropertyName, TypeName) \ + inline v8::Local Environment::PropertyName() const { \ + return PersistentToLocal::Strong(PropertyName##_); \ + } \ + inline void Environment::set_##PropertyName(v8::Local value) { \ + PropertyName##_.Reset(isolate(), value); \ } - ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) #undef V diff --git a/src/env.cc b/src/env.cc index 65467587ffcdd84..7d0064eb2fa83f8 100644 --- a/src/env.cc +++ b/src/env.cc @@ -1369,7 +1369,7 @@ EnvSerializeInfo Environment::Serialize(SnapshotCreator* creator) { } \ id++; \ } while (0); - ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) + PER_ISOLATE_TEMPLATES(V) #undef V id = 0; @@ -1503,7 +1503,7 @@ void Environment::DeserializeProperties(const EnvSerializeInfo* info) { id++; #define V(PropertyName, TypeName) SetProperty(PropertyName, TypeName, \ templates, template, isolate_) - ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V); + PER_ISOLATE_TEMPLATES(V); #undef V i = 0; // index to the array diff --git a/src/env.h b/src/env.h index 52bfaa3db8d46c8..64183e0df47516e 100644 --- a/src/env.h +++ b/src/env.h @@ -469,7 +469,7 @@ class NoArrayBufferZeroFillScope { V(x_forwarded_string, "x-forwarded-for") \ V(zero_return_string, "ZERO_RETURN") -#define ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) \ +#define PER_ISOLATE_TEMPLATES(V) \ V(async_wrap_ctor_template, v8::FunctionTemplate) \ V(async_wrap_object_ctor_template, v8::FunctionTemplate) \ V(base_object_ctor_template, v8::FunctionTemplate) \ @@ -1359,8 +1359,8 @@ class Environment : public MemoryRetainer { #define V(PropertyName, TypeName) \ inline v8::Local PropertyName() const; \ inline void set_ ## PropertyName(v8::Local value); + PER_ISOLATE_TEMPLATES(V) ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) - ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) #undef V inline v8::Local context() const; @@ -1652,9 +1652,11 @@ class Environment : public MemoryRetainer { template void ForEachBaseObject(T&& iterator); +#define V(PropertyName, TypeName) v8::Eternal PropertyName##_; + PER_ISOLATE_TEMPLATES(V) +#undef V #define V(PropertyName, TypeName) v8::Global PropertyName ## _; ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) - ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES(V) #undef V v8::Global context_;