[compiler] Speed up mid-tier regalloc checks

This minor change in how we iterate the virtual registers speeds up the
consistency checks by a factor of more than four.

R=thibaudm@chromium.org

Bug: chromium:1271369
Change-Id: Ieb9640d52c84fabacbbcf0fea56825fb594cfc21
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3406759
Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78738}
This commit is contained in:
Clemens Backes 2022-01-21 18:54:55 +01:00 committed by V8 LUCI CQ
parent 94c17edbb7
commit 78b5ff5be5

View File

@ -1949,10 +1949,9 @@ void SinglePassRegisterAllocator::UpdateVirtualRegisterState() {
void SinglePassRegisterAllocator::CheckConsistency() {
#ifdef DEBUG
for (int virtual_register = 0;
virtual_register < data_->code()->VirtualRegisterCount();
virtual_register++) {
RegisterIndex reg = RegisterForVirtualRegister(virtual_register);
int virtual_register = -1;
for (RegisterIndex reg : virtual_register_to_reg_) {
++virtual_register;
if (!reg.is_valid()) continue;
CHECK_NOT_NULL(register_state_);
// The register must be set to allocated.
@ -1960,6 +1959,7 @@ void SinglePassRegisterAllocator::CheckConsistency() {
// reg <-> vreg linking is consistent.
CHECK_EQ(virtual_register, VirtualRegisterForRegister(reg));
}
CHECK_EQ(data_->code()->VirtualRegisterCount() - 1, virtual_register);
RegisterBitVector used_registers;
for (RegisterIndex reg : *register_state_) {