diff options
author | 2023-04-25 16:40:06 +0000 | |
---|---|---|
committer | 2023-04-27 10:53:55 +0000 | |
commit | cde6497d286337de2ed21c71c85157e2745b742b (patch) | |
tree | 087d790efb6987f5aab1da7cd91b89bedcdc5725 /compiler/optimizing/code_generator.h | |
parent | 79dc217688a774fc532584f6551a0aec8b45bc4a (diff) |
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
Diffstat (limited to 'compiler/optimizing/code_generator.h')
-rw-r--r-- | compiler/optimizing/code_generator.h | 24 |
1 files changed, 8 insertions, 16 deletions
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<kArenaAllocCodeGenerator> { 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<int32_t, float>(constant->AsFloatConstantOrNull()->GetValue()); + return bit_cast<int32_t, float>(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<int32_t, float>(constant->AsFloatConstantOrNull()->GetValue()); + return bit_cast<int32_t, float>(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<int64_t, double>(constant->AsDoubleConstantOrNull()->GetValue()); + return bit_cast<int64_t, double>(constant->AsDoubleConstant()->GetValue()); } } |