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
diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc
index f832d9c..774deec 100644
--- a/compiler/optimizing/intrinsics.cc
+++ b/compiler/optimizing/intrinsics.cc
@@ -151,8 +151,7 @@
// for AOT. This should cover both the testing config (non-PIC boot image) and codegens that
// reject PC-relative load kinds and fall back to the runtime call.
if (compiler_options.IsAotCompiler() &&
- // TODO: Remove "OrNull".
- !invoke->AsInvokeStaticOrDirectOrNull()->HasPcRelativeMethodLoadKind()) {
+ !invoke->AsInvokeStaticOrDirect()->HasPcRelativeMethodLoadKind()) {
return false;
}
if (!compiler_options.IsBootImage() &&
@@ -210,8 +209,7 @@
}
}
if (input->IsIntConstant()) {
- // TODO: Remove "OrNull".
- int32_t value = input->AsIntConstantOrNull()->GetValue();
+ int32_t value = input->AsIntConstant()->GetValue();
if (static_cast<uint32_t>(value) - static_cast<uint32_t>(low) <
static_cast<uint32_t>(high - low + 1)) {
// No call, we shall use direct pointer to the Integer object.
@@ -236,8 +234,7 @@
DCHECK(compiler_options.IsAotCompiler());
DCHECK(CheckIntegerCache(self, runtime->GetClassLinker(), boot_image_live_objects, cache));
if (input->IsIntConstant()) {
- // TODO: Remove "OrNull".
- int32_t value = input->AsIntConstantOrNull()->GetValue();
+ int32_t value = input->AsIntConstant()->GetValue();
// Retrieve the `value` from the lowest cached Integer.
ObjPtr<mirror::Object> low_integer =
IntrinsicObjects::GetIntegerValueOfObject(boot_image_live_objects, 0u);
@@ -311,8 +308,7 @@
info.length = dchecked_integral_cast<uint32_t>(high - info.low + 1);
if (invoke->InputAt(0)->IsIntConstant()) {
- // TODO: Remove "OrNull".
- int32_t input_value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue();
+ int32_t input_value = invoke->InputAt(0)->AsIntConstant()->GetValue();
uint32_t index = static_cast<uint32_t>(input_value) - static_cast<uint32_t>(info.low);
if (index < static_cast<uint32_t>(info.length)) {
info.value_boot_image_reference = IntrinsicObjects::EncodePatch(
@@ -347,8 +343,7 @@
IntrinsicObjects::GetIntegerValueOfCache(boot_image_live_objects)->GetLength());
if (invoke->InputAt(0)->IsIntConstant()) {
- // TODO: Remove "OrNull".
- int32_t input_value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue();
+ int32_t input_value = invoke->InputAt(0)->AsIntConstant()->GetValue();
uint32_t index = static_cast<uint32_t>(input_value) - static_cast<uint32_t>(info.low);
if (index < static_cast<uint32_t>(info.length)) {
ObjPtr<mirror::Object> integer =