Revert "Remove bogus fastpath from String::Equals(const StringPiece&)"
This reverts commit 8438ed31e10f3881ed92f03877d5edaca7d5b48c.
Bug: 10614658
Change-Id: I335f10a7140e1644957bc1cee21a9b310a558499
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index f824dd7..4fd9a60 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -353,41 +353,27 @@
void DexFile::InitIndex() {
CHECK_EQ(index_.size(), 0U) << GetLocation();
-bool debug_file = (GetLocation() == "/data/app/com.eclipsim.gpsstatus2-1.apk");
for (size_t i = 0; i < NumClassDefs(); ++i) {
const ClassDef& class_def = GetClassDef(i);
const char* descriptor = GetClassDescriptor(class_def);
-bool debug_log = (strcmp(descriptor, "Lo/coN;") == 0);
-if (debug_log) { LG << this << " XXX bdc DexFile::InitIndex " << GetLocation() << " i=" << i << " descriptor=" << descriptor << " strlen(descriptor)=" << strlen(descriptor); }
index_.Put(descriptor, i);
}
-if (debug_file) { LG << this << " XXX bdc DexFile::InitIndex " << GetLocation() << " index_.size()=" << index_.size(); }
}
bool DexFile::FindClassDefIndex(const StringPiece& descriptor, uint32_t& idx) const {
-bool debug_file = (GetLocation() == "/data/app/com.eclipsim.gpsstatus2-1.apk");
-bool debug_log = (descriptor == "Lo/coN;");
Index::const_iterator it = index_.find(descriptor);
if (it == index_.end()) {
-if (debug_log) { LG << this << " XXX bdc DexFile::FindClassDefIndex(" << descriptor << ") => false debug_log=" << debug_log << " descriptor.size()=" << descriptor.size() << " " << strlen("Lo/coN;"); }
-if (debug_file) { LG << this << " XXX bdc DexFile::FindClassDefIndex " << GetLocation() << " index_.size()=" << index_.size(); }
return false;
}
idx = it->second;
-if (debug_log) { LG << this << " XXX bdc DexFile::FindClassDefIndex(" << descriptor << ") => true idx=" << idx; }
return true;
}
const DexFile::ClassDef* DexFile::FindClassDef(const StringPiece& descriptor) const {
uint32_t idx;
-bool debug_file = (GetLocation() == "/data/app/com.eclipsim.gpsstatus2-1.apk");
-bool debug_log = (descriptor == "Lo/coN;");
if (FindClassDefIndex(descriptor, idx)) {
-if (debug_log) { LG << this << " XXX bdc DexFile::FindClassDef(" << descriptor << ") => success"; }
return &GetClassDef(idx);
}
-if (debug_log) { LG << this << " XXX bdc DexFile::FindClassDef(" << descriptor << ") => NULL debug_log=" << debug_log << " descriptor.size()=" << descriptor.size() << " " << strlen("Lo/coN;"); }
-if (debug_file) { LG << this << " XXX bdc DexFile::FindClassDef " << GetLocation() << " index_.size()=" << index_.size(); }
return NULL;
}
diff --git a/runtime/entrypoints/quick/quick_throw_entrypoints.cc b/runtime/entrypoints/quick/quick_throw_entrypoints.cc
index 2b060f8..f67b2fc 100644
--- a/runtime/entrypoints/quick/quick_throw_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_throw_entrypoints.cc
@@ -58,7 +58,6 @@
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll);
ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- LG << "artThrowNullPointerExceptionFromCode GetDexPc=0x" << std::hex << throw_location.GetDexPc();
ThrowNullPointerExceptionFromDexPC(throw_location);
self->QuickDeliverException();
}
diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc
index b8765af..814305c 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -42,27 +42,26 @@
class ObjectTest : public CommonTest {
protected:
- void AssertString(int32_t expected_utf16_length,
+ void AssertString(int32_t length,
const char* utf8_in,
const char* utf16_expected_le,
int32_t expected_hash)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- UniquePtr<uint16_t[]> utf16_expected(new uint16_t[expected_utf16_length]);
- for (int32_t i = 0; i < expected_utf16_length; i++) {
+ UniquePtr<uint16_t[]> utf16_expected(new uint16_t[length]);
+ for (int32_t i = 0; i < length; i++) {
uint16_t ch = (((utf16_expected_le[i*2 + 0] & 0xff) << 8) |
((utf16_expected_le[i*2 + 1] & 0xff) << 0));
utf16_expected[i] = ch;
}
Thread* self = Thread::Current();
- SirtRef<String> string(self, String::AllocFromModifiedUtf8(self, expected_utf16_length, utf8_in));
- ASSERT_EQ(expected_utf16_length, string->GetLength());
+ SirtRef<String> string(self, String::AllocFromModifiedUtf8(self, length, utf8_in));
+ ASSERT_EQ(length, string->GetLength());
ASSERT_TRUE(string->GetCharArray() != NULL);
ASSERT_TRUE(string->GetCharArray()->GetData() != NULL);
- // strlen is necessary because the 1-character string "\x00\x00" is interpreted as ""
- ASSERT_TRUE(string->Equals(utf8_in) || (expected_utf16_length == 1 && strlen(utf8_in) == 0));
- ASSERT_TRUE(string->Equals(StringPiece(utf8_in)) || (expected_utf16_length == 1 && strlen(utf8_in) == 0));
- for (int32_t i = 0; i < expected_utf16_length; i++) {
+ // strlen is necessary because the 1-character string "\0" is interpreted as ""
+ ASSERT_TRUE(string->Equals(utf8_in) || length != static_cast<int32_t>(strlen(utf8_in)));
+ for (int32_t i = 0; i < length; i++) {
EXPECT_EQ(utf16_expected[i], string->CharAt(i));
}
EXPECT_EQ(expected_hash, string->GetHashCode());
diff --git a/runtime/mirror/string.cc b/runtime/mirror/string.cc
index f8a0e53..54ba3b0 100644
--- a/runtime/mirror/string.cc
+++ b/runtime/mirror/string.cc
@@ -224,6 +224,9 @@
}
bool String::Equals(const StringPiece& modified_utf8) const {
+ if (modified_utf8.size() != GetLength()) {
+ return false;
+ }
const char* p = modified_utf8.data();
for (int32_t i = 0; i < GetLength(); ++i) {
uint16_t ch = GetUtf16FromUtf8(&p);
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc
index a5eaad6..2f4e427 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -142,20 +142,17 @@
const DexFile* dex_file = toDexFile(cookie);
if (dex_file == NULL) {
VLOG(class_linker) << "Failed to find dex_file";
- LG << "XXX bdc Failed to find dex_file";
return NULL;
}
ScopedUtfChars class_name(env, javaName);
if (class_name.c_str() == NULL) {
- VLOG(class_linker) << "Failed to find class_name to lookup in " << dex_file->GetLocation();
- LG << "XXX bdc Failed to find class_name to lookup in " << dex_file->GetLocation();
+ VLOG(class_linker) << "Failed to find class_name";
return NULL;
}
const std::string descriptor(DotToDescriptor(class_name.c_str()));
const DexFile::ClassDef* dex_class_def = dex_file->FindClassDef(descriptor);
if (dex_class_def == NULL) {
- VLOG(class_linker) << "Failed to find dex_class_def " << descriptor << " in " << dex_file->GetLocation();
- LG << dex_file << " XXX bdc Failed to find dex_class_def " << descriptor << " in " << dex_file->GetLocation();
+ VLOG(class_linker) << "Failed to find dex_class_def";
return NULL;
}
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
@@ -163,8 +160,7 @@
mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(javaLoader);
mirror::Class* result = class_linker->DefineClass(descriptor.c_str(), class_loader, *dex_file,
*dex_class_def);
- VLOG(class_linker) << "DexFile_defineClassNative for " << " in " << dex_file->GetLocation() << descriptor << " returning " << result;
- LG << dex_file << " XXX bdc DexFile_defineClassNative for " << descriptor << " in " << dex_file->GetLocation() << " returning " << result;
+ VLOG(class_linker) << "DexFile_defineClassNative returning " << result;
return soa.AddLocalReference<jclass>(result);
}
diff --git a/runtime/reflection.cc b/runtime/reflection.cc
index 5e44a4c..3e58b4b 100644
--- a/runtime/reflection.cc
+++ b/runtime/reflection.cc
@@ -38,13 +38,6 @@
jmethodID mid = soa.Env()->FromReflectedMethod(javaMethod);
mirror::ArtMethod* m = soa.DecodeMethod(mid);
- std::string pretty_descriptor(PrettyDescriptor(m->GetDeclaringClass()));
- if (true ||
- StartsWith(pretty_descriptor, "Lcom/eclipsim/gpsstatus2/") ||
- StartsWith(pretty_descriptor, "Lo/")) {
- LG << "XXX bdc InvokeMethod reflectively calling " << PrettyMethod(m);
- }
-
mirror::Class* declaring_class = m->GetDeclaringClass();
if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(declaring_class, true, true)) {
return NULL;
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 26b9c31..a454195 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -819,8 +819,7 @@
mh.ChangeMethod(m);
const char* source_file(mh.GetDeclaringClassSourceFile());
os << "(" << (source_file != NULL ? source_file : "unavailable")
- << ":" << line_number << ")"
- << " <0x" << std::hex << GetDexPc() << ">";
+ << ":" << line_number << ")";
}
os << "\n";
if (frame_count == 0) {
@@ -1922,7 +1921,6 @@
ThrowLocation throw_location;
mirror::Throwable* exception = GetException(&throw_location);
CHECK(exception != NULL);
- LG << "XXX bdc QuickDeliverException " << PrettyMethod(throw_location.GetMethod()) << " " << std::hex << throw_location.GetDexPc();
// Don't leave exception visible while we try to find the handler, which may cause class
// resolution.
ClearException();