Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (215636 => 215637)
--- trunk/Source/_javascript_Core/ChangeLog 2017-04-21 21:08:36 UTC (rev 215636)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-04-21 21:14:15 UTC (rev 215637)
@@ -16,6 +16,24 @@
2017-04-21 Keith Miller <[email protected]>
+ Remove LL/SC from Atomics
+ https://bugs.webkit.org/show_bug.cgi?id=171141
+
+ Reviewed by Saam Barati.
+
+ Adding load link and store conditionally was not an actual progression
+ and the existing code is causing problems for users of Atomics. So let's
+ get rid of it.
+
+ * heap/LargeAllocation.h:
+ (JSC::LargeAllocation::testAndSetMarked):
+ * heap/MarkedBlock.h:
+ (JSC::MarkedBlock::testAndSetMarked):
+ * heap/SlotVisitor.cpp:
+ (JSC::SlotVisitor::setMarkedAndAppendToMarkStack):
+
+2017-04-21 Keith Miller <[email protected]>
+
Unreviewed, fix Cloop build.
* jit/ExecutableAllocator.h:
Modified: trunk/Source/_javascript_Core/heap/LargeAllocation.h (215636 => 215637)
--- trunk/Source/_javascript_Core/heap/LargeAllocation.h 2017-04-21 21:08:36 UTC (rev 215636)
+++ trunk/Source/_javascript_Core/heap/LargeAllocation.h 2017-04-21 21:14:15 UTC (rev 215637)
@@ -121,7 +121,7 @@
return true;
return m_isMarked.compareExchangeStrong(false, true);
}
- ALWAYS_INLINE bool testAndSetMarked(HeapCell*, Dependency, TransactionAbortLikelihood = TransactionAbortLikelihood::Likely) { return testAndSetMarked(); }
+ ALWAYS_INLINE bool testAndSetMarked(HeapCell*, Dependency) { return testAndSetMarked(); }
void clearMarked() { m_isMarked.store(false); }
void noteMarked() { }
Modified: trunk/Source/_javascript_Core/heap/MarkedBlock.h (215636 => 215637)
--- trunk/Source/_javascript_Core/heap/MarkedBlock.h 2017-04-21 21:08:36 UTC (rev 215636)
+++ trunk/Source/_javascript_Core/heap/MarkedBlock.h 2017-04-21 21:14:15 UTC (rev 215637)
@@ -259,7 +259,7 @@
bool isMarked(HeapVersion markingVersion, const void*);
bool isMarkedConcurrently(HeapVersion markingVersion, const void*);
bool isMarked(const void*, Dependency);
- bool testAndSetMarked(const void*, Dependency, TransactionAbortLikelihood = TransactionAbortLikelihood::Likely);
+ bool testAndSetMarked(const void*, Dependency);
bool isAtom(const void*);
void clearMarked(const void*);
@@ -535,10 +535,10 @@
return m_marks.get(atomNumber(p), dependency);
}
-inline bool MarkedBlock::testAndSetMarked(const void* p, Dependency dependency, TransactionAbortLikelihood abortLikelihood)
+inline bool MarkedBlock::testAndSetMarked(const void* p, Dependency dependency)
{
assertMarksNotStale();
- return m_marks.concurrentTestAndSet(atomNumber(p), dependency, abortLikelihood);
+ return m_marks.concurrentTestAndSet(atomNumber(p), dependency);
}
inline bool MarkedBlock::Handle::isNewlyAllocated(const void* p)
Modified: trunk/Source/_javascript_Core/heap/SlotVisitor.cpp (215636 => 215637)
--- trunk/Source/_javascript_Core/heap/SlotVisitor.cpp 2017-04-21 21:08:36 UTC (rev 215636)
+++ trunk/Source/_javascript_Core/heap/SlotVisitor.cpp 2017-04-21 21:14:15 UTC (rev 215637)
@@ -252,7 +252,7 @@
template<typename ContainerType>
ALWAYS_INLINE void SlotVisitor::setMarkedAndAppendToMarkStack(ContainerType& container, JSCell* cell, Dependency dependency)
{
- if (container.testAndSetMarked(cell, dependency, TransactionAbortLikelihood::Unlikely))
+ if (container.testAndSetMarked(cell, dependency))
return;
ASSERT(cell->structure());
Modified: trunk/Source/WTF/ChangeLog (215636 => 215637)
--- trunk/Source/WTF/ChangeLog 2017-04-21 21:08:36 UTC (rev 215636)
+++ trunk/Source/WTF/ChangeLog 2017-04-21 21:14:15 UTC (rev 215637)
@@ -1,3 +1,28 @@
+2017-04-21 Keith Miller <[email protected]>
+
+ Remove LL/SC from Atomics
+ https://bugs.webkit.org/show_bug.cgi?id=171141
+
+ Reviewed by Saam Barati.
+
+ Adding load link and store conditionally was not an actual progression
+ and the existing code is causing problems for users of Atomics. So let's
+ get rid of it.
+
+ * wtf/Atomics.h:
+ (WTF::hasFence):
+ (WTF::Atomic::exchange):
+ (WTF::Atomic::transaction):
+ (WTF::Atomic::transactionRelaxed):
+ (WTF::Atomic::prepare): Deleted.
+ (WTF::Atomic::attempt): Deleted.
+ * wtf/Bitmap.h:
+ (WTF::WordType>::concurrentTestAndSet):
+ (WTF::WordType>::concurrentTestAndClear):
+ * wtf/LockAlgorithm.h:
+ (WTF::LockAlgorithm::lockFast):
+ (WTF::LockAlgorithm::unlockFast):
+
2017-04-21 Commit Queue <[email protected]>
Unreviewed, rolling out r215620 and r215623.
Modified: trunk/Source/WTF/wtf/Atomics.h (215636 => 215637)
--- trunk/Source/WTF/wtf/Atomics.h 2017-04-21 21:08:36 UTC (rev 215636)
+++ trunk/Source/WTF/wtf/Atomics.h 2017-04-21 21:14:15 UTC (rev 215637)
@@ -44,11 +44,6 @@
{
return order != std::memory_order_relaxed;
}
-
-enum class TransactionAbortLikelihood {
- Unlikely,
- Likely
-};
// Atomic wraps around std::atomic with the sole purpose of making the compare_exchange
// operations not alter the expected value. This is more in line with how we typically
@@ -116,132 +111,29 @@
ALWAYS_INLINE T exchangeXor(U operand, std::memory_order order = std::memory_order_seq_cst) { return value.fetch_xor(operand, order); }
ALWAYS_INLINE T exchange(T newValue, std::memory_order order = std::memory_order_seq_cst) { return value.exchange(newValue, order); }
-
-#if HAVE(LL_SC)
- ALWAYS_INLINE T loadLink(std::memory_order order = std::memory_order_seq_cst);
- ALWAYS_INLINE bool storeCond(T value, std::memory_order order = std::memory_order_seq_cst);
-#endif // HAVE(LL_SC)
- ALWAYS_INLINE T prepare(std::memory_order order = std::memory_order_seq_cst)
- {
-#if HAVE(LL_SC)
- return loadLink(order);
-#else
- UNUSED_PARAM(order);
- return load(std::memory_order_relaxed);
-#endif
- }
-
-#if HAVE(LL_SC)
- static const bool prepareIsFast = false;
-#else
- static const bool prepareIsFast = true;
-#endif
-
- ALWAYS_INLINE bool attempt(T oldValue, T newValue, std::memory_order order = std::memory_order_seq_cst)
- {
-#if HAVE(LL_SC)
- UNUSED_PARAM(oldValue);
- return storeCond(newValue, order);
-#else
- return compareExchangeWeak(oldValue, newValue, order);
-#endif
- }
-
template<typename Func>
- ALWAYS_INLINE bool transaction(const Func& func, std::memory_order order = std::memory_order_seq_cst, TransactionAbortLikelihood abortLikelihood = TransactionAbortLikelihood::Likely)
+ ALWAYS_INLINE bool transaction(const Func& func, std::memory_order order = std::memory_order_seq_cst)
{
- // If preparing is not fast then we want to skip the loop when func would fail.
- if (!prepareIsFast && abortLikelihood == TransactionAbortLikelihood::Likely) {
+ for (;;) {
T oldValue = load(std::memory_order_relaxed);
- // Note: many funcs will constant-fold to true, which will kill all of this code.
- if (!func(oldValue))
- return false;
- }
- for (;;) {
- T oldValue = prepare(order);
T newValue = oldValue;
if (!func(newValue))
return false;
- if (attempt(oldValue, newValue, order))
+ if (compareExchangeWeak(oldValue, newValue, order))
return true;
}
}
template<typename Func>
- ALWAYS_INLINE bool transactionRelaxed(const Func& func, TransactionAbortLikelihood abortLikelihood = TransactionAbortLikelihood::Likely)
+ ALWAYS_INLINE bool transactionRelaxed(const Func& func)
{
- return transaction(func, std::memory_order_relaxed, abortLikelihood);
+ return transaction(func, std::memory_order_relaxed);
}
std::atomic<T> value;
};
-#if CPU(ARM64) && HAVE(LL_SC)
-#define DEFINE_LL_SC(width, modifier, suffix) \
- template<> \
- ALWAYS_INLINE uint ## width ## _t Atomic<uint ## width ##_t>::loadLink(std::memory_order order) \
- { \
- int ## width ## _t result; \
- if (hasFence(order)) { \
- asm volatile ( \
- "ldaxr" suffix " %" modifier "0, [%1]" \
- : "=r"(result) \
- : "r"(this) \
- : "memory"); \
- } else { \
- asm volatile ( \
- "ldxr" suffix " %" modifier "0, [%1]" \
- : "=r"(result) \
- : "r"(this) \
- : "memory"); \
- } \
- return result; \
- } \
- \
- template<> \
- ALWAYS_INLINE bool Atomic<uint ## width ## _t>::storeCond(uint ## width ## _t value, std::memory_order order) \
- { \
- bool result; \
- if (hasFence(order)) { \
- asm volatile ( \
- "stlxr" suffix " %w0, %" modifier "1, [%2]" \
- : "=&r"(result) \
- : "r"(value), "r"(this) \
- : "memory"); \
- } else { \
- asm volatile ( \
- "stxr" suffix " %w0, %" modifier "1, [%2]" \
- : "=&r"(result) \
- : "r"(value), "r"(this) \
- : "memory"); \
- } \
- return !result; \
- } \
- \
- template<> \
- ALWAYS_INLINE int ## width ## _t Atomic<int ## width ## _t>::loadLink(std::memory_order order) \
- { \
- return bitwise_cast<Atomic<uint ## width ## _t>*>(this)->loadLink(order); \
- } \
- \
- template<> \
- ALWAYS_INLINE bool Atomic<int ## width ## _t>::storeCond(int ## width ## _t value, std::memory_order order) \
- { \
- return bitwise_cast<Atomic<uint ## width ## _t>*>(this)->storeCond(value, order); \
- }
-
-DEFINE_LL_SC(8, "w", "b")
-DEFINE_LL_SC(16, "w", "h")
-DEFINE_LL_SC(32, "w", "")
-DEFINE_LL_SC(64, "", "")
-#if OS(DARWIN)
-DEFINE_LL_SC(ptr, "", "")
-#endif
-
-#undef DEFINE_LL_SC
-#endif // CPU(ARM64) && HAVE(LL_SC)
-
template<typename T>
inline T atomicLoad(T* location, std::memory_order order = std::memory_order_seq_cst)
{
@@ -541,7 +433,6 @@
using WTF::Atomic;
using WTF::Dependency;
using WTF::DependencyWith;
-using WTF::TransactionAbortLikelihood;
using WTF::consume;
using WTF::dependency;
using WTF::dependencyWith;
Modified: trunk/Source/WTF/wtf/Bitmap.h (215636 => 215637)
--- trunk/Source/WTF/wtf/Bitmap.h 2017-04-21 21:08:36 UTC (rev 215636)
+++ trunk/Source/WTF/wtf/Bitmap.h 2017-04-21 21:14:15 UTC (rev 215637)
@@ -45,8 +45,8 @@
void set(size_t, bool);
bool testAndSet(size_t);
bool testAndClear(size_t);
- bool concurrentTestAndSet(size_t, Dependency = nullDependency(), TransactionAbortLikelihood = TransactionAbortLikelihood::Likely);
- bool concurrentTestAndClear(size_t, Dependency = nullDependency(), TransactionAbortLikelihood = TransactionAbortLikelihood::Likely);
+ bool concurrentTestAndSet(size_t, Dependency = nullDependency());
+ bool concurrentTestAndClear(size_t, Dependency = nullDependency());
size_t nextPossiblyUnset(size_t) const;
void clear(size_t);
void clearAll();
@@ -177,7 +177,7 @@
}
template<size_t bitmapSize, typename WordType>
-ALWAYS_INLINE bool Bitmap<bitmapSize, WordType>::concurrentTestAndSet(size_t n, Dependency dependency, TransactionAbortLikelihood abortLikelihood)
+ALWAYS_INLINE bool Bitmap<bitmapSize, WordType>::concurrentTestAndSet(size_t n, Dependency dependency)
{
WordType mask = one << (n % wordSize);
size_t index = n / wordSize;
@@ -189,12 +189,11 @@
value |= mask;
return true;
- },
- abortLikelihood);
+ });
}
template<size_t bitmapSize, typename WordType>
-ALWAYS_INLINE bool Bitmap<bitmapSize, WordType>::concurrentTestAndClear(size_t n, Dependency dependency, TransactionAbortLikelihood abortLikelihood)
+ALWAYS_INLINE bool Bitmap<bitmapSize, WordType>::concurrentTestAndClear(size_t n, Dependency dependency)
{
WordType mask = one << (n % wordSize);
size_t index = n / wordSize;
@@ -206,8 +205,7 @@
value &= ~mask;
return true;
- },
- abortLikelihood);
+ });
}
template<size_t bitmapSize, typename WordType>
Modified: trunk/Source/WTF/wtf/LockAlgorithm.h (215636 => 215637)
--- trunk/Source/WTF/wtf/LockAlgorithm.h 2017-04-21 21:08:36 UTC (rev 215636)
+++ trunk/Source/WTF/wtf/LockAlgorithm.h 2017-04-21 21:14:15 UTC (rev 215637)
@@ -57,8 +57,7 @@
value |= isHeldBit;
return true;
},
- std::memory_order_acquire,
- TransactionAbortLikelihood::Unlikely);
+ std::memory_order_acquire);
}
static void lock(Atomic<LockType>& lock)
@@ -92,8 +91,7 @@
value &= ~isHeldBit;
return true;
},
- std::memory_order_relaxed,
- TransactionAbortLikelihood::Unlikely);
+ std::memory_order_relaxed);
}
static void unlock(Atomic<LockType>& lock)
Modified: trunk/Source/WTF/wtf/Platform.h (215636 => 215637)
--- trunk/Source/WTF/wtf/Platform.h 2017-04-21 21:08:36 UTC (rev 215636)
+++ trunk/Source/WTF/wtf/Platform.h 2017-04-21 21:14:15 UTC (rev 215637)
@@ -761,10 +761,6 @@
#define ENABLE_CONCURRENT_JS 1
#endif
-#if CPU(ARM64)
-#define HAVE_LL_SC 1
-#endif // CPU(ARM64) && OS(DARWIN)
-
#if __has_include(<System/pthread_machdep.h>)
#define HAVE_FAST_TLS 1
#endif