Bug 1752870 - Filter code ranges before searching. r=rhunt

When searching a lazy stub segment for the code range that holds a
particular PC value, we can quickly exclude segments that are
guaranteed not to match by comparing the PC to the values at the
segment's endpoints - the code ranges in a segment are sorted, and
this filtering will cause the search to skip most segments.  This very
significantly reduces the time spent in the search.

Differential Revision: https://phabricator.services.mozilla.com/D137518
This commit is contained in:
Lars T Hansen 2022-02-02 14:56:59 +00:00
Родитель 7e909fb3ff
Коммит 0e05bd1298
1 изменённых файлов: 5 добавлений и 0 удалений

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

@ -680,6 +680,11 @@ bool LazyStubSegment::addIndirectStubs(
}
const CodeRange* LazyStubSegment::lookupRange(const void* pc) const {
// Do not search if the search will not find anything. There can be many
// segments, each with many entries.
if (pc < base() || pc >= base() + length()) {
return nullptr;
}
return LookupInSorted(codeRanges_,
CodeRange::OffsetInCode((uint8_t*)pc - base()));
}