Diff
Modified: trunk/Source/_javascript_Core/API/JSValue.mm (181484 => 181485)
--- trunk/Source/_javascript_Core/API/JSValue.mm 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/API/JSValue.mm 2015-03-13 20:04:29 UTC (rev 181485)
@@ -41,8 +41,8 @@
#import <wtf/HashMap.h>
#import <wtf/HashSet.h>
#import <wtf/ObjcRuntimeExtras.h>
+#import <wtf/SpinLock.h>
#import <wtf/Vector.h>
-#import <wtf/TCSpinLock.h>
#import <wtf/text/WTFString.h>
#import <wtf/text/StringHash.h>
@@ -1102,7 +1102,7 @@
static StructTagHandler* handerForStructTag(const char* encodedType)
{
- static SpinLock handerForStructTagLock = SPINLOCK_INITIALIZER;
+ static StaticSpinLock handerForStructTagLock;
SpinLockHolder lockHolder(&handerForStructTagLock);
static StructHandlers* structHandlers = createStructHandlerMap();
Modified: trunk/Source/_javascript_Core/API/JSWrapperMap.mm (181484 => 181485)
--- trunk/Source/_javascript_Core/API/JSWrapperMap.mm 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/API/JSWrapperMap.mm 2015-03-13 20:04:29 UTC (rev 181485)
@@ -39,7 +39,6 @@
#import "WeakGCMap.h"
#import "WeakGCMapInlines.h"
#import <wtf/HashSet.h>
-#import <wtf/TCSpinLock.h>
#import <wtf/Vector.h>
#import <wtf/spi/cocoa/NSMapTableSPI.h>
Modified: trunk/Source/_javascript_Core/ChangeLog (181484 => 181485)
--- trunk/Source/_javascript_Core/ChangeLog 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-03-13 20:04:29 UTC (rev 181485)
@@ -1,3 +1,34 @@
+2015-03-13 Mark Lam <[email protected]>
+
+ Replace TCSpinLock with a new WTF::SpinLock based on WTF::Atomic.
+ <https://webkit.org/b/142674>
+
+ Reviewed by Filip Pizlo.
+
+ * API/JSValue.mm:
+ (handerForStructTag):
+ * API/JSWrapperMap.mm:
+ * dfg/DFGCommon.cpp:
+ (JSC::DFG::startCrashing):
+ (JSC::DFG::isCrashing):
+ - Changed to use a StaticSpinLock since that's what this code was trying to do
+ anyway.
+ * heap/CopiedBlock.h:
+ (JSC::CopiedBlock::CopiedBlock):
+ * heap/CopiedSpace.cpp:
+ (JSC::CopiedSpace::CopiedSpace):
+ * heap/CopiedSpace.h:
+ * heap/GCThreadSharedData.cpp:
+ (JSC::GCThreadSharedData::GCThreadSharedData):
+ * heap/GCThreadSharedData.h:
+ * heap/ListableHandler.h:
+ (JSC::ListableHandler::List::List):
+ * parser/SourceProvider.cpp:
+ * profiler/ProfilerDatabase.cpp:
+ (JSC::Profiler::Database::addDatabaseToAtExit):
+ (JSC::Profiler::Database::removeDatabaseFromAtExit):
+ (JSC::Profiler::Database::removeFirstAtExitDatabase):
+
2015-03-13 Ryosuke Niwa <[email protected]>
BytecodeGenerator needs to be re-entrant to support miranda functions
Modified: trunk/Source/_javascript_Core/dfg/DFGCommon.cpp (181484 => 181485)
--- trunk/Source/_javascript_Core/dfg/DFGCommon.cpp 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/dfg/DFGCommon.cpp 2015-03-13 20:04:29 UTC (rev 181485)
@@ -34,17 +34,16 @@
namespace JSC { namespace DFG {
-static Atomic<unsigned> crashLock;
+static StaticSpinLock crashLock;
void startCrashing()
{
- while (!crashLock.compare_exchange_weak(0, 1, std::memory_order_acquire))
- std::this_thread::yield();
+ crashLock.lock();
}
bool isCrashing()
{
- return !!crashLock.load(std::memory_order_acquire);
+ return crashLock.isLocked();
}
} } // namespace JSC::DFG
Modified: trunk/Source/_javascript_Core/heap/CopiedBlock.h (181484 => 181485)
--- trunk/Source/_javascript_Core/heap/CopiedBlock.h 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/heap/CopiedBlock.h 2015-03-13 20:04:29 UTC (rev 181485)
@@ -32,7 +32,7 @@
#include "Options.h"
#include <wtf/Atomics.h>
#include <wtf/DoublyLinkedList.h>
-#include <wtf/TCSpinLock.h>
+#include <wtf/SpinLock.h>
namespace JSC {
@@ -152,7 +152,6 @@
, m_liveObjects(0)
#endif
{
- m_workListLock.Init();
ASSERT(is8ByteAligned(reinterpret_cast<void*>(m_remaining)));
}
Modified: trunk/Source/_javascript_Core/heap/CopiedSpace.cpp (181484 => 181485)
--- trunk/Source/_javascript_Core/heap/CopiedSpace.cpp 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/heap/CopiedSpace.cpp 2015-03-13 20:04:29 UTC (rev 181485)
@@ -39,7 +39,6 @@
, m_shouldDoCopyPhase(false)
, m_numberOfLoanedBlocks(0)
{
- m_toSpaceLock.Init();
}
CopiedSpace::~CopiedSpace()
Modified: trunk/Source/_javascript_Core/heap/CopiedSpace.h (181484 => 181485)
--- trunk/Source/_javascript_Core/heap/CopiedSpace.h 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/heap/CopiedSpace.h 2015-03-13 20:04:29 UTC (rev 181485)
@@ -37,8 +37,8 @@
#include <wtf/OSAllocator.h>
#include <wtf/PageAllocationAligned.h>
#include <wtf/PageBlock.h>
+#include <wtf/SpinLock.h>
#include <wtf/StdLibExtras.h>
-#include <wtf/TCSpinLock.h>
#include <wtf/ThreadingPrimitives.h>
namespace JSC {
Modified: trunk/Source/_javascript_Core/heap/GCThreadSharedData.cpp (181484 => 181485)
--- trunk/Source/_javascript_Core/heap/GCThreadSharedData.cpp 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/heap/GCThreadSharedData.cpp 2015-03-13 20:04:29 UTC (rev 181485)
@@ -81,7 +81,6 @@
, m_gcThreadsShouldWait(false)
, m_currentPhase(NoPhase)
{
- m_copyLock.Init();
#if ENABLE(PARALLEL_GC)
// Grab the lock so the new GC threads can be properly initialized before they start running.
std::unique_lock<std::mutex> lock(m_phaseMutex);
Modified: trunk/Source/_javascript_Core/heap/GCThreadSharedData.h (181484 => 181485)
--- trunk/Source/_javascript_Core/heap/GCThreadSharedData.h 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/heap/GCThreadSharedData.h 2015-03-13 20:04:29 UTC (rev 181485)
@@ -33,7 +33,7 @@
#include "WeakReferenceHarvester.h"
#include <condition_variable>
#include <wtf/HashSet.h>
-#include <wtf/TCSpinLock.h>
+#include <wtf/SpinLock.h>
#include <wtf/Vector.h>
namespace JSC {
Modified: trunk/Source/_javascript_Core/heap/ListableHandler.h (181484 => 181485)
--- trunk/Source/_javascript_Core/heap/ListableHandler.h 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/heap/ListableHandler.h 2015-03-13 20:04:29 UTC (rev 181485)
@@ -23,8 +23,8 @@
#include <stdint.h>
#include <wtf/Locker.h>
#include <wtf/Noncopyable.h>
+#include <wtf/SpinLock.h>
#include <wtf/ThreadingPrimitives.h>
-#include <wtf/TCSpinLock.h>
namespace JSC {
@@ -61,7 +61,6 @@
List()
: m_first(0)
{
- m_lock.Init();
}
void addThreadSafe(T* handler)
Modified: trunk/Source/_javascript_Core/parser/SourceProvider.cpp (181484 => 181485)
--- trunk/Source/_javascript_Core/parser/SourceProvider.cpp 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/parser/SourceProvider.cpp 2015-03-13 20:04:29 UTC (rev 181485)
@@ -27,8 +27,8 @@
#include "SourceProvider.h"
#include "JSCInlines.h"
+#include <wtf/SpinLock.h>
#include <wtf/StdLibExtras.h>
-#include <wtf/TCSpinLock.h>
namespace JSC {
@@ -44,7 +44,7 @@
{
}
-static TCMalloc_SpinLock providerIdLock = SPINLOCK_INITIALIZER;
+static StaticSpinLock providerIdLock;
void SourceProvider::getID()
{
Modified: trunk/Source/_javascript_Core/profiler/ProfilerDatabase.cpp (181484 => 181485)
--- trunk/Source/_javascript_Core/profiler/ProfilerDatabase.cpp 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/_javascript_Core/profiler/ProfilerDatabase.cpp 2015-03-13 20:04:29 UTC (rev 181485)
@@ -35,7 +35,7 @@
static std::atomic<int> databaseCounter;
-static SpinLock registrationLock = SPINLOCK_INITIALIZER;
+static StaticSpinLock registrationLock;
static std::atomic<int> didRegisterAtExit;
static Database* firstDatabase;
@@ -138,14 +138,14 @@
if (++didRegisterAtExit == 1)
atexit(atExitCallback);
- TCMalloc_SpinLockHolder holder(®istrationLock);
+ SpinLockHolder holder(registrationLock);
m_nextRegisteredDatabase = firstDatabase;
firstDatabase = this;
}
void Database::removeDatabaseFromAtExit()
{
- TCMalloc_SpinLockHolder holder(®istrationLock);
+ SpinLockHolder holder(registrationLock);
for (Database** current = &firstDatabase; *current; current = &(*current)->m_nextRegisteredDatabase) {
if (*current != this)
continue;
@@ -163,7 +163,7 @@
Database* Database::removeFirstAtExitDatabase()
{
- TCMalloc_SpinLockHolder holder(®istrationLock);
+ SpinLockHolder holder(registrationLock);
Database* result = firstDatabase;
if (result) {
firstDatabase = result->m_nextRegisteredDatabase;
Modified: trunk/Source/WTF/ChangeLog (181484 => 181485)
--- trunk/Source/WTF/ChangeLog 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WTF/ChangeLog 2015-03-13 20:04:29 UTC (rev 181485)
@@ -1,5 +1,47 @@
2015-03-13 Mark Lam <[email protected]>
+ Replace TCSpinLock with a new WTF::SpinLock based on WTF::Atomic.
+ <https://webkit.org/b/142674>
+
+ Reviewed by Filip Pizlo.
+
+ We no longer use TCMalloc in our code, and we now have C++11. This replaces the
+ TCMalloc_SpinLock with a new WTF::SpinLock based on WTF::Atomic (which is a
+ wrapper around std::atomic).
+
+ Note that there is a StaticSpinLock and a SpinLock:
+
+ 1. StaticSpinLock is an alias for SpinLockBase, and its initialization relies on
+ static / global std:atomic being automatically initialized to 0 at compile time.
+ Hence, StaticSpinLock should only be used for statics / globals (including
+ static members of classes / structs).
+
+ 2. SpinLock is derived from SpinLockBase, and adds a default constructor to
+ initialize its internal atomic value to 0. Because SpinLock has a constructor,
+ it cannot be used for statics / globals. Objects that want to embed a spin
+ lock as an instance field should use SpinLock so that it is initialized properly.
+ std::atomic will not automatically initialize instance fields to 0. Hence,
+ StaticSpinLock will not work correctly as instance fields of a class / struct.
+
+ * WTF.vcxproj/WTF.vcxproj:
+ * WTF.vcxproj/WTF.vcxproj.filters:
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/CMakeLists.txt:
+ * wtf/MetaAllocator.cpp:
+ (WTF::MetaAllocator::~MetaAllocator):
+ (WTF::MetaAllocator::MetaAllocator):
+ * wtf/MetaAllocator.h:
+ * wtf/SpinLock.h: Added.
+ (WTF::SpinLockBase::lock):
+ (WTF::SpinLockBase::unlock):
+ (WTF::SpinLockBase::isLocked):
+ (WTF::SpinLockBase::slowLock):
+ (WTF::SpinLock::SpinLock):
+ * wtf/TCSpinLock.h: Removed.
+ * wtf/text/AtomicString.cpp:
+
+2015-03-13 Mark Lam <[email protected]>
+
Introduce WTF::Atomic to wrap std::atomic for a friendlier CAS.
<https://webkit.org/b/142661>
Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj (181484 => 181485)
--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj 2015-03-13 20:04:29 UTC (rev 181485)
@@ -271,6 +271,7 @@
<ClInclude Include="..\wtf\SHA1.h" />
<ClInclude Include="..\wtf\SinglyLinkedList.h" />
<ClInclude Include="..\wtf\SixCharacterHash.h" />
+ <ClInclude Include="..\wtf\SpinLock.h" />
<ClInclude Include="..\wtf\StackBounds.h" />
<ClInclude Include="..\wtf\StaticConstructors.h" />
<ClInclude Include="..\wtf\StdLibExtras.h" />
@@ -278,7 +279,6 @@
<ClInclude Include="..\wtf\StringExtras.h" />
<ClInclude Include="..\wtf\StringHasher.h" />
<ClInclude Include="..\wtf\StringPrintStream.h" />
- <ClInclude Include="..\wtf\TCSpinLock.h" />
<ClInclude Include="..\wtf\TemporaryChange.h" />
<ClInclude Include="..\wtf\text\ASCIIFastPath.h" />
<ClInclude Include="..\wtf\text\AtomicString.h" />
Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters (181484 => 181485)
--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters 2015-03-13 20:04:29 UTC (rev 181485)
@@ -612,6 +612,9 @@
<ClInclude Include="..\wtf\SinglyLinkedList.h">
<Filter>wtf</Filter>
</ClInclude>
+ <ClInclude Include="..\wtf\SpinLock.h">
+ <Filter>wtf</Filter>
+ </ClInclude>
<ClInclude Include="..\wtf\StackBounds.h">
<Filter>wtf</Filter>
</ClInclude>
@@ -633,9 +636,6 @@
<ClInclude Include="..\wtf\StringPrintStream.h">
<Filter>wtf</Filter>
</ClInclude>
- <ClInclude Include="..\wtf\TCSpinLock.h">
- <Filter>wtf</Filter>
- </ClInclude>
<ClInclude Include="..\wtf\TemporaryChange.h">
<Filter>wtf</Filter>
</ClInclude>
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (181484 => 181485)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2015-03-13 20:04:29 UTC (rev 181485)
@@ -221,7 +221,6 @@
A8A4742A151A825B004123FF /* StdLibExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47311151A825B004123FF /* StdLibExtras.h */; };
A8A4742C151A825B004123FF /* StringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47313151A825B004123FF /* StringExtras.h */; };
A8A4742D151A825B004123FF /* StringHasher.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47314151A825B004123FF /* StringHasher.h */; };
- A8A47430151A825B004123FF /* TCSpinLock.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47317151A825B004123FF /* TCSpinLock.h */; };
A8A47433151A825B004123FF /* TemporaryChange.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4731A151A825B004123FF /* TemporaryChange.h */; };
A8A47434151A825B004123FF /* ASCIIFastPath.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4731C151A825B004123FF /* ASCIIFastPath.h */; };
A8A47435151A825B004123FF /* AtomicString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A4731D151A825B004123FF /* AtomicString.cpp */; };
@@ -279,6 +278,7 @@
E4A0AD3A1A96245500536DF6 /* WorkQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A0AD381A96245500536DF6 /* WorkQueue.h */; };
E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; };
EB95E1F0161A72410089A2F5 /* ByteOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = EB95E1EF161A72410089A2F5 /* ByteOrder.h */; };
+ FE91E8811AB2A0200099895F /* SpinLock.h in Headers */ = {isa = PBXBuildFile; fileRef = FE91E8801AB2A0200099895F /* SpinLock.h */; };
FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; };
FEDACD3E1630F83F00C69634 /* StackStats.h in Headers */ = {isa = PBXBuildFile; fileRef = FEDACD3C1630F83F00C69634 /* StackStats.h */; };
/* End PBXBuildFile section */
@@ -513,7 +513,6 @@
A8A47311151A825B004123FF /* StdLibExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdLibExtras.h; sourceTree = "<group>"; };
A8A47313151A825B004123FF /* StringExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringExtras.h; sourceTree = "<group>"; };
A8A47314151A825B004123FF /* StringHasher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringHasher.h; sourceTree = "<group>"; };
- A8A47317151A825B004123FF /* TCSpinLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCSpinLock.h; sourceTree = "<group>"; };
A8A4731A151A825B004123FF /* TemporaryChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporaryChange.h; sourceTree = "<group>"; };
A8A4731C151A825B004123FF /* ASCIIFastPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCIIFastPath.h; sourceTree = "<group>"; };
A8A4731D151A825B004123FF /* AtomicString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AtomicString.cpp; sourceTree = "<group>"; };
@@ -571,6 +570,7 @@
E4A0AD381A96245500536DF6 /* WorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkQueue.h; sourceTree = "<group>"; };
E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueueCocoa.cpp; sourceTree = "<group>"; };
EB95E1EF161A72410089A2F5 /* ByteOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteOrder.h; sourceTree = "<group>"; };
+ FE91E8801AB2A0200099895F /* SpinLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpinLock.h; sourceTree = "<group>"; };
FEDACD3B1630F83F00C69634 /* StackStats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackStats.cpp; sourceTree = "<group>"; };
FEDACD3C1630F83F00C69634 /* StackStats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackStats.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -850,6 +850,7 @@
A748745017A0BDAE00FA04CB /* SixCharacterHash.h */,
A8A4730C151A825B004123FF /* SizeLimits.cpp */,
A8A4730D151A825B004123FF /* Spectrum.h */,
+ FE91E8801AB2A0200099895F /* SpinLock.h */,
A8A4730E151A825B004123FF /* StackBounds.cpp */,
A8A4730F151A825B004123FF /* StackBounds.h */,
FEDACD3B1630F83F00C69634 /* StackStats.cpp */,
@@ -863,7 +864,6 @@
A8A47314151A825B004123FF /* StringHasher.h */,
0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */,
0FDDBFA61666DFA300C55FEF /* StringPrintStream.h */,
- A8A47317151A825B004123FF /* TCSpinLock.h */,
A8A4731A151A825B004123FF /* TemporaryChange.h */,
A8A4732F151A825B004123FF /* ThreadFunctionInvocation.h */,
A8A47330151A825B004123FF /* ThreadIdentifierDataPthreads.cpp */,
@@ -1182,6 +1182,7 @@
A8A4743B151A825B004123FF /* StringBuffer.h in Headers */,
A8A4743D151A825B004123FF /* StringBuilder.h in Headers */,
A8A4743E151A825B004123FF /* StringConcatenate.h in Headers */,
+ FE91E8811AB2A0200099895F /* SpinLock.h in Headers */,
A8A4742C151A825B004123FF /* StringExtras.h in Headers */,
A8A4743F151A825B004123FF /* StringHash.h in Headers */,
A748745417A0BDAE00FA04CB /* StringHashDumpContext.h in Headers */,
@@ -1191,7 +1192,6 @@
0FDDBFA81666DFA300C55FEF /* StringPrintStream.h in Headers */,
1AFDE6531953B23D00C48FFA /* Optional.h in Headers */,
A8A473B8151A825B004123FF /* strtod.h in Headers */,
- A8A47430151A825B004123FF /* TCSpinLock.h in Headers */,
E15556F618A0CC18006F48FB /* CryptographicUtilities.h in Headers */,
83FBA93219DF459700F30ADB /* TypeCasts.h in Headers */,
1A6EB1E0187D0BD30030126F /* StringView.h in Headers */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (181484 => 181485)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2015-03-13 20:04:29 UTC (rev 181485)
@@ -87,6 +87,7 @@
SHA1.h
SaturatedArithmetic.h
SegmentedVector.h
+ SpinLock.h
StackBounds.h
StackStats.h
StaticConstructors.h
@@ -95,7 +96,6 @@
StringExtras.h
StringHasher.h
StringPrintStream.h
- TCSpinLock.h
ThreadIdentifierDataPthreads.h
ThreadSafeRefCounted.h
ThreadSpecific.h
Modified: trunk/Source/WTF/wtf/MetaAllocator.cpp (181484 => 181485)
--- trunk/Source/WTF/wtf/MetaAllocator.cpp 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WTF/wtf/MetaAllocator.cpp 2015-03-13 20:04:29 UTC (rev 181485)
@@ -43,7 +43,6 @@
freeFreeSpaceNode(node);
node = next;
}
- m_lock.Finalize();
#ifndef NDEBUG
ASSERT(!m_mallocBalance);
#endif
@@ -129,8 +128,6 @@
, m_numFrees(0)
#endif
{
- m_lock.Init();
-
for (m_logPageSize = 0; m_logPageSize < 32; ++m_logPageSize) {
if (static_cast<size_t>(1) << m_logPageSize == m_pageSize)
break;
Modified: trunk/Source/WTF/wtf/MetaAllocator.h (181484 => 181485)
--- trunk/Source/WTF/wtf/MetaAllocator.h 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WTF/wtf/MetaAllocator.h 2015-03-13 20:04:29 UTC (rev 181485)
@@ -37,7 +37,7 @@
#include <wtf/RedBlackTree.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
-#include <wtf/TCSpinLock.h>
+#include <wtf/SpinLock.h>
namespace WTF {
Added: trunk/Source/WTF/wtf/SpinLock.h (0 => 181485)
--- trunk/Source/WTF/wtf/SpinLock.h (rev 0)
+++ trunk/Source/WTF/wtf/SpinLock.h 2015-03-13 20:04:29 UTC (rev 181485)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SpinLock_h
+#define SpinLock_h
+
+#include <thread>
+#include <wtf/Atomics.h>
+#include <wtf/Locker.h>
+
+namespace WTF {
+
+// SpinLockBase is a struct without an explicitly defined constructors so that
+// it can be initialized at compile time. See StaticSpinLock below.
+struct SpinLockBase {
+
+ void lock()
+ {
+ while (!m_lock.compare_exchange_weak(0, 1, std::memory_order_acquire))
+ std::this_thread::yield();
+ }
+
+ void unlock()
+ {
+ m_lock.store(0, std::memory_order_release);
+ }
+
+ bool isLocked() const
+ {
+ return m_lock.load(std::memory_order_acquire);
+ }
+
+ Atomic<unsigned> m_lock;
+};
+
+// SpinLock is for use as instance variables in structs and classes, not as
+// statics and globals.
+struct SpinLock : public SpinLockBase {
+ SpinLock()
+ {
+ m_lock.store(0, std::memory_order_relaxed);
+ }
+};
+
+// StaticSpinLock is for use as statics and globals, not as instance variables.
+typedef SpinLockBase StaticSpinLock;
+typedef Locker<SpinLockBase> SpinLockHolder;
+
+} // namespace WTF
+
+using WTF::StaticSpinLock;
+using WTF::SpinLock;
+using WTF::SpinLockHolder;
+
+#endif // SpinLock_h
Deleted: trunk/Source/WTF/wtf/TCSpinLock.h (181484 => 181485)
--- trunk/Source/WTF/wtf/TCSpinLock.h 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WTF/wtf/TCSpinLock.h 2015-03-13 20:04:29 UTC (rev 181485)
@@ -1,133 +0,0 @@
-// Copyright (c) 2005, 2006, Google Inc.
-// Copyright (c) 2010, Patrick Gansterer <[email protected]>
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Sanjay Ghemawat <[email protected]>
-
-#ifndef TCMALLOC_INTERNAL_SPINLOCK_H__
-#define TCMALLOC_INTERNAL_SPINLOCK_H__
-
-#include <wtf/Atomics.h>
-#if OS(UNIX)
-#include <sched.h>
-#endif
-
-#if ENABLE(COMPARE_AND_SWAP)
-
-static void TCMalloc_SlowLock(unsigned* lockword);
-
-// The following is a struct so that it can be initialized at compile time
-struct TCMalloc_SpinLock {
- void Lock() {
- if (!WTF::weakCompareAndSwap(&lockword_, 0, 1))
- TCMalloc_SlowLock(&lockword_);
- WTF::memoryBarrierAfterLock();
- }
-
- void Unlock() {
- WTF::memoryBarrierBeforeUnlock();
- lockword_ = 0;
- }
-
- // Report if we think the lock can be held by this thread.
- // When the lock is truly held by the invoking thread
- // we will always return true.
- // Indended to be used as CHECK(lock.IsHeld());
- bool IsHeld() const {
- return lockword_ != 0;
- }
-
- void Init() { lockword_ = 0; }
- void Finalize() { }
-
- unsigned lockword_;
-};
-
-#define SPINLOCK_INITIALIZER { 0 }
-
-static void TCMalloc_SlowLock(unsigned* lockword) {
- do {
-#if OS(WINDOWS)
- Sleep(0);
-#else
- sched_yield();
-#endif
- } while (!WTF::weakCompareAndSwap(lockword, 0, 1));
-}
-
-#else
-
-#include <pthread.h>
-
-// Portable version
-struct TCMalloc_SpinLock {
- pthread_mutex_t private_lock_;
-
- inline void Init() {
- if (pthread_mutex_init(&private_lock_, NULL) != 0) CRASH();
- }
- inline void Finalize() {
- if (pthread_mutex_destroy(&private_lock_) != 0) CRASH();
- }
- inline void Lock() {
- if (pthread_mutex_lock(&private_lock_) != 0) CRASH();
- }
- inline void Unlock() {
- if (pthread_mutex_unlock(&private_lock_) != 0) CRASH();
- }
- bool IsHeld() {
- if (pthread_mutex_trylock(&private_lock_))
- return true;
-
- Unlock();
- return false;
- }
-};
-
-#define SPINLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }
-
-#endif
-
-// Corresponding locker object that arranges to acquire a spinlock for
-// the duration of a C++ scope.
-class TCMalloc_SpinLockHolder {
- private:
- TCMalloc_SpinLock* lock_;
- public:
- inline explicit TCMalloc_SpinLockHolder(TCMalloc_SpinLock* l)
- : lock_(l) { l->Lock(); }
- inline ~TCMalloc_SpinLockHolder() { lock_->Unlock(); }
-};
-
-// Short-hands for convenient use by tcmalloc.cc
-typedef TCMalloc_SpinLock SpinLock;
-typedef TCMalloc_SpinLockHolder SpinLockHolder;
-
-#endif // TCMALLOC_INTERNAL_SPINLOCK_H__
Modified: trunk/Source/WTF/wtf/text/AtomicString.cpp (181484 => 181485)
--- trunk/Source/WTF/wtf/text/AtomicString.cpp 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WTF/wtf/text/AtomicString.cpp 2015-03-13 20:04:29 UTC (rev 181485)
@@ -33,7 +33,7 @@
#include <wtf/unicode/UTF8.h>
#if USE(WEB_THREAD)
-#include "TCSpinLock.h"
+#include "SpinLock.h"
#endif
namespace WTF {
@@ -47,7 +47,7 @@
class AtomicStringTableLocker : public SpinLockHolder {
WTF_MAKE_NONCOPYABLE(AtomicStringTableLocker);
- static SpinLock s_stringTableLock;
+ static StaticSpinLock s_stringTableLock;
public:
AtomicStringTableLocker()
: SpinLockHolder(&s_stringTableLock)
@@ -55,7 +55,7 @@
}
};
-SpinLock AtomicStringTableLocker::s_stringTableLock = SPINLOCK_INITIALIZER;
+StaticSpinLock AtomicStringTableLocker::s_stringTableLock;
#else
Modified: trunk/Source/WebCore/ChangeLog (181484 => 181485)
--- trunk/Source/WebCore/ChangeLog 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WebCore/ChangeLog 2015-03-13 20:04:29 UTC (rev 181485)
@@ -1,3 +1,17 @@
+2015-03-13 Mark Lam <[email protected]>
+
+ Replace TCSpinLock with a new WTF::SpinLock based on WTF::Atomic.
+ <https://webkit.org/b/142674>
+
+ Reviewed by Filip Pizlo.
+
+ No new tests because there is no new functionality. This is a refactoring effort.
+
+ * bindings/objc/WebScriptObject.mm:
+ * platform/ios/wak/WAKWindow.mm:
+ (-[WAKWindow initWithLayer:]):
+ (-[WAKWindow initWithFrame:]):
+
2015-03-13 Doug Russell <[email protected]>
AX: Provide API for assistive tech to ignore DOM key event handlers
Modified: trunk/Source/WebCore/bindings/objc/WebScriptObject.mm (181484 => 181485)
--- trunk/Source/WebCore/bindings/objc/WebScriptObject.mm 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WebCore/bindings/objc/WebScriptObject.mm 2015-03-13 20:04:29 UTC (rev 181485)
@@ -48,7 +48,7 @@
#import <runtime/JSLock.h>
#import <runtime/Completion.h>
#import <runtime/Completion.h>
-#import <wtf/TCSpinLock.h>
+#import <wtf/SpinLock.h>
#import <wtf/Threading.h>
#import <wtf/spi/cocoa/NSMapTableSPI.h>
#import <wtf/text/WTFString.h>
@@ -72,7 +72,7 @@
namespace WebCore {
static NSMapTable* JSWrapperCache;
-static SpinLock spinLock = SPINLOCK_INITIALIZER;
+static StaticSpinLock spinLock;
NSObject* getJSWrapper(JSObject* impl)
{
Modified: trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm (181484 => 181485)
--- trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm 2015-03-13 20:04:29 UTC (rev 181485)
@@ -36,7 +36,7 @@
#import "WKContentObservation.h"
#import "WKViewPrivate.h"
#import <QuartzCore/QuartzCore.h>
-#import <wtf/TCSpinLock.h>
+#import <wtf/SpinLock.h>
WEBCORE_EXPORT NSString * const WAKWindowScreenScaleDidChangeNotification = @"WAKWindowScreenScaleDidChangeNotification";
WEBCORE_EXPORT NSString * const WAKWindowVisibilityDidChangeNotification = @"WAKWindowVisibilityDidChangeNotification";
@@ -77,7 +77,6 @@
_frozenVisibleRect = CGRectNull;
- _exposedScrollViewRectLock = SPINLOCK_INITIALIZER;
_exposedScrollViewRect = CGRectNull;
return self;
@@ -93,7 +92,6 @@
_frame = frame;
_screenScale = wkGetScreenScaleFactor();
- _exposedScrollViewRectLock = SPINLOCK_INITIALIZER;
_exposedScrollViewRect = CGRectNull;
return self;
Modified: trunk/Source/WebKit2/ChangeLog (181484 => 181485)
--- trunk/Source/WebKit2/ChangeLog 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WebKit2/ChangeLog 2015-03-13 20:04:29 UTC (rev 181485)
@@ -1,3 +1,17 @@
+2015-03-13 Mark Lam <[email protected]>
+
+ Replace TCSpinLock with a new WTF::SpinLock based on WTF::Atomic.
+ <https://webkit.org/b/142674>
+
+ Reviewed by Filip Pizlo.
+
+ * WebProcess/WebPage/EventDispatcher.cpp:
+ (WebKit::EventDispatcher::EventDispatcher):
+ * WebProcess/WebPage/EventDispatcher.h:
+ * WebProcess/WebPage/ViewUpdateDispatcher.cpp:
+ (WebKit::ViewUpdateDispatcher::ViewUpdateDispatcher):
+ * WebProcess/WebPage/ViewUpdateDispatcher.h:
+
2015-03-10 Conrad Shultz <[email protected]>
Allow clients to selectively disable plug-ins
Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp (181484 => 181485)
--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp 2015-03-13 20:04:29 UTC (rev 181485)
@@ -54,9 +54,6 @@
EventDispatcher::EventDispatcher()
: m_queue(WorkQueue::create("com.apple.WebKit.EventDispatcher", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive))
, m_recentWheelEventDeltaTracker(std::make_unique<WheelEventDeltaTracker>())
-#if ENABLE(IOS_TOUCH_EVENTS)
- , m_touchEventsLock(SPINLOCK_INITIALIZER)
-#endif
{
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h (181484 => 181485)
--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h 2015-03-13 20:04:29 UTC (rev 181485)
@@ -34,7 +34,7 @@
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/RefPtr.h>
-#include <wtf/TCSpinLock.h>
+#include <wtf/SpinLock.h>
#include <wtf/ThreadingPrimitives.h>
namespace WebCore {
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.cpp (181484 => 181485)
--- trunk/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.cpp 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.cpp 2015-03-13 20:04:29 UTC (rev 181485)
@@ -42,7 +42,6 @@
ViewUpdateDispatcher::ViewUpdateDispatcher()
: m_queue(WorkQueue::create("com.apple.WebKit.ViewUpdateDispatcher"))
- , m_dataMutex(SPINLOCK_INITIALIZER)
{
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.h (181484 => 181485)
--- trunk/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.h 2015-03-13 19:24:01 UTC (rev 181484)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.h 2015-03-13 20:04:29 UTC (rev 181485)
@@ -31,7 +31,7 @@
#include "VisibleContentRectUpdateInfo.h"
#include <wtf/HashMap.h>
#include <wtf/Ref.h>
-#include <wtf/TCSpinLock.h>
+#include <wtf/SpinLock.h>
namespace WebKit {