Commit c5d998a2 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[objects] Skip acquiring main thread's string lock via local heap

This has similar performance as the thread_id check. It removes the need
to get the isolate for this check though, so it's a net positive.

Bug: v8:7790
Change-Id: I329bb9d5fe695fb9ef4990ba3593703b1eedca0d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2546690Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71259}
parent 5b634597
......@@ -41,6 +41,10 @@ class SharedStringAccessGuardIfNeeded {
}
static bool IsNeeded(String str, Isolate** out_isolate = nullptr) {
LocalHeap* local_heap = LocalHeap::Current();
// Don't acquire the lock for the main thread.
if (!local_heap || local_heap->is_main_thread()) return false;
Isolate* isolate;
if (!GetIsolateFromHeapObject(str, &isolate)) {
// If we can't get the isolate from the String, it must be read-only.
......@@ -48,7 +52,7 @@ class SharedStringAccessGuardIfNeeded {
return false;
}
if (out_isolate) *out_isolate = isolate;
return ThreadId::Current() != isolate->thread_id();
return true;
}
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment