Bug 1682504 part 2 - Remove ICStubIterator and ICStubConstIterator. r=iain

These iterators are fairly complicated (the patch deletes > 130 lines of code) and
they were only used in a few places.

This simplifies the next patch a bit.

Depends on D114721

Differential Revision: https://phabricator.services.mozilla.com/D114722
This commit is contained in:
Jan de Mooij 2021-05-12 05:33:14 +00:00
Родитель b88dab62ca
Коммит 6b47f74c17
3 изменённых файлов: 14 добавлений и 147 удалений

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

@ -1920,11 +1920,15 @@ bool BaselineCacheIRCompiler::init(CacheKind kind) {
return true;
}
static void ResetEnteredCounts(ICFallbackStub* stub) {
for (ICStubIterator iter = stub->beginChain(); *iter != stub; iter++) {
iter->toCacheIRStub()->resetEnteredCount();
static void ResetEnteredCounts(ICFallbackStub* fallback) {
ICStub* stub = fallback->icEntry()->firstStub();
while (true) {
stub->resetEnteredCount();
if (stub->isFallback()) {
return;
}
stub = stub->toCacheIRStub()->next();
}
stub->resetEnteredCount();
}
static ICStubSpace* StubSpaceForStub(bool makesGCCalls, JSScript* script,
@ -2005,8 +2009,8 @@ ICCacheIRStub* js::jit::AttachBaselineCacheIRStub(
// Ensure we don't attach duplicate stubs. This can happen if a stub failed
// for some reason and the IR generator doesn't check for exactly the same
// conditions.
for (ICStubConstIterator iter = stub->beginChainConst(); *iter != stub;
iter++) {
for (ICStub* iter = stub->icEntry()->firstStub(); iter != stub;
iter = iter->toCacheIRStub()->next()) {
auto otherStub = iter->toCacheIRStub();
if (otherStub->stubInfo() != stubInfo) {
continue;

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

@ -398,42 +398,6 @@ void ICScript::initICEntries(JSContext* cx, JSScript* script) {
MOZ_ASSERT(icEntryIndex == numICEntries());
}
ICStubConstIterator& ICStubConstIterator::operator++() {
MOZ_ASSERT(currentStub_ != nullptr);
currentStub_ = currentStub_->toCacheIRStub()->next();
return *this;
}
ICStubIterator::ICStubIterator(ICFallbackStub* fallbackStub, bool end)
: icEntry_(fallbackStub->icEntry()),
fallbackStub_(fallbackStub),
previousStub_(nullptr),
currentStub_(end ? fallbackStub : icEntry_->firstStub()),
unlinked_(false) {}
ICStubIterator& ICStubIterator::operator++() {
MOZ_ASSERT(!currentStub_->isFallback());
if (!unlinked_) {
previousStub_ = currentStub_->toCacheIRStub();
}
currentStub_ = currentStub_->toCacheIRStub()->next();
unlinked_ = false;
return *this;
}
void ICStubIterator::unlink(JSContext* cx) {
MOZ_ASSERT(currentStub_ != fallbackStub_);
MOZ_ASSERT(currentStub_->maybeNext() != nullptr);
MOZ_ASSERT(!unlinked_);
fallbackStub_->unlinkStub(cx->zone(), previousStub_,
currentStub_->toCacheIRStub());
// Mark the current iterator position as unlinked, so operator++ works
// properly.
unlinked_ = true;
}
bool ICCacheIRStub::makesGCCalls() const { return stubInfo()->makesGCCalls(); }
void ICFallbackStub::trackNotAttached() { state().trackNotAttached(); }
@ -534,8 +498,10 @@ void ICFallbackStub::unlinkStub(Zone* zone, ICCacheIRStub* prev,
}
void ICFallbackStub::discardStubs(JSContext* cx) {
for (ICStubIterator iter = beginChain(); !iter.atEnd(); iter++) {
iter.unlink(cx);
ICStub* stub = icEntry()->firstStub();
while (stub != this) {
unlinkStub(cx->zone(), /* prev = */ nullptr, stub->toCacheIRStub());
stub = stub->toCacheIRStub()->next();
}
}

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

@ -162,103 +162,6 @@ class ICEntry {
void trace(JSTracer* trc);
};
// Constant iterator that traverses arbitrary chains of ICStubs.
// No requirements are made of the ICStub used to construct this
// iterator, aside from that the stub be part of a nullptr-terminated
// chain.
// The iterator is considered to be at its end once it has been
// incremented _past_ the last stub. Thus, if 'atEnd()' returns
// true, the '*' and '->' operations are not valid.
class ICStubConstIterator {
friend class ICStub;
friend class ICFallbackStub;
private:
ICStub* currentStub_;
public:
explicit ICStubConstIterator(ICStub* currentStub)
: currentStub_(currentStub) {}
bool operator==(const ICStubConstIterator& other) const {
return currentStub_ == other.currentStub_;
}
bool operator!=(const ICStubConstIterator& other) const {
return !(*this == other);
}
ICStubConstIterator& operator++();
ICStubConstIterator operator++(int) {
ICStubConstIterator oldThis(*this);
++(*this);
return oldThis;
}
ICStub* operator*() const {
MOZ_ASSERT(currentStub_);
return currentStub_;
}
ICStub* operator->() const {
MOZ_ASSERT(currentStub_);
return currentStub_;
}
bool atEnd() const { return currentStub_ == nullptr; }
};
// Iterator that traverses "regular" IC chains that start at an ICEntry
// and are terminated with an ICFallbackStub.
//
// The iterator is considered to be at its end once it is _at_ the
// fallback stub. Thus, unlike the ICStubConstIterator, operators
// '*' and '->' are valid even if 'atEnd()' returns true - they
// will act on the fallback stub.
//
// This iterator also allows unlinking of stubs being traversed.
// Note that 'unlink' does not implicitly advance the iterator -
// it must be advanced explicitly using '++'.
class ICStubIterator {
friend class ICFallbackStub;
private:
ICEntry* icEntry_;
ICFallbackStub* fallbackStub_;
ICCacheIRStub* previousStub_;
ICStub* currentStub_;
bool unlinked_;
explicit ICStubIterator(ICFallbackStub* fallbackStub, bool end = false);
public:
bool operator==(const ICStubIterator& other) const {
// == should only ever be called on stubs from the same chain.
MOZ_ASSERT(icEntry_ == other.icEntry_);
MOZ_ASSERT(fallbackStub_ == other.fallbackStub_);
return currentStub_ == other.currentStub_;
}
bool operator!=(const ICStubIterator& other) const {
return !(*this == other);
}
ICStubIterator& operator++();
ICStubIterator operator++(int) {
ICStubIterator oldThis(*this);
++(*this);
return oldThis;
}
ICStub* operator*() const { return currentStub_; }
ICStub* operator->() const { return currentStub_; }
bool atEnd() const { return currentStub_ == (ICStub*)fallbackStub_; }
void unlink(JSContext* cx);
};
//
// Base class for all IC stubs.
//
@ -359,12 +262,6 @@ class ICFallbackStub final : public ICStub {
// Add a new stub to the IC chain terminated by this fallback stub.
inline void addNewStub(ICCacheIRStub* stub);
ICStubConstIterator beginChainConst() const {
return ICStubConstIterator(icEntry_->firstStub());
}
ICStubIterator beginChain() { return ICStubIterator(this); }
void discardStubs(JSContext* cx);
void clearUsedByTranspiler() { state_.clearUsedByTranspiler(); }