From cc8df6b8fca5fb99161d45409b179302e1b3f114 Mon Sep 17 00:00:00 2001 From: Mert Can Altin Date: Sat, 17 Jan 2026 18:47:50 +0300 Subject: [PATCH] src: cache context lookup in vectored io loops --- src/env-inl.h | 2 +- src/env.h | 2 +- src/node_realm-inl.h | 5 +++++ src/node_realm.cc | 4 ---- src/node_realm.h | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index b6a85ce214e0ac..761a7bfc995528 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -897,7 +897,7 @@ v8::Local Environment::context() const { return principal_realm()->context(); } -Realm* Environment::principal_realm() const { +PrincipalRealm* Environment::principal_realm() const { return principal_realm_.get(); } diff --git a/src/env.h b/src/env.h index 6098541a9c70a1..5fabc366c6e68b 100644 --- a/src/env.h +++ b/src/env.h @@ -886,7 +886,7 @@ class Environment final : public MemoryRetainer { // Get the context with an explicit realm instead when possible. // Deprecate soon. inline v8::Local context() const; - inline Realm* principal_realm() const; + inline PrincipalRealm* principal_realm() const; #if HAVE_INSPECTOR inline inspector::Agent* inspector_agent() const { diff --git a/src/node_realm-inl.h b/src/node_realm-inl.h index 9d0510f42d5c0c..b004bd1e150020 100644 --- a/src/node_realm-inl.h +++ b/src/node_realm-inl.h @@ -5,6 +5,7 @@ #include "node_context_data.h" #include "node_realm.h" +#include "util-inl.h" namespace node { @@ -46,6 +47,10 @@ inline v8::Isolate* Realm::isolate() const { return isolate_; } +inline v8::Local Realm::context() const { + return PersistentToLocal::Strong(context_); +} + inline Realm::Kind Realm::kind() const { return kind_; } diff --git a/src/node_realm.cc b/src/node_realm.cc index 3674235a4e34da..d2459d4eeb3373 100644 --- a/src/node_realm.cc +++ b/src/node_realm.cc @@ -295,10 +295,6 @@ void Realm::VerifyNoStrongBaseObjects() { }); } -v8::Local Realm::context() const { - return PersistentToLocal::Strong(context_); -} - // Per-realm strong value accessors. The per-realm values should avoid being // accessed across realms. #define V(PropertyName, TypeName) \ diff --git a/src/node_realm.h b/src/node_realm.h index 63a23013cb1f63..2ed04aa271b4c4 100644 --- a/src/node_realm.h +++ b/src/node_realm.h @@ -121,7 +121,7 @@ class Realm : public MemoryRetainer { inline Environment* env() const; inline v8::Isolate* isolate() const; inline Kind kind() const; - virtual v8::Local context() const; + inline virtual v8::Local context() const; inline bool has_run_bootstrapping_code() const; // Methods created using SetMethod(), SetPrototypeMethod(), etc. inside