Skip to content

Commit db0db5c

Browse files
author
Mihai Alexandru Michis
committedFeb 12, 2020
Backed out changeset f3d9fbb2daf1 (bug 1613985) for causing hazard bustages on Linux.
CLOSED TREE
1 parent 9f94033 commit db0db5c

20 files changed

+95
-48
lines changed
 

‎mfbt/Array.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Array {
2828
using ElementType = T;
2929
static constexpr size_t Length = _Length;
3030

31-
Array() = default;
31+
Array() {}
3232

3333
template <typename... Args>
3434
MOZ_IMPLICIT constexpr Array(Args&&... aArgs)

‎mfbt/Atomics.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ struct AutoRecordAtomicAccess;
160160
template <>
161161
struct AutoRecordAtomicAccess<recordreplay::Behavior::DontPreserve> {
162162
explicit AutoRecordAtomicAccess(const void* aValue) {}
163-
~AutoRecordAtomicAccess() = default;
163+
~AutoRecordAtomicAccess() {}
164164
};
165165

166166
template <>

‎mfbt/DebugOnly.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class MOZ_STACK_CLASS DebugOnly {
4141
#ifdef DEBUG
4242
T value;
4343

44-
DebugOnly() = default;
44+
DebugOnly() {}
4545
MOZ_IMPLICIT DebugOnly(const T& aOther) : value(aOther) {}
4646
DebugOnly(const DebugOnly& aOther) : value(aOther.value) {}
4747
DebugOnly& operator=(const T& aRhs) {
@@ -65,7 +65,7 @@ class MOZ_STACK_CLASS DebugOnly {
6565
const T& operator->() const { return value; }
6666

6767
#else
68-
DebugOnly() = default;
68+
DebugOnly() {}
6969
MOZ_IMPLICIT DebugOnly(const T&) {}
7070
DebugOnly(const DebugOnly&) {}
7171
DebugOnly& operator=(const T&) { return *this; }
@@ -79,7 +79,7 @@ class MOZ_STACK_CLASS DebugOnly {
7979
#endif
8080

8181
/*
82-
* DebugOnly must always have a user-defined destructor or else it will
82+
* DebugOnly must always have a destructor or else it will
8383
* generate "unused variable" warnings, exactly what it's intended
8484
* to avoid!
8585
*/

‎mfbt/EnumeratedArray.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class EnumeratedArray {
5050
ArrayType mArray;
5151

5252
public:
53-
EnumeratedArray() = default;
53+
EnumeratedArray() {}
5454

5555
template <typename... Args>
5656
MOZ_IMPLICIT constexpr EnumeratedArray(Args&&... aArgs)

‎mfbt/HashTable.h

+18-8
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,11 @@ class HashMap {
178178
explicit HashMap(uint32_t aLen) : mImpl(AllocPolicy(), aLen) {}
179179

180180
// HashMap is movable.
181-
HashMap(HashMap&& aRhs) = default;
182-
HashMap& operator=(HashMap&& aRhs) = default;
181+
HashMap(HashMap&& aRhs) : mImpl(std::move(aRhs.mImpl)) {}
182+
void operator=(HashMap&& aRhs) {
183+
MOZ_ASSERT(this != &aRhs, "self-move assignment is prohibited");
184+
mImpl = std::move(aRhs.mImpl);
185+
}
183186

184187
// -- Status and sizing ----------------------------------------------------
185188

@@ -460,8 +463,11 @@ class HashSet {
460463
explicit HashSet(uint32_t aLen) : mImpl(AllocPolicy(), aLen) {}
461464

462465
// HashSet is movable.
463-
HashSet(HashSet&& aRhs) = default;
464-
HashSet& operator=(HashSet&& aRhs) = default;
466+
HashSet(HashSet&& aRhs) : mImpl(std::move(aRhs.mImpl)) {}
467+
void operator=(HashSet&& aRhs) {
468+
MOZ_ASSERT(this != &aRhs, "self-move assignment is prohibited");
469+
mImpl = std::move(aRhs.mImpl);
470+
}
465471

466472
// -- Status and sizing ----------------------------------------------------
467473

@@ -905,8 +911,13 @@ class HashMapEntry {
905911
: key_(std::forward<KeyInput>(aKey)),
906912
value_(std::forward<ValueInput>(aValue)) {}
907913

908-
HashMapEntry(HashMapEntry&& aRhs) = default;
909-
HashMapEntry& operator=(HashMapEntry&& aRhs) = default;
914+
HashMapEntry(HashMapEntry&& aRhs)
915+
: key_(std::move(aRhs.key_)), value_(std::move(aRhs.value_)) {}
916+
917+
void operator=(HashMapEntry&& aRhs) {
918+
key_ = std::move(aRhs.key_);
919+
value_ = std::move(aRhs.value_);
920+
}
910921

911922
using KeyType = Key;
912923
using ValueType = Value;
@@ -1503,14 +1514,13 @@ class HashTable : private AllocPolicy {
15031514

15041515
// HashTable is movable
15051516
HashTable(HashTable&& aRhs) : AllocPolicy(std::move(aRhs)) { moveFrom(aRhs); }
1506-
HashTable& operator=(HashTable&& aRhs) {
1517+
void operator=(HashTable&& aRhs) {
15071518
MOZ_ASSERT(this != &aRhs, "self-move assignment is prohibited");
15081519
if (mTable) {
15091520
destroyTable(*this, mTable, capacity());
15101521
}
15111522
AllocPolicy::operator=(std::move(aRhs));
15121523
moveFrom(aRhs);
1513-
return *this;
15141524
}
15151525

15161526
private:

‎mfbt/JSONWriter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace mozilla {
110110
class JSONWriteFunc {
111111
public:
112112
virtual void Write(const char* aStr) = 0;
113-
virtual ~JSONWriteFunc() = default;
113+
virtual ~JSONWriteFunc() {}
114114
};
115115

116116
// Ideally this would be within |EscapedString| but when compiling with GCC

‎mfbt/LinkedList.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,10 @@ class AutoCleanLinkedList : public LinkedList<T> {
620620
public:
621621
~AutoCleanLinkedList() { clear(); }
622622

623-
AutoCleanLinkedList& operator=(AutoCleanLinkedList&& aOther) = default;
623+
AutoCleanLinkedList& operator=(AutoCleanLinkedList&& aOther) {
624+
LinkedList<T>::operator=(std::forward<LinkedList<T>>(aOther));
625+
return *this;
626+
}
624627

625628
void clear() {
626629
while (ClientType element = this->popFirst()) {

‎mfbt/Opaque.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Opaque final {
2626
T mValue;
2727

2828
public:
29-
Opaque() = default;
29+
Opaque() {}
3030
explicit Opaque(T aValue) : mValue(aValue) {}
3131

3232
bool operator==(const Opaque& aOther) const {

‎mfbt/Pair.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,20 @@ struct Pair : private detail::PairHelper<A, B> {
142142
Pair(AArg&& aA, BArg&& aB)
143143
: Base(std::forward<AArg>(aA), std::forward<BArg>(aB)) {}
144144

145-
Pair(Pair&& aOther) = default;
145+
Pair(Pair&& aOther)
146+
: Base(std::move(aOther.first()), std::move(aOther.second())) {}
147+
146148
Pair(const Pair& aOther) = default;
147149

148-
Pair& operator=(Pair&& aOther) = default;
150+
Pair& operator=(Pair&& aOther) {
151+
MOZ_ASSERT(this != &aOther, "Self-moves are prohibited");
152+
153+
first() = std::move(aOther.first());
154+
second() = std::move(aOther.second());
155+
156+
return *this;
157+
}
158+
149159
Pair& operator=(const Pair& aOther) = default;
150160

151161
/** The A instance. */

‎mfbt/RecordReplay.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void Initialize(int aArgc, char* aArgv[]) {
138138
// Record/replay API functions can't GC, but we can't use
139139
// JS::AutoSuppressGCAnalysis here due to linking issues.
140140
struct AutoSuppressGCAnalysis {
141-
AutoSuppressGCAnalysis() = default;
141+
AutoSuppressGCAnalysis() {}
142142
~AutoSuppressGCAnalysis() {
143143
#ifdef DEBUG
144144
// Need nontrivial destructor.

‎mfbt/RollingMean.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ class RollingMean {
4444
MOZ_ASSERT(aMaxValues > 0);
4545
}
4646

47-
RollingMean& operator=(RollingMean&& aOther) = default;
47+
RollingMean& operator=(RollingMean&& aOther) {
48+
MOZ_ASSERT(this != &aOther, "self-assignment is forbidden");
49+
this->~RollingMean();
50+
new (this) RollingMean(aOther.mMaxValues);
51+
mInsertIndex = aOther.mInsertIndex;
52+
mTotal = aOther.mTotal;
53+
mValues.swap(aOther.mValues);
54+
return *this;
55+
}
4856

4957
/**
5058
* Insert a value into the rolling mean.

‎mfbt/Scoped.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ class MOZ_NON_TEMPORARY_CLASS Scoped {
174174
Super::operator=(aRhs); \
175175
return *this; \
176176
} \
177-
name& operator=(name&& aRhs) = default; \
178-
\
177+
name& operator=(name&& aRhs) { \
178+
Super::operator=(std::move(aRhs)); \
179+
return *this; \
180+
} \
179181
explicit name(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) \
180182
: Super(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT) {} \
181183
explicit name(Resource aRhs MOZ_GUARD_OBJECT_NOTIFIER_PARAM) \
@@ -184,8 +186,8 @@ class MOZ_NON_TEMPORARY_CLASS Scoped {
184186
: Super(std::move(aRhs) MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) {} \
185187
\
186188
private: \
187-
explicit name(const name&) = delete; \
188-
name& operator=(const name&) = delete; \
189+
explicit name(name&) = delete; \
190+
name& operator=(name&) = delete; \
189191
};
190192

191193
/*

‎mfbt/Span.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class extent_type {
260260

261261
static_assert(Ext >= 0, "A fixed-size Span must be >= 0 in size.");
262262

263-
constexpr extent_type() = default;
263+
constexpr extent_type() {}
264264

265265
template <index_type Other>
266266
constexpr MOZ_IMPLICIT extent_type(extent_type<Other> ext) {

‎mfbt/ThreadSafeWeakPtr.h

+13-5
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,21 @@ class ThreadSafeWeakPtr {
258258
typedef typename T::ThreadSafeWeakReference ThreadSafeWeakReference;
259259

260260
public:
261-
ThreadSafeWeakPtr() = default;
261+
ThreadSafeWeakPtr() {}
262262

263-
ThreadSafeWeakPtr& operator=(const ThreadSafeWeakPtr& aOther) = default;
264-
ThreadSafeWeakPtr(const ThreadSafeWeakPtr& aOther) = default;
263+
ThreadSafeWeakPtr& operator=(const ThreadSafeWeakPtr& aOther) {
264+
mRef = aOther.mRef;
265+
return *this;
266+
}
267+
268+
ThreadSafeWeakPtr(const ThreadSafeWeakPtr& aOther) : mRef(aOther.mRef) {}
269+
270+
ThreadSafeWeakPtr& operator=(ThreadSafeWeakPtr&& aOther) {
271+
mRef = aOther.mRef.forget();
272+
return *this;
273+
}
265274

266-
ThreadSafeWeakPtr& operator=(ThreadSafeWeakPtr&& aOther) = default;
267-
ThreadSafeWeakPtr(ThreadSafeWeakPtr&& aOther) = default;
275+
ThreadSafeWeakPtr(ThreadSafeWeakPtr&& aOther) : mRef(aOther.mRef.forget()) {}
268276

269277
ThreadSafeWeakPtr& operator=(const RefPtr<T>& aOther) {
270278
if (aOther) {

‎mfbt/UniquePtr.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ class UniquePtr<T[], D> {
474474
template <typename T>
475475
class DefaultDelete {
476476
public:
477-
constexpr DefaultDelete() = default;
477+
constexpr DefaultDelete() {}
478478

479479
template <typename U>
480480
MOZ_IMPLICIT DefaultDelete(
@@ -492,7 +492,7 @@ class DefaultDelete {
492492
template <typename T>
493493
class DefaultDelete<T[]> {
494494
public:
495-
constexpr DefaultDelete() = default;
495+
constexpr DefaultDelete() {}
496496

497497
void operator()(T* aPtr) const {
498498
static_assert(sizeof(T) > 0, "T must be complete");

‎mfbt/tests/TestRollingMean.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class MyClass {
3232

3333
class RollingMeanSuite {
3434
public:
35-
RollingMeanSuite() = default;
35+
RollingMeanSuite() {}
3636

3737
void runTests() {
3838
testZero();

‎mfbt/tests/TestSPSCQueue.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using namespace mozilla;
2323
template <typename T>
2424
class SequenceGenerator {
2525
public:
26-
SequenceGenerator() = default;
26+
SequenceGenerator() {}
2727
void Get(T* aElements, size_t aCount) {
2828
for (size_t i = 0; i < aCount; i++) {
2929
aElements[i] = static_cast<T>(mIndex);
@@ -40,7 +40,7 @@ class SequenceGenerator {
4040
template <typename T>
4141
class SequenceVerifier {
4242
public:
43-
SequenceVerifier() = default;
43+
SequenceVerifier() {}
4444
void Check(T* aElements, size_t aCount) {
4545
for (size_t i = 0; i < aCount; i++) {
4646
if (aElements[i] != static_cast<T>(mIndex)) {

‎mfbt/tests/TestTypeTraits.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ struct NE1 {
168168
};
169169
struct NE2 : virtual E1 {};
170170
struct NE3 : E2 {
171-
virtual ~NE3() = default;
171+
virtual ~NE3() {}
172172
};
173173
struct NE4 {
174174
virtual void f() {}
@@ -258,13 +258,13 @@ struct TrivialCtor1 {
258258
};
259259

260260
struct DefaultCtor0 {
261-
DefaultCtor0() = default;
261+
DefaultCtor0() {}
262262
};
263263
struct DefaultCtor1 {
264264
DefaultCtor1() = default;
265265
};
266266
struct DefaultCtor2 {
267-
DefaultCtor2() = default;
267+
DefaultCtor2() {}
268268
explicit DefaultCtor2(int) {}
269269
};
270270

@@ -276,7 +276,7 @@ struct NoDefaultCtor1 {
276276
};
277277

278278
class PrivateCtor0 {
279-
PrivateCtor0() = default;
279+
PrivateCtor0() {}
280280
};
281281
class PrivateCtor1 {
282282
PrivateCtor1() = default;

‎mfbt/tests/TestUniquePtr.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static void TestDeleterType() {
7777
typedef int* Ptr;
7878
struct Deleter {
7979
typedef Ptr pointer;
80-
Deleter() = default;
80+
Deleter() {}
8181
void operator()(int* p) { delete p; }
8282
};
8383
UniquePtr<Ptr, Deleter> u(new int, Deleter());
@@ -216,7 +216,7 @@ static size_t FreeClassCounter = 0;
216216

217217
struct FreeClass {
218218
public:
219-
FreeClass() = default;
219+
FreeClass() {}
220220

221221
void operator()(int* aPtr) {
222222
FreeClassCounter++;
@@ -366,7 +366,7 @@ static bool TestFunctionReferenceDeleter() {
366366

367367
template <typename T>
368368
struct AppendNullptrTwice {
369-
AppendNullptrTwice() = default;
369+
AppendNullptrTwice() {}
370370

371371
bool operator()(Vector<T>& vec) {
372372
CHECK(vec.append(nullptr));
@@ -481,8 +481,8 @@ static bool TestArray() {
481481
}
482482

483483
struct Q {
484-
Q() = default;
485-
Q(const Q&) = default;
484+
Q() {}
485+
Q(const Q&) {}
486486

487487
Q(Q&, char) {}
488488

‎mfbt/tests/gtest/TestMozDbg.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ using namespace mozilla;
2424
struct Number {
2525
explicit Number(int aValue) : mValue(aValue) {}
2626

27-
Number(const Number& aOther) = default;
27+
Number(const Number& aOther) : mValue(aOther.mValue) {}
2828

2929
Number(Number&& aOther) : mValue(aOther.mValue) { aOther.mValue = 0; }
3030

31-
Number& operator=(const Number& aOther) = default;
31+
Number& operator=(const Number& aOther) {
32+
mValue = aOther.mValue;
33+
return *this;
34+
}
3235

3336
Number& operator=(Number&& aOther) {
3437
mValue = aOther.mValue;
@@ -50,7 +53,10 @@ struct MoveOnly {
5053

5154
MoveOnly(MoveOnly&& aOther) : mValue(aOther.mValue) { aOther.mValue = 0; }
5255

53-
MoveOnly& operator=(MoveOnly& aOther) = default;
56+
MoveOnly& operator=(MoveOnly& aOther) {
57+
mValue = aOther.mValue;
58+
return *this;
59+
}
5460

5561
MoveOnly& operator=(MoveOnly&& aOther) {
5662
mValue = aOther.mValue;

0 commit comments

Comments
 (0)
Failed to load comments.