Remove bogus fastpath from String::Equals(const StringPiece&)

Bug: 10614658
Change-Id: I907ec77a65c1ae29e800356abdf755a457620081
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 4fd9a60..f824dd7 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -353,27 +353,41 @@
 
 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 f67b2fc..2b060f8 100644
--- a/runtime/entrypoints/quick/quick_throw_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_throw_entrypoints.cc
@@ -58,6 +58,7 @@
     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 814305c..b8765af 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -42,26 +42,27 @@
 
 class ObjectTest : public CommonTest {
  protected:
-  void AssertString(int32_t length,
+  void AssertString(int32_t expected_utf16_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[length]);
-    for (int32_t i = 0; i < length; i++) {
+    UniquePtr<uint16_t[]> utf16_expected(new uint16_t[expected_utf16_length]);
+    for (int32_t i = 0; i < expected_utf16_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, length, utf8_in));
-    ASSERT_EQ(length, string->GetLength());
+    SirtRef<String> string(self, String::AllocFromModifiedUtf8(self, expected_utf16_length, utf8_in));
+    ASSERT_EQ(expected_utf16_length, string->GetLength());
     ASSERT_TRUE(string->GetCharArray() != NULL);
     ASSERT_TRUE(string->GetCharArray()->GetData() != NULL);
-    // 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++) {
+    // 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++) {
       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 54ba3b0..f8a0e53 100644
--- a/runtime/mirror/string.cc
+++ b/runtime/mirror/string.cc
@@ -224,9 +224,6 @@
 }
 
 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 2f4e427..a5eaad6 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -142,17 +142,20 @@
   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";
+    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();
     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";
+    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();
     return NULL;
   }
   ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
@@ -160,7 +163,8 @@
   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 returning " << result;
+  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;
   return soa.AddLocalReference<jclass>(result);
 }
 
diff --git a/runtime/reflection.cc b/runtime/reflection.cc
index 3e58b4b..5e44a4c 100644
--- a/runtime/reflection.cc
+++ b/runtime/reflection.cc
@@ -38,6 +38,13 @@
   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 a454195..26b9c31 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -819,7 +819,8 @@
         mh.ChangeMethod(m);
         const char* source_file(mh.GetDeclaringClassSourceFile());
         os << "(" << (source_file != NULL ? source_file : "unavailable")
-           << ":" << line_number << ")";
+           << ":" << line_number << ")"
+           << " <0x" << std::hex << GetDexPc() << ">";
       }
       os << "\n";
       if (frame_count == 0) {
@@ -1921,6 +1922,7 @@
   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();