ARM64: Improve String.equals() intrinsic for const strings.
And add additional tests to 021-string2.
aosp_angler-userdebug:
before:
arm64 boot*.oat: 43324664
arm64 boot*.oat/string compression: 43411112
after:
arm64 boot*.oat: 43300136 (-24528)
arm64 boot*.oat/string compression: 43345464 (-65648)
The string compression code size difference drops from
86448 to 45328.
Test: m test-art-target on Nexus 6P
Test: m test-art-target on Nexus 6P with string compression enabled.
Bug: 31040547
Change-Id: I99a3777b91b248da2b0ac25abd260f9e5abb2c09
diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h
index 9b8445d..c2407d7 100644
--- a/runtime/mirror/string-inl.h
+++ b/runtime/mirror/string-inl.h
@@ -308,7 +308,7 @@
}
template<typename MemoryType>
-bool String::AllASCII(const MemoryType* const chars, const int length) {
+inline bool String::AllASCII(const MemoryType* chars, const int length) {
static_assert(std::is_unsigned<MemoryType>::value, "Expecting unsigned MemoryType");
for (int i = 0; i < length; ++i) {
// Valid ASCII characters are in range 1..0x7f. Zero is not considered ASCII
@@ -320,6 +320,13 @@
return true;
}
+inline bool String::DexFileStringAllASCII(const char* chars, const int length) {
+ // For strings from the dex file we just need to check that
+ // the terminating character is at the right position.
+ DCHECK_EQ(AllASCII(reinterpret_cast<const uint8_t*>(chars), length), chars[length] == 0);
+ return chars[length] == 0;
+}
+
} // namespace mirror
} // namespace art