[liftoff] Mark tagged safepoint slots in reversed order

Setting the highest bit first saves cost for repeatedly growing the
underlying bitvector.

R=jkummerow@chromium.org

Bug: v8:13063
Change-Id: Ic324caa20c91dd6f55760944c3dafe7f1dc018b4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3776340
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81849}
This commit is contained in:
Clemens Backes 2022-07-20 10:54:35 +02:00 committed by V8 LUCI CQ
parent 3c984ee9ee
commit 9b913366d4
2 changed files with 9 additions and 1 deletions

View File

@ -100,6 +100,12 @@ class SmallVector {
T* end() { return end_; }
const T* end() const { return end_; }
auto rbegin() { return std::reverse_iterator{end_}; }
auto rbegin() const { return std::reverse_iterator{end_}; }
auto rend() { return std::reverse_iterator{begin_}; }
auto rend() const { return std::reverse_iterator{begin_}; }
size_t size() const { return end_ - begin_; }
bool empty() const { return end_ == begin_; }
size_t capacity() const { return end_of_storage_ - begin_; }

View File

@ -569,7 +569,9 @@ void LiftoffAssembler::CacheState::GetTaggedSlotsForOOLCode(
void LiftoffAssembler::CacheState::DefineSafepoint(
SafepointTableBuilder::Safepoint& safepoint) {
for (const auto& slot : stack_state) {
// Go in reversed order to set the higher bits first; this avoids cost for
// growing the underlying bitvector.
for (const auto& slot : base::Reversed(stack_state)) {
if (is_reference(slot.kind())) {
DCHECK(slot.is_stack());
safepoint.DefineTaggedStackSlot(GetSafepointIndexForStackSlot(slot));