src: create per isolate proxy env template

PR-URL: https://github.com/nodejs/node/pull/48655
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
legendecas authored and Michaël Zasso committed 2023-11-23 10:15:43 +01:00
1 parent 91aa9dd23a
commit aadff07e59
4 files changed
+7 -4

No files matched your search

+1
View File
@@ -501,6 +501,7 @@ void IsolateData::CreateProperties() {
binding::CreateInternalBindingTemplates(this);
contextify::ContextifyContext::InitializeGlobalTemplates(this);
CreateEnvProxyTemplate(this);
}
constexpr uint16_t kDefaultCppGCEmebdderID = 0x90de;
+2 -1
View File
@@ -456,7 +456,8 @@ static void EnvDefiner(Local<Name> property,
}
}
void CreateEnvProxyTemplate(Isolate* isolate, IsolateData* isolate_data) {
void CreateEnvProxyTemplate(IsolateData* isolate_data) {
Isolate* isolate = isolate_data->isolate();
HandleScope scope(isolate);
if (!isolate_data->env_proxy_template().IsEmpty()) return;
Local<FunctionTemplate> env_proxy_ctor_template =
+1 -1
View File
@@ -15,7 +15,7 @@ class MemoryTracker;
class ExternalReferenceRegistry;
class Realm;
void CreateEnvProxyTemplate(v8::Isolate* isolate, IsolateData* isolate_data);
void CreateEnvProxyTemplate(IsolateData* isolate_data);
// Most of the time, it's best to use `console.error` to write
// to the process.stderr stream. However, in some cases, such as
+3 -2
View File
@@ -344,10 +344,11 @@ MaybeLocal<Value> PrincipalRealm::BootstrapRealm() {
return MaybeLocal<Value>();
}
// Setup process.env proxy.
Local<String> env_string = FIXED_ONE_BYTE_STRING(isolate_, "env");
Local<Object> env_proxy;
CreateEnvProxyTemplate(isolate_, env_->isolate_data());
if (!env_->env_proxy_template()->NewInstance(context()).ToLocal(&env_proxy) ||
if (!isolate_data()->env_proxy_template()->NewInstance(context()).ToLocal(
&env_proxy) ||
process_object()->Set(context(), env_string, env_proxy).IsNothing()) {
return MaybeLocal<Value>();
}