Don't use UTF16 length as length for MUTF8.
Bug 11367555.
Change-Id: Ia0b07072a1a49d435c3b71ed9a668b316b7ff5d8
diff --git a/compiler/dex/quick/gen_invoke.cc b/compiler/dex/quick/gen_invoke.cc
index 62feade..5a1d3d1 100644
--- a/compiler/dex/quick/gen_invoke.cc
+++ b/compiler/dex/quick/gen_invoke.cc
@@ -1232,7 +1232,7 @@
const DexFile::MethodId& target_mid = cu_->dex_file->GetMethodId(info->index);
const DexFile::TypeId& declaring_type = cu_->dex_file->GetTypeId(target_mid.class_idx_);
StringPiece tgt_methods_declaring_class(
- cu_->dex_file->StringDataAsStringPieceByIdx(declaring_type.descriptor_idx_));
+ cu_->dex_file->StringDataByIdx(declaring_type.descriptor_idx_));
if (tgt_methods_declaring_class.starts_with("Ljava/lang/Double;")) {
std::string tgt_method(PrettyMethod(info->index, *cu_->dex_file));
if (tgt_method == "long java.lang.Double.doubleToRawLongBits(double)") {
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();
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 971021f..fe21eff 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -309,7 +309,7 @@
}
// Checks if class specified by type_idx is one of the image_classes_
- bool IsImageClass(const StringPiece& descriptor) const;
+ bool IsImageClass(const char* descriptor) const;
void RecordClassStatus(ClassReference ref, mirror::Class::Status status)
LOCKS_EXCLUDED(compiled_classes_lock_);
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index 871cfd5..e66e214 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -244,7 +244,7 @@
}
bool ImageWriter::IsImageClass(const Class* klass) {
- return compiler_driver_.IsImageClass(ClassHelper(klass).GetDescriptorAsStringPiece());
+ return compiler_driver_.IsImageClass(ClassHelper(klass).GetDescriptor());
}
struct NonImageClasses {
@@ -299,7 +299,7 @@
bool ImageWriter::NonImageClassesVisitor(Class* klass, void* arg) {
NonImageClasses* context = reinterpret_cast<NonImageClasses*>(arg);
if (!context->image_writer->IsImageClass(klass)) {
- context->non_image_classes->insert(ClassHelper(klass).GetDescriptorAsStringPiece().as_string());
+ context->non_image_classes->insert(ClassHelper(klass).GetDescriptor());
}
return true;
}