Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(975)

Unified Diff: Source/platform/heap/ThreadState.cpp

Issue 794223003: Cheaper thread-safe atomic initialization of static references. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add type check for initial value Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/heap/ThreadState.cpp
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
index 8457be83bbd1a27098cdbd68e03016b0987146ce..a0e71cd8b9e0f8cca790d40180f2b855c3c4bc4c 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -142,7 +142,7 @@ SafePointBarrier* ThreadState::s_safePointBarrier = nullptr;
static Mutex& threadAttachMutex()
{
- AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
+ AtomicallyInitializedStaticReference(Mutex, mutex, (new Mutex));
return mutex;
}
@@ -488,7 +488,7 @@ void ThreadState::visitPersistentRoots(Visitor* visitor)
// However we acquire the mutex to make mutation and traversal of this
// list symmetrical.
MutexLocker locker(globalRootsMutex());
- globalRoots()->trace(visitor);
+ globalRoots().trace(visitor);
}
for (ThreadState* state : attachedThreads())
@@ -684,15 +684,15 @@ bool ThreadState::popAndInvokeWeakPointerCallback(Visitor* visitor)
return false;
}
-PersistentNode* ThreadState::globalRoots()
+PersistentNode& ThreadState::globalRoots()
{
- AtomicallyInitializedStatic(PersistentNode*, anchor = new PersistentAnchor);
+ AtomicallyInitializedStaticReference(PersistentNode, anchor, new PersistentAnchor);
return anchor;
}
Mutex& ThreadState::globalRootsMutex()
{
- AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
+ AtomicallyInitializedStaticReference(Mutex, mutex, new Mutex);
return mutex;
}

Powered by Google App Engine
This is Rietveld 408576698