Bug 1694600: Make ICScript::hash more precise r=jandem

Once the entry count of a non-first stub is greater than 0, incrementing it further won't affect our decision to transpile, so it shouldn't change the hash.

Differential Revision: https://phabricator.services.mozilla.com/D106515
This commit is contained in:
Iain Ireland 2021-02-26 21:23:36 +00:00
parent d6c95021b2
commit d270fbf50c
2 changed files with 9 additions and 8 deletions

View File

@ -676,10 +676,10 @@ JitScript* ICScript::outerJitScript() {
// different decision in WarpScriptOracle::maybeInlineIC. This means:
//
// 1. The hash will change if we attach a new stub.
// 2. The hash will change if we increment the entered count of any
// CacheIR stub other than the first.
// 3. The hash will change if we increment the entered count of the
// fallback stub.
// 2. The hash will change if the entered count of any CacheIR stub
// other than the first changes from 0.
// 3. The hash will change if the entered count of the fallback stub
// changes from 0.
//
HashNumber ICScript::hash() {
HashNumber h = 0;
@ -689,18 +689,18 @@ HashNumber ICScript::hash() {
// Hash the address of the first stub.
h = mozilla::AddToHash(h, stub);
// Hash the entered count of each subsequent CacheIRStub.
// Hash whether subsequent stubs have entry count 0.
if (!stub->isFallback()) {
stub = stub->toCacheIRStub()->next();
while (!stub->isFallback()) {
h = mozilla::AddToHash(h, stub->enteredCount());
h = mozilla::AddToHash(h, stub->enteredCount() == 0);
stub = stub->toCacheIRStub()->next();
}
}
// Hash the enteredCount of the fallback stub.
// Hash whether the fallback has entry count 0.
MOZ_ASSERT(stub->isFallback());
h = mozilla::AddToHash(h, stub->enteredCount());
h = mozilla::AddToHash(h, stub->enteredCount() == 0);
}
if (inlinedChildren_) {

View File

@ -844,6 +844,7 @@ AbortReasonOr<Ok> WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots,
// Don't optimize if there are other stubs with entered-count > 0. Counters
// are reset when a new stub is attached so this means the stub that was added
// most recently didn't handle all cases.
// If this code is changed, ICScript::hash may also need changing.
for (ICStub* next = stub->next(); next; next = next->maybeNext()) {
if (next->enteredCount() == 0) {
continue;