From cde6497d286337de2ed21c71c85157e2745b742b Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 25 Apr 2023 16:40:06 +0000 Subject: Optimizing: Add `HInstruction::As##type()`. After the old implementation was renamed in https://android-review.googlesource.com/2526708 , we introduce a new function with the old name but new behavior, just `DCHECK()`-ing the instruction kind before casting down the pointer. We change appropriate calls from `As##type##OrNull()` to `As##type()` to avoid unncessary run-time checks and reduce the size of libart-compiler.so. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 181943478 Change-Id: I025681612a77ca2157fed4886ca47f2053975d4e --- compiler/optimizing/common_arm.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'compiler/optimizing/common_arm.h') diff --git a/compiler/optimizing/common_arm.h b/compiler/optimizing/common_arm.h index 53768efad6..5f71cb906c 100644 --- a/compiler/optimizing/common_arm.h +++ b/compiler/optimizing/common_arm.h @@ -155,14 +155,12 @@ inline vixl::aarch32::DRegister DRegisterFromS(vixl::aarch32::SRegister s) { inline int32_t Int32ConstantFrom(HInstruction* instr) { if (instr->IsIntConstant()) { - // TODO: Remove "OrNull". - return instr->AsIntConstantOrNull()->GetValue(); + return instr->AsIntConstant()->GetValue(); } else if (instr->IsNullConstant()) { return 0; } else { DCHECK(instr->IsLongConstant()) << instr->DebugName(); - // TODO: Remove "OrNull". - const int64_t ret = instr->AsLongConstantOrNull()->GetValue(); + const int64_t ret = instr->AsLongConstant()->GetValue(); DCHECK_GE(ret, std::numeric_limits::min()); DCHECK_LE(ret, std::numeric_limits::max()); return ret; @@ -176,21 +174,18 @@ inline int32_t Int32ConstantFrom(Location location) { inline int64_t Int64ConstantFrom(Location location) { HConstant* instr = location.GetConstant(); if (instr->IsIntConstant()) { - // TODO: Remove "OrNull". - return instr->AsIntConstantOrNull()->GetValue(); + return instr->AsIntConstant()->GetValue(); } else if (instr->IsNullConstant()) { return 0; } else { DCHECK(instr->IsLongConstant()) << instr->DebugName(); - // TODO: Remove "OrNull". - return instr->AsLongConstantOrNull()->GetValue(); + return instr->AsLongConstant()->GetValue(); } } inline uint64_t Uint64ConstantFrom(HInstruction* instr) { DCHECK(instr->IsConstant()) << instr->DebugName(); - // TODO: Remove "OrNull". - return instr->AsConstantOrNull()->GetValueAsUint64(); + return instr->AsConstant()->GetValueAsUint64(); } inline vixl::aarch32::Operand OperandFrom(Location location, DataType::Type type) { -- cgit v1.2.3-59-g8ed1b