summaryrefslogtreecommitdiff
path: root/compiler/optimizing/intrinsics_arm64.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_arm64.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_arm64.cc')
-rw-r--r--compiler/optimizing/intrinsics_arm64.cc52
1 files changed, 17 insertions, 35 deletions
diff --git a/compiler/optimizing/intrinsics_arm64.cc b/compiler/optimizing/intrinsics_arm64.cc
index 01138ff9d9..c6df9e2e4d 100644
--- a/compiler/optimizing/intrinsics_arm64.cc
+++ b/compiler/optimizing/intrinsics_arm64.cc
@@ -103,8 +103,7 @@ class ReadBarrierSystemArrayCopySlowPathARM64 : public SlowPathCodeARM64 {
<< "Unexpected instruction in read barrier arraycopy slow path: "
<< instruction_->DebugName();
DCHECK(instruction_->GetLocations()->Intrinsified());
- // TODO: Remove "OrNull".
- DCHECK_EQ(instruction_->AsInvokeOrNull()->GetIntrinsic(), Intrinsics::kSystemArrayCopy);
+ DCHECK_EQ(instruction_->AsInvoke()->GetIntrinsic(), Intrinsics::kSystemArrayCopy);
const int32_t element_size = DataType::Size(DataType::Type::kReference);
@@ -1898,8 +1897,7 @@ constexpr size_t kShortConstStringEqualsCutoffInBytes = 32;
static const char* GetConstString(HInstruction* candidate, uint32_t* utf16_length) {
if (candidate->IsLoadString()) {
- // TODO: Remove "OrNull".
- HLoadString* load_string = candidate->AsLoadStringOrNull();
+ HLoadString* load_string = candidate->AsLoadString();
const DexFile& dex_file = load_string->GetDexFile();
return dex_file.StringDataAndUtf16LengthByIdx(load_string->GetStringIndex(), utf16_length);
}
@@ -2109,8 +2107,7 @@ static void GenerateVisitStringIndexOf(HInvoke* invoke,
SlowPathCodeARM64* slow_path = nullptr;
HInstruction* code_point = invoke->InputAt(1);
if (code_point->IsIntConstant()) {
- // TODO: Remove "OrNull".
- if (static_cast<uint32_t>(code_point->AsIntConstantOrNull()->GetValue()) > 0xFFFFU) {
+ if (static_cast<uint32_t>(code_point->AsIntConstant()->GetValue()) > 0xFFFFU) {
// Always needs the slow-path. We could directly dispatch to it, but this case should be
// rare, so for simplicity just put the full slow-path down and branch unconditionally.
slow_path = new (codegen->GetScopedAllocator()) IntrinsicSlowPathARM64(invoke);
@@ -2641,8 +2638,7 @@ static void CheckSystemArrayCopyPosition(MacroAssembler* masm,
bool length_is_input_length = false) {
const int32_t length_offset = mirror::Array::LengthOffset().Int32Value();
if (pos.IsConstant()) {
- // TODO: Remove "OrNull".
- int32_t pos_const = pos.GetConstant()->AsIntConstantOrNull()->GetValue();
+ int32_t pos_const = pos.GetConstant()->AsIntConstant()->GetValue();
if (pos_const == 0) {
if (!length_is_input_length) {
// Check that length(input) >= length.
@@ -2698,8 +2694,7 @@ static void GenSystemArrayCopyAddresses(MacroAssembler* masm,
const uint32_t data_offset = mirror::Array::DataOffset(element_size).Uint32Value();
if (src_pos.IsConstant()) {
- // TODO: Remove "OrNull".
- int32_t constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
+ int32_t constant = src_pos.GetConstant()->AsIntConstant()->GetValue();
__ Add(src_base, src, element_size * constant + data_offset);
} else {
__ Add(src_base, src, data_offset);
@@ -2707,8 +2702,7 @@ static void GenSystemArrayCopyAddresses(MacroAssembler* masm,
}
if (dst_pos.IsConstant()) {
- // TODO: Remove "OrNull".
- int32_t constant = dst_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
+ int32_t constant = dst_pos.GetConstant()->AsIntConstant()->GetValue();
__ Add(dst_base, dst, element_size * constant + data_offset);
} else {
__ Add(dst_base, dst, data_offset);
@@ -2717,8 +2711,7 @@ static void GenSystemArrayCopyAddresses(MacroAssembler* masm,
if (src_end.IsValid()) {
if (copy_length.IsConstant()) {
- // TODO: Remove "OrNull".
- int32_t constant = copy_length.GetConstant()->AsIntConstantOrNull()->GetValue();
+ int32_t constant = copy_length.GetConstant()->AsIntConstant()->GetValue();
__ Add(src_end, src_base, element_size * constant);
} else {
__ Add(src_end, src_base, Operand(XRegisterFrom(copy_length), LSL, element_size_shift));
@@ -2759,11 +2752,8 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopyChar(HInvoke* invoke) {
__ B(slow_path->GetEntryLabel(), hi);
} else {
// We have already checked in the LocationsBuilder for the constant case.
- // TODO: Remove "OrNull".
- DCHECK_GE(length.GetConstant()->AsIntConstantOrNull()->GetValue(), 0);
- // TODO: Remove "OrNull".
- DCHECK_LE(length.GetConstant()->AsIntConstantOrNull()->GetValue(),
- kSystemArrayCopyCharThreshold);
+ DCHECK_GE(length.GetConstant()->AsIntConstant()->GetValue(), 0);
+ DCHECK_LE(length.GetConstant()->AsIntConstant()->GetValue(), kSystemArrayCopyCharThreshold);
}
Register src_curr_addr = WRegisterFrom(locations->GetTemp(0));
@@ -2867,8 +2857,7 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopyChar(HInvoke* invoke) {
};
if (length.IsConstant()) {
- // TODO: Remove "OrNull".
- const int32_t constant_length = length.GetConstant()->AsIntConstantOrNull()->GetValue();
+ const int32_t constant_length = length.GetConstant()->AsIntConstant()->GetValue();
if (constant_length >= unroll_threshold) {
__ Mov(length_tmp, constant_length - chars_per_block);
emitHeadLoop();
@@ -3009,11 +2998,9 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopy(HInvoke* invoke) {
// If source and destination are the same, we go to slow path if we need to do
// forward copying.
if (src_pos.IsConstant()) {
- // TODO: Remove "OrNull".
- int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
+ int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstant()->GetValue();
if (dest_pos.IsConstant()) {
- // TODO: Remove "OrNull".
- int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
+ int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue();
if (optimizations.GetDestinationIsSource()) {
// Checked when building locations.
DCHECK_GE(src_pos_constant, dest_pos_constant);
@@ -3023,8 +3010,7 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopy(HInvoke* invoke) {
}
// Checked when building locations.
DCHECK(!optimizations.GetDestinationIsSource() ||
- // TODO: Remove "OrNull".
- (src_pos_constant >= dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue()));
+ (src_pos_constant >= dest_pos.GetConstant()->AsIntConstant()->GetValue()));
} else {
if (!optimizations.GetDestinationIsSource()) {
__ Cmp(src, dest);
@@ -3297,8 +3283,7 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopy(HInvoke* invoke) {
__ Cbnz(temp2, intrinsic_slow_path->GetEntryLabel());
}
- // TODO: Remove "OrNull".
- if (length.IsConstant() && length.GetConstant()->AsIntConstantOrNull()->GetValue() == 0) {
+ if (length.IsConstant() && length.GetConstant()->AsIntConstant()->GetValue() == 0) {
// Null constant length: not need to emit the loop code at all.
} else {
Register src_curr_addr = temp1.X();
@@ -3505,8 +3490,7 @@ void IntrinsicCodeGeneratorARM64::VisitIntegerValueOf(HInvoke* invoke) {
CheckEntrypointTypes<kQuickAllocObjectWithChecks, void*, mirror::Class*>();
};
if (invoke->InputAt(0)->IsConstant()) {
- // TODO: Remove "OrNull".
- int32_t value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue();
+ int32_t value = invoke->InputAt(0)->AsIntConstant()->GetValue();
if (static_cast<uint32_t>(value - info.low) < info.length) {
// Just embed the j.l.Integer in the code.
DCHECK_NE(info.value_boot_image_reference, IntegerValueOfInfo::kInvalidReference);
@@ -3881,8 +3865,7 @@ void IntrinsicCodeGeneratorARM64::VisitCRC32UpdateBytes(HInvoke* invoke) {
Register array = XRegisterFrom(locations->InAt(1));
Location offset = locations->InAt(2);
if (offset.IsConstant()) {
- // TODO: Remove "OrNull".
- int32_t offset_value = offset.GetConstant()->AsIntConstantOrNull()->GetValue();
+ int32_t offset_value = offset.GetConstant()->AsIntConstant()->GetValue();
__ Add(ptr, array, array_data_offset + offset_value);
} else {
__ Add(ptr, array, array_data_offset);
@@ -4379,8 +4362,7 @@ class VarHandleSlowPathARM64 : public IntrinsicSlowPathARM64 {
private:
HInvoke* GetInvoke() const {
- // TODO: Remove "OrNull".
- return GetInstruction()->AsInvokeOrNull();
+ return GetInstruction()->AsInvoke();
}
mirror::VarHandle::AccessModeTemplate GetAccessModeTemplate() const {