Don't use UTF16 length as length for MUTF8.

Bug 11367555.

Change-Id: Ia0b07072a1a49d435c3b71ed9a668b316b7ff5d8
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 91b0188..7653d16 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -600,11 +600,11 @@
   UpdateImageClasses(timings);
 }
 
-bool CompilerDriver::IsImageClass(const StringPiece& descriptor) const {
+bool CompilerDriver::IsImageClass(const char* descriptor) const {
   if (!IsImage()) {
     return true;
   } else {
-    return image_classes_->find(descriptor.data()) != image_classes_->end();
+    return image_classes_->find(descriptor) != image_classes_->end();
   }
 }
 
@@ -780,7 +780,7 @@
 bool CompilerDriver::CanAssumeTypeIsPresentInDexCache(const DexFile& dex_file,
                                                       uint32_t type_idx) {
   if (IsImage() &&
-      IsImageClass(dex_file.StringDataAsStringPieceByIdx(dex_file.GetTypeId(type_idx).descriptor_idx_))) {
+      IsImageClass(dex_file.StringDataByIdx(dex_file.GetTypeId(type_idx).descriptor_idx_))) {
     if (kIsDebugBuild) {
       ScopedObjectAccess soa(Thread::Current());
       mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(dex_file);
@@ -1108,7 +1108,7 @@
   }
   if (!use_dex_cache && compiling_boot) {
     MethodHelper mh(method);
-    if (!IsImageClass(mh.GetDeclaringClassDescriptorAsStringPiece())) {
+    if (!IsImageClass(mh.GetDeclaringClassDescriptor())) {
       // We can only branch directly to Methods that are resolved in the DexCache.
       // Otherwise we won't invoke the resolution trampoline.
       use_dex_cache = true;
@@ -1573,8 +1573,8 @@
     CHECK(soa.Self()->IsExceptionPending());
     mirror::Throwable* exception = soa.Self()->GetException(NULL);
     VLOG(compiler) << "Exception during type resolution: " << exception->Dump();
-    if (ClassHelper(exception->GetClass()).GetDescriptorAsStringPiece() ==
-        "Ljava/lang/OutOfMemoryError;") {
+    if (strcmp("Ljava/lang/OutOfMemoryError;",
+               ClassHelper(exception->GetClass()).GetDescriptor()) == 0) {
       // There's little point continuing compilation if the heap is exhausted.
       LOG(FATAL) << "Out of memory during type resolution for compilation";
     }
@@ -2089,11 +2089,11 @@
   const DexFile* dex_file = manager->GetDexFile();
   const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_index);
   const DexFile::TypeId& class_type_id = dex_file->GetTypeId(class_def.class_idx_);
-  StringPiece descriptor(dex_file->StringDataAsStringPieceByIdx(class_type_id.descriptor_idx_));
+  const char* descriptor = dex_file->StringDataByIdx(class_type_id.descriptor_idx_);
 
   ScopedObjectAccess soa(Thread::Current());
   mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(manager->GetClassLoader());
-  mirror::Class* klass = manager->GetClassLinker()->FindClass(descriptor.data(), class_loader);
+  mirror::Class* klass = manager->GetClassLinker()->FindClass(descriptor, class_loader);
   if (klass != NULL) {
     // Only try to initialize classes that were successfully verified.
     if (klass->IsVerified()) {
@@ -2123,7 +2123,7 @@
             bool is_black_listed = StringPiece(descriptor).ends_with("$NoPreloadHolder;");
             if (!is_black_listed) {
               for (size_t i = 0; i < arraysize(class_initializer_black_list); ++i) {
-                if (descriptor == class_initializer_black_list[i]) {
+                if (strcmp(descriptor, class_initializer_black_list[i]) == 0) {
                   is_black_listed = true;
                   break;
                 }
@@ -2131,7 +2131,7 @@
             }
             if (!is_black_listed) {
               VLOG(compiler) << "Initializing: " << descriptor;
-              if (descriptor == "Ljava/lang/Void;") {
+              if (strcmp("Ljava/lang/Void;", descriptor) == 0) {
                 // Hand initialize j.l.Void to avoid Dex file operations in un-started runtime.
                 ObjectLock lock(soa.Self(), klass);
                 mirror::ObjectArray<mirror::ArtField>* fields = klass->GetSFields();