Bug 1502207 Part 2 - Fix useUse new atomic access API in Gecko, r=froydnj.

--HG--
extra : rebase_source : 2b9b5bb77fb53cd9f028912b4ba54136c9066447
This commit is contained in:
Brian Hackett 2018-10-25 11:42:18 -10:00
Родитель 55571f2bbf
Коммит bae5179cfb
3 изменённых файлов: 21 добавлений и 21 удалений

Просмотреть файл

@ -158,13 +158,13 @@ template<recordreplay::Behavior Recording> struct AutoRecordAtomicAccess;
template<>
struct AutoRecordAtomicAccess<recordreplay::Behavior::DontPreserve> {
AutoRecordAtomicAccess() {}
explicit AutoRecordAtomicAccess(const void* aValue) {}
~AutoRecordAtomicAccess() {}
};
template<>
struct AutoRecordAtomicAccess<recordreplay::Behavior::Preserve> {
AutoRecordAtomicAccess() { recordreplay::BeginOrderedAtomicAccess(); }
explicit AutoRecordAtomicAccess(const void* aValue) { recordreplay::BeginOrderedAtomicAccess(aValue); }
~AutoRecordAtomicAccess() { recordreplay::EndOrderedAtomicAccess(); }
};
@ -218,26 +218,26 @@ struct IntrinsicMemoryOps : public IntrinsicBase<T, Order>
static T load(const typename Base::ValueType& aPtr)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
return aPtr.load(Base::OrderedOp::LoadOrder);
}
static void store(typename Base::ValueType& aPtr, T aVal)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
aPtr.store(aVal, Base::OrderedOp::StoreOrder);
}
static T exchange(typename Base::ValueType& aPtr, T aVal)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
return aPtr.exchange(aVal, Base::OrderedOp::AtomicRMWOrder);
}
static bool compareExchange(typename Base::ValueType& aPtr,
T aOldVal, T aNewVal)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
return aPtr.compare_exchange_strong(aOldVal, aNewVal,
Base::OrderedOp::AtomicRMWOrder,
Base::OrderedOp::CompareExchangeFailureOrder);
@ -251,13 +251,13 @@ struct IntrinsicAddSub : public IntrinsicBase<T, Order>
static T add(typename Base::ValueType& aPtr, T aVal)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
return aPtr.fetch_add(aVal, Base::OrderedOp::AtomicRMWOrder);
}
static T sub(typename Base::ValueType& aPtr, T aVal)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
return aPtr.fetch_sub(aVal, Base::OrderedOp::AtomicRMWOrder);
}
};
@ -269,13 +269,13 @@ struct IntrinsicAddSub<T*, Order, Recording> : public IntrinsicBase<T*, Order>
static T* add(typename Base::ValueType& aPtr, ptrdiff_t aVal)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
return aPtr.fetch_add(aVal, Base::OrderedOp::AtomicRMWOrder);
}
static T* sub(typename Base::ValueType& aPtr, ptrdiff_t aVal)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
return aPtr.fetch_sub(aVal, Base::OrderedOp::AtomicRMWOrder);
}
};
@ -304,19 +304,19 @@ struct AtomicIntrinsics : public IntrinsicMemoryOps<T, Order, Recording>,
static T or_(typename Base::ValueType& aPtr, T aVal)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
return aPtr.fetch_or(aVal, Base::OrderedOp::AtomicRMWOrder);
}
static T xor_(typename Base::ValueType& aPtr, T aVal)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
return aPtr.fetch_xor(aVal, Base::OrderedOp::AtomicRMWOrder);
}
static T and_(typename Base::ValueType& aPtr, T aVal)
{
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(&aPtr);
return aPtr.fetch_and(aVal, Base::OrderedOp::AtomicRMWOrder);
}
};

Просмотреть файл

@ -124,7 +124,7 @@ public:
// first increment on that thread. The necessary memory
// synchronization is done by the mechanism that transfers the
// pointer between threads.
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(this);
return mValue.fetch_add(1, std::memory_order_relaxed) + 1;
}
@ -134,7 +134,7 @@ public:
// release semantics so that prior writes on this thread are visible
// to the thread that destroys the object when it reads mValue with
// acquire semantics.
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(this);
T result = mValue.fetch_sub(1, std::memory_order_release) - 1;
if (result == 0) {
// We're going to destroy the object on this thread, so we need
@ -149,7 +149,7 @@ public:
// This method is only called in debug builds, so we're not too concerned
// about its performance.
void operator=(const T& aValue) {
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(this);
mValue.store(aValue, std::memory_order_seq_cst);
}
@ -157,7 +157,7 @@ public:
{
// Use acquire semantics since we're not sure what the caller is
// doing.
AutoRecordAtomicAccess<Recording> record;
AutoRecordAtomicAccess<Recording> record(this);
return mValue.load(std::memory_order_acquire);
}

Просмотреть файл

@ -339,7 +339,7 @@ public:
// first increment on that thread. The necessary memory
// synchronization is done by the mechanism that transfers the
// pointer between threads.
detail::AutoRecordAtomicAccess<Recording> record;
detail::AutoRecordAtomicAccess<Recording> record(this);
return mValue.fetch_add(1, std::memory_order_relaxed) + 1;
}
MOZ_ALWAYS_INLINE nsrefcnt operator--()
@ -348,7 +348,7 @@ public:
// release semantics so that prior writes on this thread are visible
// to the thread that destroys the object when it reads mValue with
// acquire semantics.
detail::AutoRecordAtomicAccess<Recording> record;
detail::AutoRecordAtomicAccess<Recording> record(this);
nsrefcnt result = mValue.fetch_sub(1, std::memory_order_release) - 1;
if (result == 0) {
// We're going to destroy the object on this thread, so we need
@ -364,7 +364,7 @@ public:
{
// Use release semantics since we're not sure what the caller is
// doing.
detail::AutoRecordAtomicAccess<Recording> record;
detail::AutoRecordAtomicAccess<Recording> record(this);
mValue.store(aValue, std::memory_order_release);
return aValue;
}
@ -373,7 +373,7 @@ public:
{
// Use acquire semantics since we're not sure what the caller is
// doing.
detail::AutoRecordAtomicAccess<Recording> record;
detail::AutoRecordAtomicAccess<Recording> record(this);
return mValue.load(std::memory_order_acquire);
}