Title: [161161] trunk/Source/_javascript_Core
- Revision
- 161161
- Author
- [email protected]
- Date
- 2013-12-30 17:22:01 -0800 (Mon, 30 Dec 2013)
Log Message
Stop using ThreadCondition in BlockAllocator
https://bugs.webkit.org/show_bug.cgi?id=126313
Reviewed by Sam Weinig.
* heap/BlockAllocator.cpp:
(JSC::BlockAllocator::~BlockAllocator):
(JSC::BlockAllocator::waitForDuration):
(JSC::BlockAllocator::blockFreeingThreadMain):
* heap/BlockAllocator.h:
(JSC::BlockAllocator::deallocate):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (161160 => 161161)
--- trunk/Source/_javascript_Core/ChangeLog 2013-12-31 00:31:11 UTC (rev 161160)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-12-31 01:22:01 UTC (rev 161161)
@@ -1,5 +1,19 @@
2013-12-30 Anders Carlsson <[email protected]>
+ Stop using ThreadCondition in BlockAllocator
+ https://bugs.webkit.org/show_bug.cgi?id=126313
+
+ Reviewed by Sam Weinig.
+
+ * heap/BlockAllocator.cpp:
+ (JSC::BlockAllocator::~BlockAllocator):
+ (JSC::BlockAllocator::waitForDuration):
+ (JSC::BlockAllocator::blockFreeingThreadMain):
+ * heap/BlockAllocator.h:
+ (JSC::BlockAllocator::deallocate):
+
+2013-12-30 Anders Carlsson <[email protected]>
+
Stop using ThreadCondition in jsc.cpp
https://bugs.webkit.org/show_bug.cgi?id=126311
Modified: trunk/Source/_javascript_Core/heap/BlockAllocator.cpp (161160 => 161161)
--- trunk/Source/_javascript_Core/heap/BlockAllocator.cpp 2013-12-31 00:31:11 UTC (rev 161160)
+++ trunk/Source/_javascript_Core/heap/BlockAllocator.cpp 2013-12-31 01:22:01 UTC (rev 161161)
@@ -61,9 +61,9 @@
{
releaseFreeRegions();
{
- MutexLocker locker(m_emptyRegionConditionLock);
+ std::lock_guard<std::mutex> lock(m_emptyRegionConditionMutex);
m_blockFreeingThreadShouldQuit = true;
- m_emptyRegionCondition.broadcast();
+ m_emptyRegionCondition.notify_all();
}
if (m_blockFreeingThread)
waitForThreadCompletion(m_blockFreeingThread);
@@ -101,22 +101,17 @@
}
}
-void BlockAllocator::waitForRelativeTimeWhileHoldingLock(double relative)
+void BlockAllocator::waitForDuration(std::chrono::milliseconds duration)
{
- if (m_blockFreeingThreadShouldQuit)
- return;
+ std::unique_lock<std::mutex> lock(m_emptyRegionConditionMutex);
- m_emptyRegionCondition.timedWait(m_emptyRegionConditionLock, currentTime() + relative);
-}
-
-void BlockAllocator::waitForRelativeTime(double relative)
-{
// If this returns early, that's fine, so long as it doesn't do it too
// frequently. It would only be a bug if this function failed to return
// when it was asked to do so.
-
- MutexLocker locker(m_emptyRegionConditionLock);
- waitForRelativeTimeWhileHoldingLock(relative);
+ if (m_blockFreeingThreadShouldQuit)
+ return;
+
+ m_emptyRegionCondition.wait_for(lock, duration);
}
void BlockAllocator::blockFreeingThreadStartFunc(void* blockAllocator)
@@ -130,7 +125,7 @@
while (!m_blockFreeingThreadShouldQuit) {
// Generally wait for one second before scavenging free blocks. This
// may return early, particularly when we're being asked to quit.
- waitForRelativeTime(1.0);
+ waitForDuration(std::chrono::seconds(1));
if (m_blockFreeingThreadShouldQuit)
break;
@@ -141,11 +136,11 @@
// Sleep until there is actually work to do rather than waking up every second to check.
{
- MutexLocker locker(m_emptyRegionConditionLock);
+ std::unique_lock<std::mutex> lock(m_emptyRegionConditionMutex);
SpinLockHolder regionLocker(&m_regionLock);
while (!m_numberOfEmptyRegions && !m_blockFreeingThreadShouldQuit) {
m_regionLock.Unlock();
- m_emptyRegionCondition.wait(m_emptyRegionConditionLock);
+ m_emptyRegionCondition.wait(lock);
m_regionLock.Lock();
}
currentNumberOfEmptyRegions = m_numberOfEmptyRegions;
Modified: trunk/Source/_javascript_Core/heap/BlockAllocator.h (161160 => 161161)
--- trunk/Source/_javascript_Core/heap/BlockAllocator.h 2013-12-31 00:31:11 UTC (rev 161160)
+++ trunk/Source/_javascript_Core/heap/BlockAllocator.h 2013-12-31 01:22:01 UTC (rev 161161)
@@ -29,6 +29,7 @@
#include "GCActivityCallback.h"
#include "HeapBlock.h"
#include "Region.h"
+#include <mutex>
#include <wtf/DoublyLinkedList.h>
#include <wtf/Forward.h>
#include <wtf/PageAllocationAligned.h>
@@ -60,8 +61,7 @@
template <typename T> void deallocateCustomSize(T*);
private:
- void waitForRelativeTimeWhileHoldingLock(double relative);
- void waitForRelativeTime(double relative);
+ void waitForDuration(std::chrono::milliseconds);
friend ThreadIdentifier createBlockFreeingThread(BlockAllocator*);
void blockFreeingThreadMain();
@@ -105,8 +105,8 @@
bool m_isCurrentlyAllocating;
bool m_blockFreeingThreadShouldQuit;
SpinLock m_regionLock;
- Mutex m_emptyRegionConditionLock;
- ThreadCondition m_emptyRegionCondition;
+ std::mutex m_emptyRegionConditionMutex;
+ std::condition_variable m_emptyRegionCondition;
ThreadIdentifier m_blockFreeingThread;
};
@@ -199,8 +199,8 @@
}
if (shouldWakeBlockFreeingThread) {
- MutexLocker mutexLocker(m_emptyRegionConditionLock);
- m_emptyRegionCondition.signal();
+ std::lock_guard<std::mutex> lock(m_emptyRegionConditionMutex);
+ m_emptyRegionCondition.notify_one();
}
if (!m_blockFreeingThread)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes