We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9859f98 commit 8fb76caCopy full SHA for 8fb76ca
1 file changed
test-app/runtime/src/main/cpp/Runtime.cpp
@@ -170,7 +170,18 @@ Runtime* Runtime::GetRuntime(int runtimeId) {
170
}
171
172
Runtime* Runtime::GetRuntime(v8::Isolate* isolate) {
173
- Runtime* runtime = nullptr;
+ /*
174
+ * Hot path, called from V8 callbacks on the isolate's own thread. The slot
175
+ * is written once in PrepareV8Runtime before the isolate runs any JS, so
176
+ * reading it requires no lock.
177
+ */
178
+ auto runtime = static_cast<Runtime*>(
179
+ isolate->GetData((uint32_t)Runtime::IsolateData::RUNTIME));
180
+ if (runtime != nullptr) {
181
+ return runtime;
182
+ }
183
+
184
+ // covers the window during isolate setup before SetData has run
185
{
186
std::lock_guard<std::mutex> lock(s_runtimeCacheMutex);
187
auto it = s_isolate2RuntimesCache.find(isolate);
0 commit comments