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/code_generator.h | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'compiler/optimizing/code_generator.h') diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index 59ae213960..9872efaa4a 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -552,45 +552,37 @@ class CodeGenerator : public DeletableArenaObject { static int8_t GetInt8ValueOf(HConstant* constant) { DCHECK(constant->IsIntConstant()); - // TODO: Remove "OrNull". - return constant->AsIntConstantOrNull()->GetValue(); + return constant->AsIntConstant()->GetValue(); } static int16_t GetInt16ValueOf(HConstant* constant) { DCHECK(constant->IsIntConstant()); - // TODO: Remove "OrNull". - return constant->AsIntConstantOrNull()->GetValue(); + return constant->AsIntConstant()->GetValue(); } static int32_t GetInt32ValueOf(HConstant* constant) { if (constant->IsIntConstant()) { - // TODO: Remove "OrNull". - return constant->AsIntConstantOrNull()->GetValue(); + return constant->AsIntConstant()->GetValue(); } else if (constant->IsNullConstant()) { return 0; } else { DCHECK(constant->IsFloatConstant()); - // TODO: Remove "OrNull". - return bit_cast(constant->AsFloatConstantOrNull()->GetValue()); + return bit_cast(constant->AsFloatConstant()->GetValue()); } } static int64_t GetInt64ValueOf(HConstant* constant) { if (constant->IsIntConstant()) { - // TODO: Remove "OrNull". - return constant->AsIntConstantOrNull()->GetValue(); + return constant->AsIntConstant()->GetValue(); } else if (constant->IsNullConstant()) { return 0; } else if (constant->IsFloatConstant()) { - // TODO: Remove "OrNull". - return bit_cast(constant->AsFloatConstantOrNull()->GetValue()); + return bit_cast(constant->AsFloatConstant()->GetValue()); } else if (constant->IsLongConstant()) { - // TODO: Remove "OrNull". - return constant->AsLongConstantOrNull()->GetValue(); + return constant->AsLongConstant()->GetValue(); } else { DCHECK(constant->IsDoubleConstant()); - // TODO: Remove "OrNull". - return bit_cast(constant->AsDoubleConstantOrNull()->GetValue()); + return bit_cast(constant->AsDoubleConstant()->GetValue()); } } -- cgit v1.2.3-59-g8ed1b