summaryrefslogtreecommitdiff
path: root/compiler/optimizing/intrinsics.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2023-04-25 16:40:06 +0000
committer Vladimir Marko <vmarko@google.com> 2023-04-27 10:53:55 +0000
commitcde6497d286337de2ed21c71c85157e2745b742b (patch)
tree087d790efb6987f5aab1da7cd91b89bedcdc5725 /compiler/optimizing/intrinsics.cc
parent79dc217688a774fc532584f6551a0aec8b45bc4a (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/intrinsics.cc')
-rw-r--r--compiler/optimizing/intrinsics.cc15
1 files changed, 5 insertions, 10 deletions
diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc
index f832d9c8bf..774deec438 100644
--- a/compiler/optimizing/intrinsics.cc
+++ b/compiler/optimizing/intrinsics.cc
@@ -151,8 +151,7 @@ static bool CanReferenceBootImageObjects(HInvoke* invoke, const CompilerOptions&
// 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 @@ void IntrinsicVisitor::ComputeIntegerValueOfLocations(HInvoke* invoke,
}
}
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 @@ void IntrinsicVisitor::ComputeIntegerValueOfLocations(HInvoke* invoke,
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 @@ IntrinsicVisitor::IntegerValueOfInfo IntrinsicVisitor::ComputeIntegerValueOfInfo
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 @@ IntrinsicVisitor::IntegerValueOfInfo IntrinsicVisitor::ComputeIntegerValueOfInfo
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 =