From 8082a8f51a8bf7e04133eb80de17ce73cc034086 Mon Sep 17 00:00:00 2001 From: Clemens Backes Date: Wed, 1 Feb 2023 15:31:53 +0100 Subject: [PATCH] [liftoff] Add some more assumptions In particular, {CountTrailingZeros} can skip a dynamic check if it knows that the input is not zero. R=ahaas@chromium.org Bug: v8:13565, v8:13673 Change-Id: I46d4fea2952d22f57b0695f5db690d6fefd7c1ad Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4212401 Commit-Queue: Clemens Backes Reviewed-by: Andreas Haas Cr-Commit-Position: refs/heads/main@{#85597} --- src/codegen/register-base.h | 2 +- src/wasm/baseline/liftoff-register.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/codegen/register-base.h b/src/codegen/register-base.h index 10bdc759ba..6d9432360f 100644 --- a/src/codegen/register-base.h +++ b/src/codegen/register-base.h @@ -34,7 +34,7 @@ class RegisterBase { static constexpr SubType no_reg() { return SubType{kCode_no_reg}; } static constexpr SubType from_code(int8_t code) { - DCHECK(base::IsInRange(static_cast(code), 0, kNumRegisters - 1)); + V8_ASSUME(code >= 0 && code < kNumRegisters); return SubType{code}; } diff --git a/src/wasm/baseline/liftoff-register.h b/src/wasm/baseline/liftoff-register.h index ea7eaec235..6bc3652d16 100644 --- a/src/wasm/baseline/liftoff-register.h +++ b/src/wasm/baseline/liftoff-register.h @@ -446,13 +446,13 @@ class LiftoffRegList { } LiftoffRegister GetFirstRegSet() const { - DCHECK(!is_empty()); + V8_ASSUME(regs_ != 0); int first_code = base::bits::CountTrailingZeros(regs_); return LiftoffRegister::from_liftoff_code(first_code); } LiftoffRegister GetLastRegSet() const { - DCHECK(!is_empty()); + V8_ASSUME(regs_ != 0); int last_code = 8 * sizeof(regs_) - 1 - base::bits::CountLeadingZeros(regs_); return LiftoffRegister::from_liftoff_code(last_code);