Backed out 2 changesets (bug 1626884, bug 1627198) for bustages on ElfLoader.h CLOSED TREE

Backed out changeset b545e60f385c (bug 1627198)
Backed out changeset 16ee5dd004d3 (bug 1626884)

--HG--
extra : histedit_source : 21258c723c796773307977dabbd50de5aba6bd34
This commit is contained in:
Narcis Beleuzu 2020-04-03 21:56:38 +03:00
Родитель 367ad2118d
Коммит f6ebb84618
4 изменённых файлов: 83 добавлений и 151 удалений

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

@ -88,17 +88,10 @@ class RC {
public:
explicit RC(T aCount) : mValue(aCount) {}
RC(const RC&) = delete;
RC& operator=(const RC&) = delete;
RC(RC&&) = delete;
RC& operator=(RC&&) = delete;
T operator++() { return ++mValue; }
T operator--() { return --mValue; }
#ifdef DEBUG
void operator=(const T& aValue) { mValue = aValue; }
#endif
operator T() const { return mValue; }
@ -111,11 +104,6 @@ class RC<T, AtomicRefCount> {
public:
explicit RC(T aCount) : mValue(aCount) {}
RC(const RC&) = delete;
RC& operator=(const RC&) = delete;
RC(RC&&) = delete;
RC& operator=(RC&&) = delete;
T operator++() {
// Memory synchronization is not required when incrementing a
// reference count. The first increment of a reference count on a
@ -151,13 +139,11 @@ class RC<T, AtomicRefCount> {
return result;
}
#ifdef DEBUG
// This method is only called in debug builds, so we're not too concerned
// about its performance.
void operator=(const T& aValue) {
mValue.store(aValue, std::memory_order_seq_cst);
}
#endif
operator T() const {
// Use acquire semantics since we're not sure what the caller is
@ -173,9 +159,7 @@ template <typename T, RefCountAtomicity Atomicity>
class RefCounted {
protected:
RefCounted() : mRefCnt(0) {}
#ifdef DEBUG
~RefCounted() { MOZ_ASSERT(mRefCnt == detail::DEAD); }
#endif
public:
// Compatibility with nsRefPtr.

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

@ -442,13 +442,90 @@ class nsBaseHashtable
return Iterator(const_cast<nsBaseHashtable*>(this));
}
using typename nsTHashtable<EntryType>::iterator;
using typename nsTHashtable<EntryType>::const_iterator;
// STL-style iterators to allow the use in range-based for loops, e.g.
template <typename T>
class base_iterator
: public std::iterator<std::forward_iterator_tag, T, int32_t> {
public:
using typename std::iterator<std::forward_iterator_tag, T,
int32_t>::value_type;
using typename std::iterator<std::forward_iterator_tag, T,
int32_t>::difference_type;
using nsTHashtable<EntryType>::begin;
using nsTHashtable<EntryType>::end;
using nsTHashtable<EntryType>::cbegin;
using nsTHashtable<EntryType>::cend;
using iterator_type = base_iterator;
using const_iterator_type = base_iterator<const T>;
using EndIteratorTag = PLDHashTable::Iterator::EndIteratorTag;
base_iterator(base_iterator&& aOther) = default;
base_iterator& operator=(base_iterator&& aOther) {
// User-defined because the move assignment operator is deleted in
// PLDHashtable::Iterator.
return operator=(static_cast<const base_iterator&>(aOther));
}
base_iterator(const base_iterator& aOther)
: mIterator{aOther.mIterator.Clone()} {}
base_iterator& operator=(const base_iterator& aOther) {
// Since PLDHashTable::Iterator has no assignment operator, we destroy and
// recreate mIterator.
mIterator.~Iterator();
new (&mIterator) PLDHashTable::Iterator(aOther.mIterator.Clone());
return *this;
}
explicit base_iterator(PLDHashTable::Iterator aFrom)
: mIterator{std::move(aFrom)} {}
explicit base_iterator(const nsBaseHashtable* aTable)
: mIterator{&const_cast<nsBaseHashtable*>(aTable)->mTable} {}
base_iterator(const nsBaseHashtable* aTable, EndIteratorTag aTag)
: mIterator{&const_cast<nsBaseHashtable*>(aTable)->mTable, aTag} {}
bool operator==(const iterator_type& aRhs) const {
return mIterator == aRhs.mIterator;
}
bool operator!=(const iterator_type& aRhs) const {
return !(*this == aRhs);
}
value_type* operator->() const {
return static_cast<value_type*>(mIterator.Get());
}
value_type& operator*() const {
return *static_cast<value_type*>(mIterator.Get());
}
iterator_type& operator++() {
mIterator.Next();
return *this;
}
iterator_type operator++(int) {
iterator_type it = *this;
++*this;
return it;
}
operator const_iterator_type() const {
return const_iterator_type{mIterator.Clone()};
}
private:
PLDHashTable::Iterator mIterator;
};
using const_iterator = base_iterator<const EntryType>;
using iterator = base_iterator<EntryType>;
iterator begin() { return iterator{this}; }
const_iterator begin() const { return const_iterator{this}; }
const_iterator cbegin() const { return begin(); }
iterator end() { return iterator{this, typename iterator::EndIteratorTag{}}; }
const_iterator end() const {
return const_iterator{this, typename const_iterator::EndIteratorTag{}};
}
const_iterator cend() const { return end(); }
/**
* reset the hashtable, removing all entries

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

@ -23,81 +23,6 @@
#include "mozilla/fallible.h"
#include "nsPointerHashKeys.h"
namespace detail {
// STL-style iterators to allow the use in range-based for loops, e.g.
template <typename T>
class nsTHashtable_base_iterator
: public std::iterator<std::forward_iterator_tag, T, int32_t> {
public:
using
typename std::iterator<std::forward_iterator_tag, T, int32_t>::value_type;
using typename std::iterator<std::forward_iterator_tag, T,
int32_t>::difference_type;
using iterator_type = nsTHashtable_base_iterator;
using const_iterator_type = nsTHashtable_base_iterator<const T>;
using EndIteratorTag = PLDHashTable::Iterator::EndIteratorTag;
nsTHashtable_base_iterator(nsTHashtable_base_iterator&& aOther) = default;
nsTHashtable_base_iterator& operator=(nsTHashtable_base_iterator&& aOther) {
// User-defined because the move assignment operator is deleted in
// PLDHashtable::Iterator.
return operator=(static_cast<const nsTHashtable_base_iterator&>(aOther));
}
nsTHashtable_base_iterator(const nsTHashtable_base_iterator& aOther)
: mIterator{aOther.mIterator.Clone()} {}
nsTHashtable_base_iterator& operator=(
const nsTHashtable_base_iterator& aOther) {
// Since PLDHashTable::Iterator has no assignment operator, we destroy and
// recreate mIterator.
mIterator.~Iterator();
new (&mIterator) PLDHashTable::Iterator(aOther.mIterator.Clone());
return *this;
}
explicit nsTHashtable_base_iterator(PLDHashTable::Iterator aFrom)
: mIterator{std::move(aFrom)} {}
explicit nsTHashtable_base_iterator(const PLDHashTable& aTable)
: mIterator{&const_cast<PLDHashTable&>(aTable)} {}
nsTHashtable_base_iterator(const PLDHashTable& aTable, EndIteratorTag aTag)
: mIterator{&const_cast<PLDHashTable&>(aTable), aTag} {}
bool operator==(const iterator_type& aRhs) const {
return mIterator == aRhs.mIterator;
}
bool operator!=(const iterator_type& aRhs) const { return !(*this == aRhs); }
value_type* operator->() const {
return static_cast<value_type*>(mIterator.Get());
}
value_type& operator*() const {
return *static_cast<value_type*>(mIterator.Get());
}
iterator_type& operator++() {
mIterator.Next();
return *this;
}
iterator_type operator++(int) {
iterator_type it = *this;
++*this;
return it;
}
operator const_iterator_type() const {
return const_iterator_type{mIterator.Clone()};
}
private:
PLDHashTable::Iterator mIterator;
};
} // namespace detail
/**
* a base class for templated hashtables.
*
@ -327,20 +252,6 @@ class MOZ_NEEDS_NO_VTABLE_TYPE nsTHashtable {
return Iterator(const_cast<nsTHashtable*>(this));
}
using const_iterator = ::detail::nsTHashtable_base_iterator<const EntryType>;
using iterator = ::detail::nsTHashtable_base_iterator<EntryType>;
iterator begin() { return iterator{mTable}; }
const_iterator begin() const { return const_iterator{mTable}; }
const_iterator cbegin() const { return begin(); }
iterator end() {
return iterator{mTable, typename iterator::EndIteratorTag{}};
}
const_iterator end() const {
return const_iterator{mTable, typename const_iterator::EndIteratorTag{}};
}
const_iterator cend() const { return end(); }
/**
* Remove all entries, return hashtable to "pristine" state. It's
* conceptually the same as calling the destructor and then re-calling the
@ -656,20 +567,6 @@ class nsTHashtable<nsPtrHashKey<T>>
return Iterator(const_cast<nsTHashtable*>(this));
}
using const_iterator = ::detail::nsTHashtable_base_iterator<const EntryType>;
using iterator = ::detail::nsTHashtable_base_iterator<EntryType>;
iterator begin() { return iterator{mTable}; }
const_iterator begin() const { return const_iterator{mTable}; }
const_iterator cbegin() const { return begin(); }
iterator end() {
return iterator{mTable, typename iterator::EndIteratorTag{}};
}
const_iterator end() const {
return const_iterator{mTable, typename const_iterator::EndIteratorTag{}};
}
const_iterator cend() const { return end(); }
void SwapElements(nsTHashtable& aOther) { Base::SwapElements(aOther); }
};

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

@ -139,19 +139,6 @@ static void testTHashtable(nsTHashtable<EntityToUnicodeEntry>& hash,
uint32_t count = nsTIterPrint(hash);
EXPECT_EQ(count, numEntries);
for (const auto& entry :
const_cast<const nsTHashtable<EntityToUnicodeEntry>&>(hash)) {
static_assert(std::is_same_v<decltype(entry), const EntityToUnicodeEntry&>);
}
for (auto& entry : hash) {
static_assert(std::is_same_v<decltype(entry), EntityToUnicodeEntry&>);
}
EXPECT_EQ(numEntries == ENTITY_COUNT ? 6 : 0,
std::count_if(hash.cbegin(), hash.cend(), [](const auto& entry) {
return entry.mNode->mUnicode >= 170;
}));
}
//
@ -281,19 +268,6 @@ TEST(Hashtable, THashtable)
ASSERT_EQ(count, uint32_t(0));
}
TEST(Hashtable, PtrHashtable)
{
nsTHashtable<nsPtrHashKey<int>> hash;
for (const auto& entry :
const_cast<const nsTHashtable<nsPtrHashKey<int>>&>(hash)) {
static_assert(std::is_same_v<decltype(entry), const nsPtrHashKey<int>&>);
}
for (auto& entry : hash) {
static_assert(std::is_same_v<decltype(entry), nsPtrHashKey<int>&>);
}
}
TEST(Hashtable, Move)
{
const void* kPtr = reinterpret_cast<void*>(static_cast<uintptr_t>(0xbadc0de));