ARM: Improve String.equals() intrinsic for const strings.
And add tests for the relevant string lengths to 021-string2
and remove obsolete inlining-prevention code from that test.
Also a minor fix of the cutoff check for arm64.
This is a follow-up to the ARM64 change
https://android-review.googlesource.com/336648 .
aosp_angler-userdebug:
before:
arm boot*.oat: 34153044
arm boot*.oat/no string compression: 34107776
after:
arm boot*.oat: 34132740 (−20304)
arm boot*.oat/no string compression: 34099508 (−8268)
The string compression code size difference drops from
45268 to 33232.
Test: m test-art-target on Nexus 6P
Test: m test-art-target on Nexus 6P with string compression disabled.
Bug: 31040547
Change-Id: I4ec73d444d9f56aaf8aa08369c830f398df2168a
diff --git a/compiler/optimizing/intrinsics_arm64.cc b/compiler/optimizing/intrinsics_arm64.cc
index e5463bf..69aaee2 100644
--- a/compiler/optimizing/intrinsics_arm64.cc
+++ b/compiler/optimizing/intrinsics_arm64.cc
@@ -1641,12 +1641,13 @@
}
// Assertions that must hold in order to compare strings 8 bytes at a time.
+ // Ok to do this because strings are zero-padded to kObjectAlignment.
DCHECK_ALIGNED(value_offset, 8);
static_assert(IsAligned<8>(kObjectAlignment), "String of odd length is not zero padded");
if (const_string != nullptr &&
- const_string_length < (is_compressed ? kShortConstStringEqualsCutoffInBytes
- : kShortConstStringEqualsCutoffInBytes / 2u)) {
+ const_string_length <= (is_compressed ? kShortConstStringEqualsCutoffInBytes
+ : kShortConstStringEqualsCutoffInBytes / 2u)) {
// Load and compare the contents. Though we know the contents of the short const string
// at compile time, materializing constants may be more code than loading from memory.
int32_t offset = value_offset;
@@ -1654,7 +1655,7 @@
RoundUp(is_compressed ? const_string_length : const_string_length * 2u, 8u);
temp = temp.X();
temp1 = temp1.X();
- while (remaining_bytes > 8u) {
+ while (remaining_bytes > sizeof(uint64_t)) {
Register temp2 = XRegisterFrom(locations->GetTemp(0));
__ Ldp(temp, temp1, MemOperand(str.X(), offset));
__ Ldp(temp2, out, MemOperand(arg.X(), offset));
@@ -1690,7 +1691,6 @@
temp1 = temp1.X();
Register temp2 = XRegisterFrom(locations->GetTemp(0));
// Loop to compare strings 8 bytes at a time starting at the front of the string.
- // Ok to do this because strings are zero-padded to kObjectAlignment.
__ Bind(&loop);
__ Ldr(out, MemOperand(str.X(), temp1));
__ Ldr(temp2, MemOperand(arg.X(), temp1));