Remove mirror:: and ArtMethod deps in utils.{h,cc}
The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance. This episode
finds us removing references to ArtMethod/ArtField/mirror.
One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument. I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful. I have tried to remove as many cases
as possible where it was clear p != nullptr.
Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index bc8facd..51bf9ea 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -86,7 +86,7 @@
MakeExecutable(code_ptr, code.size());
const void* method_code = CompiledMethod::CodePointer(code_ptr,
compiled_method->GetInstructionSet());
- LOG(INFO) << "MakeExecutable " << PrettyMethod(method) << " code=" << method_code;
+ LOG(INFO) << "MakeExecutable " << method->PrettyMethod() << " code=" << method_code;
class_linker_->SetEntryPointsToCompiledCode(method, method_code);
} else {
// No code? You must mean to go into the interpreter.
diff --git a/compiler/compiler.cc b/compiler/compiler.cc
index 1626317..c500921 100644
--- a/compiler/compiler.cc
+++ b/compiler/compiler.cc
@@ -47,12 +47,12 @@
if (code_item.insns_size_in_code_units_ >= UINT16_MAX / 4) {
LOG(INFO) << "Method exceeds compiler instruction limit: "
<< code_item.insns_size_in_code_units_
- << " in " << PrettyMethod(method_idx, dex_file);
+ << " in " << dex_file.PrettyMethod(method_idx);
return true;
}
if (code_item.registers_size_ >= UINT16_MAX / 4) {
LOG(INFO) << "Method exceeds compiler virtual register limit: "
- << code_item.registers_size_ << " in " << PrettyMethod(method_idx, dex_file);
+ << code_item.registers_size_ << " in " << dex_file.PrettyMethod(method_idx);
return true;
}
return false;
diff --git a/compiler/debug/elf_symtab_writer.h b/compiler/debug/elf_symtab_writer.h
index 045eddd..af9f091 100644
--- a/compiler/debug/elf_symtab_writer.h
+++ b/compiler/debug/elf_symtab_writer.h
@@ -69,7 +69,7 @@
name_offset = strtab->Write(info.trampoline_name);
} else {
DCHECK(info.dex_file != nullptr);
- std::string name = PrettyMethod(info.dex_method_index, *info.dex_file, with_signature);
+ std::string name = info.dex_file->PrettyMethod(info.dex_method_index, with_signature);
if (deduped_addresses.find(info.code_address) != deduped_addresses.end()) {
name += " [DEDUPED]";
}
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index 236a3b2..9c1d72b 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -212,7 +212,7 @@
VLOG(compiler) << "Replacing " << Instruction::Name(inst->Opcode())
<< " by " << Instruction::Name(Instruction::RETURN_VOID_NO_BARRIER)
<< " at dex pc " << StringPrintf("0x%x", dex_pc) << " in method "
- << PrettyMethod(unit_.GetDexMethodIndex(), GetDexFile(), true);
+ << GetDexFile().PrettyMethod(unit_.GetDexMethodIndex(), true);
inst->SetOpcode(Instruction::RETURN_VOID_NO_BARRIER);
}
@@ -232,7 +232,7 @@
VLOG(compiler) << "Removing " << Instruction::Name(inst->Opcode())
<< " by replacing it with 2 NOPs at dex pc "
<< StringPrintf("0x%x", dex_pc) << " in method "
- << PrettyMethod(unit_.GetDexMethodIndex(), GetDexFile(), true);
+ << GetDexFile().PrettyMethod(unit_.GetDexMethodIndex(), true);
// We are modifying 4 consecutive bytes.
inst->SetOpcode(Instruction::NOP);
inst->SetVRegA_10x(0u); // keep compliant with verifier.
@@ -262,7 +262,7 @@
<< " by replacing field index " << field_idx
<< " by field offset " << field_offset.Int32Value()
<< " at dex pc " << StringPrintf("0x%x", dex_pc) << " in method "
- << PrettyMethod(unit_.GetDexMethodIndex(), GetDexFile(), true);
+ << GetDexFile().PrettyMethod(unit_.GetDexMethodIndex(), true);
// We are modifying 4 consecutive bytes.
inst->SetOpcode(new_opcode);
// Replace field index by field offset.
@@ -300,12 +300,12 @@
uint32_t vtable_idx = resolved_method->GetMethodIndex();
DCHECK(IsUint<16>(vtable_idx));
VLOG(compiler) << "Quickening " << Instruction::Name(inst->Opcode())
- << "(" << PrettyMethod(method_idx, GetDexFile(), true) << ")"
+ << "(" << GetDexFile().PrettyMethod(method_idx, true) << ")"
<< " to " << Instruction::Name(new_opcode)
<< " by replacing method index " << method_idx
<< " by vtable index " << vtable_idx
<< " at dex pc " << StringPrintf("0x%x", dex_pc) << " in method "
- << PrettyMethod(unit_.GetDexMethodIndex(), GetDexFile(), true);
+ << GetDexFile().PrettyMethod(unit_.GetDexMethodIndex(), true);
// We are modifying 4 consecutive bytes.
inst->SetOpcode(new_opcode);
// Replace method index by vtable index.
diff --git a/compiler/dex/verification_results.cc b/compiler/dex/verification_results.cc
index d87762d..511a787 100644
--- a/compiler/dex/verification_results.cc
+++ b/compiler/dex/verification_results.cc
@@ -58,8 +58,7 @@
auto it = verified_methods_.find(ref);
if (it != verified_methods_.end()) {
// TODO: Investigate why are we doing the work again for this method and try to avoid it.
- LOG(WARNING) << "Method processed more than once: "
- << PrettyMethod(ref.dex_method_index, *ref.dex_file);
+ LOG(WARNING) << "Method processed more than once: " << ref.PrettyMethod();
if (!Runtime::Current()->UseJitCompilation()) {
DCHECK_EQ(it->second->GetDevirtMap().size(), verified_method->GetDevirtMap().size());
DCHECK_EQ(it->second->GetSafeCastSet().size(), verified_method->GetSafeCastSet().size());
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index afaec52..7d2abdf 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -617,7 +617,7 @@
if (kTimeCompileMethod) {
uint64_t duration_ns = NanoTime() - start_ns;
if (duration_ns > MsToNs(driver->GetCompiler()->GetMaximumCompilationTimeBeforeWarning())) {
- LOG(WARNING) << "Compilation of " << PrettyMethod(method_idx, dex_file)
+ LOG(WARNING) << "Compilation of " << dex_file.PrettyMethod(method_idx)
<< " took " << PrettyDuration(duration_ns);
}
}
@@ -639,7 +639,7 @@
if (self->IsExceptionPending()) {
ScopedObjectAccess soa(self);
- LOG(FATAL) << "Unexpected exception compiling: " << PrettyMethod(method_idx, dex_file) << "\n"
+ LOG(FATAL) << "Unexpected exception compiling: " << dex_file.PrettyMethod(method_idx) << "\n"
<< self->GetException()->Dump();
}
}
@@ -940,7 +940,7 @@
return true;
}
- std::string tmp = PrettyMethod(method_ref.dex_method_index, *method_ref.dex_file, true);
+ std::string tmp = method_ref.dex_file->PrettyMethod(method_ref.dex_method_index, true);
return methods_to_compile_->find(tmp.c_str()) != methods_to_compile_->end();
}
@@ -955,7 +955,7 @@
if (kDebugProfileGuidedCompilation) {
LOG(INFO) << "[ProfileGuidedCompilation] "
<< (result ? "Compiled" : "Skipped") << " method:"
- << PrettyMethod(method_ref.dex_method_index, *method_ref.dex_file, true);
+ << method_ref.dex_file->PrettyMethod(method_ref.dex_method_index, true);
}
return result;
}
@@ -1679,7 +1679,7 @@
const DexFile& original_dex_file = *klass->GetDexCache()->GetDexFile();
if (&dex_file != &original_dex_file) {
if (class_loader == nullptr) {
- LOG(WARNING) << "Skipping class " << PrettyDescriptor(klass) << " from "
+ LOG(WARNING) << "Skipping class " << klass->PrettyDescriptor() << " from "
<< dex_file.GetLocation() << " previously found in "
<< original_dex_file.GetLocation();
}
@@ -1991,7 +1991,7 @@
manager_->GetCompiler()->SetHadHardVerifierFailure();
}
} else if (!SkipClass(jclass_loader, dex_file, klass.Get())) {
- CHECK(klass->IsResolved()) << PrettyClass(klass.Get());
+ CHECK(klass->IsResolved()) << klass->PrettyClass();
class_linker->VerifyClass(soa.Self(), klass, log_level_);
if (klass->IsErroneous()) {
@@ -2002,13 +2002,14 @@
}
CHECK(klass->IsCompileTimeVerified() || klass->IsErroneous())
- << PrettyDescriptor(klass.Get()) << ": state=" << klass->GetStatus();
+ << klass->PrettyDescriptor() << ": state=" << klass->GetStatus();
// It is *very* problematic if there are verification errors in the boot classpath. For example,
// we rely on things working OK without verification when the decryption dialog is brought up.
// So abort in a debug build if we find this violated.
DCHECK(!manager_->GetCompiler()->GetCompilerOptions().IsBootImage() || klass->IsVerified())
- << "Boot classpath class " << PrettyClass(klass.Get()) << " failed to fully verify.";
+ << "Boot classpath class " << klass->PrettyClass()
+ << " failed to fully verify.";
}
soa.Self()->AssertNoPendingException();
}
@@ -2446,14 +2447,14 @@
CompiledMethod* const compiled_method,
size_t non_relative_linker_patch_count) {
DCHECK(GetCompiledMethod(method_ref) == nullptr)
- << PrettyMethod(method_ref.dex_method_index, *method_ref.dex_file);
+ << method_ref.dex_file->PrettyMethod(method_ref.dex_method_index);
{
MutexLock mu(Thread::Current(), compiled_methods_lock_);
compiled_methods_.Put(method_ref, compiled_method);
non_relative_linker_patch_count_ += non_relative_linker_patch_count;
}
DCHECK(GetCompiledMethod(method_ref) != nullptr)
- << PrettyMethod(method_ref.dex_method_index, *method_ref.dex_file);
+ << method_ref.dex_file->PrettyMethod(method_ref.dex_method_index);
}
void CompilerDriver::RemoveCompiledMethod(const MethodReference& method_ref) {
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc
index e323b16..20f0e5e 100644
--- a/compiler/driver/compiler_driver_test.cc
+++ b/compiler/driver/compiler_driver_test.cc
@@ -216,7 +216,7 @@
const auto pointer_size = class_linker->GetImagePointerSize();
for (auto& m : klass->GetDirectMethods(pointer_size)) {
- std::string name = PrettyMethod(&m, true);
+ std::string name = m.PrettyMethod(true);
const void* code = m.GetEntryPointFromQuickCompiledCodePtrSize(pointer_size);
ASSERT_NE(code, nullptr);
if (expected->find(name) != expected->end()) {
@@ -273,7 +273,7 @@
const auto pointer_size = class_linker->GetImagePointerSize();
size_t number_of_compiled_methods = 0;
for (auto& m : klass->GetVirtualMethods(pointer_size)) {
- std::string name = PrettyMethod(&m, true);
+ std::string name = m.PrettyMethod(true);
const void* code = m.GetEntryPointFromQuickCompiledCodePtrSize(pointer_size);
ASSERT_NE(code, nullptr);
if (expected_methods.find(name) != expected_methods.end()) {
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h
index 3c920d9..4eb6954 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -29,6 +29,8 @@
namespace art {
+class DexFile;
+
class CompilerOptions FINAL {
public:
// Guide heuristics to determine whether to compile method if profile data not available.
diff --git a/compiler/driver/dex_compilation_unit.cc b/compiler/driver/dex_compilation_unit.cc
index b0ee448..64fd9e7 100644
--- a/compiler/driver/dex_compilation_unit.cc
+++ b/compiler/driver/dex_compilation_unit.cc
@@ -45,7 +45,7 @@
const std::string& DexCompilationUnit::GetSymbol() {
if (symbol_.empty()) {
symbol_ = "dex_";
- symbol_ += MangleForJni(PrettyMethod(dex_method_idx_, *dex_file_));
+ symbol_ += MangleForJni(dex_file_->PrettyMethod(dex_method_idx_));
}
return symbol_;
}
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index 8f15ea4..b19a95b 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -114,7 +114,7 @@
static void CheckNoDexObjectsCallback(Object* obj, void* arg ATTRIBUTE_UNUSED)
REQUIRES_SHARED(Locks::mutator_lock_) {
Class* klass = obj->GetClass();
- CHECK_NE(PrettyClass(klass), "com.android.dex.Dex");
+ CHECK_NE(Class::PrettyClass(klass), "com.android.dex.Dex");
}
static void CheckNoDexObjects() {
@@ -489,7 +489,7 @@
if (method != nullptr && !method->IsRuntimeMethod()) {
mirror::Class* klass = method->GetDeclaringClass();
CHECK(klass == nullptr || KeepClass(klass))
- << PrettyClass(klass) << " should be a kept class";
+ << Class::PrettyClass(klass) << " should be a kept class";
}
}
}
@@ -757,7 +757,7 @@
if (klass->GetStatus() == mirror::Class::kStatusError) {
result = true;
} else {
- CHECK(klass->GetVerifyError() == nullptr) << PrettyClass(klass);
+ CHECK(klass->GetVerifyError() == nullptr) << klass->PrettyClass();
}
if (!result) {
// Check interfaces since these wont be visited through VisitReferences.)
@@ -910,7 +910,7 @@
} else {
// Check that the class is still in the classes table.
DCHECK(class_linker->ClassInClassTable(declaring_class)) << "Class "
- << PrettyClass(declaring_class) << " not in class linker table";
+ << Class::PrettyClass(declaring_class) << " not in class linker table";
}
}
ArtField** resolved_fields = dex_cache->GetResolvedFields();
@@ -947,7 +947,7 @@
image_writer->DumpImageClasses();
std::string temp;
CHECK(image_writer->KeepClass(klass)) << klass->GetDescriptor(&temp)
- << " " << PrettyDescriptor(klass);
+ << " " << klass->PrettyDescriptor();
}
}
}
@@ -1100,7 +1100,7 @@
DCHECK_NE(as_klass->GetStatus(), mirror::Class::kStatusError);
if (compile_app_image_) {
// Extra sanity, no boot loader classes should be left!
- CHECK(!IsBootClassLoaderClass(as_klass)) << PrettyClass(as_klass);
+ CHECK(!IsBootClassLoaderClass(as_klass)) << as_klass->PrettyClass();
}
LengthPrefixedArray<ArtField>* fields[] = {
as_klass->GetSFieldsPtr(), as_klass->GetIFieldsPtr(),
@@ -1136,7 +1136,7 @@
ArtField* field = &cur_fields->At(i);
auto it2 = native_object_relocations_.find(field);
CHECK(it2 == native_object_relocations_.end()) << "Field at index=" << i
- << " already assigned " << PrettyField(field) << " static=" << field->IsStatic();
+ << " already assigned " << field->PrettyField() << " static=" << field->IsStatic();
DCHECK(!IsInBootImage(field));
native_object_relocations_.emplace(
field,
@@ -1268,7 +1268,7 @@
size_t oat_index) {
DCHECK(!IsInBootImage(method));
CHECK(!NativeRelocationAssigned(method)) << "Method " << method << " already assigned "
- << PrettyMethod(method);
+ << ArtMethod::PrettyMethod(method);
if (method->IsRuntimeMethod()) {
TryAssignConflictTableOffset(method->GetImtConflictTable(target_ptr_size_), oat_index);
}
@@ -1282,7 +1282,7 @@
ImageWriter* writer = reinterpret_cast<ImageWriter*>(arg);
DCHECK(writer != nullptr);
if (!Runtime::Current()->GetHeap()->ObjectIsInBootImageSpace(obj)) {
- CHECK(writer->IsImageBinSlotAssigned(obj)) << PrettyTypeOf(obj) << " " << obj;
+ CHECK(writer->IsImageBinSlotAssigned(obj)) << mirror::Object::PrettyTypeOf(obj) << " " << obj;
}
}
@@ -1690,7 +1690,8 @@
ArtMethod* ImageWriter::GetImageMethodAddress(ArtMethod* method) {
auto it = native_object_relocations_.find(method);
- CHECK(it != native_object_relocations_.end()) << PrettyMethod(method) << " @ " << method;
+ CHECK(it != native_object_relocations_.end()) << ArtMethod::PrettyMethod(method) << " @ "
+ << method;
size_t oat_index = GetOatIndex(method->GetDexCache());
ImageInfo& image_info = GetImageInfo(oat_index);
CHECK_GE(it->second.offset, image_info.image_end_) << "ArtMethods should be after Objects";
@@ -1877,7 +1878,7 @@
void ImageWriter::FixupPointerArray(mirror::Object* dst, mirror::PointerArray* arr,
mirror::Class* klass, Bin array_type) {
CHECK(klass->IsArrayClass());
- CHECK(arr->IsIntArray() || arr->IsLongArray()) << PrettyClass(klass) << " " << arr;
+ CHECK(arr->IsIntArray() || arr->IsLongArray()) << klass->PrettyClass() << " " << arr;
// Fixup int and long pointers for the ArtMethod or ArtField arrays.
const size_t num_elements = arr->GetLength();
dst->SetClass(GetImageAddress(arr->GetClass()));
@@ -1889,15 +1890,15 @@
if (UNLIKELY(it == native_object_relocations_.end())) {
if (it->second.IsArtMethodRelocation()) {
auto* method = reinterpret_cast<ArtMethod*>(elem);
- LOG(FATAL) << "No relocation entry for ArtMethod " << PrettyMethod(method) << " @ "
- << method << " idx=" << i << "/" << num_elements << " with declaring class "
- << PrettyClass(method->GetDeclaringClass());
+ LOG(FATAL) << "No relocation entry for ArtMethod " << method->PrettyMethod() << " @ "
+ << method << " idx=" << i << "/" << num_elements << " with declaring class "
+ << Class::PrettyClass(method->GetDeclaringClass());
} else {
CHECK_EQ(array_type, kBinArtField);
auto* field = reinterpret_cast<ArtField*>(elem);
- LOG(FATAL) << "No relocation entry for ArtField " << PrettyField(field) << " @ "
+ LOG(FATAL) << "No relocation entry for ArtField " << field->PrettyField() << " @ "
<< field << " idx=" << i << "/" << num_elements << " with declaring class "
- << PrettyClass(field->GetDeclaringClass());
+ << Class::PrettyClass(field->GetDeclaringClass());
}
UNREACHABLE();
} else {
@@ -2013,7 +2014,7 @@
template <>
std::string PrettyPrint(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) {
- return PrettyMethod(method);
+ return ArtMethod::PrettyMethod(method);
}
template <typename T>
@@ -2228,11 +2229,11 @@
const uint8_t* ImageWriter::GetQuickCode(ArtMethod* method,
const ImageInfo& image_info,
bool* quick_is_interpreted) {
- DCHECK(!method->IsResolutionMethod()) << PrettyMethod(method);
- DCHECK_NE(method, Runtime::Current()->GetImtConflictMethod()) << PrettyMethod(method);
- DCHECK(!method->IsImtUnimplementedMethod()) << PrettyMethod(method);
- DCHECK(method->IsInvokable()) << PrettyMethod(method);
- DCHECK(!IsInBootImage(method)) << PrettyMethod(method);
+ DCHECK(!method->IsResolutionMethod()) << method->PrettyMethod();
+ DCHECK_NE(method, Runtime::Current()->GetImtConflictMethod()) << method->PrettyMethod();
+ DCHECK(!method->IsImtUnimplementedMethod()) << method->PrettyMethod();
+ DCHECK(method->IsInvokable()) << method->PrettyMethod();
+ DCHECK(!IsInBootImage(method)) << method->PrettyMethod();
// Use original code if it exists. Otherwise, set the code pointer to the resolution
// trampoline.
@@ -2310,7 +2311,7 @@
break;
}
}
- CHECK(found_one) << "Expected to find callee save method but got " << PrettyMethod(orig);
+ CHECK(found_one) << "Expected to find callee save method but got " << orig->PrettyMethod();
CHECK(copy->IsRuntimeMethod());
}
} else {
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index 4ef2db8..c398703 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -208,7 +208,7 @@
// Ensure the class is initialized.
Handle<mirror::Class> h_class(hs.NewHandle(method->GetDeclaringClass()));
if (!runtime->GetClassLinker()->EnsureInitialized(self, h_class, true, true)) {
- VLOG(jit) << "JIT failed to initialize " << PrettyMethod(method);
+ VLOG(jit) << "JIT failed to initialize " << method->PrettyMethod();
return false;
}
@@ -226,7 +226,7 @@
<< " "
<< code_cache->GetMemorySizeOfCodePointer(ptr)
<< " "
- << PrettyMethod(method)
+ << method->PrettyMethod()
<< std::endl;
std::string str = stream.str();
bool res = perf_file_->WriteFully(str.c_str(), str.size());
diff --git a/compiler/jni/quick/jni_compiler.cc b/compiler/jni/quick/jni_compiler.cc
index 13d8c16..e171441 100644
--- a/compiler/jni/quick/jni_compiler.cc
+++ b/compiler/jni/quick/jni_compiler.cc
@@ -96,24 +96,24 @@
bool is_critical_native = (optimization_flags == Compiler::kCriticalNative);
VLOG(jni) << "JniCompile: Method :: "
- << art::PrettyMethod(method_idx, dex_file, /* with signature */ true)
+ << dex_file.PrettyMethod(method_idx, /* with signature */ true)
<< " :: access_flags = " << std::hex << access_flags << std::dec;
if (UNLIKELY(is_fast_native)) {
VLOG(jni) << "JniCompile: Fast native method detected :: "
- << art::PrettyMethod(method_idx, dex_file, /* with signature */ true);
+ << dex_file.PrettyMethod(method_idx, /* with signature */ true);
}
if (UNLIKELY(is_critical_native)) {
VLOG(jni) << "JniCompile: Critical native method detected :: "
- << art::PrettyMethod(method_idx, dex_file, /* with signature */ true);
+ << dex_file.PrettyMethod(method_idx, /* with signature */ true);
}
if (kIsDebugBuild) {
// Don't allow both @FastNative and @CriticalNative. They are mutually exclusive.
if (UNLIKELY(is_fast_native && is_critical_native)) {
LOG(FATAL) << "JniCompile: Method cannot be both @CriticalNative and @FastNative"
- << art::PrettyMethod(method_idx, dex_file, /* with_signature */ true);
+ << dex_file.PrettyMethod(method_idx, /* with_signature */ true);
}
// @CriticalNative - extra checks:
@@ -124,15 +124,15 @@
CHECK(is_static)
<< "@CriticalNative functions cannot be virtual since that would"
<< "require passing a reference parameter (this), which is illegal "
- << art::PrettyMethod(method_idx, dex_file, /* with_signature */ true);
+ << dex_file.PrettyMethod(method_idx, /* with_signature */ true);
CHECK(!is_synchronized)
<< "@CriticalNative functions cannot be synchronized since that would"
<< "require passing a (class and/or this) reference parameter, which is illegal "
- << art::PrettyMethod(method_idx, dex_file, /* with_signature */ true);
+ << dex_file.PrettyMethod(method_idx, /* with_signature */ true);
for (size_t i = 0; i < strlen(shorty); ++i) {
CHECK_NE(Primitive::kPrimNot, Primitive::GetType(shorty[i]))
<< "@CriticalNative methods' shorty types must not have illegal references "
- << art::PrettyMethod(method_idx, dex_file, /* with_signature */ true);
+ << dex_file.PrettyMethod(method_idx, /* with_signature */ true);
}
}
}
diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc
index b4c60d1..593d8e9 100644
--- a/compiler/oat_test.cc
+++ b/compiler/oat_test.cc
@@ -65,14 +65,14 @@
method->GetDexMethodIndex()));
if (compiled_method == nullptr) {
- EXPECT_TRUE(oat_method.GetQuickCode() == nullptr) << PrettyMethod(method) << " "
+ EXPECT_TRUE(oat_method.GetQuickCode() == nullptr) << method->PrettyMethod() << " "
<< oat_method.GetQuickCode();
EXPECT_EQ(oat_method.GetFrameSizeInBytes(), 0U);
EXPECT_EQ(oat_method.GetCoreSpillMask(), 0U);
EXPECT_EQ(oat_method.GetFpSpillMask(), 0U);
} else {
const void* quick_oat_code = oat_method.GetQuickCode();
- EXPECT_TRUE(quick_oat_code != nullptr) << PrettyMethod(method);
+ EXPECT_TRUE(quick_oat_code != nullptr) << method->PrettyMethod();
EXPECT_EQ(oat_method.GetFrameSizeInBytes(), compiled_method->GetFrameSizeInBytes());
EXPECT_EQ(oat_method.GetCoreSpillMask(), compiled_method->GetCoreSpillMask());
EXPECT_EQ(oat_method.GetFpSpillMask(), compiled_method->GetFpSpillMask());
@@ -82,7 +82,7 @@
EXPECT_FALSE(quick_code.empty());
size_t code_size = quick_code.size() * sizeof(quick_code[0]);
EXPECT_EQ(0, memcmp(quick_oat_code, &quick_code[0], code_size))
- << PrettyMethod(method) << " " << code_size;
+ << method->PrettyMethod() << " " << code_size;
CHECK_EQ(0, memcmp(quick_oat_code, &quick_code[0], code_size));
}
}
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index 44c26ed..52134e8 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -759,7 +759,7 @@
if (writer_->relative_patcher_->GetOffset(method_ref) != 0u) {
// TODO: Should this be a hard failure?
LOG(WARNING) << "Multiple definitions of "
- << PrettyMethod(method_ref.dex_method_index, *method_ref.dex_file)
+ << method_ref.dex_file->PrettyMethod(method_ref.dex_method_index)
<< " offsets " << writer_->relative_patcher_->GetOffset(method_ref)
<< " " << quick_code_offset;
} else {
@@ -967,7 +967,7 @@
invoke_type);
if (method == nullptr) {
LOG(FATAL_WITHOUT_ABORT) << "Unexpected failure to resolve a method: "
- << PrettyMethod(it.GetMemberIndex(), *dex_file_, true);
+ << dex_file_->PrettyMethod(it.GetMemberIndex(), true);
soa.Self()->AssertPendingException();
mirror::Throwable* exc = soa.Self()->GetException();
std::string dump = exc->Dump();
@@ -1073,7 +1073,7 @@
GetInstructionSetAlignment(compiled_method->GetInstructionSet()));
DCHECK_EQ(method_offsets.code_offset_,
offset_ + sizeof(OatQuickMethodHeader) + compiled_method->CodeDelta())
- << PrettyMethod(it.GetMemberIndex(), *dex_file_);
+ << dex_file_->PrettyMethod(it.GetMemberIndex());
const OatQuickMethodHeader& method_header =
oat_class->method_headers_[method_offsets_index_];
if (!out->WriteFully(&method_header, sizeof(method_header))) {
@@ -1185,7 +1185,7 @@
void ReportWriteFailure(const char* what, const ClassDataItemIterator& it) {
PLOG(ERROR) << "Failed to write " << what << " for "
- << PrettyMethod(it.GetMemberIndex(), *dex_file_) << " to " << out_->GetLocation();
+ << dex_file_->PrettyMethod(it.GetMemberIndex()) << " to " << out_->GetLocation();
}
ArtMethod* GetTargetMethod(const LinkerPatch& patch)
@@ -1370,13 +1370,13 @@
DCHECK((compiled_method->GetVmapTable().size() == 0u && map_offset == 0u) ||
(compiled_method->GetVmapTable().size() != 0u && map_offset != 0u))
<< compiled_method->GetVmapTable().size() << " " << map_offset << " "
- << PrettyMethod(it.GetMemberIndex(), *dex_file_);
+ << dex_file_->PrettyMethod(it.GetMemberIndex());
if (map_offset != 0u) {
// Transform map_offset to actual oat data offset.
map_offset = (code_offset - compiled_method->CodeDelta()) - map_offset;
DCHECK_NE(map_offset, 0u);
- DCHECK_LE(map_offset, offset_) << PrettyMethod(it.GetMemberIndex(), *dex_file_);
+ DCHECK_LE(map_offset, offset_) << dex_file_->PrettyMethod(it.GetMemberIndex());
ArrayRef<const uint8_t> map = compiled_method->GetVmapTable();
size_t map_size = map.size() * sizeof(map[0]);
@@ -1401,7 +1401,7 @@
void ReportWriteFailure(const ClassDataItemIterator& it) {
PLOG(ERROR) << "Failed to write map for "
- << PrettyMethod(it.GetMemberIndex(), *dex_file_) << " to " << out_->GetLocation();
+ << dex_file_->PrettyMethod(it.GetMemberIndex()) << " to " << out_->GetLocation();
}
};
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index 86742e6..2927e1f 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -51,7 +51,7 @@
if (compiler_options.IsHugeMethod(code_item_.insns_size_in_code_units_)) {
VLOG(compiler) << "Skip compilation of huge method "
- << PrettyMethod(dex_compilation_unit_->GetDexMethodIndex(), *dex_file_)
+ << dex_file_->PrettyMethod(dex_compilation_unit_->GetDexMethodIndex())
<< ": " << code_item_.insns_size_in_code_units_ << " code units";
MaybeRecordStat(MethodCompilationStat::kNotCompiledHugeMethod);
return true;
@@ -61,7 +61,7 @@
if (compiler_options.IsLargeMethod(code_item_.insns_size_in_code_units_)
&& (number_of_branches == 0)) {
VLOG(compiler) << "Skip compilation of large method with no branch "
- << PrettyMethod(dex_compilation_unit_->GetDexMethodIndex(), *dex_file_)
+ << dex_file_->PrettyMethod(dex_compilation_unit_->GetDexMethodIndex())
<< ": " << code_item_.insns_size_in_code_units_ << " code units";
MaybeRecordStat(MethodCompilationStat::kNotCompiledLargeMethodNoBranches);
return true;
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index 912ee29..09dcefa 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -441,8 +441,8 @@
void VisitInvoke(HInvoke* invoke) OVERRIDE {
StartAttributeStream("dex_file_index") << invoke->GetDexMethodIndex();
- StartAttributeStream("method_name") << PrettyMethod(
- invoke->GetDexMethodIndex(), GetGraph()->GetDexFile(), /* with_signature */ false);
+ StartAttributeStream("method_name") << GetGraph()->GetDexFile().PrettyMethod(
+ invoke->GetDexMethodIndex(), /* with_signature */ false);
}
void VisitInvokeUnresolved(HInvokeUnresolved* invoke) OVERRIDE {
@@ -465,15 +465,15 @@
}
void VisitInstanceFieldGet(HInstanceFieldGet* iget) OVERRIDE {
- StartAttributeStream("field_name") << PrettyField(iget->GetFieldInfo().GetFieldIndex(),
- iget->GetFieldInfo().GetDexFile(),
+ StartAttributeStream("field_name") <<
+ iget->GetFieldInfo().GetDexFile().PrettyField(iget->GetFieldInfo().GetFieldIndex(),
/* with type */ false);
StartAttributeStream("field_type") << iget->GetFieldType();
}
void VisitInstanceFieldSet(HInstanceFieldSet* iset) OVERRIDE {
- StartAttributeStream("field_name") << PrettyField(iset->GetFieldInfo().GetFieldIndex(),
- iset->GetFieldInfo().GetDexFile(),
+ StartAttributeStream("field_name") <<
+ iset->GetFieldInfo().GetDexFile().PrettyField(iset->GetFieldInfo().GetFieldIndex(),
/* with type */ false);
StartAttributeStream("field_type") << iset->GetFieldType();
}
@@ -604,7 +604,8 @@
: instruction->GetReferenceTypeInfo();
ScopedObjectAccess soa(Thread::Current());
if (info.IsValid()) {
- StartAttributeStream("klass") << PrettyDescriptor(info.GetTypeHandle().Get());
+ StartAttributeStream("klass")
+ << mirror::Class::PrettyDescriptor(info.GetTypeHandle().Get());
StartAttributeStream("can_be_null")
<< std::boolalpha << instruction->CanBeNull() << std::noboolalpha;
StartAttributeStream("exact") << std::boolalpha << info.IsExact() << std::noboolalpha;
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 6080551..9faa98a 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -90,14 +90,14 @@
if (!TryInline(call)) {
if (kIsDebugBuild && IsCompilingWithCoreImage()) {
std::string callee_name =
- PrettyMethod(call->GetDexMethodIndex(), *outer_compilation_unit_.GetDexFile());
+ outer_compilation_unit_.GetDexFile()->PrettyMethod(call->GetDexMethodIndex());
bool should_inline = callee_name.find("$inline$") != std::string::npos;
CHECK(!should_inline) << "Could not inline " << callee_name;
}
} else {
if (kIsDebugBuild && IsCompilingWithCoreImage()) {
std::string callee_name =
- PrettyMethod(call->GetDexMethodIndex(), *outer_compilation_unit_.GetDexFile());
+ outer_compilation_unit_.GetDexFile()->PrettyMethod(call->GetDexMethodIndex());
bool must_not_inline = callee_name.find("$noinline$") != std::string::npos;
CHECK(!must_not_inline) << "Should not have inlined " << callee_name;
}
@@ -203,10 +203,10 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
uint32_t index = DexFile::kDexNoIndex;
if (cls->GetDexCache() == nullptr) {
- DCHECK(cls->IsArrayClass()) << PrettyClass(cls);
+ DCHECK(cls->IsArrayClass()) << cls->PrettyClass();
index = cls->FindTypeIndexInOtherDexFile(dex_file);
} else if (cls->GetDexTypeIndex() == DexFile::kDexNoIndex16) {
- DCHECK(cls->IsProxyClass()) << PrettyClass(cls);
+ DCHECK(cls->IsProxyClass()) << cls->PrettyClass();
// TODO: deal with proxy classes.
} else if (IsSameDexFile(cls->GetDexFile(), dex_file)) {
DCHECK_EQ(cls->GetDexCache(), dex_cache.Get());
@@ -266,7 +266,7 @@
ScopedObjectAccess soa(Thread::Current());
uint32_t method_index = invoke_instruction->GetDexMethodIndex();
const DexFile& caller_dex_file = *caller_compilation_unit_.GetDexFile();
- VLOG(compiler) << "Try inlining " << PrettyMethod(method_index, caller_dex_file);
+ VLOG(compiler) << "Try inlining " << caller_dex_file.PrettyMethod(method_index);
// We can query the dex cache directly. The verifier has populated it already.
ArtMethod* resolved_method = invoke_instruction->GetResolvedMethod();
@@ -304,7 +304,7 @@
const InlineCache& ic = *profiling_info->GetInlineCache(invoke_instruction->GetDexPc());
if (ic.IsUninitialized()) {
VLOG(compiler) << "Interface or virtual call to "
- << PrettyMethod(method_index, caller_dex_file)
+ << caller_dex_file.PrettyMethod(method_index)
<< " is not hit and not inlined";
return false;
} else if (ic.IsMonomorphic()) {
@@ -322,7 +322,7 @@
} else {
DCHECK(ic.IsMegamorphic());
VLOG(compiler) << "Interface or virtual call to "
- << PrettyMethod(method_index, caller_dex_file)
+ << caller_dex_file.PrettyMethod(method_index)
<< " is megamorphic and not inlined";
MaybeRecordStat(kMegamorphicCall);
return false;
@@ -331,7 +331,7 @@
}
VLOG(compiler) << "Interface or virtual call to "
- << PrettyMethod(method_index, caller_dex_file)
+ << caller_dex_file.PrettyMethod(method_index)
<< " could not be statically determined";
return false;
}
@@ -366,7 +366,7 @@
uint32_t class_index = FindClassIndexIn(
ic.GetMonomorphicType(), caller_dex_file, caller_compilation_unit_.GetDexCache());
if (class_index == DexFile::kDexNoIndex) {
- VLOG(compiler) << "Call to " << PrettyMethod(resolved_method)
+ VLOG(compiler) << "Call to " << ArtMethod::PrettyMethod(resolved_method)
<< " from inline cache is not inlined because its class is not"
<< " accessible to the caller";
return false;
@@ -526,7 +526,7 @@
}
if (!one_target_inlined) {
- VLOG(compiler) << "Call to " << PrettyMethod(resolved_method)
+ VLOG(compiler) << "Call to " << ArtMethod::PrettyMethod(resolved_method)
<< " from inline cache is not inlined because none"
<< " of its targets could be inlined";
return false;
@@ -660,7 +660,7 @@
actual_method = new_method;
} else if (actual_method != new_method) {
// Different methods, bailout.
- VLOG(compiler) << "Call to " << PrettyMethod(resolved_method)
+ VLOG(compiler) << "Call to " << ArtMethod::PrettyMethod(resolved_method)
<< " from inline cache is not inlined because it resolves"
<< " to different methods";
return false;
@@ -794,7 +794,7 @@
ArtMethod* method,
HInstruction** return_replacement) {
if (method->IsProxyMethod()) {
- VLOG(compiler) << "Method " << PrettyMethod(method)
+ VLOG(compiler) << "Method " << method->PrettyMethod()
<< " is not inlined because of unimplemented inline support for proxy methods.";
return false;
}
@@ -804,11 +804,12 @@
if (!compiler_driver_->MayInline(method->GetDexFile(),
outer_compilation_unit_.GetDexFile())) {
if (TryPatternSubstitution(invoke_instruction, method, return_replacement)) {
- VLOG(compiler) << "Successfully replaced pattern of invoke " << PrettyMethod(method);
+ VLOG(compiler) << "Successfully replaced pattern of invoke "
+ << method->PrettyMethod();
MaybeRecordStat(kReplacedInvokeWithSimplePattern);
return true;
}
- VLOG(compiler) << "Won't inline " << PrettyMethod(method) << " in "
+ VLOG(compiler) << "Won't inline " << method->PrettyMethod() << " in "
<< outer_compilation_unit_.GetDexFile()->GetLocation() << " ("
<< caller_compilation_unit_.GetDexFile()->GetLocation() << ") from "
<< method->GetDexFile()->GetLocation();
@@ -820,14 +821,14 @@
const DexFile::CodeItem* code_item = method->GetCodeItem();
if (code_item == nullptr) {
- VLOG(compiler) << "Method " << PrettyMethod(method)
+ VLOG(compiler) << "Method " << method->PrettyMethod()
<< " is not inlined because it is native";
return false;
}
size_t inline_max_code_units = compiler_driver_->GetCompilerOptions().GetInlineMaxCodeUnits();
if (code_item->insns_size_in_code_units_ > inline_max_code_units) {
- VLOG(compiler) << "Method " << PrettyMethod(method)
+ VLOG(compiler) << "Method " << method->PrettyMethod()
<< " is too big to inline: "
<< code_item->insns_size_in_code_units_
<< " > "
@@ -836,13 +837,13 @@
}
if (code_item->tries_size_ != 0) {
- VLOG(compiler) << "Method " << PrettyMethod(method)
+ VLOG(compiler) << "Method " << method->PrettyMethod()
<< " is not inlined because of try block";
return false;
}
if (!method->IsCompilable()) {
- VLOG(compiler) << "Method " << PrettyMethod(method)
+ VLOG(compiler) << "Method " << method->PrettyMethod()
<< " has soft failures un-handled by the compiler, so it cannot be inlined";
}
@@ -851,7 +852,7 @@
if (Runtime::Current()->UseJitCompilation() ||
!compiler_driver_->IsMethodVerifiedWithoutFailures(
method->GetDexMethodIndex(), class_def_idx, *method->GetDexFile())) {
- VLOG(compiler) << "Method " << PrettyMethod(method)
+ VLOG(compiler) << "Method " << method->PrettyMethod()
<< " couldn't be verified, so it cannot be inlined";
return false;
}
@@ -861,7 +862,7 @@
invoke_instruction->AsInvokeStaticOrDirect()->IsStaticWithImplicitClinitCheck()) {
// Case of a static method that cannot be inlined because it implicitly
// requires an initialization check of its declaring class.
- VLOG(compiler) << "Method " << PrettyMethod(method)
+ VLOG(compiler) << "Method " << method->PrettyMethod()
<< " is not inlined because it is static and requires a clinit"
<< " check that cannot be emitted due to Dex cache limitations";
return false;
@@ -871,7 +872,7 @@
return false;
}
- VLOG(compiler) << "Successfully inlined " << PrettyMethod(method);
+ VLOG(compiler) << "Successfully inlined " << method->PrettyMethod();
MaybeRecordStat(kInlinedInvoke);
return true;
}
@@ -1143,14 +1144,14 @@
handles_);
if (builder.BuildGraph() != kAnalysisSuccess) {
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " could not be built, so cannot be inlined";
return false;
}
if (!RegisterAllocator::CanAllocateRegistersFor(*callee_graph,
compiler_driver_->GetInstructionSet())) {
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " cannot be inlined because of the register allocator";
return false;
}
@@ -1200,7 +1201,7 @@
// a throw predecessor.
HBasicBlock* exit_block = callee_graph->GetExitBlock();
if (exit_block == nullptr) {
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " could not be inlined because it has an infinite loop";
return false;
}
@@ -1213,7 +1214,7 @@
}
}
if (has_throw_predecessor) {
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " could not be inlined because one branch always throws";
return false;
}
@@ -1231,7 +1232,7 @@
if (block->IsLoopHeader() && block->GetLoopInformation()->IsIrreducible()) {
// Don't inline methods with irreducible loops, they could prevent some
// optimizations to run.
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " could not be inlined because it contains an irreducible loop";
return false;
}
@@ -1240,28 +1241,28 @@
!instr_it.Done();
instr_it.Advance()) {
if (number_of_instructions++ == number_of_instructions_budget) {
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " is not inlined because its caller has reached"
<< " its instruction budget limit.";
return false;
}
HInstruction* current = instr_it.Current();
if (!can_inline_environment && current->NeedsEnvironment()) {
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " is not inlined because its caller has reached"
<< " its environment budget limit.";
return false;
}
if (!same_dex_file && current->NeedsEnvironment()) {
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " could not be inlined because " << current->DebugName()
<< " needs an environment and is in a different dex file";
return false;
}
if (!same_dex_file && current->NeedsDexCacheOfDeclaringClass()) {
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " could not be inlined because " << current->DebugName()
<< " it is in a different dex file and requires access to the dex cache";
return false;
@@ -1269,7 +1270,7 @@
if (current->IsNewInstance() &&
(current->AsNewInstance()->GetEntrypoint() == kQuickAllocObjectWithAccessCheck)) {
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " could not be inlined because it is using an entrypoint"
<< " with access checks";
// Allocation entrypoint does not handle inlined frames.
@@ -1278,7 +1279,7 @@
if (current->IsNewArray() &&
(current->AsNewArray()->GetEntrypoint() == kQuickAllocArrayWithAccessCheck)) {
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " could not be inlined because it is using an entrypoint"
<< " with access checks";
// Allocation entrypoint does not handle inlined frames.
@@ -1290,7 +1291,7 @@
current->IsUnresolvedStaticFieldSet() ||
current->IsUnresolvedInstanceFieldSet()) {
// Entrypoint for unresolved fields does not handle inlined frames.
- VLOG(compiler) << "Method " << PrettyMethod(method_index, callee_dex_file)
+ VLOG(compiler) << "Method " << callee_dex_file.PrettyMethod(method_index)
<< " could not be inlined because it is using an unresolved"
<< " entrypoint";
return false;
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index f7d67db..613e008 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -1065,7 +1065,7 @@
// reject any class where this is violated. However, the verifier only does these checks
// on non trivially dead instructions, so we just bailout the compilation.
VLOG(compiler) << "Did not compile "
- << PrettyMethod(dex_compilation_unit_->GetDexMethodIndex(), *dex_file_)
+ << dex_file_->PrettyMethod(dex_compilation_unit_->GetDexMethodIndex())
<< " because of non-sequential dex register pair in wide argument";
MaybeRecordStat(MethodCompilationStat::kNotCompiledMalformedOpcode);
return false;
@@ -1079,7 +1079,7 @@
if (*argument_index != invoke->GetNumberOfArguments()) {
VLOG(compiler) << "Did not compile "
- << PrettyMethod(dex_compilation_unit_->GetDexMethodIndex(), *dex_file_)
+ << dex_file_->PrettyMethod(dex_compilation_unit_->GetDexMethodIndex())
<< " because of wrong number of arguments in invoke instruction";
MaybeRecordStat(MethodCompilationStat::kNotCompiledMalformedOpcode);
return false;
@@ -2716,7 +2716,7 @@
default:
VLOG(compiler) << "Did not compile "
- << PrettyMethod(dex_compilation_unit_->GetDexMethodIndex(), *dex_file_)
+ << dex_file_->PrettyMethod(dex_compilation_unit_->GetDexMethodIndex())
<< " because of unhandled instruction "
<< instruction.Name();
MaybeRecordStat(MethodCompilationStat::kNotCompiledUnhandledInstruction);
diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc
index 412ccfc..8327a4c 100644
--- a/compiler/optimizing/intrinsics.cc
+++ b/compiler/optimizing/intrinsics.cc
@@ -146,7 +146,7 @@
if (!CheckInvokeType(intrinsic, invoke)) {
LOG(WARNING) << "Found an intrinsic with unexpected invoke type: "
<< intrinsic << " for "
- << PrettyMethod(invoke->GetDexMethodIndex(), invoke->GetDexFile())
+ << invoke->GetDexFile().PrettyMethod(invoke->GetDexMethodIndex())
<< invoke->DebugName();
} else {
invoke->SetIntrinsic(intrinsic,
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index 1e69966..59cc009 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -2295,7 +2295,7 @@
ScopedObjectAccess soa(Thread::Current());
os << "["
<< " is_valid=" << rhs.IsValid()
- << " type=" << (!rhs.IsValid() ? "?" : PrettyClass(rhs.GetTypeHandle().Get()))
+ << " type=" << (!rhs.IsValid() ? "?" : mirror::Class::PrettyClass(rhs.GetTypeHandle().Get()))
<< " is_exact=" << rhs.IsExact()
<< " ]";
return os;
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 4370a84..6ba0963 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -173,7 +173,7 @@
const char* GetMethodName() {
// PrettyMethod() is expensive, so we delay calling it until we actually have to.
if (cached_method_name_.empty()) {
- cached_method_name_ = PrettyMethod(graph_->GetMethodIdx(), graph_->GetDexFile());
+ cached_method_name_ = graph_->GetDexFile().PrettyMethod(graph_->GetMethodIdx());
}
return cached_method_name_.c_str();
}
@@ -1044,7 +1044,7 @@
if (kArenaAllocatorCountAllocations) {
if (arena.BytesAllocated() > kArenaAllocatorMemoryReportThreshold) {
MemStats mem_stats(arena.GetMemStats());
- LOG(INFO) << PrettyMethod(method_idx, dex_file) << " " << Dumpable<MemStats>(mem_stats);
+ LOG(INFO) << dex_file.PrettyMethod(method_idx) << " " << Dumpable<MemStats>(mem_stats);
}
}
}
@@ -1066,7 +1066,7 @@
// instruction set is supported -- and has support for read
// barriers, if they are enabled). This makes sure we're not
// regressing.
- std::string method_name = PrettyMethod(method_idx, dex_file);
+ std::string method_name = dex_file.PrettyMethod(method_idx);
bool shouldCompile = method_name.find("$opt$") != std::string::npos;
DCHECK((method != nullptr) || !shouldCompile) << "Didn't compile " << method_name;
}
@@ -1131,7 +1131,7 @@
if (kArenaAllocatorCountAllocations) {
if (arena.BytesAllocated() > kArenaAllocatorMemoryReportThreshold) {
MemStats mem_stats(arena.GetMemStats());
- LOG(INFO) << PrettyMethod(method_idx, *dex_file) << " " << Dumpable<MemStats>(mem_stats);
+ LOG(INFO) << dex_file->PrettyMethod(method_idx) << " " << Dumpable<MemStats>(mem_stats);
}
}
}
diff --git a/compiler/optimizing/prepare_for_register_allocation.cc b/compiler/optimizing/prepare_for_register_allocation.cc
index 8fb5396..a4df9e5 100644
--- a/compiler/optimizing/prepare_for_register_allocation.cc
+++ b/compiler/optimizing/prepare_for_register_allocation.cc
@@ -44,7 +44,7 @@
// Add a fake environment for String.charAt() inline info as we want
// the exception to appear as being thrown from there.
const DexFile& dex_file = check->GetEnvironment()->GetDexFile();
- DCHECK_STREQ(PrettyMethod(check->GetStringCharAtMethodIndex(), dex_file).c_str(),
+ DCHECK_STREQ(dex_file.PrettyMethod(check->GetStringCharAtMethodIndex()).c_str(),
"char java.lang.String.charAt(int)");
ArenaAllocator* arena = GetGraph()->GetArena();
HEnvironment* environment = new (arena) HEnvironment(arena,
diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc
index 83698ad..b16c3ea 100644
--- a/compiler/optimizing/reference_type_propagation.cc
+++ b/compiler/optimizing/reference_type_propagation.cc
@@ -448,9 +448,9 @@
mirror::Class* declaring_class = method->GetDeclaringClass();
DCHECK(declaring_class != nullptr);
DCHECK(declaring_class->IsStringClass())
- << "Expected String class: " << PrettyDescriptor(declaring_class);
+ << "Expected String class: " << declaring_class->PrettyDescriptor();
DCHECK(method->IsConstructor())
- << "Expected String.<init>: " << PrettyMethod(method);
+ << "Expected String.<init>: " << method->PrettyMethod();
}
instr->SetReferenceTypeInfo(
ReferenceTypeInfo::Create(handle_cache_->GetStringClassHandle(), /* is_exact */ true));
diff --git a/compiler/utils/test_dex_file_builder_test.cc b/compiler/utils/test_dex_file_builder_test.cc
index 7a424a2..da4ac79 100644
--- a/compiler/utils/test_dex_file_builder_test.cc
+++ b/compiler/utils/test_dex_file_builder_test.cc
@@ -66,14 +66,14 @@
}
ASSERT_EQ(1u, dex_file->NumFieldIds());
- EXPECT_STREQ("[I TestClass.intField", PrettyField(0u, *dex_file).c_str());
+ EXPECT_STREQ("[I TestClass.intField", dex_file->PrettyField(0u).c_str());
ASSERT_EQ(2u, dex_file->NumProtoIds());
ASSERT_EQ(2u, dex_file->NumMethodIds());
EXPECT_STREQ("TestClass TestClass.bar(java.lang.Object, java.lang.Object[])",
- PrettyMethod(0u, *dex_file).c_str());
+ dex_file->PrettyMethod(0u).c_str());
EXPECT_STREQ("int TestClass.foo()",
- PrettyMethod(1u, *dex_file).c_str());
+ dex_file->PrettyMethod(1u).c_str());
EXPECT_EQ(0u, builder.GetStringIdx("Arbitrary string"));
EXPECT_EQ(2u, builder.GetTypeIdx("Ljava/lang/Class;"));
diff --git a/imgdiag/imgdiag.cc b/imgdiag/imgdiag.cc
index ace21aa..f197fc1 100644
--- a/imgdiag/imgdiag.cc
+++ b/imgdiag/imgdiag.cc
@@ -222,9 +222,9 @@
// Attempt to find fields for all dirty bytes.
mirror::Class* klass = obj->GetClass();
if (obj->IsClass()) {
- os << tabs << "Class " << PrettyClass(obj->AsClass()) << " " << obj << "\n";
+ os << tabs << "Class " << mirror::Class::PrettyClass(obj->AsClass()) << " " << obj << "\n";
} else {
- os << tabs << "Instance of " << PrettyClass(klass) << " " << obj << "\n";
+ os << tabs << "Instance of " << mirror::Class::PrettyClass(klass) << " " << obj << "\n";
}
std::unordered_set<ArtField*> dirty_instance_fields;
@@ -263,7 +263,7 @@
if (!dirty_instance_fields.empty()) {
os << tabs << "Dirty instance fields " << dirty_instance_fields.size() << "\n";
for (ArtField* field : dirty_instance_fields) {
- os << tabs << PrettyField(field)
+ os << tabs << ArtField::PrettyField(field)
<< " original=" << PrettyFieldValue(field, obj)
<< " remote=" << PrettyFieldValue(field, remote_obj) << "\n";
}
@@ -271,7 +271,7 @@
if (!dirty_static_fields.empty()) {
os << tabs << "Dirty static fields " << dirty_static_fields.size() << "\n";
for (ArtField* field : dirty_static_fields) {
- os << tabs << PrettyField(field)
+ os << tabs << ArtField::PrettyField(field)
<< " original=" << PrettyFieldValue(field, obj)
<< " remote=" << PrettyFieldValue(field, remote_obj) << "\n";
}
@@ -681,7 +681,7 @@
class_data[klass].dirty_object_byte_count * 1.0f / object_sizes;
float avg_object_size = object_sizes * 1.0f / dirty_object_count;
const std::string& descriptor = class_data[klass].descriptor;
- os << " " << PrettyClass(klass) << " ("
+ os << " " << mirror::Class::PrettyClass(klass) << " ("
<< "objects: " << dirty_object_count << ", "
<< "avg dirty bytes: " << avg_dirty_bytes_per_class << ", "
<< "avg object size: " << avg_object_size << ", "
@@ -789,7 +789,7 @@
int object_sizes = class_data[klass].false_dirty_byte_count;
float avg_object_size = object_sizes * 1.0f / object_count;
const std::string& descriptor = class_data[klass].descriptor;
- os << " " << PrettyClass(klass) << " ("
+ os << " " << mirror::Class::PrettyClass(klass) << " ("
<< "objects: " << object_count << ", "
<< "avg object size: " << avg_object_size << ", "
<< "total bytes: " << object_sizes << ", "
@@ -824,7 +824,7 @@
os << "\n" << " Clean object count by class:\n";
for (const auto& vk_pair : clean_object_class_values) {
- os << " " << PrettyClass(vk_pair.second) << " (" << vk_pair.first << ")\n";
+ os << " " << mirror::Class::PrettyClass(vk_pair.second) << " (" << vk_pair.first << ")\n";
}
return true;
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index 2fcc0cf..c7bf231 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -940,7 +940,7 @@
return success;
}
- std::string pretty_method = PrettyMethod(dex_method_idx, dex_file, true);
+ std::string pretty_method = dex_file.PrettyMethod(dex_method_idx, true);
vios->Stream() << StringPrintf("%d: %s (dex_method_idx=%d)\n",
class_method_index, pretty_method.c_str(),
dex_method_idx);
@@ -1681,7 +1681,7 @@
virtual void Visit(ArtMethod* method) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_) {
std::ostream& indent_os = image_dumper_->vios_.Stream();
- indent_os << method << " " << " ArtMethod: " << PrettyMethod(method) << "\n";
+ indent_os << method << " " << " ArtMethod: " << ArtMethod::PrettyMethod(method) << "\n";
image_dumper_->DumpMethod(method, indent_os);
indent_os << "\n";
}
@@ -1696,16 +1696,16 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
CHECK(type != nullptr);
if (value == nullptr) {
- os << StringPrintf("null %s\n", PrettyDescriptor(type).c_str());
+ os << StringPrintf("null %s\n", type->PrettyDescriptor().c_str());
} else if (type->IsStringClass()) {
mirror::String* string = value->AsString();
os << StringPrintf("%p String: %s\n", string,
PrintableString(string->ToModifiedUtf8().c_str()).c_str());
} else if (type->IsClassClass()) {
mirror::Class* klass = value->AsClass();
- os << StringPrintf("%p Class: %s\n", klass, PrettyDescriptor(klass).c_str());
+ os << StringPrintf("%p Class: %s\n", klass, mirror::Class::PrettyDescriptor(klass).c_str());
} else {
- os << StringPrintf("%p %s\n", value.Ptr(), PrettyDescriptor(type).c_str());
+ os << StringPrintf("%p %s\n", value.Ptr(), type->PrettyDescriptor().c_str());
}
}
@@ -1825,17 +1825,18 @@
mirror::Class* obj_class = obj->GetClass();
if (obj_class->IsArrayClass()) {
- os << StringPrintf("%p: %s length:%d\n", obj, PrettyDescriptor(obj_class).c_str(),
+ os << StringPrintf("%p: %s length:%d\n", obj, obj_class->PrettyDescriptor().c_str(),
obj->AsArray()->GetLength());
} else if (obj->IsClass()) {
mirror::Class* klass = obj->AsClass();
- os << StringPrintf("%p: java.lang.Class \"%s\" (", obj, PrettyDescriptor(klass).c_str())
+ os << StringPrintf("%p: java.lang.Class \"%s\" (", obj,
+ mirror::Class::PrettyDescriptor(klass).c_str())
<< klass->GetStatus() << ")\n";
} else if (obj_class->IsStringClass()) {
os << StringPrintf("%p: java.lang.String %s\n", obj,
PrintableString(obj->AsString()->ToModifiedUtf8().c_str()).c_str());
} else {
- os << StringPrintf("%p: %s\n", obj, PrettyDescriptor(obj_class).c_str());
+ os << StringPrintf("%p: %s\n", obj, obj_class->PrettyDescriptor().c_str());
}
ScopedIndentation indent1(&state->vios_);
DumpFields(os, obj, obj_class);
@@ -1906,7 +1907,7 @@
msg = "null";
} else if (method_section.Contains(
reinterpret_cast<uint8_t*>(elem) - state->image_space_.Begin())) {
- msg = PrettyMethod(reinterpret_cast<ArtMethod*>(elem));
+ msg = reinterpret_cast<ArtMethod*>(elem)->PrettyMethod();
} else {
msg = "<not in method section>";
}
@@ -1940,7 +1941,7 @@
msg = "null";
} else if (field_section.Contains(
reinterpret_cast<uint8_t*>(elem) - state->image_space_.Begin())) {
- msg = PrettyField(reinterpret_cast<ArtField*>(elem));
+ msg = reinterpret_cast<ArtField*>(elem)->PrettyField();
} else {
msg = "<not in field section>";
}
@@ -1968,7 +1969,7 @@
if (elem == nullptr) {
msg = "null";
} else {
- msg = PrettyClass(elem);
+ msg = elem->PrettyClass();
}
os << StringPrintf("%p %s\n", elem, msg.c_str());
}
@@ -2005,7 +2006,8 @@
if (table != nullptr) {
indent_os << "IMT conflict table " << table << " method: ";
for (size_t i = 0, count = table->NumEntries(pointer_size); i < count; ++i) {
- indent_os << PrettyMethod(table->GetImplementationMethod(i, pointer_size)) << " ";
+ indent_os << ArtMethod::PrettyMethod(table->GetImplementationMethod(i, pointer_size))
+ << " ";
}
}
} else {
@@ -2207,7 +2209,7 @@
os << "\nBig methods (size > " << i << " standard deviations the norm):\n";
first = false;
}
- os << PrettyMethod(method_outlier[j]) << " requires storage of "
+ os << ArtMethod::PrettyMethod(method_outlier[j]) << " requires storage of "
<< PrettySize(cur_size) << "\n";
method_outlier_size[j] = 0; // don't consider this method again
dumped_values++;
@@ -2247,7 +2249,7 @@
<< " standard deviations the norm):\n";
first = false;
}
- os << PrettyMethod(method_outlier[j]) << " expanded code by "
+ os << ArtMethod::PrettyMethod(method_outlier[j]) << " expanded code by "
<< cur_expansion << "\n";
method_outlier_expansion[j] = 0.0; // don't consider this method again
dumped_values++;
@@ -2771,7 +2773,7 @@
return;
}
table_index++;
- std::cerr << " " << PrettyMethod(ptr, true) << std::endl;
+ std::cerr << " " << ptr->PrettyMethod(true) << std::endl;
}
}
@@ -2850,7 +2852,7 @@
PrintTable(current_table, pointer_size);
}
} else {
- std::cerr << " " << PrettyMethod(ptr, true) << std::endl;
+ std::cerr << " " << ptr->PrettyMethod(true) << std::endl;
}
}
@@ -2867,7 +2869,7 @@
uint32_t class_hash, name_hash, signature_hash;
ImTable::GetImtHashComponents(&iface_method, &class_hash, &name_hash, &signature_hash);
uint32_t imt_slot = ImTable::GetImtIndex(&iface_method);
- std::cerr << " " << PrettyMethod(&iface_method, true)
+ std::cerr << " " << iface_method.PrettyMethod(true)
<< " slot=" << imt_slot
<< std::hex
<< " class_hash=0x" << class_hash
@@ -2920,7 +2922,7 @@
}
table_index++;
- std::string p_name = PrettyMethod(ptr2, true);
+ std::string p_name = ptr2->PrettyMethod(true);
if (StartsWith(p_name, method.c_str())) {
std::cerr << " Slot "
<< index
@@ -2933,7 +2935,7 @@
}
}
} else {
- std::string p_name = PrettyMethod(ptr, true);
+ std::string p_name = ptr->PrettyMethod(true);
if (StartsWith(p_name, method.c_str())) {
std::cerr << " Slot " << index << " (1)" << std::endl;
std::cerr << " " << p_name << std::endl;
@@ -2947,7 +2949,7 @@
if (num_methods > 0) {
for (ArtMethod& iface_method : iface->GetMethods(pointer_size)) {
if (ImTable::GetImtIndex(&iface_method) == index) {
- std::string i_name = PrettyMethod(&iface_method, true);
+ std::string i_name = iface_method.PrettyMethod(true);
if (StartsWith(i_name, method.c_str())) {
std::cerr << " Slot " << index << " (1)" << std::endl;
std::cerr << " " << p_name << " (" << i_name << ")" << std::endl;
diff --git a/runtime/arch/stub_test.cc b/runtime/arch/stub_test.cc
index 432ba36..4638c3f 100644
--- a/runtime/arch/stub_test.cc
+++ b/runtime/arch/stub_test.cc
@@ -1168,7 +1168,7 @@
reinterpret_cast<size_t>(nullptr),
StubTest::GetEntrypoint(self, kQuickAllocArrayResolved),
self);
- EXPECT_FALSE(self->IsExceptionPending()) << PrettyTypeOf(self->GetException());
+ EXPECT_FALSE(self->IsExceptionPending()) << mirror::Object::PrettyTypeOf(self->GetException());
EXPECT_NE(reinterpret_cast<size_t>(nullptr), result);
mirror::Object* obj = reinterpret_cast<mirror::Object*>(result);
EXPECT_TRUE(obj->IsArrayInstance());
@@ -2036,7 +2036,7 @@
env->CallBooleanMethod(jarray_list, add_jmethod, jobj);
- ASSERT_FALSE(self->IsExceptionPending()) << PrettyTypeOf(self->GetException());
+ ASSERT_FALSE(self->IsExceptionPending()) << mirror::Object::PrettyTypeOf(self->GetException());
// Contains.
diff --git a/runtime/art_field-inl.h b/runtime/art_field-inl.h
index 24bbcfb..b9f688d 100644
--- a/runtime/art_field-inl.h
+++ b/runtime/art_field-inl.h
@@ -62,7 +62,7 @@
}
inline uint32_t ArtField::Get32(ObjPtr<mirror::Object> object) {
- DCHECK(object != nullptr) << PrettyField(this);
+ DCHECK(object != nullptr) << PrettyField();
DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted());
if (UNLIKELY(IsVolatile())) {
return object->GetField32Volatile(GetOffset());
@@ -72,7 +72,7 @@
template<bool kTransactionActive>
inline void ArtField::Set32(ObjPtr<mirror::Object> object, uint32_t new_value) {
- DCHECK(object != nullptr) << PrettyField(this);
+ DCHECK(object != nullptr) << PrettyField();
DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted());
if (UNLIKELY(IsVolatile())) {
object->SetField32Volatile<kTransactionActive>(GetOffset(), new_value);
@@ -82,7 +82,7 @@
}
inline uint64_t ArtField::Get64(ObjPtr<mirror::Object> object) {
- DCHECK(object != nullptr) << PrettyField(this);
+ DCHECK(object != nullptr) << PrettyField();
DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted());
if (UNLIKELY(IsVolatile())) {
return object->GetField64Volatile(GetOffset());
@@ -92,7 +92,7 @@
template<bool kTransactionActive>
inline void ArtField::Set64(ObjPtr<mirror::Object> object, uint64_t new_value) {
- DCHECK(object != nullptr) << PrettyField(this);
+ DCHECK(object != nullptr) << PrettyField();
DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted());
if (UNLIKELY(IsVolatile())) {
object->SetField64Volatile<kTransactionActive>(GetOffset(), new_value);
@@ -103,7 +103,7 @@
template<class MirrorType>
inline ObjPtr<MirrorType> ArtField::GetObj(ObjPtr<mirror::Object> object) {
- DCHECK(object != nullptr) << PrettyField(this);
+ DCHECK(object != nullptr) << PrettyField();
DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted());
if (UNLIKELY(IsVolatile())) {
return object->GetFieldObjectVolatile<MirrorType>(GetOffset());
@@ -113,7 +113,7 @@
template<bool kTransactionActive>
inline void ArtField::SetObj(ObjPtr<mirror::Object> object, ObjPtr<mirror::Object> new_value) {
- DCHECK(object != nullptr) << PrettyField(this);
+ DCHECK(object != nullptr) << PrettyField();
DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted());
if (UNLIKELY(IsVolatile())) {
object->SetFieldObjectVolatile<kTransactionActive>(GetOffset(), new_value);
@@ -123,8 +123,8 @@
}
#define FIELD_GET(object, type) \
- DCHECK_EQ(Primitive::kPrim ## type, GetTypeAsPrimitiveType()) << PrettyField(this); \
- DCHECK((object) != nullptr) << PrettyField(this); \
+ DCHECK_EQ(Primitive::kPrim ## type, GetTypeAsPrimitiveType()) << PrettyField(); \
+ DCHECK((object) != nullptr) << PrettyField(); \
DCHECK(!IsStatic() || ((object) == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); \
if (UNLIKELY(IsVolatile())) { \
return (object)->GetField ## type ## Volatile(GetOffset()); \
@@ -132,8 +132,8 @@
return (object)->GetField ## type(GetOffset());
#define FIELD_SET(object, type, value) \
- DCHECK_EQ(Primitive::kPrim ## type, GetTypeAsPrimitiveType()) << PrettyField(this); \
- DCHECK((object) != nullptr) << PrettyField(this); \
+ DCHECK_EQ(Primitive::kPrim ## type, GetTypeAsPrimitiveType()) << PrettyField(); \
+ DCHECK((object) != nullptr) << PrettyField(); \
DCHECK(!IsStatic() || ((object) == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); \
if (UNLIKELY(IsVolatile())) { \
(object)->SetField ## type ## Volatile<kTransactionActive>(GetOffset(), value); \
@@ -183,7 +183,7 @@
inline int32_t ArtField::GetInt(ObjPtr<mirror::Object> object) {
if (kIsDebugBuild) {
Primitive::Type type = GetTypeAsPrimitiveType();
- CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this);
+ CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField();
}
return Get32(object);
}
@@ -192,7 +192,7 @@
inline void ArtField::SetInt(ObjPtr<mirror::Object> object, int32_t i) {
if (kIsDebugBuild) {
Primitive::Type type = GetTypeAsPrimitiveType();
- CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this);
+ CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField();
}
Set32<kTransactionActive>(object, i);
}
@@ -200,7 +200,7 @@
inline int64_t ArtField::GetLong(ObjPtr<mirror::Object> object) {
if (kIsDebugBuild) {
Primitive::Type type = GetTypeAsPrimitiveType();
- CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this);
+ CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField();
}
return Get64(object);
}
@@ -209,13 +209,13 @@
inline void ArtField::SetLong(ObjPtr<mirror::Object> object, int64_t j) {
if (kIsDebugBuild) {
Primitive::Type type = GetTypeAsPrimitiveType();
- CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this);
+ CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField();
}
Set64<kTransactionActive>(object, j);
}
inline float ArtField::GetFloat(ObjPtr<mirror::Object> object) {
- DCHECK_EQ(Primitive::kPrimFloat, GetTypeAsPrimitiveType()) << PrettyField(this);
+ DCHECK_EQ(Primitive::kPrimFloat, GetTypeAsPrimitiveType()) << PrettyField();
JValue bits;
bits.SetI(Get32(object));
return bits.GetF();
@@ -223,14 +223,14 @@
template<bool kTransactionActive>
inline void ArtField::SetFloat(ObjPtr<mirror::Object> object, float f) {
- DCHECK_EQ(Primitive::kPrimFloat, GetTypeAsPrimitiveType()) << PrettyField(this);
+ DCHECK_EQ(Primitive::kPrimFloat, GetTypeAsPrimitiveType()) << PrettyField();
JValue bits;
bits.SetF(f);
Set32<kTransactionActive>(object, bits.GetI());
}
inline double ArtField::GetDouble(ObjPtr<mirror::Object> object) {
- DCHECK_EQ(Primitive::kPrimDouble, GetTypeAsPrimitiveType()) << PrettyField(this);
+ DCHECK_EQ(Primitive::kPrimDouble, GetTypeAsPrimitiveType()) << PrettyField();
JValue bits;
bits.SetJ(Get64(object));
return bits.GetD();
@@ -238,20 +238,20 @@
template<bool kTransactionActive>
inline void ArtField::SetDouble(ObjPtr<mirror::Object> object, double d) {
- DCHECK_EQ(Primitive::kPrimDouble, GetTypeAsPrimitiveType()) << PrettyField(this);
+ DCHECK_EQ(Primitive::kPrimDouble, GetTypeAsPrimitiveType()) << PrettyField();
JValue bits;
bits.SetD(d);
Set64<kTransactionActive>(object, bits.GetJ());
}
inline ObjPtr<mirror::Object> ArtField::GetObject(ObjPtr<mirror::Object> object) {
- DCHECK_EQ(Primitive::kPrimNot, GetTypeAsPrimitiveType()) << PrettyField(this);
+ DCHECK_EQ(Primitive::kPrimNot, GetTypeAsPrimitiveType()) << PrettyField();
return GetObj(object);
}
template<bool kTransactionActive>
inline void ArtField::SetObject(ObjPtr<mirror::Object> object, ObjPtr<mirror::Object> l) {
- DCHECK_EQ(Primitive::kPrimNot, GetTypeAsPrimitiveType()) << PrettyField(this);
+ DCHECK_EQ(Primitive::kPrimNot, GetTypeAsPrimitiveType()) << PrettyField();
SetObj<kTransactionActive>(object, l);
}
diff --git a/runtime/art_field.cc b/runtime/art_field.cc
index 78c62d6..b46b058 100644
--- a/runtime/art_field.cc
+++ b/runtime/art_field.cc
@@ -62,4 +62,25 @@
hs.NewHandle(dex_cache));
}
+std::string ArtField::PrettyField(ArtField* f, bool with_type) {
+ if (f == nullptr) {
+ return "null";
+ }
+ return f->PrettyField(with_type);
+}
+
+std::string ArtField::PrettyField(bool with_type) {
+ std::string result;
+ if (with_type) {
+ result += PrettyDescriptor(GetTypeDescriptor());
+ result += ' ';
+ }
+ std::string temp;
+ result += PrettyDescriptor(GetDeclaringClass()->GetDescriptor(&temp));
+ result += '.';
+ result += GetName();
+ return result;
+}
+
+
} // namespace art
diff --git a/runtime/art_field.h b/runtime/art_field.h
index 8ba383c..7c2f490 100644
--- a/runtime/art_field.h
+++ b/runtime/art_field.h
@@ -201,6 +201,13 @@
return declaring_class_;
}
+ // Returns a human-readable signature. Something like "a.b.C.f" or
+ // "int a.b.C.f" (depending on the value of 'with_type').
+ static std::string PrettyField(ArtField* f, bool with_type = true)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ std::string PrettyField(bool with_type = true)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
// Update the declaring class with the passed in visitor. Does not use read barrier.
template <typename Visitor>
ALWAYS_INLINE void UpdateObjects(const Visitor& visitor)
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index 1aa6a00..499b7fe 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -55,7 +55,7 @@
if (!IsRuntimeMethod()) {
CHECK(result != nullptr) << this;
CHECK(result->IsIdxLoaded() || result->IsErroneous())
- << result->GetStatus() << " " << PrettyClass(result);
+ << result->GetStatus() << " " << result->PrettyClass();
} else {
CHECK(result == nullptr) << this;
}
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 937dcee..3065f68 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -276,7 +276,7 @@
if (LIKELY(have_quick_code)) {
if (kLogInvocationStartAndReturn) {
LOG(INFO) << StringPrintf(
- "Invoking '%s' quick code=%p static=%d", PrettyMethod(this).c_str(),
+ "Invoking '%s' quick code=%p static=%d", PrettyMethod().c_str(),
GetEntryPointFromQuickCompiledCode(), static_cast<int>(IsStatic() ? 1 : 0));
}
@@ -287,7 +287,7 @@
? nullptr
: GetOatMethodQuickCode(runtime->GetClassLinker()->GetImagePointerSize());
CHECK(oat_quick_code == nullptr || oat_quick_code != GetEntryPointFromQuickCompiledCode())
- << "Don't call compiled code when -Xint " << PrettyMethod(this);
+ << "Don't call compiled code when -Xint " << PrettyMethod();
}
if (!IsStatic()) {
@@ -302,11 +302,11 @@
self->DeoptimizeWithDeoptimizationException(result);
}
if (kLogInvocationStartAndReturn) {
- LOG(INFO) << StringPrintf("Returned '%s' quick code=%p", PrettyMethod(this).c_str(),
+ LOG(INFO) << StringPrintf("Returned '%s' quick code=%p", PrettyMethod().c_str(),
GetEntryPointFromQuickCompiledCode());
}
} else {
- LOG(INFO) << "Not invoking '" << PrettyMethod(this) << "' code=null";
+ LOG(INFO) << "Not invoking '" << PrettyMethod() << "' code=null";
if (result != nullptr) {
result->SetJ(0);
}
@@ -318,9 +318,9 @@
}
void ArtMethod::RegisterNative(const void* native_method, bool is_fast) {
- CHECK(IsNative()) << PrettyMethod(this);
- CHECK(!IsFastNative()) << PrettyMethod(this);
- CHECK(native_method != nullptr) << PrettyMethod(this);
+ CHECK(IsNative()) << PrettyMethod();
+ CHECK(!IsFastNative()) << PrettyMethod();
+ CHECK(native_method != nullptr) << PrettyMethod();
if (is_fast) {
SetAccessFlags(GetAccessFlags() | kAccFastNative);
}
@@ -328,7 +328,7 @@
}
void ArtMethod::UnregisterNative() {
- CHECK(IsNative() && !IsFastNative()) << PrettyMethod(this);
+ CHECK(IsNative() && !IsFastNative()) << PrettyMethod();
// restore stub to lookup native pointer via dlsym
RegisterNative(GetJniDlsymLookupStub(), false);
}
@@ -421,7 +421,7 @@
oat_method_index++;
}
CHECK(found_virtual) << "Didn't find oat method index for virtual method: "
- << PrettyMethod(method);
+ << method->PrettyMethod();
}
DCHECK_EQ(oat_method_index,
GetOatMethodIndexFromMethodIndex(*declaring_class->GetDexCache()->GetDexFile(),
@@ -482,7 +482,7 @@
Runtime* runtime = Runtime::Current();
const void* existing_entry_point = GetEntryPointFromQuickCompiledCode();
- CHECK(existing_entry_point != nullptr) << PrettyMethod(this) << "@" << this;
+ CHECK(existing_entry_point != nullptr) << PrettyMethod() << "@" << this;
ClassLinker* class_linker = runtime->GetClassLinker();
if (class_linker->IsQuickGenericJniStub(existing_entry_point)) {
@@ -517,7 +517,7 @@
return method_header;
} else {
DCHECK(!code_cache->ContainsPc(reinterpret_cast<const void*>(pc)))
- << PrettyMethod(this)
+ << PrettyMethod()
<< ", pc=" << std::hex << pc
<< ", entry_point=" << std::hex << reinterpret_cast<uintptr_t>(existing_entry_point)
<< ", copy=" << std::boolalpha << IsCopied()
@@ -549,7 +549,7 @@
}
const void* oat_entry_point = oat_method.GetQuickCode();
if (oat_entry_point == nullptr || class_linker->IsQuickGenericJniStub(oat_entry_point)) {
- DCHECK(IsNative()) << PrettyMethod(this);
+ DCHECK(IsNative()) << PrettyMethod();
return nullptr;
}
@@ -561,7 +561,7 @@
}
DCHECK(method_header->Contains(pc))
- << PrettyMethod(this)
+ << PrettyMethod()
<< " " << std::hex << pc << " " << oat_entry_point
<< " " << (uintptr_t)(method_header->code_ + method_header->code_size_);
return method_header;
@@ -637,4 +637,66 @@
return runtime->GetClassLinker()->GetImagePointerSize() == pointer_size;
}
+std::string ArtMethod::PrettyMethod(ArtMethod* m, bool with_signature) {
+ if (m == nullptr) {
+ return "null";
+ }
+ return m->PrettyMethod(with_signature);
+}
+
+std::string ArtMethod::PrettyMethod(bool with_signature) {
+ ArtMethod* m = this;
+ if (!m->IsRuntimeMethod()) {
+ m = m->GetInterfaceMethodIfProxy(Runtime::Current()->GetClassLinker()->GetImagePointerSize());
+ }
+ std::string result(PrettyDescriptor(m->GetDeclaringClassDescriptor()));
+ result += '.';
+ result += m->GetName();
+ if (UNLIKELY(m->IsFastNative())) {
+ result += "!";
+ }
+ if (with_signature) {
+ const Signature signature = m->GetSignature();
+ std::string sig_as_string(signature.ToString());
+ if (signature == Signature::NoSignature()) {
+ return result + sig_as_string;
+ }
+ result = PrettyReturnType(sig_as_string.c_str()) + " " + result +
+ PrettyArguments(sig_as_string.c_str());
+ }
+ return result;
+}
+
+std::string ArtMethod::JniShortName() {
+ std::string class_name(GetDeclaringClassDescriptor());
+ // Remove the leading 'L' and trailing ';'...
+ CHECK_EQ(class_name[0], 'L') << class_name;
+ CHECK_EQ(class_name[class_name.size() - 1], ';') << class_name;
+ class_name.erase(0, 1);
+ class_name.erase(class_name.size() - 1, 1);
+
+ std::string method_name(GetName());
+
+ std::string short_name;
+ short_name += "Java_";
+ short_name += MangleForJni(class_name);
+ short_name += "_";
+ short_name += MangleForJni(method_name);
+ return short_name;
+}
+
+std::string ArtMethod::JniLongName() {
+ std::string long_name;
+ long_name += JniShortName();
+ long_name += "__";
+
+ std::string signature(GetSignature().ToString());
+ signature.erase(0, 1);
+ signature.erase(signature.begin() + signature.find(')'), signature.end());
+
+ long_name += MangleForJni(signature);
+
+ return long_name;
+}
+
} // namespace art
diff --git a/runtime/art_method.h b/runtime/art_method.h
index 0d0bf20..b68e099 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -614,6 +614,20 @@
// Returns whether the method has any compiled code, JIT or AOT.
bool HasAnyCompiledCode() REQUIRES_SHARED(Locks::mutator_lock_);
+ // Returns a human-readable signature for 'm'. Something like "a.b.C.m" or
+ // "a.b.C.m(II)V" (depending on the value of 'with_signature').
+ static std::string PrettyMethod(ArtMethod* m, bool with_signature = true)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ std::string PrettyMethod(bool with_signature = true)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ // Returns the JNI native function name for the non-overloaded method 'm'.
+ std::string JniShortName()
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ // Returns the JNI native function name for the overloaded method 'm'.
+ std::string JniLongName()
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
+
// Update heap objects and non-entrypoint pointers by the passed in visitor for image relocation.
// Does not use read barrier.
diff --git a/runtime/check_jni.cc b/runtime/check_jni.cc
index 5ec9898..a1ce30b 100644
--- a/runtime/check_jni.cc
+++ b/runtime/check_jni.cc
@@ -289,7 +289,7 @@
mirror::Class* c = o->GetClass();
if (c->FindInstanceField(f->GetName(), f->GetTypeDescriptor()) == nullptr) {
AbortF("jfieldID %s not valid for an object of class %s",
- PrettyField(f).c_str(), PrettyTypeOf(o).c_str());
+ f->PrettyField().c_str(), o->PrettyTypeOf().c_str());
return false;
}
return true;
@@ -318,17 +318,17 @@
return false;
}
if (type != Primitive::GetType(m->GetShorty()[0])) {
- AbortF("the return type of %s does not match %s", function_name_, PrettyMethod(m).c_str());
+ AbortF("the return type of %s does not match %s", function_name_, m->PrettyMethod().c_str());
return false;
}
bool is_static = (invoke == kStatic);
if (is_static != m->IsStatic()) {
if (is_static) {
AbortF("calling non-static method %s with %s",
- PrettyMethod(m).c_str(), function_name_);
+ m->PrettyMethod().c_str(), function_name_);
} else {
AbortF("calling static method %s with %s",
- PrettyMethod(m).c_str(), function_name_);
+ m->PrettyMethod().c_str(), function_name_);
}
return false;
}
@@ -336,17 +336,18 @@
ObjPtr<mirror::Class> c = soa.Decode<mirror::Class>(jc);
if (!m->GetDeclaringClass()->IsAssignableFrom(c)) {
AbortF("can't call %s %s with class %s", invoke == kStatic ? "static" : "nonvirtual",
- PrettyMethod(m).c_str(), PrettyClass(c).c_str());
+ m->PrettyMethod().c_str(), mirror::Class::PrettyClass(c).c_str());
return false;
}
}
if (invoke != kStatic) {
ObjPtr<mirror::Object> o = soa.Decode<mirror::Object>(jobj);
if (o == nullptr) {
- AbortF("can't call %s on null object", PrettyMethod(m).c_str());
+ AbortF("can't call %s on null object", m->PrettyMethod().c_str());
return false;
} else if (!o->InstanceOf(m->GetDeclaringClass())) {
- AbortF("can't call %s on instance of %s", PrettyMethod(m).c_str(), PrettyTypeOf(o).c_str());
+ AbortF("can't call %s on instance of %s", m->PrettyMethod().c_str(),
+ o->PrettyTypeOf().c_str());
return false;
}
}
@@ -366,7 +367,8 @@
return false;
}
if (c != f->GetDeclaringClass()) {
- AbortF("static jfieldID %p not valid for class %s", fid, PrettyClass(c).c_str());
+ AbortF("static jfieldID %p not valid for class %s", fid,
+ mirror::Class::PrettyClass(c).c_str());
return false;
}
return true;
@@ -389,7 +391,8 @@
}
ObjPtr<mirror::Class> c = soa.Decode<mirror::Class>(java_class);
if (!m->GetDeclaringClass()->IsAssignableFrom(c)) {
- AbortF("can't call static %s on class %s", PrettyMethod(m).c_str(), PrettyClass(c).c_str());
+ AbortF("can't call static %s on class %s", m->PrettyMethod().c_str(),
+ mirror::Class::PrettyClass(c).c_str());
return false;
}
return true;
@@ -410,10 +413,11 @@
}
ObjPtr<mirror::Object> o = soa.Decode<mirror::Object>(java_object);
if (o == nullptr) {
- AbortF("can't call %s on null object", PrettyMethod(m).c_str());
+ AbortF("can't call %s on null object", m->PrettyMethod().c_str());
return false;
} else if (!o->InstanceOf(m->GetDeclaringClass())) {
- AbortF("can't call %s on instance of %s", PrettyMethod(m).c_str(), PrettyTypeOf(o).c_str());
+ AbortF("can't call %s on instance of %s", m->PrettyMethod().c_str(),
+ o->PrettyTypeOf().c_str());
return false;
}
return true;
@@ -481,7 +485,7 @@
LOG(INFO) << "JNI: call to " << function_name_ << "(" << msg << ")";
} else if (entry) {
if (has_method_) {
- std::string methodName(PrettyMethod(traceMethod, false));
+ std::string methodName(ArtMethod::PrettyMethod(traceMethod, false));
LOG(INFO) << "JNI: " << methodName << " -> " << function_name_ << "(" << msg << ")";
indent_ = methodName.size() + 1;
} else {
@@ -532,7 +536,7 @@
Thread* self = Thread::Current();
ScopedObjectAccess soa(self);
ArtMethod* traceMethod = self->GetCurrentMethod(nullptr);
- std::string methodName(PrettyMethod(traceMethod, false));
+ std::string methodName(ArtMethod::PrettyMethod(traceMethod, false));
LOG(INFO) << "JNI: " << methodName << " -> " << function_name_ << "(" << msg << ")";
indent_ = methodName.size() + 1;
} else {
@@ -567,7 +571,7 @@
soa.Decode<mirror::Class>(WellKnownClasses::java_lang_reflect_Constructor) != c) {
AbortF("expected java.lang.reflect.Method or "
"java.lang.reflect.Constructor but got object of type %s: %p",
- PrettyTypeOf(method).c_str(), jmethod);
+ method->PrettyTypeOf().c_str(), jmethod);
return false;
}
return true;
@@ -581,7 +585,7 @@
return false;
}
if (!method->IsConstructor() || method->IsStatic()) {
- AbortF("expected a constructor but %s: %p", PrettyMethod(method).c_str(), mid);
+ AbortF("expected a constructor but %s: %p", method->PrettyMethod().c_str(), mid);
return false;
}
return true;
@@ -597,7 +601,7 @@
mirror::Class* c = field->GetClass();
if (soa.Decode<mirror::Class>(WellKnownClasses::java_lang_reflect_Field) != c) {
AbortF("expected java.lang.reflect.Field but got object of type %s: %p",
- PrettyTypeOf(field).c_str(), jfield);
+ field->PrettyTypeOf().c_str(), jfield);
return false;
}
return true;
@@ -608,7 +612,7 @@
ObjPtr<mirror::Object> obj = soa.Decode<mirror::Object>(jobj);
if (!obj->GetClass()->IsThrowableClass()) {
AbortF("expected java.lang.Throwable but got object of type "
- "%s: %p", PrettyTypeOf(obj).c_str(), obj.Ptr());
+ "%s: %p", obj->PrettyTypeOf().c_str(), obj.Ptr());
return false;
}
return true;
@@ -619,7 +623,7 @@
ObjPtr<mirror::Class> c = soa.Decode<mirror::Class>(jc);
if (!c->IsThrowableClass()) {
AbortF("expected java.lang.Throwable class but got object of "
- "type %s: %p", PrettyDescriptor(c).c_str(), c.Ptr());
+ "type %s: %p", c->PrettyDescriptor().c_str(), c.Ptr());
return false;
}
return true;
@@ -649,7 +653,7 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
ObjPtr<mirror::Class> c = soa.Decode<mirror::Class>(jc);
if (!c->IsInstantiableNonArray()) {
- AbortF("can't make objects of type %s: %p", PrettyDescriptor(c).c_str(), c.Ptr());
+ AbortF("can't make objects of type %s: %p", c->PrettyDescriptor().c_str(), c.Ptr());
return false;
}
return true;
@@ -663,7 +667,7 @@
ObjPtr<mirror::Array> a = soa.Decode<mirror::Array>(array);
if (a->GetClass()->GetComponentType()->GetPrimitiveType() != type) {
AbortF("incompatible array type %s expected %s[]: %p",
- PrettyDescriptor(a->GetClass()).c_str(), PrettyDescriptor(type).c_str(), array);
+ a->GetClass()->PrettyDescriptor().c_str(), PrettyDescriptor(type).c_str(), array);
return false;
}
return true;
@@ -682,12 +686,13 @@
DCHECK(field != nullptr); // Already checked by Check.
if (is_static != field->IsStatic()) {
AbortF("attempt to access %s field %s: %p",
- field->IsStatic() ? "static" : "non-static", PrettyField(field).c_str(), fid);
+ field->IsStatic() ? "static" : "non-static", field->PrettyField().c_str(), fid);
return false;
}
if (type != field->GetTypeAsPrimitiveType()) {
AbortF("attempt to access field %s of type %s with the wrong type %s: %p",
- PrettyField(field).c_str(), PrettyDescriptor(field->GetTypeDescriptor()).c_str(),
+ field->PrettyField().c_str(),
+ PrettyDescriptor(field->GetTypeDescriptor()).c_str(),
PrettyDescriptor(type).c_str(), fid);
return false;
}
@@ -695,20 +700,20 @@
ObjPtr<mirror::Object> o = soa.Decode<mirror::Object>(obj);
if (o == nullptr || !o->IsClass()) {
AbortF("attempt to access static field %s with a class argument of type %s: %p",
- PrettyField(field).c_str(), PrettyTypeOf(o).c_str(), fid);
+ field->PrettyField().c_str(), o->PrettyTypeOf().c_str(), fid);
return false;
}
ObjPtr<mirror::Class> c = o->AsClass();
if (c != field->GetDeclaringClass()) {
AbortF("attempt to access static field %s with an incompatible class argument of %s: %p",
- PrettyField(field).c_str(), PrettyDescriptor(c).c_str(), fid);
+ field->PrettyField().c_str(), mirror::Class::PrettyDescriptor(c).c_str(), fid);
return false;
}
} else {
ObjPtr<mirror::Object> o = soa.Decode<mirror::Object>(obj);
if (o == nullptr || !field->GetDeclaringClass()->IsAssignableFrom(o->GetClass())) {
AbortF("attempt to access field %s from an object argument of type %s: %p",
- PrettyField(field).c_str(), PrettyTypeOf(o).c_str(), fid);
+ field->PrettyField().c_str(), o->PrettyTypeOf().c_str(), fid);
return false;
}
}
@@ -808,7 +813,7 @@
break;
}
if (!okay) {
- AbortF("%s has wrong type: %s", what, PrettyTypeOf(obj).c_str());
+ AbortF("%s has wrong type: %s", what, mirror::Object::PrettyTypeOf(obj).c_str());
return false;
}
@@ -942,9 +947,9 @@
} else if (!Runtime::Current()->GetHeap()->IsValidObjectAddress(c.Ptr())) {
StringAppendF(msg, "INVALID POINTER:%p", jc);
} else if (!c->IsClass()) {
- *msg += "INVALID NON-CLASS OBJECT OF TYPE:" + PrettyTypeOf(c);
+ *msg += "INVALID NON-CLASS OBJECT OF TYPE:" + c->PrettyTypeOf();
} else {
- *msg += PrettyClass(c);
+ *msg += c->PrettyClass();
if (!entry) {
StringAppendF(msg, " (%p)", jc);
}
@@ -954,7 +959,7 @@
case 'f': { // jfieldID
jfieldID fid = arg.f;
ArtField* f = soa.DecodeField(fid);
- *msg += PrettyField(f);
+ *msg += ArtField::PrettyField(f);
if (!entry) {
StringAppendF(msg, " (%p)", fid);
}
@@ -963,7 +968,7 @@
case 'm': { // jmethodID
jmethodID mid = arg.m;
ArtMethod* m = soa.DecodeMethod(mid);
- *msg += PrettyMethod(m);
+ *msg += ArtMethod::PrettyMethod(m);
if (!entry) {
StringAppendF(msg, " (%p)", mid);
}
@@ -1115,7 +1120,7 @@
java_array, a.Ptr());
return false;
} else if (!a->IsArrayInstance()) {
- AbortF("jarray argument has non-array type: %s", PrettyTypeOf(a).c_str());
+ AbortF("jarray argument has non-array type: %s", a->PrettyTypeOf().c_str());
return false;
}
return true;
diff --git a/runtime/check_reference_map_visitor.h b/runtime/check_reference_map_visitor.h
index ab712f9..93fdaa6 100644
--- a/runtime/check_reference_map_visitor.h
+++ b/runtime/check_reference_map_visitor.h
@@ -41,10 +41,10 @@
return true;
}
- LOG(INFO) << "At " << PrettyMethod(m, false);
+ LOG(INFO) << "At " << m->PrettyMethod(false);
if (m->IsCalleeSaveMethod()) {
- LOG(WARNING) << "no PC for " << PrettyMethod(m);
+ LOG(WARNING) << "no PC for " << m->PrettyMethod();
return true;
}
diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h
index 126187f..3e842d2 100644
--- a/runtime/class_linker-inl.h
+++ b/runtime/class_linker-inl.h
@@ -260,8 +260,8 @@
}
}
}
- LOG(FATAL) << "Didn't find dex cache for " << PrettyClass(proxy_class) << " "
- << PrettyMethod(proxy_method);
+ LOG(FATAL) << "Didn't find dex cache for " << proxy_class->PrettyClass() << " "
+ << proxy_method->PrettyMethod();
UNREACHABLE();
}
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 63de76c..733bd30 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -149,7 +149,7 @@
const char* descriptor = obj->AsClass()->GetDescriptor(&temp);
if (HasInitWithString(self, class_linker, descriptor)) {
- self->ThrowNewException(descriptor, PrettyDescriptor(c).c_str());
+ self->ThrowNewException(descriptor, c->PrettyDescriptor().c_str());
} else {
self->ThrowNewException(descriptor, nullptr);
}
@@ -175,15 +175,16 @@
if (c->GetVerifyError() != nullptr) {
mirror::Object* verify_error = c->GetVerifyError();
if (verify_error->IsClass()) {
- extra = PrettyDescriptor(verify_error->AsClass());
+ extra = mirror::Class::PrettyDescriptor(verify_error->AsClass());
} else {
extra = verify_error->AsThrowable()->Dump();
}
}
- LOG(INFO) << "Rejecting re-init on previously-failed class " << PrettyClass(c) << ": " << extra;
+ LOG(INFO) << "Rejecting re-init on previously-failed class " << c->PrettyClass()
+ << ": " << extra;
}
- CHECK(c->IsErroneous()) << PrettyClass(c) << " " << c->GetStatus();
+ CHECK(c->IsErroneous()) << c->PrettyClass() << " " << c->GetStatus();
Thread* self = Thread::Current();
if (runtime->IsAotCompiler()) {
// At compile time, accurate errors and NCDFE are disabled to speed compilation.
@@ -199,7 +200,7 @@
// the top-level exception must be a NoClassDefFoundError. The potentially already pending
// exception will be a cause.
self->ThrowNewWrappedException("Ljava/lang/NoClassDefFoundError;",
- PrettyDescriptor(c).c_str());
+ c->PrettyDescriptor().c_str());
}
}
}
@@ -294,7 +295,7 @@
*field_offset = MemberOffset(RoundUp(field_offset->Uint32Value(), n));
AddFieldGap(old_offset.Uint32Value(), field_offset->Uint32Value(), gaps);
}
- CHECK(type != Primitive::kPrimNot) << PrettyField(field); // should be primitive types
+ CHECK(type != Primitive::kPrimNot) << field->PrettyField(); // should be primitive types
grouped_and_sorted_fields->pop_front();
if (!gaps->empty() && gaps->top().size >= n) {
FieldGap gap = gaps->top();
@@ -779,11 +780,11 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
if (m->IsRuntimeMethod()) {
mirror::Class* declaring_class = m->GetDeclaringClassUnchecked();
- CHECK(declaring_class == nullptr) << declaring_class << " " << PrettyMethod(m);
+ CHECK(declaring_class == nullptr) << declaring_class << " " << m->PrettyMethod();
} else if (m->IsCopied()) {
- CHECK(m->GetDeclaringClass() != nullptr) << PrettyMethod(m);
+ CHECK(m->GetDeclaringClass() != nullptr) << m->PrettyMethod();
} else if (expected_class != nullptr) {
- CHECK_EQ(m->GetDeclaringClassUnchecked(), expected_class) << PrettyMethod(m);
+ CHECK_EQ(m->GetDeclaringClassUnchecked(), expected_class) << m->PrettyMethod();
}
if (!spaces.empty()) {
bool contains = false;
@@ -1010,7 +1011,7 @@
spaces[i]->GetLiveBitmap()->Walk(CheckTrampolines, &data);
if (data.error) {
ArtMethod* m = data.m;
- LOG(ERROR) << "Found a broken ArtMethod: " << PrettyMethod(m);
+ LOG(ERROR) << "Found a broken ArtMethod: " << ArtMethod::PrettyMethod(m);
*error_msg = "Found an ArtMethod with a bad entrypoint";
return false;
}
@@ -1097,7 +1098,7 @@
DCHECK(dex_file_field != nullptr);
DCHECK(dex_file_name_field != nullptr);
DCHECK(element != nullptr);
- CHECK_EQ(dex_file_field->GetDeclaringClass(), element->GetClass()) << PrettyTypeOf(element);
+ CHECK_EQ(dex_file_field->GetDeclaringClass(), element->GetClass()) << element->PrettyTypeOf();
ObjPtr<mirror::Object> dex_file = dex_file_field->GetObject(element);
if (dex_file == nullptr) {
return nullptr;
@@ -1125,7 +1126,8 @@
while (!ClassLinker::IsBootClassLoader(soa, class_loader)) {
if (soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_PathClassLoader) !=
class_loader->GetClass()) {
- *error_msg = StringPrintf("Unknown class loader type %s", PrettyTypeOf(class_loader).c_str());
+ *error_msg = StringPrintf("Unknown class loader type %s",
+ class_loader->PrettyTypeOf().c_str());
// Unsupported class loader.
return false;
}
@@ -1213,7 +1215,7 @@
REQUIRES_SHARED(Locks::mutator_lock_, Locks::classlinker_classes_lock_) {
mirror::Class* klass = method->GetDeclaringClass();
if (klass != nullptr && !Runtime::Current()->GetHeap()->ObjectIsInBootImageSpace(klass)) {
- CHECK_EQ(table_->LookupByDescriptor(klass), klass) << PrettyClass(klass);
+ CHECK_EQ(table_->LookupByDescriptor(klass), klass) << mirror::Class::PrettyClass(klass);
}
}
@@ -1415,7 +1417,7 @@
!IsQuickGenericJniStub(code) &&
!IsQuickToInterpreterBridge(code) &&
!m.IsNative()) {
- DCHECK_EQ(code, oat_code) << PrettyMethod(&m);
+ DCHECK_EQ(code, oat_code) << m.PrettyMethod();
}
}
for (ArtMethod& m : klass->GetVirtualMethods(kRuntimePointerSize)) {
@@ -1425,7 +1427,7 @@
!IsQuickGenericJniStub(code) &&
!IsQuickToInterpreterBridge(code) &&
!m.IsNative()) {
- DCHECK_EQ(code, oat_code) << PrettyMethod(&m);
+ DCHECK_EQ(code, oat_code) << m.PrettyMethod();
}
}
}
@@ -1466,7 +1468,7 @@
DCHECK(
space_->GetImageHeader().GetImageSection(ImageHeader::kSectionDexCacheArrays).Contains(
reinterpret_cast<uint8_t*>(strings) - space_->Begin()))
- << "String dex cache array for " << PrettyClass(klass) << " is not in app image";
+ << "String dex cache array for " << klass->PrettyClass() << " is not in app image";
// Dex caches have already been updated, so take the strings pointer from there.
mirror::StringDexCacheType* new_strings = klass->GetDexCache()->GetStrings();
DCHECK_NE(strings, new_strings);
@@ -2270,7 +2272,7 @@
return nullptr;
}
// Return the loaded class. No exceptions should be pending.
- CHECK(klass->IsResolved()) << PrettyClass(klass);
+ CHECK(klass->IsResolved()) << klass->PrettyClass();
self->AssertNoPendingException();
return klass;
}
@@ -2707,7 +2709,7 @@
// Special case to get oat code without overwriting a trampoline.
const void* ClassLinker::GetQuickOatCodeFor(ArtMethod* method) {
- CHECK(method->IsInvokable()) << PrettyMethod(method);
+ CHECK(method->IsInvokable()) << method->PrettyMethod();
if (method->IsProxyMethod()) {
return GetQuickProxyInvokeHandler();
}
@@ -2766,7 +2768,7 @@
}
void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) {
- DCHECK(klass->IsInitialized()) << PrettyDescriptor(klass);
+ DCHECK(klass->IsInitialized()) << klass->PrettyDescriptor();
if (klass->NumDirectMethods() == 0) {
return; // No direct methods => no static methods.
}
@@ -2782,7 +2784,7 @@
CHECK(dex_class_def != nullptr);
const uint8_t* class_data = dex_file.GetClassData(*dex_class_def);
// There should always be class data if there were direct methods.
- CHECK(class_data != nullptr) << PrettyDescriptor(klass);
+ CHECK(class_data != nullptr) << klass->PrettyDescriptor();
ClassDataItemIterator it(dex_file, class_data);
// Skip fields
while (it.HasNextStaticField()) {
@@ -3021,7 +3023,7 @@
}
if (UNLIKELY(num_sfields != it.NumStaticFields()) ||
UNLIKELY(num_ifields != it.NumInstanceFields())) {
- LOG(WARNING) << "Duplicate fields in class " << PrettyDescriptor(klass.Get())
+ LOG(WARNING) << "Duplicate fields in class " << klass->PrettyDescriptor()
<< " (unique static fields: " << num_sfields << "/" << it.NumStaticFields()
<< ", unique instance fields: " << num_ifields << "/" << it.NumInstanceFields() << ")";
// NOTE: Not shrinking the over-allocated sfields/ifields, just setting size.
@@ -3137,7 +3139,7 @@
} else {
if (UNLIKELY((access_flags & kAccConstructor) == 0)) {
LOG(WARNING) << method_name << " didn't have expected constructor access flag in class "
- << PrettyDescriptor(klass.Get()) << " in dex file " << dex_file.GetLocation();
+ << klass->PrettyDescriptor() << " in dex file " << dex_file.GetLocation();
access_flags |= kAccConstructor;
}
}
@@ -3661,8 +3663,8 @@
// If we got this far then we have a hard failure.
std::string error_msg =
StringPrintf("Rejecting class %s that attempts to sub-type erroneous class %s",
- PrettyDescriptor(klass.Get()).c_str(),
- PrettyDescriptor(supertype.Get()).c_str());
+ klass->PrettyDescriptor().c_str(),
+ supertype->PrettyDescriptor().c_str());
LOG(WARNING) << error_msg << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8();
StackHandleScope<1> hs(self);
Handle<mirror::Throwable> cause(hs.NewHandle(self->GetException()));
@@ -3698,8 +3700,9 @@
old_status == mirror::Class::kStatusVerifyingAtRuntime) {
lock.WaitIgnoringInterrupts();
CHECK(klass->IsErroneous() || (klass->GetStatus() > old_status))
- << "Class '" << PrettyClass(klass.Get()) << "' performed an illegal verification state "
- << "transition from " << old_status << " to " << klass->GetStatus();
+ << "Class '" << klass->PrettyClass()
+ << "' performed an illegal verification state transition from " << old_status
+ << " to " << klass->GetStatus();
old_status = klass->GetStatus();
}
@@ -3723,7 +3726,7 @@
mirror::Class::SetStatus(klass, mirror::Class::kStatusVerifying, self);
} else {
CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime)
- << PrettyClass(klass.Get());
+ << klass->PrettyClass();
CHECK(!Runtime::Current()->IsAotCompiler());
mirror::Class::SetStatus(klass, mirror::Class::kStatusVerifyingAtRuntime, self);
}
@@ -3812,9 +3815,10 @@
if (preverified || verifier_failure != verifier::MethodVerifier::kHardFailure) {
if (!preverified && verifier_failure != verifier::MethodVerifier::kNoFailure) {
- VLOG(class_linker) << "Soft verification failure in class " << PrettyDescriptor(klass.Get())
- << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8()
- << " because: " << error_msg;
+ VLOG(class_linker) << "Soft verification failure in class "
+ << klass->PrettyDescriptor()
+ << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8()
+ << " because: " << error_msg;
}
self->AssertNoPendingException();
// Make sure all classes referenced by catch blocks are resolved.
@@ -3845,7 +3849,7 @@
}
}
} else {
- VLOG(verifier) << "Verification failed on class " << PrettyDescriptor(klass.Get())
+ VLOG(verifier) << "Verification failed on class " << klass->PrettyDescriptor()
<< " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8()
<< " because: " << error_msg;
self->AssertNoPendingException();
@@ -3961,7 +3965,7 @@
}
std::string temp;
LOG(FATAL) << "Unexpected class status: " << oat_file_class_status
- << " " << dex_file.GetLocation() << " " << PrettyClass(klass) << " "
+ << " " << dex_file.GetLocation() << " " << klass->PrettyClass() << " "
<< klass->GetDescriptor(&temp);
UNREACHABLE();
}
@@ -4062,7 +4066,7 @@
// They have as many virtual methods as the array
auto h_methods = hs.NewHandle(soa.Decode<mirror::ObjectArray<mirror::Method>>(methods));
DCHECK_EQ(h_methods->GetClass(), mirror::Method::ArrayClass())
- << PrettyClass(h_methods->GetClass());
+ << mirror::Class::PrettyClass(h_methods->GetClass());
const size_t num_virtual_methods = h_methods->GetLength();
// Create the methods array.
@@ -4142,11 +4146,11 @@
Handle<mirror::String> decoded_name = hs2.NewHandle(soa.Decode<mirror::String>(name));
std::string interfaces_field_name(StringPrintf("java.lang.Class[] %s.interfaces",
decoded_name->ToModifiedUtf8().c_str()));
- CHECK_EQ(PrettyField(klass->GetStaticField(0)), interfaces_field_name);
+ CHECK_EQ(ArtField::PrettyField(klass->GetStaticField(0)), interfaces_field_name);
std::string throws_field_name(StringPrintf("java.lang.Class[][] %s.throws",
decoded_name->ToModifiedUtf8().c_str()));
- CHECK_EQ(PrettyField(klass->GetStaticField(1)), throws_field_name);
+ CHECK_EQ(ArtField::PrettyField(klass->GetStaticField(1)), throws_field_name);
CHECK_EQ(klass.Get()->GetInterfaces(),
soa.Decode<mirror::ObjectArray<mirror::Class>>(interfaces));
@@ -4320,7 +4324,7 @@
return false;
}
- CHECK(klass->IsResolved()) << PrettyClass(klass.Get()) << ": state=" << klass->GetStatus();
+ CHECK(klass->IsResolved()) << klass->PrettyClass() << ": state=" << klass->GetStatus();
if (!klass->IsVerified()) {
VerifyClass(self, klass);
@@ -4334,7 +4338,7 @@
if (self->IsExceptionPending()) {
// Check that it's a VerifyError.
DCHECK_EQ("java.lang.Class<java.lang.VerifyError>",
- PrettyClass(self->GetException()->GetClass()));
+ mirror::Class::PrettyClass(self->GetException()->GetClass()));
} else {
// Check that another thread attempted initialization.
DCHECK_NE(0, klass->GetClinitThreadId());
@@ -4387,7 +4391,7 @@
}
self->AllowThreadSuspension();
- CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusVerified) << PrettyClass(klass.Get())
+ CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusVerified) << klass->PrettyClass()
<< " self.tid=" << self->GetTid() << " clinit.tid=" << klass->GetClinitThreadId();
// From here out other threads may observe that we're initializing and so changes of state
@@ -4412,7 +4416,7 @@
// the super class became erroneous due to initialization.
CHECK(handle_scope_super->IsErroneous() && self->IsExceptionPending())
<< "Super class initialization failed for "
- << PrettyDescriptor(handle_scope_super.Get())
+ << handle_scope_super->PrettyDescriptor()
<< " that has unexpected status " << handle_scope_super->GetStatus()
<< "\nPending exception:\n"
<< (self->GetException() != nullptr ? self->GetException()->Dump() : "");
@@ -4527,7 +4531,8 @@
} else if (Runtime::Current()->IsTransactionAborted()) {
// The exception thrown when the transaction aborted has been caught and cleared
// so we need to throw it again now.
- VLOG(compiler) << "Return from class initializer of " << PrettyDescriptor(klass.Get())
+ VLOG(compiler) << "Return from class initializer of "
+ << mirror::Class::PrettyDescriptor(klass.Get())
<< " without exception while transaction was aborted: re-throw it now.";
Runtime::Current()->ThrowTransactionAbortError(self);
mirror::Class::SetStatus(klass, mirror::Class::kStatusError, self);
@@ -4629,14 +4634,14 @@
// The caller wants an exception, but it was thrown in a
// different thread. Synthesize one here.
ThrowNoClassDefFoundError("<clinit> failed for class %s; see exception in other thread",
- PrettyDescriptor(klass.Get()).c_str());
+ klass->PrettyDescriptor().c_str());
VlogClassInitializationFailure(klass);
return false;
}
if (klass->IsInitialized()) {
return true;
}
- LOG(FATAL) << "Unexpected class status. " << PrettyClass(klass.Get()) << " is "
+ LOG(FATAL) << "Unexpected class status. " << klass->PrettyClass() << " is "
<< klass->GetStatus();
}
UNREACHABLE();
@@ -4653,15 +4658,15 @@
const DexFile::MethodId& method_id = dex_file->GetMethodId(m->GetDexMethodIndex());
const DexFile::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id);
uint16_t return_type_idx = proto_id.return_type_idx_;
- std::string return_type = PrettyType(return_type_idx, *dex_file);
- std::string class_loader = PrettyTypeOf(m->GetDeclaringClass()->GetClassLoader());
+ std::string return_type = dex_file->PrettyType(return_type_idx);
+ std::string class_loader = mirror::Object::PrettyTypeOf(m->GetDeclaringClass()->GetClassLoader());
ThrowWrappedLinkageError(klass.Get(),
"While checking class %s method %s signature against %s %s: "
"Failed to resolve return type %s with %s",
- PrettyDescriptor(klass.Get()).c_str(),
- PrettyMethod(method).c_str(),
+ mirror::Class::PrettyDescriptor(klass.Get()).c_str(),
+ ArtMethod::PrettyMethod(method).c_str(),
super_klass->IsInterface() ? "interface" : "superclass",
- PrettyDescriptor(super_klass.Get()).c_str(),
+ mirror::Class::PrettyDescriptor(super_klass.Get()).c_str(),
return_type.c_str(), class_loader.c_str());
}
@@ -4675,15 +4680,15 @@
DCHECK(Thread::Current()->IsExceptionPending());
DCHECK(!m->IsProxyMethod());
const DexFile* dex_file = m->GetDexFile();
- std::string arg_type = PrettyType(arg_type_idx, *dex_file);
- std::string class_loader = PrettyTypeOf(m->GetDeclaringClass()->GetClassLoader());
+ std::string arg_type = dex_file->PrettyType(arg_type_idx);
+ std::string class_loader = mirror::Object::PrettyTypeOf(m->GetDeclaringClass()->GetClassLoader());
ThrowWrappedLinkageError(klass.Get(),
"While checking class %s method %s signature against %s %s: "
"Failed to resolve arg %u type %s with %s",
- PrettyDescriptor(klass.Get()).c_str(),
- PrettyMethod(method).c_str(),
+ mirror::Class::PrettyDescriptor(klass.Get()).c_str(),
+ ArtMethod::PrettyMethod(method).c_str(),
super_klass->IsInterface() ? "interface" : "superclass",
- PrettyDescriptor(super_klass.Get()).c_str(),
+ mirror::Class::PrettyDescriptor(super_klass.Get()).c_str(),
index, arg_type.c_str(), class_loader.c_str());
}
@@ -4694,10 +4699,10 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
ThrowLinkageError(klass.Get(),
"Class %s method %s resolves differently in %s %s: %s",
- PrettyDescriptor(klass.Get()).c_str(),
- PrettyMethod(method).c_str(),
+ mirror::Class::PrettyDescriptor(klass.Get()).c_str(),
+ ArtMethod::PrettyMethod(method).c_str(),
super_klass->IsInterface() ? "interface" : "superclass",
- PrettyDescriptor(super_klass.Get()).c_str(),
+ mirror::Class::PrettyDescriptor(super_klass.Get()).c_str(),
error_msg.c_str());
}
@@ -4725,9 +4730,9 @@
if (UNLIKELY(other_return_type != return_type.Get())) {
ThrowSignatureMismatch(klass, super_klass, method1,
StringPrintf("Return types mismatch: %s(%p) vs %s(%p)",
- PrettyClassAndClassLoader(return_type.Get()).c_str(),
+ return_type->PrettyClassAndClassLoader().c_str(),
return_type.Get(),
- PrettyClassAndClassLoader(other_return_type).c_str(),
+ other_return_type->PrettyClassAndClassLoader().c_str(),
other_return_type));
return false;
}
@@ -4738,7 +4743,7 @@
if (types2 != nullptr && types2->Size() != 0) {
ThrowSignatureMismatch(klass, super_klass, method1,
StringPrintf("Type list mismatch with %s",
- PrettyMethod(method2, true).c_str()));
+ method2->PrettyMethod(true).c_str()));
return false;
}
return true;
@@ -4746,7 +4751,7 @@
if (types1->Size() != 0) {
ThrowSignatureMismatch(klass, super_klass, method1,
StringPrintf("Type list mismatch with %s",
- PrettyMethod(method2, true).c_str()));
+ method2->PrettyMethod(true).c_str()));
return false;
}
return true;
@@ -4755,7 +4760,7 @@
if (UNLIKELY(num_types != types2->Size())) {
ThrowSignatureMismatch(klass, super_klass, method1,
StringPrintf("Type list mismatch with %s",
- PrettyMethod(method2, true).c_str()));
+ method2->PrettyMethod(true).c_str()));
return false;
}
for (uint32_t i = 0; i < num_types; ++i) {
@@ -4780,9 +4785,9 @@
ThrowSignatureMismatch(klass, super_klass, method1,
StringPrintf("Parameter %u type mismatch: %s(%p) vs %s(%p)",
i,
- PrettyClassAndClassLoader(param_type.Get()).c_str(),
+ param_type->PrettyClassAndClassLoader().c_str(),
param_type.Get(),
- PrettyClassAndClassLoader(other_param_type).c_str(),
+ other_param_type->PrettyClassAndClassLoader().c_str(),
other_param_type));
return false;
}
@@ -4848,7 +4853,7 @@
const bool success = InitializeClass(self, c, can_init_fields, can_init_parents);
if (!success) {
if (can_init_fields && can_init_parents) {
- CHECK(self->IsExceptionPending()) << PrettyClass(c.Get());
+ CHECK(self->IsExceptionPending()) << c->PrettyClass();
}
} else {
self->AssertNoPendingException();
@@ -4989,7 +4994,7 @@
if (!klass->IsTemp() || (!init_done_ && klass->GetClassSize() == class_size)) {
// We don't need to retire this class as it has no embedded tables or it was created the
// correct size during class linker initialization.
- CHECK_EQ(klass->GetClassSize(), class_size) << PrettyDescriptor(klass.Get());
+ CHECK_EQ(klass->GetClassSize(), class_size) << klass->PrettyDescriptor();
if (klass->ShouldHaveEmbeddedVTable()) {
klass->PopulateEmbeddedVTable(image_pointer_size_);
@@ -5228,13 +5233,13 @@
LOG(WARNING) << "Incompatible structural change detected: " <<
StringPrintf(
"Structural change of %s is hazardous (%s at compile time, %s at runtime): %s",
- PrettyType(super_class_def->class_idx_, dex_file).c_str(),
+ dex_file.PrettyType(super_class_def->class_idx_).c_str(),
class_oat_file->GetLocation().c_str(),
loaded_super_oat_file->GetLocation().c_str(),
error_msg.c_str());
ThrowIncompatibleClassChangeError(klass.Get(),
"Structural change of %s is hazardous (%s at compile time, %s at runtime): %s",
- PrettyType(super_class_def->class_idx_, dex_file).c_str(),
+ dex_file.PrettyType(super_class_def->class_idx_).c_str(),
class_oat_file->GetLocation().c_str(),
loaded_super_oat_file->GetLocation().c_str(),
error_msg.c_str());
@@ -5261,7 +5266,7 @@
if (super_class_idx == class_def.class_idx_) {
ThrowClassCircularityError(klass.Get(),
"Class %s extends itself",
- PrettyDescriptor(klass.Get()).c_str());
+ klass->PrettyDescriptor().c_str());
return false;
}
@@ -5273,8 +5278,8 @@
// Verify
if (!klass->CanAccess(super_class)) {
ThrowIllegalAccessError(klass.Get(), "Class %s extended by class %s is inaccessible",
- PrettyDescriptor(super_class).c_str(),
- PrettyDescriptor(klass.Get()).c_str());
+ super_class->PrettyDescriptor().c_str(),
+ klass->PrettyDescriptor().c_str());
return false;
}
CHECK(super_class->IsResolved());
@@ -5299,8 +5304,8 @@
// TODO: the RI seemed to ignore this in my testing.
ThrowIllegalAccessError(klass.Get(),
"Interface %s implemented by class %s is inaccessible",
- PrettyDescriptor(interface).c_str(),
- PrettyDescriptor(klass.Get()).c_str());
+ interface->PrettyDescriptor().c_str(),
+ klass->PrettyDescriptor().c_str());
return false;
}
}
@@ -5322,22 +5327,22 @@
}
if (super == nullptr) {
ThrowLinkageError(klass.Get(), "No superclass defined for class %s",
- PrettyDescriptor(klass.Get()).c_str());
+ klass->PrettyDescriptor().c_str());
return false;
}
// Verify
if (super->IsFinal() || super->IsInterface()) {
ThrowIncompatibleClassChangeError(klass.Get(),
"Superclass %s of %s is %s",
- PrettyDescriptor(super).c_str(),
- PrettyDescriptor(klass.Get()).c_str(),
+ super->PrettyDescriptor().c_str(),
+ klass->PrettyDescriptor().c_str(),
super->IsFinal() ? "declared final" : "an interface");
return false;
}
if (!klass->CanAccess(super)) {
ThrowIllegalAccessError(klass.Get(), "Superclass %s is inaccessible to class %s",
- PrettyDescriptor(super).c_str(),
- PrettyDescriptor(klass.Get()).c_str());
+ super->PrettyDescriptor().c_str(),
+ klass->PrettyDescriptor().c_str());
return false;
}
@@ -5362,7 +5367,7 @@
if (init_done_ && super == GetClassRoot(kJavaLangRefReference)) {
ThrowLinkageError(klass.Get(),
"Class %s attempts to subclass java.lang.ref.Reference, which is not allowed",
- PrettyDescriptor(klass.Get()).c_str());
+ klass->PrettyDescriptor().c_str());
return false;
}
@@ -5404,7 +5409,7 @@
REQUIRES_SHARED(Locks::mutator_lock_) :
dex_file_(method->GetDexFile()), mid_(&dex_file_->GetMethodId(method->GetDexMethodIndex())),
name_(nullptr), name_len_(0) {
- DCHECK(!method->IsProxyMethod()) << PrettyMethod(method);
+ DCHECK(!method->IsProxyMethod()) << method->PrettyMethod();
}
const char* GetName() {
@@ -5416,7 +5421,7 @@
bool HasSameNameAndSignature(ArtMethod* other)
REQUIRES_SHARED(Locks::mutator_lock_) {
- DCHECK(!other->IsProxyMethod()) << PrettyMethod(other);
+ DCHECK(!other->IsProxyMethod()) << other->PrettyMethod();
const DexFile* other_dex_file = other->GetDexFile();
const DexFile::MethodId& other_mid = other_dex_file->GetMethodId(other->GetDexMethodIndex());
if (dex_file_ == other_dex_file) {
@@ -5579,7 +5584,7 @@
} else {
DCHECK(super_class->IsAbstract() && !super_class->IsArrayClass());
auto* super_vtable = super_class->GetVTable();
- CHECK(super_vtable != nullptr) << PrettyClass(super_class.Get());
+ CHECK(super_vtable != nullptr) << super_class->PrettyClass();
// We might need to change vtable if we have new virtual methods or new interfaces (since that
// might give us new default methods). See comment above.
if (num_virtual_methods == 0 && super_class->GetIfTableCount() == klass->GetIfTableCount()) {
@@ -5637,14 +5642,14 @@
super_method->GetAccessFlags())) {
if (super_method->IsFinal()) {
ThrowLinkageError(klass.Get(), "Method %s overrides final method in class %s",
- PrettyMethod(virtual_method).c_str(),
+ ArtMethod::PrettyMethod(virtual_method).c_str(),
super_method->GetDeclaringClassDescriptor());
return false;
}
vtable->SetElementPtrSize(j, virtual_method, image_pointer_size_);
virtual_method->SetMethodIndex(j);
} else {
- LOG(WARNING) << "Before Android 4.1, method " << PrettyMethod(virtual_method)
+ LOG(WARNING) << "Before Android 4.1, method " << ArtMethod::PrettyMethod(virtual_method)
<< " would have incorrectly overridden the package-private method in "
<< PrettyDescriptor(super_method->GetDeclaringClassDescriptor());
}
@@ -5691,9 +5696,10 @@
// then.
default_translations->insert(
{j, ClassLinker::MethodTranslation::CreateTranslatedMethod(default_method)});
- VLOG(class_linker) << "Method " << PrettyMethod(super_method)
- << " overridden by default " << PrettyMethod(default_method)
- << " in " << PrettyClass(klass.Get());
+ VLOG(class_linker) << "Method " << super_method->PrettyMethod()
+ << " overridden by default "
+ << default_method->PrettyMethod()
+ << " in " << mirror::Class::PrettyClass(klass.Get());
}
break;
}
@@ -5855,7 +5861,8 @@
// The verifier should have caught the non-public method for dex version 37. Just warn and
// skip it since this is from before default-methods so we don't really need to care that it
// has code.
- LOG(WARNING) << "Interface method " << PrettyMethod(current_method) << " is not public! "
+ LOG(WARNING) << "Interface method " << current_method->PrettyMethod()
+ << " is not public! "
<< "This will be a fatal error in subsequent versions of android. "
<< "Continuing anyway.";
}
@@ -5872,9 +5879,9 @@
iface,
image_pointer_size_)) {
VLOG(class_linker) << "Conflicting default method implementations found: "
- << PrettyMethod(current_method) << " and "
- << PrettyMethod(*out_default_method) << " in class "
- << PrettyClass(klass.Get()) << " conflict.";
+ << current_method->PrettyMethod() << " and "
+ << ArtMethod::PrettyMethod(*out_default_method) << " in class "
+ << klass->PrettyClass() << " conflict.";
*out_default_method = nullptr;
return DefaultMethodSearchResult::kDefaultConflict;
} else {
@@ -5897,18 +5904,20 @@
// We should now finish traversing the graph to find if we have default methods that
// conflict.
} else {
- VLOG(class_linker) << "A default method '" << PrettyMethod(current_method) << "' was "
- << "skipped because it was overridden by an abstract method in a "
- << "subinterface on class '" << PrettyClass(klass.Get()) << "'";
+ VLOG(class_linker) << "A default method '" << current_method->PrettyMethod()
+ << "' was "
+ << "skipped because it was overridden by an abstract method in a "
+ << "subinterface on class '" << klass->PrettyClass() << "'";
}
}
break;
}
}
if (*out_default_method != nullptr) {
- VLOG(class_linker) << "Default method '" << PrettyMethod(*out_default_method) << "' selected "
- << "as the implementation for '" << PrettyMethod(target_method) << "' "
- << "in '" << PrettyClass(klass.Get()) << "'";
+ VLOG(class_linker) << "Default method '" << (*out_default_method)->PrettyMethod()
+ << "' selected "
+ << "as the implementation for '" << target_method->PrettyMethod()
+ << "' in '" << klass->PrettyClass() << "'";
return DefaultMethodSearchResult::kDefaultFound;
} else {
return DefaultMethodSearchResult::kAbstractFound;
@@ -5986,8 +5995,8 @@
}
void ClassLinker::FillIMTAndConflictTables(mirror::Class* klass) {
- DCHECK(klass->ShouldHaveImt()) << PrettyClass(klass);
- DCHECK(!klass->IsTemp()) << PrettyClass(klass);
+ DCHECK(klass->ShouldHaveImt()) << klass->PrettyClass();
+ DCHECK(!klass->IsTemp()) << klass->PrettyClass();
ArtMethod* imt_data[ImTable::kSize];
Runtime* const runtime = Runtime::Current();
ArtMethod* const unimplemented_method = runtime->GetImtUnimplementedMethod();
@@ -6248,8 +6257,8 @@
for (int32_t j = 0; j < ifcount; j++) {
mirror::Class* super_interface = interface->GetIfTable()->GetInterface(j);
DCHECK(ContainsElement(classes_in_iftable, super_interface))
- << "Iftable does not contain " << PrettyClass(super_interface)
- << ", a superinterface of " << PrettyClass(interface);
+ << "Iftable does not contain " << mirror::Class::PrettyClass(super_interface)
+ << ", a superinterface of " << interface->PrettyClass();
}
}
}
@@ -6261,8 +6270,9 @@
mirror::Class* if_b = iftable->GetInterface(j);
// !(if_a <: if_b)
CHECK(!if_b->IsAssignableFrom(if_a))
- << "Bad interface order: " << PrettyClass(if_a) << " (index " << i << ") extends "
- << PrettyClass(if_b) << " (index " << j << ") and so should be after it in the "
+ << "Bad interface order: " << mirror::Class::PrettyClass(if_a) << " (index " << i
+ << ") extends "
+ << if_b->PrettyClass() << " (index " << j << ") and so should be after it in the "
<< "interface list.";
}
}
@@ -6311,7 +6321,7 @@
std::string temp;
ThrowIncompatibleClassChangeError(klass.Get(),
"Class %s implements non-interface class %s",
- PrettyDescriptor(klass.Get()).c_str(),
+ klass->PrettyDescriptor().c_str(),
PrettyDescriptor(interface->GetDescriptor(&temp)).c_str());
return false;
}
@@ -6404,16 +6414,17 @@
CHECK(m != nullptr);
CHECK_EQ(m->GetMethodIndexDuringLinking(), i)
- << PrettyMethod(m) << " has an unexpected method index for its spot in the vtable for class"
- << PrettyClass(klass.Get());
+ << m->PrettyMethod()
+ << " has an unexpected method index for its spot in the vtable for class"
+ << klass->PrettyClass();
ArraySlice<ArtMethod> virtuals = klass->GetVirtualMethodsSliceUnchecked(pointer_size);
auto is_same_method = [m] (const ArtMethod& meth) {
return &meth == m;
};
CHECK((super_vtable_length > i && superclass->GetVTableEntry(i, pointer_size) == m) ||
std::find_if(virtuals.begin(), virtuals.end(), is_same_method) != virtuals.end())
- << PrettyMethod(m) << " does not seem to be owned by current class "
- << PrettyClass(klass.Get()) << " or any of its superclasses!";
+ << m->PrettyMethod() << " does not seem to be owned by current class "
+ << klass->PrettyClass() << " or any of its superclasses!";
}
}
@@ -6441,8 +6452,9 @@
!name_comparator.HasSameNameAndSignature(
other_entry->GetInterfaceMethodIfProxy(pointer_size)))
<< "vtable entries " << i << " and " << j << " are identical for "
- << PrettyClass(klass.Get()) << " in method " << PrettyMethod(vtable_entry) << " and "
- << PrettyMethod(other_entry);
+ << klass->PrettyClass() << " in method "
+ << vtable_entry->PrettyMethod()
+ << " and " << other_entry->PrettyMethod();
}
}
}
@@ -6639,7 +6651,8 @@
self->EndAssertNoThreadSuspension(old_cause);
ThrowIllegalAccessError(klass.Get(),
"Method '%s' implementing interface method '%s' is not public",
- PrettyMethod(vtable_method).c_str(), PrettyMethod(interface_method).c_str());
+ vtable_method->PrettyMethod().c_str(),
+ interface_method->PrettyMethod().c_str());
return false;
} else if (UNLIKELY(vtable_method->IsOverridableByDefaultMethod())) {
// We might have a newer, better, default method for this, so we just skip it. If we
@@ -6698,8 +6711,10 @@
// illegal states, incorrect vtable size, and incorrect or inconsistent iftable entries)
// in this class and any subclasses.
DCHECK(vtable_impl == nullptr || vtable_impl == supers_method)
- << "vtable_impl was " << PrettyMethod(vtable_impl) << " and not 'nullptr' or "
- << PrettyMethod(supers_method) << " as expected. IFTable appears to be corrupt!";
+ << "vtable_impl was " << ArtMethod::PrettyMethod(vtable_impl)
+ << " and not 'nullptr' or "
+ << supers_method->PrettyMethod()
+ << " as expected. IFTable appears to be corrupt!";
vtable_impl = supers_method;
}
}
@@ -6799,7 +6814,7 @@
ArtMethod* miranda_method = FindSameNameAndSignature(interface_name_comparator,
miranda_methods);
if (miranda_method == nullptr) {
- DCHECK(interface_method->IsAbstract()) << PrettyMethod(interface_method);
+ DCHECK(interface_method->IsAbstract()) << interface_method->PrettyMethod();
miranda_method = reinterpret_cast<ArtMethod*>(allocator.Alloc(method_size));
CHECK(miranda_method != nullptr);
// Point the interface table at a phantom slot.
@@ -6831,7 +6846,8 @@
if (has_new_virtuals) {
DCHECK(!is_interface || (default_methods.empty() && miranda_methods.empty()))
<< "Interfaces should only have default-conflict methods appended to them.";
- VLOG(class_linker) << PrettyClass(klass.Get()) << ": miranda_methods=" << miranda_methods.size()
+ VLOG(class_linker) << mirror::Class::PrettyClass(klass.Get()) << ": miranda_methods="
+ << miranda_methods.size()
<< " default_methods=" << default_methods.size()
<< " overriding_default_methods=" << overriding_default_methods.size()
<< " default_conflict_methods=" << default_conflict_methods.size()
@@ -6964,7 +6980,7 @@
auto translated_method_it = move_table.find(new_method);
CHECK(translated_method_it != move_table.end())
<< "We must have a translation for methods added to the classes methods_ array! We "
- << "could not find the ArtMethod added for " << PrettyMethod(new_method);
+ << "could not find the ArtMethod added for " << ArtMethod::PrettyMethod(new_method);
ArtMethod* new_vtable_method = translated_method_it->second;
// Leave the declaring class alone the method's dex_code_item_offset_ and dex_method_index_
// fields are references into the dex file the method was defined in. Since the ArtMethod
@@ -7036,11 +7052,11 @@
for (size_t j = 0, count = iftable->GetMethodArrayCount(i); j < count; ++j) {
auto* method_array = iftable->GetMethodArray(i);
auto* m = method_array->GetElementPtrSize<ArtMethod*>(j, image_pointer_size_);
- DCHECK(m != nullptr) << PrettyClass(klass.Get());
+ DCHECK(m != nullptr) << klass->PrettyClass();
auto it = move_table.find(m);
if (it != move_table.end()) {
auto* new_m = it->second;
- DCHECK(new_m != nullptr) << PrettyClass(klass.Get());
+ DCHECK(new_m != nullptr) << klass->PrettyClass();
method_array->SetElementPtrSize(j, new_m, image_pointer_size_);
}
}
@@ -7068,7 +7084,7 @@
[m] (ArtMethod& meth) {
return &meth == m;
}) != m->GetDeclaringClass()->GetMethods(image_pointer_size_).end())
- << "Obsolete methods " << PrettyMethod(m) << " is in dex cache!";
+ << "Obsolete methods " << m->PrettyMethod() << " is in dex cache!";
}
}
// Put some random garbage in old methods to help find stale pointers.
@@ -7151,12 +7167,12 @@
mirror::Class* super_class = klass->GetSuperClass();
if (super_class != nullptr) {
CHECK(super_class->IsResolved())
- << PrettyClass(klass.Get()) << " " << PrettyClass(super_class);
+ << klass->PrettyClass() << " " << super_class->PrettyClass();
field_offset = MemberOffset(super_class->GetObjectSize());
}
}
- CHECK_EQ(num_fields == 0, fields == nullptr) << PrettyClass(klass.Get());
+ CHECK_EQ(num_fields == 0, fields == nullptr) << klass->PrettyClass();
// we want a relatively stable order so that adding new fields
// minimizes disruption of C++ version such as Class and Method.
@@ -7222,9 +7238,9 @@
if (!is_static && klass->DescriptorEquals("Ljava/lang/ref/Reference;")) {
// We know there are no non-reference fields in the Reference classes, and we know
// that 'referent' is alphabetically last, so this is easy...
- CHECK_EQ(num_reference_fields, num_fields) << PrettyClass(klass.Get());
+ CHECK_EQ(num_reference_fields, num_fields) << klass->PrettyClass();
CHECK_STREQ(fields->At(num_fields - 1).GetName(), "referent")
- << PrettyClass(klass.Get());
+ << klass->PrettyClass();
--num_reference_fields;
}
@@ -7253,11 +7269,11 @@
cur_super = cur_super->GetSuperClass();
}
if (super_class == nullptr) {
- CHECK_EQ(total_reference_instance_fields, 1u) << PrettyDescriptor(klass.Get());
+ CHECK_EQ(total_reference_instance_fields, 1u) << klass->PrettyDescriptor();
} else {
// Check that there is at least num_reference_fields other than Object.class.
CHECK_GE(total_reference_instance_fields, 1u + num_reference_fields)
- << PrettyClass(klass.Get());
+ << klass->PrettyClass();
}
}
if (!klass->IsVariableSize()) {
@@ -7285,8 +7301,8 @@
for (size_t i = 0; i < num_fields; i++) {
ArtField* field = &fields->At(i);
VLOG(class_linker) << "LinkFields: " << (is_static ? "static" : "instance")
- << " class=" << PrettyClass(klass.Get()) << " field=" << PrettyField(field) << " offset="
- << field->GetOffsetDuringLinking();
+ << " class=" << klass->PrettyClass() << " field=" << field->PrettyField()
+ << " offset=" << field->GetOffsetDuringLinking();
if (i != 0) {
ArtField* const prev_field = &fields->At(i - 1);
// NOTE: The field names can be the same. This is not possible in the Java language
@@ -7448,7 +7464,7 @@
}
}
DCHECK((resolved == nullptr) || resolved->IsResolved() || resolved->IsErroneous())
- << PrettyDescriptor(resolved) << " " << resolved->GetStatus();
+ << resolved->PrettyDescriptor() << " " << resolved->GetStatus();
return resolved;
}
@@ -7513,7 +7529,7 @@
if (UNLIKELY(!klass->IsInterface())) {
ThrowIncompatibleClassChangeError(klass,
"Found class %s, but interface was expected",
- PrettyDescriptor(klass).c_str());
+ klass->PrettyDescriptor().c_str());
return nullptr;
} else {
resolved = klass->FindInterfaceMethod(dex_cache.Get(), method_idx, image_pointer_size_);
@@ -7679,7 +7695,8 @@
return nullptr;
}
if (klass->IsInterface()) {
- LOG(FATAL) << "ResolveAmbiguousMethod: unexpected method in interface: " << PrettyClass(klass);
+ LOG(FATAL) << "ResolveAmbiguousMethod: unexpected method in interface: "
+ << klass->PrettyClass();
return nullptr;
}
diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc
index 4fac830..ab18627 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -332,9 +332,9 @@
EXPECT_FALSE(method.IsDirect());
EXPECT_TRUE(method.IsCopied());
EXPECT_TRUE(method.GetDeclaringClass()->IsInterface())
- << "declaring class: " << PrettyClass(method.GetDeclaringClass());
+ << "declaring class: " << method.GetDeclaringClass()->PrettyClass();
EXPECT_TRUE(method.GetDeclaringClass()->IsAssignableFrom(klass.Get()))
- << "declaring class: " << PrettyClass(method.GetDeclaringClass());
+ << "declaring class: " << method.GetDeclaringClass()->PrettyClass();
}
for (size_t i = 0; i < klass->NumInstanceFields(); i++) {
@@ -366,8 +366,7 @@
if (current_ref_offset.Uint32Value() == end_ref_offset.Uint32Value()) {
// While Reference.referent is not primitive, the ClassLinker
// treats it as such so that the garbage collector won't scan it.
- EXPECT_EQ(PrettyField(field),
- "java.lang.Object java.lang.ref.Reference.referent");
+ EXPECT_EQ(field->PrettyField(), "java.lang.Object java.lang.ref.Reference.referent");
} else {
current_ref_offset = MemberOffset(current_ref_offset.Uint32Value() +
sizeof(mirror::HeapReference<mirror::Object>));
@@ -1215,14 +1214,14 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
if (!method->IsNative() && !method->IsAbstract()) {
EXPECT_EQ((method->GetAccessFlags() & kAccSkipAccessChecks) != 0U, verified)
- << PrettyMethod(method, true);
+ << method->PrettyMethod(true);
}
}
static void CheckVerificationAttempted(mirror::Class* c, bool preverified)
REQUIRES_SHARED(Locks::mutator_lock_) {
EXPECT_EQ((c->GetAccessFlags() & kAccVerificationAttempted) != 0U, preverified)
- << "Class " << PrettyClass(c) << " not as expected";
+ << "Class " << mirror::Class::PrettyClass(c) << " not as expected";
for (auto& m : c->GetMethods(kRuntimePointerSize)) {
CheckMethod(&m, preverified);
}
diff --git a/runtime/common_throws.cc b/runtime/common_throws.cc
index 0aa33c6..b0aba59 100644
--- a/runtime/common_throws.cc
+++ b/runtime/common_throws.cc
@@ -42,8 +42,8 @@
if (referrer != nullptr) {
std::string location(referrer->GetLocation());
if (!location.empty()) {
- os << " (declaration of '" << PrettyDescriptor(referrer)
- << "' appears in " << location << ")";
+ os << " (declaration of '" << referrer->PrettyDescriptor()
+ << "' appears in " << location << ")";
}
}
}
@@ -89,15 +89,14 @@
void ThrowAbstractMethodError(ArtMethod* method) {
ThrowException("Ljava/lang/AbstractMethodError;", nullptr,
StringPrintf("abstract method \"%s\"",
- PrettyMethod(method).c_str()).c_str());
+ ArtMethod::PrettyMethod(method).c_str()).c_str());
}
void ThrowAbstractMethodError(uint32_t method_idx, const DexFile& dex_file) {
ThrowException("Ljava/lang/AbstractMethodError;", /* referrer */ nullptr,
StringPrintf("abstract method \"%s\"",
- PrettyMethod(method_idx,
- dex_file,
- /* with_signature */ true).c_str()).c_str());
+ dex_file.PrettyMethod(method_idx,
+ /* with_signature */ true).c_str()).c_str());
}
// ArithmeticException
@@ -119,8 +118,8 @@
ObjPtr<mirror::Class> array_class) {
ThrowException("Ljava/lang/ArrayStoreException;", nullptr,
StringPrintf("%s cannot be stored in an array of type %s",
- PrettyDescriptor(element_class).c_str(),
- PrettyDescriptor(array_class).c_str()).c_str());
+ mirror::Class::PrettyDescriptor(element_class).c_str(),
+ mirror::Class::PrettyDescriptor(array_class).c_str()).c_str());
}
// ClassCastException
@@ -128,8 +127,8 @@
void ThrowClassCastException(ObjPtr<mirror::Class> dest_type, ObjPtr<mirror::Class> src_type) {
ThrowException("Ljava/lang/ClassCastException;", nullptr,
StringPrintf("%s cannot be cast to %s",
- PrettyDescriptor(src_type).c_str(),
- PrettyDescriptor(dest_type).c_str()).c_str());
+ mirror::Class::PrettyDescriptor(src_type).c_str(),
+ mirror::Class::PrettyDescriptor(dest_type).c_str()).c_str());
}
void ThrowClassCastException(const char* msg) {
@@ -140,7 +139,7 @@
void ThrowClassCircularityError(ObjPtr<mirror::Class> c) {
std::ostringstream msg;
- msg << PrettyDescriptor(c);
+ msg << mirror::Class::PrettyDescriptor(c);
ThrowException("Ljava/lang/ClassCircularityError;", c, msg.str().c_str());
}
@@ -164,8 +163,8 @@
void ThrowIllegalAccessErrorClass(ObjPtr<mirror::Class> referrer, ObjPtr<mirror::Class> accessed) {
std::ostringstream msg;
- msg << "Illegal class access: '" << PrettyDescriptor(referrer) << "' attempting to access '"
- << PrettyDescriptor(accessed) << "'";
+ msg << "Illegal class access: '" << mirror::Class::PrettyDescriptor(referrer)
+ << "' attempting to access '" << mirror::Class::PrettyDescriptor(accessed) << "'";
ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
}
@@ -174,30 +173,31 @@
ArtMethod* called,
InvokeType type) {
std::ostringstream msg;
- msg << "Illegal class access ('" << PrettyDescriptor(referrer) << "' attempting to access '"
- << PrettyDescriptor(accessed) << "') in attempt to invoke " << type
- << " method " << PrettyMethod(called).c_str();
+ msg << "Illegal class access ('" << mirror::Class::PrettyDescriptor(referrer)
+ << "' attempting to access '"
+ << mirror::Class::PrettyDescriptor(accessed) << "') in attempt to invoke " << type
+ << " method " << ArtMethod::PrettyMethod(called).c_str();
ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
}
void ThrowIllegalAccessErrorMethod(ObjPtr<mirror::Class> referrer, ArtMethod* accessed) {
std::ostringstream msg;
- msg << "Method '" << PrettyMethod(accessed) << "' is inaccessible to class '"
- << PrettyDescriptor(referrer) << "'";
+ msg << "Method '" << ArtMethod::PrettyMethod(accessed) << "' is inaccessible to class '"
+ << mirror::Class::PrettyDescriptor(referrer) << "'";
ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
}
void ThrowIllegalAccessErrorField(ObjPtr<mirror::Class> referrer, ArtField* accessed) {
std::ostringstream msg;
- msg << "Field '" << PrettyField(accessed, false) << "' is inaccessible to class '"
- << PrettyDescriptor(referrer) << "'";
+ msg << "Field '" << ArtField::PrettyField(accessed, false) << "' is inaccessible to class '"
+ << mirror::Class::PrettyDescriptor(referrer) << "'";
ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
}
void ThrowIllegalAccessErrorFinalField(ArtMethod* referrer, ArtField* accessed) {
std::ostringstream msg;
- msg << "Final field '" << PrettyField(accessed, false) << "' cannot be written to by method '"
- << PrettyMethod(referrer) << "'";
+ msg << "Final field '" << ArtField::PrettyField(accessed, false)
+ << "' cannot be written to by method '" << ArtMethod::PrettyMethod(referrer) << "'";
ThrowException("Ljava/lang/IllegalAccessError;",
referrer != nullptr ? referrer->GetDeclaringClass() : nullptr,
msg.str().c_str());
@@ -228,7 +228,7 @@
void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type,
ArtMethod* method, ArtMethod* referrer) {
std::ostringstream msg;
- msg << "The method '" << PrettyMethod(method) << "' was expected to be of type "
+ msg << "The method '" << ArtMethod::PrettyMethod(method) << "' was expected to be of type "
<< expected_type << " but instead was found to be of type " << found_type;
ThrowException("Ljava/lang/IncompatibleClassChangeError;",
referrer != nullptr ? referrer->GetDeclaringClass() : nullptr,
@@ -243,9 +243,10 @@
// implemented by this_object.
CHECK(this_object != nullptr);
std::ostringstream msg;
- msg << "Class '" << PrettyDescriptor(this_object->GetClass())
- << "' does not implement interface '" << PrettyDescriptor(target_class) << "' in call to '"
- << PrettyMethod(method) << "'";
+ msg << "Class '" << mirror::Class::PrettyDescriptor(this_object->GetClass())
+ << "' does not implement interface '" << mirror::Class::PrettyDescriptor(target_class)
+ << "' in call to '"
+ << ArtMethod::PrettyMethod(method) << "'";
ThrowException("Ljava/lang/IncompatibleClassChangeError;",
referrer != nullptr ? referrer->GetDeclaringClass() : nullptr,
msg.str().c_str());
@@ -258,10 +259,10 @@
// implemented by this_object.
CHECK(this_object != nullptr);
std::ostringstream msg;
- msg << "Class '" << PrettyDescriptor(this_object->GetClass())
+ msg << "Class '" << mirror::Class::PrettyDescriptor(this_object->GetClass())
<< "' does not implement interface '"
- << PrettyDescriptor(interface_method->GetDeclaringClass())
- << "' in call to '" << PrettyMethod(interface_method) << "'";
+ << mirror::Class::PrettyDescriptor(interface_method->GetDeclaringClass())
+ << "' in call to '" << ArtMethod::PrettyMethod(interface_method) << "'";
ThrowException("Ljava/lang/IncompatibleClassChangeError;",
referrer != nullptr ? referrer->GetDeclaringClass() : nullptr,
msg.str().c_str());
@@ -270,7 +271,7 @@
void ThrowIncompatibleClassChangeErrorField(ArtField* resolved_field, bool is_static,
ArtMethod* referrer) {
std::ostringstream msg;
- msg << "Expected '" << PrettyField(resolved_field) << "' to be a "
+ msg << "Expected '" << ArtField::PrettyField(resolved_field) << "' to be a "
<< (is_static ? "static" : "instance") << " field" << " rather than a "
<< (is_static ? "instance" : "static") << " field";
ThrowException("Ljava/lang/IncompatibleClassChangeError;", referrer->GetDeclaringClass(),
@@ -289,7 +290,7 @@
ThrowException("Ljava/lang/IncompatibleClassChangeError;",
/*referrer*/nullptr,
StringPrintf("Conflicting default method implementations %s",
- PrettyMethod(method).c_str()).c_str());
+ ArtMethod::PrettyMethod(method).c_str()).c_str());
}
@@ -370,7 +371,7 @@
void ThrowNullPointerExceptionForFieldAccess(ArtField* field, bool is_read) {
std::ostringstream msg;
msg << "Attempt to " << (is_read ? "read from" : "write to")
- << " field '" << PrettyField(field, true) << "' on a null object reference";
+ << " field '" << ArtField::PrettyField(field, true) << "' on a null object reference";
ThrowException("Ljava/lang/NullPointerException;", nullptr, msg.str().c_str());
}
@@ -380,7 +381,7 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
std::ostringstream msg;
msg << "Attempt to invoke " << type << " method '"
- << PrettyMethod(method_idx, dex_file, true) << "' on a null object reference";
+ << dex_file.PrettyMethod(method_idx, true) << "' on a null object reference";
ThrowException("Ljava/lang/NullPointerException;", nullptr, msg.str().c_str());
}
@@ -524,7 +525,7 @@
<< ", at "
<< instr->DumpString(dex_file)
<< " in "
- << PrettyMethod(method);
+ << method->PrettyMethod();
}
switch (instr->Opcode()) {
@@ -666,7 +667,7 @@
LOG(FATAL) << "NullPointerException at an unexpected instruction: "
<< instr->DumpString(dex_file)
<< " in "
- << PrettyMethod(method);
+ << method->PrettyMethod();
break;
}
}
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 3977e49..23fb79d 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -134,7 +134,8 @@
static std::ostream& operator<<(std::ostream& os, const Breakpoint& rhs)
REQUIRES_SHARED(Locks::mutator_lock_) {
- os << StringPrintf("Breakpoint[%s @%#x]", PrettyMethod(rhs.Method()).c_str(), rhs.DexPc());
+ os << StringPrintf("Breakpoint[%s @%#x]", ArtMethod::PrettyMethod(rhs.Method()).c_str(),
+ rhs.DexPc());
return os;
}
@@ -190,7 +191,7 @@
ArtMethod* method, uint32_t dex_pc)
OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_) {
// We're not recorded to listen to this kind of event, so complain.
- LOG(ERROR) << "Unexpected method unwind event in debugger " << PrettyMethod(method)
+ LOG(ERROR) << "Unexpected method unwind event in debugger " << ArtMethod::PrettyMethod(method)
<< " " << dex_pc;
}
@@ -236,7 +237,7 @@
// We only care about branches in the Jit.
void Branch(Thread* /*thread*/, ArtMethod* method, uint32_t dex_pc, int32_t dex_pc_offset)
OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_) {
- LOG(ERROR) << "Unexpected branch event in debugger " << PrettyMethod(method)
+ LOG(ERROR) << "Unexpected branch event in debugger " << ArtMethod::PrettyMethod(method)
<< " " << dex_pc << ", " << dex_pc_offset;
}
@@ -247,7 +248,7 @@
uint32_t dex_pc,
ArtMethod*)
OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_) {
- LOG(ERROR) << "Unexpected invoke event in debugger " << PrettyMethod(method)
+ LOG(ERROR) << "Unexpected invoke event in debugger " << ArtMethod::PrettyMethod(method)
<< " " << dex_pc;
}
@@ -1301,7 +1302,7 @@
if (new_object == nullptr) {
DCHECK(self->IsExceptionPending());
self->ClearException();
- LOG(ERROR) << "Could not allocate object of type " << PrettyDescriptor(c);
+ LOG(ERROR) << "Could not allocate object of type " << mirror::Class::PrettyDescriptor(c);
*new_object_id = 0;
return JDWP::ERR_OUT_OF_MEMORY;
}
@@ -1328,7 +1329,7 @@
if (new_array == nullptr) {
DCHECK(self->IsExceptionPending());
self->ClearException();
- LOG(ERROR) << "Could not allocate array of type " << PrettyDescriptor(c);
+ LOG(ERROR) << "Could not allocate array of type " << mirror::Class::PrettyDescriptor(c);
*new_array_id = 0;
return JDWP::ERR_OUT_OF_MEMORY;
}
@@ -1449,7 +1450,7 @@
if (code_item == nullptr) {
// We should not get here for a method without code (native, proxy or abstract). Log it and
// return the slot as is since all registers are arguments.
- LOG(WARNING) << "Trying to mangle slot for method without code " << PrettyMethod(m);
+ LOG(WARNING) << "Trying to mangle slot for method without code " << m->PrettyMethod();
return slot;
}
uint16_t ins_size = code_item->ins_size_;
@@ -1480,7 +1481,8 @@
if (code_item == nullptr) {
// We should not get here for a method without code (native, proxy or abstract). Log it and
// return the slot as is since all registers are arguments.
- LOG(WARNING) << "Trying to demangle slot for method without code " << PrettyMethod(m);
+ LOG(WARNING) << "Trying to demangle slot for method without code "
+ << m->PrettyMethod();
uint16_t vreg_count = GetMethodNumArgRegistersIncludingThis(m);
if (slot < vreg_count) {
*error = JDWP::ERR_NONE;
@@ -1496,7 +1498,7 @@
}
// Slot is invalid in the method.
- LOG(ERROR) << "Invalid local slot " << slot << " for method " << PrettyMethod(m);
+ LOG(ERROR) << "Invalid local slot " << slot << " for method " << m->PrettyMethod();
*error = JDWP::ERR_INVALID_SLOT;
return DexFile::kDexNoIndex16;
}
@@ -1784,14 +1786,16 @@
// TODO: should we give up now if receiver_class is null?
if (receiver_class != nullptr && !f->GetDeclaringClass()->IsAssignableFrom(receiver_class)) {
- LOG(INFO) << "ERR_INVALID_FIELDID: " << PrettyField(f) << " " << PrettyClass(receiver_class);
+ LOG(INFO) << "ERR_INVALID_FIELDID: " << f->PrettyField() << " "
+ << receiver_class->PrettyClass();
return JDWP::ERR_INVALID_FIELDID;
}
// Ensure the field's class is initialized.
Handle<mirror::Class> klass(hs.NewHandle(f->GetDeclaringClass()));
if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(self, klass, true, false)) {
- LOG(WARNING) << "Not able to initialize class for SetValues: " << PrettyClass(klass.Get());
+ LOG(WARNING) << "Not able to initialize class for SetValues: "
+ << mirror::Class::PrettyClass(klass.Get());
}
// The RI only enforces the static/non-static mismatch in one direction.
@@ -1803,7 +1807,7 @@
} else {
if (f->IsStatic()) {
LOG(WARNING) << "Ignoring non-nullptr receiver for ObjectReference.GetValues"
- << " on static field " << PrettyField(f);
+ << " on static field " << f->PrettyField();
}
}
if (f->IsStatic()) {
@@ -1912,7 +1916,8 @@
// Ensure the field's class is initialized.
Handle<mirror::Class> klass(hs.NewHandle(f->GetDeclaringClass()));
if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(self, klass, true, false)) {
- LOG(WARNING) << "Not able to initialize class for SetValues: " << PrettyClass(klass.Get());
+ LOG(WARNING) << "Not able to initialize class for SetValues: "
+ << mirror::Class::PrettyClass(klass.Get());
}
// The RI only enforces the static/non-static mismatch in one direction.
@@ -1924,7 +1929,7 @@
} else {
if (f->IsStatic()) {
LOG(WARNING) << "Ignoring non-nullptr receiver for ObjectReference.SetValues"
- << " on static field " << PrettyField(f);
+ << " on static field " << f->PrettyField();
}
}
if (f->IsStatic()) {
@@ -2581,7 +2586,7 @@
static std::string GetStackContextAsString(const StackVisitor& visitor)
REQUIRES_SHARED(Locks::mutator_lock_) {
return StringPrintf(" at DEX pc 0x%08x in method %s", visitor.GetDexPc(false),
- PrettyMethod(visitor.GetMethod()).c_str());
+ ArtMethod::PrettyMethod(visitor.GetMethod()).c_str());
}
static JDWP::JdwpError FailGetLocalValue(const StackVisitor& visitor, uint16_t vreg,
@@ -3150,14 +3155,14 @@
VLOG(jdwp) << "Undeoptimize the world DONE";
break;
case DeoptimizationRequest::kSelectiveDeoptimization:
- VLOG(jdwp) << "Deoptimize method " << PrettyMethod(request.Method()) << " ...";
+ VLOG(jdwp) << "Deoptimize method " << ArtMethod::PrettyMethod(request.Method()) << " ...";
instrumentation->Deoptimize(request.Method());
- VLOG(jdwp) << "Deoptimize method " << PrettyMethod(request.Method()) << " DONE";
+ VLOG(jdwp) << "Deoptimize method " << ArtMethod::PrettyMethod(request.Method()) << " DONE";
break;
case DeoptimizationRequest::kSelectiveUndeoptimization:
- VLOG(jdwp) << "Undeoptimize method " << PrettyMethod(request.Method()) << " ...";
+ VLOG(jdwp) << "Undeoptimize method " << ArtMethod::PrettyMethod(request.Method()) << " ...";
instrumentation->Undeoptimize(request.Method());
- VLOG(jdwp) << "Undeoptimize method " << PrettyMethod(request.Method()) << " DONE";
+ VLOG(jdwp) << "Undeoptimize method " << ArtMethod::PrettyMethod(request.Method()) << " DONE";
break;
default:
LOG(FATAL) << "Unsupported deoptimization request kind " << request.GetKind();
@@ -3226,14 +3231,14 @@
case DeoptimizationRequest::kSelectiveDeoptimization: {
DCHECK(req.Method() != nullptr);
VLOG(jdwp) << "Queue request #" << deoptimization_requests_.size()
- << " for deoptimization of " << PrettyMethod(req.Method());
+ << " for deoptimization of " << req.Method()->PrettyMethod();
deoptimization_requests_.push_back(req);
break;
}
case DeoptimizationRequest::kSelectiveUndeoptimization: {
DCHECK(req.Method() != nullptr);
VLOG(jdwp) << "Queue request #" << deoptimization_requests_.size()
- << " for undeoptimization of " << PrettyMethod(req.Method());
+ << " for undeoptimization of " << req.Method()->PrettyMethod();
deoptimization_requests_.push_back(req);
break;
}
@@ -3325,7 +3330,7 @@
if (!Dbg::RequiresDeoptimization()) {
// We already run in interpreter-only mode so we don't need to deoptimize anything.
VLOG(jdwp) << "No need for deoptimization when fully running with interpreter for method "
- << PrettyMethod(m);
+ << ArtMethod::PrettyMethod(m);
return DeoptimizationRequest::kNothing;
}
const Breakpoint* first_breakpoint;
@@ -3344,17 +3349,19 @@
bool need_full_deoptimization = m->IsDefault();
if (need_full_deoptimization) {
VLOG(jdwp) << "Need full deoptimization because of copying of method "
- << PrettyMethod(m);
+ << ArtMethod::PrettyMethod(m);
return DeoptimizationRequest::kFullDeoptimization;
} else {
// We don't need to deoptimize if the method has not been compiled.
const bool is_compiled = m->HasAnyCompiledCode();
if (is_compiled) {
- VLOG(jdwp) << "Need selective deoptimization for compiled method " << PrettyMethod(m);
+ VLOG(jdwp) << "Need selective deoptimization for compiled method "
+ << ArtMethod::PrettyMethod(m);
return DeoptimizationRequest::kSelectiveDeoptimization;
} else {
// Method is not compiled: we don't need to deoptimize.
- VLOG(jdwp) << "No need for deoptimization for non-compiled method " << PrettyMethod(m);
+ VLOG(jdwp) << "No need for deoptimization for non-compiled method "
+ << ArtMethod::PrettyMethod(m);
return DeoptimizationRequest::kNothing;
}
}
@@ -3584,7 +3591,8 @@
bool VisitFrame() OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_) {
// The visitor is meant to be used when handling exception from compiled code only.
- CHECK(!IsShadowFrame()) << "We only expect to visit compiled frame: " << PrettyMethod(GetMethod());
+ CHECK(!IsShadowFrame()) << "We only expect to visit compiled frame: "
+ << ArtMethod::PrettyMethod(GetMethod());
ArtMethod* method = GetMethod();
if (method == nullptr) {
// We reach an upcall and don't need to deoptimize this part of the stack (ManagedFragment)
@@ -3810,7 +3818,8 @@
VLOG(jdwp) << "Single-step thread: " << *thread;
VLOG(jdwp) << "Single-step step size: " << single_step_control->GetStepSize();
VLOG(jdwp) << "Single-step step depth: " << single_step_control->GetStepDepth();
- VLOG(jdwp) << "Single-step current method: " << PrettyMethod(single_step_control->GetMethod());
+ VLOG(jdwp) << "Single-step current method: "
+ << ArtMethod::PrettyMethod(single_step_control->GetMethod());
VLOG(jdwp) << "Single-step current line: " << line_number;
VLOG(jdwp) << "Single-step current stack depth: " << single_step_control->GetStackDepth();
VLOG(jdwp) << "Single-step dex_pc values:";
@@ -4066,12 +4075,12 @@
ArtMethod* actual_method =
pReq->klass.Read()->FindVirtualMethodForVirtualOrInterface(m, image_pointer_size);
if (actual_method != m) {
- VLOG(jdwp) << "ExecuteMethod translated " << PrettyMethod(m)
- << " to " << PrettyMethod(actual_method);
+ VLOG(jdwp) << "ExecuteMethod translated " << ArtMethod::PrettyMethod(m)
+ << " to " << ArtMethod::PrettyMethod(actual_method);
m = actual_method;
}
}
- VLOG(jdwp) << "ExecuteMethod " << PrettyMethod(m)
+ VLOG(jdwp) << "ExecuteMethod " << ArtMethod::PrettyMethod(m)
<< " receiver=" << pReq->receiver.Read()
<< " arg_count=" << pReq->arg_count;
CHECK(m != nullptr);
@@ -4873,12 +4882,13 @@
const gc::AllocRecord* record = &it->second;
LOG(INFO) << StringPrintf(" Thread %-2d %6zd bytes ", record->GetTid(), record->ByteCount())
- << PrettyClass(record->GetClass());
+ << mirror::Class::PrettyClass(record->GetClass());
for (size_t stack_frame = 0, depth = record->GetDepth(); stack_frame < depth; ++stack_frame) {
const gc::AllocRecordStackTraceElement& stack_element = record->StackElement(stack_frame);
ArtMethod* m = stack_element.GetMethod();
- LOG(INFO) << " " << PrettyMethod(m) << " line " << stack_element.ComputeLineNumber();
+ LOG(INFO) << " " << ArtMethod::PrettyMethod(m) << " line "
+ << stack_element.ComputeLineNumber();
}
// pause periodically to help logcat catch up
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 0af086c..b3317a5 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -933,7 +933,7 @@
}
if (i != parameters_size || it.HasNext()) {
LOG(ERROR) << "invalid stream - problem with parameter iterator in " << GetLocation()
- << " for method " << PrettyMethod(method_idx, *this);
+ << " for method " << this->PrettyMethod(method_idx);
return false;
}
@@ -1197,6 +1197,50 @@
return val;
}
+std::string DexFile::PrettyMethod(uint32_t method_idx, bool with_signature) const {
+ if (method_idx >= NumMethodIds()) {
+ return StringPrintf("<<invalid-method-idx-%d>>", method_idx);
+ }
+ const DexFile::MethodId& method_id = GetMethodId(method_idx);
+ std::string result(PrettyDescriptor(GetMethodDeclaringClassDescriptor(method_id)));
+ result += '.';
+ result += GetMethodName(method_id);
+ if (with_signature) {
+ const Signature signature = GetMethodSignature(method_id);
+ std::string sig_as_string(signature.ToString());
+ if (signature == Signature::NoSignature()) {
+ return result + sig_as_string;
+ }
+ result = PrettyReturnType(sig_as_string.c_str()) + " " + result +
+ PrettyArguments(sig_as_string.c_str());
+ }
+ return result;
+}
+
+std::string DexFile::PrettyField(uint32_t field_idx, bool with_type) const {
+ if (field_idx >= NumFieldIds()) {
+ return StringPrintf("<<invalid-field-idx-%d>>", field_idx);
+ }
+ const DexFile::FieldId& field_id = GetFieldId(field_idx);
+ std::string result;
+ if (with_type) {
+ result += GetFieldTypeDescriptor(field_id);
+ result += ' ';
+ }
+ result += PrettyDescriptor(GetFieldDeclaringClassDescriptor(field_id));
+ result += '.';
+ result += GetFieldName(field_id);
+ return result;
+}
+
+std::string DexFile::PrettyType(uint32_t type_idx) const {
+ if (type_idx >= NumTypeIds()) {
+ return StringPrintf("<<invalid-type-idx-%d>>", type_idx);
+ }
+ const DexFile::TypeId& type_id = GetTypeId(type_idx);
+ return PrettyDescriptor(GetTypeDescriptor(type_id));
+}
+
// Checks that visibility is as expected. Includes special behavior for M and
// before to allow runtime and build visibility when expecting runtime.
std::ostream& operator<<(std::ostream& os, const DexFile& dex_file) {
diff --git a/runtime/dex_file.h b/runtime/dex_file.h
index 29b8c3a..20f3a9c 100644
--- a/runtime/dex_file.h
+++ b/runtime/dex_file.h
@@ -1016,6 +1016,13 @@
static int64_t ReadSignedLong(const uint8_t* ptr, int zwidth);
static uint64_t ReadUnsignedLong(const uint8_t* ptr, int zwidth, bool fill_on_right);
+ // Returns a human-readable form of the method at an index.
+ std::string PrettyMethod(uint32_t method_idx, bool with_signature = true) const;
+ // Returns a human-readable form of the field at an index.
+ std::string PrettyField(uint32_t field_idx, bool with_type = true) const;
+ // Returns a human-readable form of the type at an index.
+ std::string PrettyType(uint32_t type_idx) const;
+
private:
static std::unique_ptr<const DexFile> OpenFile(int fd,
const std::string& location,
diff --git a/runtime/dex_file_annotations.cc b/runtime/dex_file_annotations.cc
index e538334..0765465 100644
--- a/runtime/dex_file_annotations.cc
+++ b/runtime/dex_file_annotations.cc
@@ -247,8 +247,7 @@
Handle<mirror::Class> annotation_class(hs.NewHandle(
class_linker->ResolveType(klass->GetDexFile(), type_index, klass.Get())));
if (annotation_class.Get() == nullptr) {
- LOG(INFO) << "Unable to resolve " << PrettyClass(klass.Get()) << " annotation class "
- << type_index;
+ LOG(INFO) << "Unable to resolve " << klass->PrettyClass() << " annotation class " << type_index;
DCHECK(Thread::Current()->IsExceptionPending());
Thread::Current()->ClearException();
return nullptr;
@@ -1316,7 +1315,7 @@
}
const DexFile::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
- DCHECK(code_item != nullptr) << PrettyMethod(method) << " " << dex_file->GetLocation();
+ DCHECK(code_item != nullptr) << method->PrettyMethod() << " " << dex_file->GetLocation();
// A method with no line number info should return -1
DexFile::LineNumFromPcContext context(rel_pc, -1);
diff --git a/runtime/dex_instruction.cc b/runtime/dex_instruction.cc
index c31d236..c766b54 100644
--- a/runtime/dex_instruction.cc
+++ b/runtime/dex_instruction.cc
@@ -209,7 +209,7 @@
case NEW_INSTANCE:
if (file != nullptr) {
uint32_t type_idx = VRegB_21c();
- os << opcode << " v" << static_cast<int>(VRegA_21c()) << ", " << PrettyType(type_idx, *file)
+ os << opcode << " v" << static_cast<int>(VRegA_21c()) << ", " << file->PrettyType(type_idx)
<< " // type@" << type_idx;
break;
}
@@ -223,7 +223,7 @@
case SGET_SHORT:
if (file != nullptr) {
uint32_t field_idx = VRegB_21c();
- os << opcode << " v" << static_cast<int>(VRegA_21c()) << ", " << PrettyField(field_idx, *file, true)
+ os << opcode << " v" << static_cast<int>(VRegA_21c()) << ", " << file->PrettyField(field_idx, true)
<< " // field@" << field_idx;
break;
}
@@ -237,7 +237,7 @@
case SPUT_SHORT:
if (file != nullptr) {
uint32_t field_idx = VRegB_21c();
- os << opcode << " v" << static_cast<int>(VRegA_21c()) << ", " << PrettyField(field_idx, *file, true)
+ os << opcode << " v" << static_cast<int>(VRegA_21c()) << ", " << file->PrettyField(field_idx, true)
<< " // field@" << field_idx;
break;
}
@@ -264,7 +264,7 @@
if (file != nullptr) {
uint32_t field_idx = VRegC_22c();
os << opcode << " v" << static_cast<int>(VRegA_22c()) << ", v" << static_cast<int>(VRegB_22c()) << ", "
- << PrettyField(field_idx, *file, true) << " // field@" << field_idx;
+ << file->PrettyField(field_idx, true) << " // field@" << field_idx;
break;
}
FALLTHROUGH_INTENDED;
@@ -287,7 +287,7 @@
if (file != nullptr) {
uint32_t field_idx = VRegC_22c();
os << opcode << " v" << static_cast<int>(VRegA_22c()) << ", v" << static_cast<int>(VRegB_22c()) << ", "
- << PrettyField(field_idx, *file, true) << " // field@" << field_idx;
+ << file->PrettyField(field_idx, true) << " // field@" << field_idx;
break;
}
FALLTHROUGH_INTENDED;
@@ -304,7 +304,7 @@
if (file != nullptr) {
uint32_t type_idx = VRegC_22c();
os << opcode << " v" << static_cast<int>(VRegA_22c()) << ", v" << static_cast<int>(VRegB_22c()) << ", "
- << PrettyType(type_idx, *file) << " // type@" << type_idx;
+ << file->PrettyType(type_idx) << " // type@" << type_idx;
break;
}
FALLTHROUGH_INTENDED;
@@ -312,7 +312,7 @@
if (file != nullptr) {
uint32_t type_idx = VRegC_22c();
os << opcode << " v" << static_cast<int>(VRegA_22c()) << ", v" << static_cast<int>(VRegB_22c()) << ", "
- << PrettyType(type_idx, *file) << " // type@" << type_idx;
+ << file->PrettyType(type_idx) << " // type@" << type_idx;
break;
}
FALLTHROUGH_INTENDED;
@@ -382,7 +382,7 @@
}
os << "v" << arg[i];
}
- os << "}, " << PrettyMethod(method_idx, *file) << " // method@" << method_idx;
+ os << "}, " << file->PrettyMethod(method_idx) << " // method@" << method_idx;
break;
}
FALLTHROUGH_INTENDED;
@@ -417,7 +417,7 @@
if (file != nullptr) {
uint32_t method_idx = VRegB_3rc();
os << StringPrintf("%s, {v%d .. v%d}, ", opcode, VRegC_3rc(), (VRegC_3rc() + VRegA_3rc() - 1))
- << PrettyMethod(method_idx, *file) << " // method@" << method_idx;
+ << file->PrettyMethod(method_idx) << " // method@" << method_idx;
break;
}
FALLTHROUGH_INTENDED;
diff --git a/runtime/dex_method_iterator_test.cc b/runtime/dex_method_iterator_test.cc
index 9f28c8c..cd8c390 100644
--- a/runtime/dex_method_iterator_test.cc
+++ b/runtime/dex_method_iterator_test.cc
@@ -40,7 +40,7 @@
InvokeType invoke_type = it.GetInvokeType();
uint32_t method_idx = it.GetMemberIndex();
if ((false)) {
- LOG(INFO) << invoke_type << " " << PrettyMethod(method_idx, dex_file);
+ LOG(INFO) << invoke_type << " " << dex_file.PrettyMethod(method_idx);
}
it.Next();
}
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h
index 8077c21..31811fb 100644
--- a/runtime/entrypoints/entrypoint_utils-inl.h
+++ b/runtime/entrypoints/entrypoint_utils-inl.h
@@ -148,12 +148,13 @@
}
if (kAccessCheck) {
if (UNLIKELY(!klass->IsInstantiable())) {
- self->ThrowNewException("Ljava/lang/InstantiationError;", PrettyDescriptor(klass).c_str());
+ self->ThrowNewException("Ljava/lang/InstantiationError;", klass->PrettyDescriptor().c_str());
*slow_path = true;
return nullptr; // Failure
}
if (UNLIKELY(klass->IsClassClass())) {
- ThrowIllegalAccessError(nullptr, "Class %s is inaccessible", PrettyDescriptor(klass).c_str());
+ ThrowIllegalAccessError(nullptr, "Class %s is inaccessible",
+ klass->PrettyDescriptor().c_str());
*slow_path = true;
return nullptr; // Failure
}
@@ -293,7 +294,7 @@
DCHECK(Thread::Current()->IsExceptionPending());
return nullptr; // Failure
}
- CHECK(klass->IsArrayClass()) << PrettyClass(klass);
+ CHECK(klass->IsArrayClass()) << klass->PrettyClass();
}
if (kAccessCheck) {
mirror::Class* referrer = method->GetDeclaringClass();
@@ -433,7 +434,7 @@
"Attempted read of %zd-bit %s on field '%s'",
expected_size * (32 / sizeof(int32_t)),
is_primitive ? "primitive" : "non-primitive",
- PrettyField(resolved_field, true).c_str());
+ resolved_field->PrettyField(true).c_str());
return nullptr; // Failure.
}
}
@@ -549,7 +550,7 @@
resolved_method->GetName(), resolved_method->GetSignature());
return nullptr; // Failure.
}
- DCHECK(klass->HasVTable()) << PrettyClass(klass);
+ DCHECK(klass->HasVTable()) << klass->PrettyClass();
return klass->GetVTableEntry(vtable_index, class_linker->GetImagePointerSize());
}
case kSuper: {
@@ -624,9 +625,10 @@
mirror::Class* klass = (*this_object)->GetClass();
ArtMethod* method = klass->FindVirtualMethodForInterface(
resolved_method, class_linker->GetImagePointerSize());
- CHECK_EQ(imt_method, method) << PrettyMethod(resolved_method) << " / " <<
- PrettyMethod(imt_method) << " / " << PrettyMethod(method) << " / " <<
- PrettyClass(klass);
+ CHECK_EQ(imt_method, method) << ArtMethod::PrettyMethod(resolved_method) << " / "
+ << imt_method->PrettyMethod() << " / "
+ << ArtMethod::PrettyMethod(method) << " / "
+ << klass->PrettyClass();
}
return imt_method;
} else {
diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc
index f8deb8f..cbefbba 100644
--- a/runtime/entrypoints/entrypoint_utils.cc
+++ b/runtime/entrypoints/entrypoint_utils.cc
@@ -61,12 +61,12 @@
if (UNLIKELY(klass->IsPrimitive() && !klass->IsPrimitiveInt())) {
if (klass->IsPrimitiveLong() || klass->IsPrimitiveDouble()) {
ThrowRuntimeException("Bad filled array request for type %s",
- PrettyDescriptor(klass).c_str());
+ klass->PrettyDescriptor().c_str());
} else {
self->ThrowNewExceptionF(
"Ljava/lang/InternalError;",
"Found type %s; filled-new-array not implemented for anything but 'int'",
- PrettyDescriptor(klass).c_str());
+ klass->PrettyDescriptor().c_str());
}
return nullptr; // Failure
}
@@ -77,7 +77,7 @@
return nullptr; // Failure
}
}
- DCHECK(klass->IsArrayClass()) << PrettyClass(klass);
+ DCHECK(klass->IsArrayClass()) << klass->PrettyClass();
return klass;
}
@@ -131,8 +131,8 @@
if (!o->InstanceOf(return_type)) {
Runtime::Current()->GetJavaVM()->JniAbortF(nullptr,
"attempt to return an instance of %s from %s",
- PrettyTypeOf(o.Get()).c_str(),
- PrettyMethod(method).c_str());
+ o->PrettyTypeOf().c_str(),
+ method->PrettyMethod().c_str());
}
}
diff --git a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc
index fec7373..aa547bf 100644
--- a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc
@@ -44,7 +44,7 @@
bool interpreter_entry = (result == GetQuickToInterpreterBridge());
instrumentation->PushInstrumentationStackFrame(self, method->IsStatic() ? nullptr : this_object,
method, lr, interpreter_entry);
- CHECK(result != nullptr) << PrettyMethod(method);
+ CHECK(result != nullptr) << method->PrettyMethod();
return result;
}
diff --git a/runtime/entrypoints/quick/quick_jni_entrypoints.cc b/runtime/entrypoints/quick/quick_jni_entrypoints.cc
index 383cdd2..b25f447 100644
--- a/runtime/entrypoints/quick/quick_jni_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_jni_entrypoints.cc
@@ -47,7 +47,7 @@
if (kIsDebugBuild) {
ArtMethod* native_method = *self->GetManagedStack()->GetTopQuickFrame();
- CHECK(native_method->IsAnnotatedWithFastNative()) << PrettyMethod(native_method);
+ CHECK(native_method->IsAnnotatedWithFastNative()) << native_method->PrettyMethod();
}
return saved_local_ref_cookie;
@@ -110,7 +110,7 @@
if (kIsDebugBuild) {
ArtMethod* native_method = *self->GetManagedStack()->GetTopQuickFrame();
- CHECK(native_method->IsAnnotatedWithFastNative()) << PrettyMethod(native_method);
+ CHECK(native_method->IsAnnotatedWithFastNative()) << native_method->PrettyMethod();
}
if (UNLIKELY(self->TestAllFlags())) {
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 750efac..0bb6581 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -660,11 +660,11 @@
StackedShadowFrameType::kDeoptimizationShadowFrame, false);
ManagedStack fragment;
- DCHECK(!method->IsNative()) << PrettyMethod(method);
+ DCHECK(!method->IsNative()) << method->PrettyMethod();
uint32_t shorty_len = 0;
ArtMethod* non_proxy_method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
const DexFile::CodeItem* code_item = non_proxy_method->GetCodeItem();
- DCHECK(code_item != nullptr) << PrettyMethod(method);
+ DCHECK(code_item != nullptr) << method->PrettyMethod();
const char* shorty = non_proxy_method->GetShorty(&shorty_len);
JValue result;
@@ -679,8 +679,8 @@
while (linked->GetLink() != nullptr) {
linked = linked->GetLink();
}
- CHECK_EQ(method, linked->GetMethod()) << PrettyMethod(method) << " "
- << PrettyMethod(linked->GetMethod());
+ CHECK_EQ(method, linked->GetMethod()) << method->PrettyMethod() << " "
+ << ArtMethod::PrettyMethod(linked->GetMethod());
}
if (VLOG_IS_ON(deopt)) {
@@ -743,7 +743,8 @@
StackHandleScope<1> hs(self);
Handle<mirror::Class> h_class(hs.NewHandle(shadow_frame->GetMethod()->GetDeclaringClass()));
if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(self, h_class, true, true)) {
- DCHECK(Thread::Current()->IsExceptionPending()) << PrettyMethod(shadow_frame->GetMethod());
+ DCHECK(Thread::Current()->IsExceptionPending())
+ << shadow_frame->GetMethod()->PrettyMethod();
self->PopManagedStackFragment(fragment);
return 0;
}
@@ -846,13 +847,13 @@
extern "C" uint64_t artQuickProxyInvokeHandler(
ArtMethod* proxy_method, mirror::Object* receiver, Thread* self, ArtMethod** sp)
REQUIRES_SHARED(Locks::mutator_lock_) {
- DCHECK(proxy_method->IsProxyMethod()) << PrettyMethod(proxy_method);
- DCHECK(receiver->GetClass()->IsProxyClass()) << PrettyMethod(proxy_method);
+ DCHECK(proxy_method->IsProxyMethod()) << proxy_method->PrettyMethod();
+ DCHECK(receiver->GetClass()->IsProxyClass()) << proxy_method->PrettyMethod();
// Ensure we don't get thread suspension until the object arguments are safely in jobjects.
const char* old_cause =
self->StartAssertNoThreadSuspension("Adding to IRT proxy object arguments");
// Register the top of the managed stack, making stack crawlable.
- DCHECK_EQ((*sp), proxy_method) << PrettyMethod(proxy_method);
+ DCHECK_EQ((*sp), proxy_method) << proxy_method->PrettyMethod();
self->VerifyStack();
// Start new JNI local reference state.
JNIEnvExt* env = self->GetJniEnv();
@@ -863,21 +864,21 @@
// Placing arguments into args vector and remove the receiver.
ArtMethod* non_proxy_method = proxy_method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
- CHECK(!non_proxy_method->IsStatic()) << PrettyMethod(proxy_method) << " "
- << PrettyMethod(non_proxy_method);
+ CHECK(!non_proxy_method->IsStatic()) << proxy_method->PrettyMethod() << " "
+ << non_proxy_method->PrettyMethod();
std::vector<jvalue> args;
uint32_t shorty_len = 0;
const char* shorty = non_proxy_method->GetShorty(&shorty_len);
BuildQuickArgumentVisitor local_ref_visitor(sp, false, shorty, shorty_len, &soa, &args);
local_ref_visitor.VisitArguments();
- DCHECK_GT(args.size(), 0U) << PrettyMethod(proxy_method);
+ DCHECK_GT(args.size(), 0U) << proxy_method->PrettyMethod();
args.erase(args.begin());
// Convert proxy method into expected interface method.
ArtMethod* interface_method = proxy_method->FindOverriddenMethod(kRuntimePointerSize);
- DCHECK(interface_method != nullptr) << PrettyMethod(proxy_method);
- DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method);
+ DCHECK(interface_method != nullptr) << proxy_method->PrettyMethod();
+ DCHECK(!interface_method->IsProxyMethod()) << interface_method->PrettyMethod();
self->EndAssertNoThreadSuspension(old_cause);
DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize);
DCHECK(!Runtime::Current()->IsActiveTransaction());
@@ -1034,7 +1035,7 @@
if (LIKELY(!self->IsExceptionPending())) {
// Incompatible class change should have been handled in resolve method.
CHECK(!called->CheckIncompatibleClassChange(invoke_type))
- << PrettyMethod(called) << " " << invoke_type;
+ << called->PrettyMethod() << " " << invoke_type;
if (virtual_or_interface || invoke_type == kSuper) {
// Refine called method based on receiver for kVirtual/kInterface, and
// caller for kSuper.
@@ -1064,8 +1065,8 @@
}
}
- CHECK(called != nullptr) << PrettyMethod(orig_called) << " "
- << PrettyTypeOf(receiver) << " "
+ CHECK(called != nullptr) << orig_called->PrettyMethod() << " "
+ << mirror::Object::PrettyTypeOf(receiver) << " "
<< invoke_type << " " << orig_called->GetVtableIndex();
// We came here because of sharpening. Ensure the dex cache is up-to-date on the method index
@@ -1999,7 +2000,7 @@
extern "C" TwoWordReturn artQuickGenericJniTrampoline(Thread* self, ArtMethod** sp)
REQUIRES_SHARED(Locks::mutator_lock_) {
ArtMethod* called = *sp;
- DCHECK(called->IsNative()) << PrettyMethod(called, true);
+ DCHECK(called->IsNative()) << called->PrettyMethod(true);
uint32_t shorty_len = 0;
const char* shorty = called->GetShorty(&shorty_len);
bool critical_native = called->IsAnnotatedWithCriticalNative();
@@ -2149,7 +2150,7 @@
const void* code = method->GetEntryPointFromQuickCompiledCode();
// When we return, the caller will branch to this address, so it had better not be 0!
- DCHECK(code != nullptr) << "Code was null in method: " << PrettyMethod(method)
+ DCHECK(code != nullptr) << "Code was null in method: " << method->PrettyMethod()
<< " location: "
<< method->GetDexFile()->GetLocation();
@@ -2240,7 +2241,7 @@
ArtMethod* interface_method = caller_method->GetDexCacheResolvedMethod(
dex_method_idx, kRuntimePointerSize);
- DCHECK(interface_method != nullptr) << dex_method_idx << " " << PrettyMethod(caller_method);
+ DCHECK(interface_method != nullptr) << dex_method_idx << " " << caller_method->PrettyMethod();
ArtMethod* method = nullptr;
ImTable* imt = cls->GetImt(kRuntimePointerSize);
@@ -2321,7 +2322,7 @@
const void* code = method->GetEntryPointFromQuickCompiledCode();
// When we return, the caller will branch to this address, so it had better not be 0!
- DCHECK(code != nullptr) << "Code was null in method: " << PrettyMethod(method)
+ DCHECK(code != nullptr) << "Code was null in method: " << method->PrettyMethod()
<< " location: " << method->GetDexFile()->GetLocation();
return GetTwoWordSuccessValue(reinterpret_cast<uintptr_t>(code),
diff --git a/runtime/gc/accounting/mod_union_table.cc b/runtime/gc/accounting/mod_union_table.cc
index 3b6750e..14f5997 100644
--- a/runtime/gc/accounting/mod_union_table.cc
+++ b/runtime/gc/accounting/mod_union_table.cc
@@ -276,8 +276,9 @@
Heap* heap = mod_union_table_->GetHeap();
space::ContinuousSpace* from_space = heap->FindContinuousSpaceFromObject(obj, false);
space::ContinuousSpace* to_space = heap->FindContinuousSpaceFromObject(ref, false);
- LOG(INFO) << "Object " << reinterpret_cast<const void*>(obj) << "(" << PrettyTypeOf(obj)
- << ")" << "References " << reinterpret_cast<const void*>(ref) << "(" << PrettyTypeOf(ref)
+ LOG(INFO) << "Object " << reinterpret_cast<const void*>(obj) << "(" << obj->PrettyTypeOf()
+ << ")" << "References "
+ << reinterpret_cast<const void*>(ref) << "(" << mirror::Object::PrettyTypeOf(ref)
<< ") without being in mod-union table";
LOG(INFO) << "FromSpace " << from_space->GetName() << " type "
<< from_space->GetGcRetentionPolicy();
diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc
index a7f2aa0..40186f8 100644
--- a/runtime/gc/allocator/rosalloc.cc
+++ b/runtime/gc/allocator/rosalloc.cc
@@ -1966,7 +1966,7 @@
CHECK_LE(obj_size + memory_tool_modifier, kLargeSizeThreshold)
<< "A run slot contains a large object " << Dump();
CHECK_EQ(SizeToIndex(obj_size + memory_tool_modifier), idx)
- << PrettyTypeOf(obj) << " "
+ << obj->PrettyTypeOf() << " "
<< "obj_size=" << obj_size << "(" << obj_size + memory_tool_modifier << "), idx=" << idx
<< " A run slot contains an object with wrong size " << Dump();
}
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index 3dee974..1931caf 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -396,8 +396,8 @@
CHECK(Runtime::Current()->GetHeap()->GetLargeObjectsSpace()->IsZygoteLargeObject(
Thread::Current(), ref.Ptr()))
<< "Non gray object references non immune, non zygote large object "<< ref << " "
- << PrettyTypeOf(ref) << " in holder " << holder << " " << PrettyTypeOf(holder)
- << " offset=" << offset.Uint32Value();
+ << mirror::Object::PrettyTypeOf(ref) << " in holder " << holder << " "
+ << mirror::Object::PrettyTypeOf(holder) << " offset=" << offset.Uint32Value();
} else {
// Make sure the large object class is immune since we will never scan the large object.
CHECK(collector_->immune_spaces_.ContainsObject(
@@ -862,7 +862,7 @@
void ConcurrentCopying::PushOntoMarkStack(mirror::Object* to_ref) {
CHECK_EQ(is_mark_stack_push_disallowed_.LoadRelaxed(), 0)
- << " " << to_ref << " " << PrettyTypeOf(to_ref);
+ << " " << to_ref << " " << mirror::Object::PrettyTypeOf(to_ref);
Thread* self = Thread::Current(); // TODO: pass self as an argument from call sites?
CHECK(thread_running_gc_ != nullptr);
MarkStackMode mark_stack_mode = mark_stack_mode_.LoadRelaxed();
@@ -951,7 +951,7 @@
collector_->AssertToSpaceInvariant(nullptr, MemberOffset(0), ref);
if (kUseBakerReadBarrier) {
CHECK_EQ(ref->GetReadBarrierPointer(), ReadBarrier::WhitePtr())
- << "Ref " << ref << " " << PrettyTypeOf(ref)
+ << "Ref " << ref << " " << ref->PrettyTypeOf()
<< " has non-white rb_ptr ";
}
}
@@ -1454,10 +1454,10 @@
mirror::Object* obj = mark_stack->PopBack();
if (kUseBakerReadBarrier) {
mirror::Object* rb_ptr = obj->GetReadBarrierPointer();
- LOG(INFO) << "On mark queue : " << obj << " " << PrettyTypeOf(obj) << " rb_ptr=" << rb_ptr
- << " is_marked=" << IsMarked(obj);
+ LOG(INFO) << "On mark queue : " << obj << " " << obj->PrettyTypeOf() << " rb_ptr="
+ << rb_ptr << " is_marked=" << IsMarked(obj);
} else {
- LOG(INFO) << "On mark queue : " << obj << " " << PrettyTypeOf(obj)
+ LOG(INFO) << "On mark queue : " << obj << " " << obj->PrettyTypeOf()
<< " is_marked=" << IsMarked(obj);
}
}
@@ -1630,7 +1630,7 @@
LogFromSpaceRefHolder(obj, offset);
}
ref->GetLockWord(false).Dump(LOG_STREAM(FATAL_WITHOUT_ABORT));
- CHECK(false) << "Found from-space ref " << ref << " " << PrettyTypeOf(ref);
+ CHECK(false) << "Found from-space ref " << ref << " " << ref->PrettyTypeOf();
} else {
AssertToSpaceInvariantInNonMovingSpace(obj, ref);
}
@@ -1677,12 +1677,14 @@
// No info.
} else if (gc_root_source->HasArtField()) {
ArtField* field = gc_root_source->GetArtField();
- LOG(FATAL_WITHOUT_ABORT) << "gc root in field " << field << " " << PrettyField(field);
+ LOG(FATAL_WITHOUT_ABORT) << "gc root in field " << field << " "
+ << ArtField::PrettyField(field);
RootPrinter root_printer;
field->VisitRoots(root_printer);
} else if (gc_root_source->HasArtMethod()) {
ArtMethod* method = gc_root_source->GetArtMethod();
- LOG(FATAL_WITHOUT_ABORT) << "gc root in method " << method << " " << PrettyMethod(method);
+ LOG(FATAL_WITHOUT_ABORT) << "gc root in method " << method << " "
+ << ArtMethod::PrettyMethod(method);
RootPrinter root_printer;
method->VisitRoots(root_printer, kRuntimePointerSize);
}
@@ -1690,7 +1692,7 @@
region_space_->DumpNonFreeRegions(LOG_STREAM(FATAL_WITHOUT_ABORT));
PrintFileToLog("/proc/self/maps", LogSeverity::FATAL_WITHOUT_ABORT);
MemMap::DumpMaps(LOG_STREAM(FATAL_WITHOUT_ABORT), true);
- CHECK(false) << "Found from-space ref " << ref << " " << PrettyTypeOf(ref);
+ CHECK(false) << "Found from-space ref " << ref << " " << ref->PrettyTypeOf();
} else {
AssertToSpaceInvariantInNonMovingSpace(nullptr, ref);
}
@@ -1699,10 +1701,10 @@
void ConcurrentCopying::LogFromSpaceRefHolder(mirror::Object* obj, MemberOffset offset) {
if (kUseBakerReadBarrier) {
- LOG(INFO) << "holder=" << obj << " " << PrettyTypeOf(obj)
+ LOG(INFO) << "holder=" << obj << " " << obj->PrettyTypeOf()
<< " holder rb_ptr=" << obj->GetReadBarrierPointer();
} else {
- LOG(INFO) << "holder=" << obj << " " << PrettyTypeOf(obj);
+ LOG(INFO) << "holder=" << obj << " " << obj->PrettyTypeOf();
}
if (region_space_->IsInFromSpace(obj)) {
LOG(INFO) << "holder is in the from-space.";
diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc
index c05719d..77d7274 100644
--- a/runtime/gc/collector/mark_sweep.cc
+++ b/runtime/gc/collector/mark_sweep.cc
@@ -423,7 +423,7 @@
<< (mark_sweep_->GetHeap()->IsLiveObjectLocked(holder_)
? "alive" : "dead")
<< " holder_size=" << holder_size
- << " holder_type=" << PrettyTypeOf(holder_)
+ << " holder_type=" << holder_->PrettyTypeOf()
<< " offset=" << offset_.Uint32Value()
<< " field=" << (field != nullptr ? field->GetName() : "nullptr")
<< " field_type="
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index f4a3aea..ba18699 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -2926,7 +2926,7 @@
if (root == nullptr) {
LOG(ERROR) << "Root is null with info " << root_info.GetType();
} else if (!VerifyReference(nullptr, root, MemberOffset(0))) {
- LOG(ERROR) << "Root " << root << " is dead with type " << PrettyTypeOf(root)
+ LOG(ERROR) << "Root " << root << " is dead with type " << mirror::Object::PrettyTypeOf(root)
<< " thread_id= " << root_info.GetThreadId() << " root_type= " << root_info.GetType();
}
}
@@ -2953,7 +2953,7 @@
LOG(ERROR) << "Object " << obj << " references dead object " << ref << " at offset "
<< offset << "\n card value = " << static_cast<int>(*card_addr);
if (heap_->IsValidObjectAddress(obj->GetClass())) {
- LOG(ERROR) << "Obj type " << PrettyTypeOf(obj);
+ LOG(ERROR) << "Obj type " << obj->PrettyTypeOf();
} else {
LOG(ERROR) << "Object " << obj << " class(" << obj->GetClass() << ") not a heap address";
}
@@ -2965,7 +2965,7 @@
mirror::Class* ref_class = space->FindRecentFreedObject(ref);
if (ref_class != nullptr) {
LOG(ERROR) << "Reference " << ref << " found as a recently freed object with class "
- << PrettyClass(ref_class);
+ << ref_class->PrettyClass();
} else {
LOG(ERROR) << "Reference " << ref << " not found as a recently freed object";
}
@@ -2973,7 +2973,7 @@
if (ref->GetClass() != nullptr && heap_->IsValidObjectAddress(ref->GetClass()) &&
ref->GetClass()->IsClass()) {
- LOG(ERROR) << "Ref type " << PrettyTypeOf(ref);
+ LOG(ERROR) << "Ref type " << ref->PrettyTypeOf();
} else {
LOG(ERROR) << "Ref " << ref << " class(" << ref->GetClass()
<< ") is not a valid heap address";
@@ -3182,8 +3182,9 @@
if (heap_->GetLiveBitmap()->Test(obj)) {
LOG(ERROR) << "Object " << obj << " found in live bitmap";
}
- LOG(ERROR) << "Object " << obj << " " << PrettyTypeOf(obj)
- << " references " << ref << " " << PrettyTypeOf(ref) << " in live stack";
+ LOG(ERROR) << "Object " << obj << " " << mirror::Object::PrettyTypeOf(obj)
+ << " references " << ref << " " << mirror::Object::PrettyTypeOf(ref)
+ << " in live stack";
// Print which field of the object is dead.
if (!obj->IsObjectArray()) {
@@ -3192,7 +3193,7 @@
for (ArtField& field : (is_static ? klass->GetSFields() : klass->GetIFields())) {
if (field.GetOffset().Int32Value() == offset.Int32Value()) {
LOG(ERROR) << (is_static ? "Static " : "") << "field in the live stack is "
- << PrettyField(&field);
+ << field.PrettyField();
break;
}
}
diff --git a/runtime/gc/reference_processor.cc b/runtime/gc/reference_processor.cc
index 4b8f38d..798ecd3 100644
--- a/runtime/gc/reference_processor.cc
+++ b/runtime/gc/reference_processor.cc
@@ -211,7 +211,7 @@
} else if (klass->IsPhantomReferenceClass()) {
phantom_reference_queue_.AtomicEnqueueIfNotEnqueued(self, ref);
} else {
- LOG(FATAL) << "Invalid reference type " << PrettyClass(klass) << " " << std::hex
+ LOG(FATAL) << "Invalid reference type " << klass->PrettyClass() << " " << std::hex
<< klass->GetAccessFlags();
}
}
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index e9c8b95..6035406 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -398,7 +398,7 @@
CHECK_ALIGNED(current, kObjectAlignment);
auto* obj = reinterpret_cast<mirror::Object*>(current);
CHECK(obj->GetClass() != nullptr) << "Image object at address " << obj << " has null class";
- CHECK(live_bitmap_->Test(obj)) << PrettyTypeOf(obj);
+ CHECK(live_bitmap_->Test(obj)) << obj->PrettyTypeOf();
if (kUseBakerOrBrooksReadBarrier) {
obj->AssertReadBarrierPointer();
}
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index ecb2157..0fde380 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -654,7 +654,7 @@
}
HprofStringId LookupClassNameId(mirror::Class* c) REQUIRES_SHARED(Locks::mutator_lock_) {
- return LookupStringId(PrettyDescriptor(c));
+ return LookupStringId(c->PrettyDescriptor());
}
void WriteFixedHeader() {
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index 36e8608..d059b97 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -234,8 +234,8 @@
CHECK_LT(instrumentation_stack_depth_, instrumentation_stack_->size());
const InstrumentationStackFrame& frame =
instrumentation_stack_->at(instrumentation_stack_depth_);
- CHECK_EQ(m, frame.method_) << "Expected " << PrettyMethod(m)
- << ", Found " << PrettyMethod(frame.method_);
+ CHECK_EQ(m, frame.method_) << "Expected " << ArtMethod::PrettyMethod(m)
+ << ", Found " << ArtMethod::PrettyMethod(frame.method_);
return_pc = frame.return_pc_;
if (kVerboseInstrumentation) {
LOG(INFO) << "Ignoring already instrumented " << frame.Dump();
@@ -337,7 +337,7 @@
if (GetCurrentQuickFrame() == nullptr) {
if (kVerboseInstrumentation) {
LOG(INFO) << " Ignoring a shadow frame. Frame " << GetFrameId()
- << " Method=" << PrettyMethod(m);
+ << " Method=" << ArtMethod::PrettyMethod(m);
}
return true; // Ignore shadow frames.
}
@@ -358,7 +358,7 @@
if (instrumentation_frame.interpreter_entry_) {
CHECK(m == Runtime::Current()->GetCalleeSaveMethod(Runtime::kSaveRefsAndArgs));
} else {
- CHECK(m == instrumentation_frame.method_) << PrettyMethod(m);
+ CHECK(m == instrumentation_frame.method_) << ArtMethod::PrettyMethod(m);
}
SetReturnPc(instrumentation_frame.return_pc_);
if (instrumentation_->ShouldNotifyMethodEnterExitEvents()) {
@@ -773,7 +773,7 @@
{
WriterMutexLock mu(self, deoptimized_methods_lock_);
bool has_not_been_deoptimized = AddDeoptimizedMethod(method);
- CHECK(has_not_been_deoptimized) << "Method " << PrettyMethod(method)
+ CHECK(has_not_been_deoptimized) << "Method " << ArtMethod::PrettyMethod(method)
<< " is already deoptimized";
}
if (!interpreter_stubs_installed_) {
@@ -797,7 +797,7 @@
{
WriterMutexLock mu(self, deoptimized_methods_lock_);
bool found_and_erased = RemoveDeoptimizedMethod(method);
- CHECK(found_and_erased) << "Method " << PrettyMethod(method)
+ CHECK(found_and_erased) << "Method " << ArtMethod::PrettyMethod(method)
<< " is not deoptimized";
empty = IsDeoptimizedMethodsEmpty();
}
@@ -1043,7 +1043,8 @@
size_t frame_id = StackVisitor::ComputeNumFrames(self, kInstrumentationStackWalk);
std::deque<instrumentation::InstrumentationStackFrame>* stack = self->GetInstrumentationStack();
if (kVerboseInstrumentation) {
- LOG(INFO) << "Entering " << PrettyMethod(method) << " from PC " << reinterpret_cast<void*>(lr);
+ LOG(INFO) << "Entering " << ArtMethod::PrettyMethod(method) << " from PC "
+ << reinterpret_cast<void*>(lr);
}
instrumentation::InstrumentationStackFrame instrumentation_frame(this_object, method, lr,
frame_id, interpreter_entry);
@@ -1098,8 +1099,8 @@
if (deoptimize && Runtime::Current()->IsDeoptimizeable(*return_pc)) {
if (kVerboseInstrumentation) {
LOG(INFO) << StringPrintf("Deoptimizing %s by returning from %s with result %#" PRIx64 " in ",
- PrettyMethod(visitor.caller).c_str(),
- PrettyMethod(method).c_str(),
+ visitor.caller->PrettyMethod().c_str(),
+ method->PrettyMethod().c_str(),
return_value.GetJ()) << *self;
}
self->PushDeoptimizationContext(return_value,
@@ -1110,7 +1111,7 @@
reinterpret_cast<uintptr_t>(GetQuickDeoptimizationEntryPoint()));
} else {
if (kVerboseInstrumentation) {
- LOG(INFO) << "Returning from " << PrettyMethod(method)
+ LOG(INFO) << "Returning from " << method->PrettyMethod()
<< " to PC " << reinterpret_cast<void*>(*return_pc);
}
return GetTwoWordSuccessValue(0, *return_pc);
@@ -1128,11 +1129,11 @@
ArtMethod* method = instrumentation_frame.method_;
if (is_deoptimization) {
if (kVerboseInstrumentation) {
- LOG(INFO) << "Popping for deoptimization " << PrettyMethod(method);
+ LOG(INFO) << "Popping for deoptimization " << ArtMethod::PrettyMethod(method);
}
} else {
if (kVerboseInstrumentation) {
- LOG(INFO) << "Popping for unwind " << PrettyMethod(method);
+ LOG(INFO) << "Popping for unwind " << ArtMethod::PrettyMethod(method);
}
// Notify listeners of method unwind.
@@ -1146,7 +1147,7 @@
std::string InstrumentationStackFrame::Dump() const {
std::ostringstream os;
- os << "Frame " << frame_id_ << " " << PrettyMethod(method_) << ":"
+ os << "Frame " << frame_id_ << " " << ArtMethod::PrettyMethod(method_) << ":"
<< reinterpret_cast<void*>(return_pc_) << " this=" << reinterpret_cast<void*>(this_object_);
return os.str();
}
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc
index f3cd25c..2e00770 100644
--- a/runtime/interpreter/interpreter.cc
+++ b/runtime/interpreter/interpreter.cc
@@ -178,7 +178,7 @@
ScopedThreadStateChange tsc(self, kNative);
fn(soa.Env(), klass.get(), arg0.get(), args[1], arg2.get(), args[3], args[4]);
} else {
- LOG(FATAL) << "Do something with static native method: " << PrettyMethod(method)
+ LOG(FATAL) << "Do something with static native method: " << method->PrettyMethod()
<< " shorty: " << shorty;
}
} else {
@@ -223,7 +223,7 @@
ScopedThreadStateChange tsc(self, kNative);
result->SetI(fn(soa.Env(), rcvr.get(), args[0], args[1]));
} else {
- LOG(FATAL) << "Do something with native method: " << PrettyMethod(method)
+ LOG(FATAL) << "Do something with native method: " << method->PrettyMethod()
<< " shorty: " << shorty;
}
}
@@ -546,7 +546,7 @@
} else {
CHECK(false) << "Unexpected instruction opcode " << instr->Opcode()
<< " at dex_pc " << dex_pc
- << " of method: " << PrettyMethod(shadow_frame->GetMethod(), false);
+ << " of method: " << ArtMethod::PrettyMethod(shadow_frame->GetMethod(), false);
}
} else {
// Nothing to do, the dex_pc is the one at which the code requested
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index 191ffcc..09d1167 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -1046,11 +1046,11 @@
if (UNLIKELY(component_class->IsPrimitive() && !is_primitive_int_component)) {
if (component_class->IsPrimitiveLong() || component_class->IsPrimitiveDouble()) {
ThrowRuntimeException("Bad filled array request for type %s",
- PrettyDescriptor(component_class).c_str());
+ component_class->PrettyDescriptor().c_str());
} else {
self->ThrowNewExceptionF("Ljava/lang/InternalError;",
"Found type %s; filled-new-array not implemented for anything but 'int'",
- PrettyDescriptor(component_class).c_str());
+ component_class->PrettyDescriptor().c_str());
}
return false;
}
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index bdb6bd3..40d6f03 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -438,7 +438,7 @@
if (kTraceExecutionEnabled) {
#define TRACE_LOG std::cerr
std::ostringstream oss;
- oss << PrettyMethod(shadow_frame.GetMethod())
+ oss << shadow_frame.GetMethod()->PrettyMethod()
<< StringPrintf("\n0x%x: ", dex_pc)
<< inst->DumpString(shadow_frame.GetMethod()->GetDexFile()) << "\n";
for (uint32_t i = 0; i < shadow_frame.NumberOfVRegs(); ++i) {
@@ -450,7 +450,7 @@
!ref_value->AsString()->IsValueNull()) {
oss << "/java.lang.String \"" << ref_value->AsString()->ToModifiedUtf8() << "\"";
} else {
- oss << "/" << PrettyTypeOf(ref_value);
+ oss << "/" << ref_value->PrettyTypeOf();
}
}
}
diff --git a/runtime/interpreter/interpreter_switch_impl.cc b/runtime/interpreter/interpreter_switch_impl.cc
index 295cdec..78afe56 100644
--- a/runtime/interpreter/interpreter_switch_impl.cc
+++ b/runtime/interpreter/interpreter_switch_impl.cc
@@ -495,7 +495,7 @@
// be finalized without a started runtime.
if (transaction_active && obj->GetClass()->IsFinalizable()) {
AbortTransactionF(self, "Allocating finalizable object in transaction: %s",
- PrettyTypeOf(obj).c_str());
+ obj->PrettyTypeOf().c_str());
HANDLE_PENDING_EXCEPTION();
break;
}
@@ -990,7 +990,7 @@
break;
}
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
- DCHECK(a->IsIntArray() || a->IsFloatArray()) << PrettyTypeOf(a);
+ DCHECK(a->IsIntArray() || a->IsFloatArray()) << a->PrettyTypeOf();
auto* array = down_cast<IntArray*>(a);
if (array->CheckIsValidIndex(index)) {
shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetWithoutChecks(index));
@@ -1009,7 +1009,7 @@
break;
}
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
- DCHECK(a->IsLongArray() || a->IsDoubleArray()) << PrettyTypeOf(a);
+ DCHECK(a->IsLongArray() || a->IsDoubleArray()) << a->PrettyTypeOf();
auto* array = down_cast<LongArray*>(a);
if (array->CheckIsValidIndex(index)) {
shadow_frame.SetVRegLong(inst->VRegA_23x(inst_data), array->GetWithoutChecks(index));
@@ -1123,7 +1123,7 @@
}
int32_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data));
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
- DCHECK(a->IsIntArray() || a->IsFloatArray()) << PrettyTypeOf(a);
+ DCHECK(a->IsIntArray() || a->IsFloatArray()) << a->PrettyTypeOf();
auto* array = down_cast<IntArray*>(a);
if (array->CheckIsValidIndex(index)) {
array->SetWithoutChecks<transaction_active>(index, val);
@@ -1143,7 +1143,7 @@
}
int64_t val = shadow_frame.GetVRegLong(inst->VRegA_23x(inst_data));
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
- DCHECK(a->IsLongArray() || a->IsDoubleArray()) << PrettyTypeOf(a);
+ DCHECK(a->IsLongArray() || a->IsDoubleArray()) << a->PrettyTypeOf();
LongArray* array = down_cast<LongArray*>(a);
if (array->CheckIsValidIndex(index)) {
array->SetWithoutChecks<transaction_active>(index, val);
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc
index 4347c37..25ce5cc 100644
--- a/runtime/interpreter/unstarted_runtime.cc
+++ b/runtime/interpreter/unstarted_runtime.cc
@@ -127,7 +127,8 @@
if (found == nullptr && abort_if_not_found) {
if (!self->IsExceptionPending()) {
AbortTransactionOrFail(self, "%s failed in un-started runtime for class: %s",
- method_name.c_str(), PrettyDescriptor(descriptor.c_str()).c_str());
+ method_name.c_str(),
+ PrettyDescriptor(descriptor.c_str()).c_str());
}
return;
}
@@ -151,7 +152,7 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
if (self->IsExceptionPending()) {
// If it is not the transaction abort exception, wrap it.
- std::string type(PrettyTypeOf(self->GetException()));
+ std::string type(mirror::Object::PrettyTypeOf(self->GetException()));
if (type != Transaction::kAbortExceptionDescriptor) {
self->ThrowNewWrappedException("Ljava/lang/ClassNotFoundException;",
"ClassNotFoundException");
@@ -242,7 +243,7 @@
if (Runtime::Current()->IsActiveTransaction()) {
if (h_klass.Get()->IsFinalizable()) {
AbortTransactionF(self, "Class for newInstance is finalizable: '%s'",
- PrettyClass(h_klass.Get()).c_str());
+ h_klass->PrettyClass().c_str());
return;
}
}
@@ -266,13 +267,13 @@
} else {
self->ThrowNewExceptionF("Ljava/lang/InternalError;",
"Could not find default constructor for '%s'",
- PrettyClass(h_klass.Get()).c_str());
+ h_klass->PrettyClass().c_str());
}
}
if (!ok) {
AbortTransactionOrFail(self, "Failed in Class.newInstance for '%s' with %s",
- PrettyClass(h_klass.Get()).c_str(),
- PrettyTypeOf(self->GetException()).c_str());
+ h_klass->PrettyClass().c_str(),
+ mirror::Object::PrettyTypeOf(self->GetException()).c_str());
}
}
@@ -300,7 +301,7 @@
if (found == nullptr) {
AbortTransactionOrFail(self, "Failed to find field in Class.getDeclaredField in un-started "
" runtime. name=%s class=%s", name2->ToModifiedUtf8().c_str(),
- PrettyDescriptor(klass).c_str());
+ klass->PrettyDescriptor().c_str());
return;
}
Runtime* runtime = Runtime::Current();
@@ -562,8 +563,8 @@
if (self->DecodeJObject(WellKnownClasses::java_lang_BootClassLoader) !=
this_classloader_class.Get()) {
AbortTransactionOrFail(self,
- "Unsupported classloader type %s for getResourceAsStream",
- PrettyClass(this_classloader_class.Get()).c_str());
+ "Unsupported classloader type %s for getResourceAsStream",
+ Class::PrettyClass(this_classloader_class.Get()).c_str());
return;
}
}
@@ -584,7 +585,7 @@
// This might have an error pending. But semantics are to just return null.
if (self->IsExceptionPending()) {
// If it is an InternalError, keep it. See CheckExceptionGenerateClassNotFound.
- std::string type(PrettyTypeOf(self->GetException()));
+ std::string type(mirror::Object::PrettyTypeOf(self->GetException()));
if (type != "java.lang.InternalError") {
self->ClearException();
}
@@ -608,8 +609,10 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
if (src_array->GetClass()->GetComponentType() != dst_array->GetClass()->GetComponentType()) {
AbortTransactionOrFail(self, "Types mismatched in arraycopy: %s vs %s.",
- PrettyDescriptor(src_array->GetClass()->GetComponentType()).c_str(),
- PrettyDescriptor(dst_array->GetClass()->GetComponentType()).c_str());
+ Class::PrettyDescriptor(
+ src_array->GetClass()->GetComponentType()).c_str(),
+ Class::PrettyDescriptor(
+ dst_array->GetClass()->GetComponentType()).c_str());
return;
}
mirror::PrimitiveArray<T>* src = down_cast<mirror::PrimitiveArray<T>*>(src_array);
@@ -674,8 +677,10 @@
GetComponentType();
if (trg_type->IsPrimitiveInt()) {
AbortTransactionOrFail(self, "Type mismatch in arraycopy: %s vs %s",
- PrettyDescriptor(src_array->GetClass()->GetComponentType()).c_str(),
- PrettyDescriptor(dst_array->GetClass()->GetComponentType()).c_str());
+ Class::PrettyDescriptor(
+ src_array->GetClass()->GetComponentType()).c_str(),
+ Class::PrettyDescriptor(
+ dst_array->GetClass()->GetComponentType()).c_str());
return;
}
@@ -714,7 +719,7 @@
PrimitiveArrayCopy<int32_t>(self, src_array, src_pos, dst_array, dst_pos, length);
} else {
AbortTransactionOrFail(self, "Unimplemented System.arraycopy for type '%s'",
- PrettyDescriptor(src_type).c_str());
+ src_type->PrettyDescriptor().c_str());
}
}
@@ -839,7 +844,7 @@
void UnstartedRuntime::UnstartedThreadLocalGet(
Thread* self, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset ATTRIBUTE_UNUSED) {
- std::string caller(PrettyMethod(shadow_frame->GetLink()->GetMethod()));
+ std::string caller(ArtMethod::PrettyMethod(shadow_frame->GetLink()->GetMethod()));
bool ok = false;
if (caller == "void java.lang.FloatingDecimal.developLongDigits(int, long, long)" ||
caller == "java.lang.String java.lang.FloatingDecimal.toJavaFormatString()") {
@@ -1204,7 +1209,7 @@
// initialization of other classes, so will *use* the value.
void UnstartedRuntime::UnstartedRuntimeAvailableProcessors(
Thread* self, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset ATTRIBUTE_UNUSED) {
- std::string caller(PrettyMethod(shadow_frame->GetLink()->GetMethod()));
+ std::string caller(ArtMethod::PrettyMethod(shadow_frame->GetLink()->GetMethod()));
if (caller == "void java.util.concurrent.SynchronousQueue.<clinit>()") {
// SynchronousQueue really only separates between single- and multiprocessor case. Return
// 8 as a conservative upper approximation.
@@ -1748,7 +1753,7 @@
// problems in core libraries.
CHECK(tables_initialized_);
- std::string name(PrettyMethod(shadow_frame->GetMethod()));
+ std::string name(ArtMethod::PrettyMethod(shadow_frame->GetMethod()));
const auto& iter = invoke_handlers_.find(name);
if (iter != invoke_handlers_.end()) {
// Clear out the result in case it's not zeroed out.
@@ -1769,7 +1774,7 @@
// Hand select a number of methods to be run in a not yet started runtime without using JNI.
void UnstartedRuntime::Jni(Thread* self, ArtMethod* method, mirror::Object* receiver,
uint32_t* args, JValue* result) {
- std::string name(PrettyMethod(method));
+ std::string name(ArtMethod::PrettyMethod(method));
const auto& iter = jni_handlers_.find(name);
if (iter != jni_handlers_.end()) {
// Clear out the result in case it's not zeroed out.
@@ -1779,7 +1784,7 @@
AbortTransactionF(self, "Attempt to invoke native method in non-started runtime: %s",
name.c_str());
} else {
- LOG(FATAL) << "Calling native method " << PrettyMethod(method) << " in an unstarted "
+ LOG(FATAL) << "Calling native method " << ArtMethod::PrettyMethod(method) << " in an unstarted "
"non-transactional runtime";
}
}
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index f2bda05..29dda88 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -235,8 +235,8 @@
void* FindNativeMethod(ArtMethod* m, std::string& detail)
REQUIRES(Locks::jni_libraries_lock_)
REQUIRES_SHARED(Locks::mutator_lock_) {
- std::string jni_short_name(JniShortName(m));
- std::string jni_long_name(JniLongName(m));
+ std::string jni_short_name(m->JniShortName());
+ std::string jni_long_name(m->JniLongName());
mirror::ClassLoader* const declaring_class_loader = m->GetDeclaringClass()->GetClassLoader();
ScopedObjectAccessUnchecked soa(Thread::Current());
void* const declaring_class_loader_allocator =
@@ -258,13 +258,13 @@
fn = library->FindSymbol(jni_long_name, shorty);
}
if (fn != nullptr) {
- VLOG(jni) << "[Found native code for " << PrettyMethod(m)
+ VLOG(jni) << "[Found native code for " << m->PrettyMethod()
<< " in \"" << library->GetPath() << "\"]";
return fn;
}
}
detail += "No implementation found for ";
- detail += PrettyMethod(m);
+ detail += m->PrettyMethod();
detail += " (tried " + jni_short_name + " and " + jni_long_name + ")";
LOG(ERROR) << detail;
return nullptr;
@@ -471,7 +471,7 @@
}
// TODO: is this useful given that we're about to dump the calling thread's stack?
if (current_method != nullptr) {
- os << "\n from " << PrettyMethod(current_method);
+ os << "\n from " << current_method->PrettyMethod();
}
os << "\n";
self->Dump(os);
@@ -904,7 +904,7 @@
CHECK(m->IsNative());
mirror::Class* c = m->GetDeclaringClass();
// If this is a static method, it could be called before the class has been initialized.
- CHECK(c->IsInitializing()) << c->GetStatus() << " " << PrettyMethod(m);
+ CHECK(c->IsInitializing()) << c->GetStatus() << " " << m->PrettyMethod();
std::string detail;
void* native_method;
Thread* self = Thread::Current();
diff --git a/runtime/jdwp/jdwp_event.cc b/runtime/jdwp/jdwp_event.cc
index 6aebe9f..85bfd17 100644
--- a/runtime/jdwp/jdwp_event.cc
+++ b/runtime/jdwp/jdwp_event.cc
@@ -1142,7 +1142,7 @@
SetJdwpLocationFromEventLocation(pCatchLoc, &jdwp_catch_location);
if (VLOG_IS_ON(jdwp)) {
- std::string exceptionClassName(PrettyDescriptor(exception_object->GetClass()));
+ std::string exceptionClassName(mirror::Class::PrettyDescriptor(exception_object->GetClass()));
LogMatchingEventsAndThread(match_list, thread_id);
VLOG(jdwp) << " throwLocation=" << jdwp_throw_location;
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index afa52ca..aa9a78b 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -246,14 +246,14 @@
// Don't compile the method if it has breakpoints.
if (Dbg::IsDebuggerActive() && Dbg::MethodHasAnyBreakpoints(method)) {
- VLOG(jit) << "JIT not compiling " << PrettyMethod(method) << " due to breakpoint";
+ VLOG(jit) << "JIT not compiling " << method->PrettyMethod() << " due to breakpoint";
return false;
}
// Don't compile the method if we are supposed to be deoptimized.
instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
if (instrumentation->AreAllMethodsDeoptimized() || instrumentation->IsDeoptimized(method)) {
- VLOG(jit) << "JIT not compiling " << PrettyMethod(method) << " due to deoptimization";
+ VLOG(jit) << "JIT not compiling " << method->PrettyMethod() << " due to deoptimization";
return false;
}
@@ -265,13 +265,13 @@
}
VLOG(jit) << "Compiling method "
- << PrettyMethod(method_to_compile)
+ << ArtMethod::PrettyMethod(method_to_compile)
<< " osr=" << std::boolalpha << osr;
bool success = jit_compile_method_(jit_compiler_handle_, method_to_compile, self, osr);
code_cache_->DoneCompiling(method_to_compile, self, osr);
if (!success) {
VLOG(jit) << "Failed to compile method "
- << PrettyMethod(method_to_compile)
+ << ArtMethod::PrettyMethod(method_to_compile)
<< " osr=" << std::boolalpha << osr;
}
return success;
@@ -424,7 +424,7 @@
// method while we are being suspended.
const size_t number_of_vregs = method->GetCodeItem()->registers_size_;
const char* shorty = method->GetShorty();
- std::string method_name(VLOG_IS_ON(jit) ? PrettyMethod(method) : "");
+ std::string method_name(VLOG_IS_ON(jit) ? method->PrettyMethod() : "");
void** memory = nullptr;
size_t frame_size = 0;
ShadowFrame* shadow_frame = nullptr;
@@ -539,7 +539,7 @@
LOG(INFO) << "Compiler allocated "
<< PrettySize(bytes)
<< " to compile "
- << PrettyMethod(method);
+ << ArtMethod::PrettyMethod(method);
}
MutexLock mu(Thread::Current(), lock_);
memory_use_.AddValue(bytes);
@@ -574,7 +574,7 @@
} else {
DCHECK(kind_ == kAllocateProfile);
if (ProfilingInfo::Create(self, method_, /* retry_allocation */ true)) {
- VLOG(jit) << "Start profiling " << PrettyMethod(method_);
+ VLOG(jit) << "Start profiling " << ArtMethod::PrettyMethod(method_);
}
}
ProfileSaver::NotifyJitActivity();
@@ -620,7 +620,7 @@
(method->GetProfilingInfo(kRuntimePointerSize) == nullptr)) {
bool success = ProfilingInfo::Create(self, method, /* retry_allocation */ false);
if (success) {
- VLOG(jit) << "Start profiling " << PrettyMethod(method);
+ VLOG(jit) << "Start profiling " << method->PrettyMethod();
}
if (thread_pool_ == nullptr) {
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index 35656cd..d3178b0 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -34,6 +34,11 @@
struct RuntimeArgumentMap;
union JValue;
+namespace mirror {
+class Object;
+class Class;
+} // namespace mirror
+
namespace jit {
class JitCodeCache;
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 2c6b249..a26d850 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -368,7 +368,7 @@
last_update_time_ns_.StoreRelease(NanoTime());
VLOG(jit)
<< "JIT added (osr=" << std::boolalpha << osr << std::noboolalpha << ") "
- << PrettyMethod(method) << "@" << method
+ << ArtMethod::PrettyMethod(method) << "@" << method
<< " ccache_size=" << PrettySize(CodeCacheSizeLocked()) << ": "
<< " dcache_size=" << PrettySize(DataCacheSizeLocked()) << ": "
<< reinterpret_cast<const void*>(method_header->GetEntryPoint()) << ","
@@ -378,7 +378,7 @@
LOG(INFO) << "JIT allocated "
<< PrettySize(code_size)
<< " for compiled code of "
- << PrettyMethod(method);
+ << ArtMethod::PrettyMethod(method);
}
}
@@ -434,7 +434,7 @@
LOG(INFO) << "JIT allocated "
<< PrettySize(size)
<< " for stack maps of "
- << PrettyMethod(method);
+ << ArtMethod::PrettyMethod(method);
}
return result;
}
@@ -806,7 +806,8 @@
}
if (kIsDebugBuild && method != nullptr) {
DCHECK_EQ(it->second, method)
- << PrettyMethod(method) << " " << PrettyMethod(it->second) << " " << std::hex << pc;
+ << ArtMethod::PrettyMethod(method) << " " << ArtMethod::PrettyMethod(it->second) << " "
+ << std::hex << pc;
}
return method_header;
}
@@ -927,7 +928,7 @@
ProfilingInfo* info = method->GetProfilingInfo(kRuntimePointerSize);
if (info == nullptr) {
- VLOG(jit) << PrettyMethod(method) << " needs a ProfilingInfo to be compiled";
+ VLOG(jit) << method->PrettyMethod() << " needs a ProfilingInfo to be compiled";
// Because the counter is not atomic, there are some rare cases where we may not
// hit the threshold for creating the ProfilingInfo. Reset the counter now to
// "correct" this.
diff --git a/runtime/jit/offline_profiling_info.cc b/runtime/jit/offline_profiling_info.cc
index aa606a2..f535151 100644
--- a/runtime/jit/offline_profiling_info.cc
+++ b/runtime/jit/offline_profiling_info.cc
@@ -629,7 +629,7 @@
os << "\n\tmethods: ";
for (const auto method_it : dex_data.method_set) {
if (dex_file != nullptr) {
- os << "\n\t\t" << PrettyMethod(method_it, *dex_file, true);
+ os << "\n\t\t" << dex_file->PrettyMethod(method_it, true);
} else {
os << method_it << ",";
}
diff --git a/runtime/jit/profiling_info.cc b/runtime/jit/profiling_info.cc
index 6ba187e..9ec46f0 100644
--- a/runtime/jit/profiling_info.cc
+++ b/runtime/jit/profiling_info.cc
@@ -99,7 +99,7 @@
void ProfilingInfo::AddInvokeInfo(uint32_t dex_pc, mirror::Class* cls) {
InlineCache* cache = GetInlineCache(dex_pc);
- CHECK(cache != nullptr) << PrettyMethod(method_) << "@" << dex_pc;
+ CHECK(cache != nullptr) << ArtMethod::PrettyMethod(method_) << "@" << dex_pc;
for (size_t i = 0; i < InlineCache::kIndividualCacheSize; ++i) {
mirror::Class* existing = cache->classes_[i].Read();
if (existing == cls) {
diff --git a/runtime/jni_env_ext-inl.h b/runtime/jni_env_ext-inl.h
index 2cc7342..004f824 100644
--- a/runtime/jni_env_ext-inl.h
+++ b/runtime/jni_env_ext-inl.h
@@ -36,7 +36,7 @@
if (entry_count > 16) {
locals.Dump(LOG_STREAM(WARNING) << "Warning: more than 16 JNI local references: "
<< entry_count << " (most recent was a "
- << PrettyTypeOf(obj) << ")\n");
+ << mirror::Object::PrettyTypeOf(obj) << ")\n");
// TODO: LOG(FATAL) in a later release?
}
}
diff --git a/runtime/jni_env_ext.cc b/runtime/jni_env_ext.cc
index 3c749d0..bae1567 100644
--- a/runtime/jni_env_ext.cc
+++ b/runtime/jni_env_ext.cc
@@ -183,11 +183,11 @@
// current thread, which isn't safe if this is the only runnable thread.
return StringPrintf("<@addr=0x%" PRIxPTR "> (a %s)",
reinterpret_cast<intptr_t>(o.Ptr()),
- PrettyTypeOf(o).c_str());
+ o->PrettyTypeOf().c_str());
} else {
// IdentityHashCode can cause thread suspension, which would invalidate o if it moved. So
// we get the pretty type before we call IdentityHashCode.
- const std::string pretty_type(PrettyTypeOf(o));
+ const std::string pretty_type(o->PrettyTypeOf());
return StringPrintf("<0x%08x> (a %s)", o->IdentityHashCode(), pretty_type.c_str());
}
}
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index 305a7e8..8238f3a 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -110,7 +110,7 @@
bool return_errors)
REQUIRES_SHARED(Locks::mutator_lock_) {
LOG(return_errors ? ::android::base::ERROR : ::android::base::FATAL)
- << "Failed to register native method in " << PrettyDescriptor(c)
+ << "Failed to register native method in " << c->PrettyDescriptor()
<< " in " << c->GetDexCache()->GetLocation()->ToModifiedUtf8()
<< ": " << kind << " is null at index " << idx;
soa.Self()->ThrowNewExceptionF("Ljava/lang/NoSuchMethodError;",
@@ -241,7 +241,7 @@
static void ThrowAIOOBE(ScopedObjectAccess& soa, mirror::Array* array, jsize start,
jsize length, const char* identifier)
REQUIRES_SHARED(Locks::mutator_lock_) {
- std::string type(PrettyTypeOf(array));
+ std::string type(array->PrettyTypeOf());
soa.Self()->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;",
"%s offset=%d length=%d %s.length=%d",
type.c_str(), start, length, identifier, array->GetLength());
@@ -283,7 +283,7 @@
if (mid == nullptr) {
ScopedObjectAccess soa(env);
LOG(ERROR) << "No <init>" << signature << " in "
- << PrettyClass(soa.Decode<mirror::Class>(exception_class));
+ << mirror::Class::PrettyClass(soa.Decode<mirror::Class>(exception_class));
return JNI_ERR;
}
@@ -486,11 +486,11 @@
jmethodID mid = env->GetMethodID(exception_class.get(), "printStackTrace", "()V");
if (mid == nullptr) {
LOG(WARNING) << "JNI WARNING: no printStackTrace()V in "
- << PrettyTypeOf(old_exception.Get());
+ << mirror::Object::PrettyTypeOf(old_exception.Get());
} else {
env->CallVoidMethod(exception.get(), mid);
if (soa.Self()->IsExceptionPending()) {
- LOG(WARNING) << "JNI WARNING: " << PrettyTypeOf(soa.Self()->GetException())
+ LOG(WARNING) << "JNI WARNING: " << mirror::Object::PrettyTypeOf(soa.Self()->GetException())
<< " thrown while calling printStackTrace";
soa.Self()->ClearException();
}
@@ -1841,7 +1841,7 @@
ScopedObjectAccess soa(env);
ObjPtr<mirror::Object> obj = soa.Decode<mirror::Object>(java_array);
if (UNLIKELY(!obj->IsArrayInstance())) {
- soa.Vm()->JniAbortF("GetArrayLength", "not an array: %s", PrettyTypeOf(obj).c_str());
+ soa.Vm()->JniAbortF("GetArrayLength", "not an array: %s", obj->PrettyTypeOf().c_str());
return 0;
}
mirror::Array* array = obj->AsArray();
@@ -1910,7 +1910,7 @@
if (UNLIKELY(element_class->IsPrimitive())) {
soa.Vm()->JniAbortF("NewObjectArray",
"not an object type: %s",
- PrettyDescriptor(element_class).c_str());
+ element_class->PrettyDescriptor().c_str());
return nullptr;
}
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
@@ -1930,8 +1930,8 @@
if (UNLIKELY(!element_class->IsAssignableFrom(initial_object->GetClass()))) {
soa.Vm()->JniAbortF("NewObjectArray", "cannot assign object of type '%s' to array with "
"element type of '%s'",
- PrettyDescriptor(initial_object->GetClass()).c_str(),
- PrettyDescriptor(element_class).c_str());
+ mirror::Class::PrettyDescriptor(initial_object->GetClass()).c_str(),
+ element_class->PrettyDescriptor().c_str());
return nullptr;
} else {
for (jsize i = 0; i < length; ++i) {
@@ -1953,7 +1953,7 @@
ObjPtr<mirror::Array> array = soa.Decode<mirror::Array>(java_array);
if (UNLIKELY(!array->GetClass()->IsPrimitiveArray())) {
soa.Vm()->JniAbortF("GetPrimitiveArrayCritical", "expected primitive array, given %s",
- PrettyDescriptor(array->GetClass()).c_str());
+ array->GetClass()->PrettyDescriptor().c_str());
return nullptr;
}
gc::Heap* heap = Runtime::Current()->GetHeap();
@@ -1981,7 +1981,7 @@
ObjPtr<mirror::Array> array = soa.Decode<mirror::Array>(java_array);
if (UNLIKELY(!array->GetClass()->IsPrimitiveArray())) {
soa.Vm()->JniAbortF("ReleasePrimitiveArrayCritical", "expected primitive array, given %s",
- PrettyDescriptor(array->GetClass()).c_str());
+ array->GetClass()->PrettyDescriptor().c_str());
return;
}
const size_t component_size = array->GetClass()->GetComponentSize();
@@ -2162,7 +2162,7 @@
ObjPtr<mirror::Class> c = soa.Decode<mirror::Class>(java_class);
if (UNLIKELY(method_count == 0)) {
LOG(WARNING) << "JNI RegisterNativeMethods: attempt to register 0 native methods for "
- << PrettyDescriptor(c);
+ << mirror::Class::PrettyDescriptor(c);
return JNI_OK;
}
CHECK_NON_NULL_ARGUMENT_FN_NAME("RegisterNatives", methods, JNI_ERR);
@@ -2250,20 +2250,20 @@
mirror::Class::kDumpClassFullDetail);
LOG(return_errors ? ::android::base::ERROR : ::android::base::FATAL)
<< "Failed to register native method "
- << PrettyDescriptor(c) << "." << name << sig << " in "
+ << c->PrettyDescriptor() << "." << name << sig << " in "
<< c->GetDexCache()->GetLocation()->ToModifiedUtf8();
ThrowNoSuchMethodError(soa, c, name, sig, "static or non-static");
return JNI_ERR;
} else if (!m->IsNative()) {
LOG(return_errors ? ::android::base::ERROR : ::android::base::FATAL)
<< "Failed to register non-native method "
- << PrettyDescriptor(c) << "." << name << sig
+ << c->PrettyDescriptor() << "." << name << sig
<< " as native";
ThrowNoSuchMethodError(soa, c, name, sig, "native");
return JNI_ERR;
}
- VLOG(jni) << "[Registering JNI native method " << PrettyMethod(m) << "]";
+ VLOG(jni) << "[Registering JNI native method " << m->PrettyMethod() << "]";
is_fast = is_fast || m->IsFastNative(); // Merge with @FastNative state.
m->RegisterNative(fnPtr, is_fast);
@@ -2276,7 +2276,7 @@
ScopedObjectAccess soa(env);
ObjPtr<mirror::Class> c = soa.Decode<mirror::Class>(java_class);
- VLOG(jni) << "[Unregistering JNI native methods for " << PrettyClass(c) << "]";
+ VLOG(jni) << "[Unregistering JNI native methods for " << mirror::Class::PrettyClass(c) << "]";
size_t unregistered_count = 0;
auto pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
@@ -2289,7 +2289,7 @@
if (unregistered_count == 0) {
LOG(WARNING) << "JNI UnregisterNatives: attempt to unregister native methods of class '"
- << PrettyDescriptor(c) << "' that contains no native methods";
+ << mirror::Class::PrettyDescriptor(c) << "' that contains no native methods";
}
return JNI_OK;
}
@@ -2428,8 +2428,9 @@
soa.Vm()->JniAbortF(fn_name,
"attempt to %s %s primitive array elements with an object of type %s",
operation,
- PrettyDescriptor(ArtArrayT::GetArrayClass()->GetComponentType()).c_str(),
- PrettyDescriptor(array->GetClass()).c_str());
+ mirror::Class::PrettyDescriptor(
+ ArtArrayT::GetArrayClass()->GetComponentType()).c_str(),
+ mirror::Class::PrettyDescriptor(array->GetClass()).c_str());
return nullptr;
}
DCHECK_EQ(sizeof(ElementT), array->GetClass()->GetComponentSize());
diff --git a/runtime/jni_internal_test.cc b/runtime/jni_internal_test.cc
index fbd670c..61208e1 100644
--- a/runtime/jni_internal_test.cc
+++ b/runtime/jni_internal_test.cc
@@ -58,7 +58,7 @@
void ExpectException(jclass exception_class) {
ScopedObjectAccess soa(env_);
EXPECT_TRUE(env_->ExceptionCheck())
- << PrettyDescriptor(soa.Decode<mirror::Class>(exception_class));
+ << mirror::Class::PrettyDescriptor(soa.Decode<mirror::Class>(exception_class));
jthrowable exception = env_->ExceptionOccurred();
EXPECT_NE(nullptr, exception);
env_->ExceptionClear();
diff --git a/runtime/method_reference.h b/runtime/method_reference.h
index f4fe9b2..0b0afe6 100644
--- a/runtime/method_reference.h
+++ b/runtime/method_reference.h
@@ -18,15 +18,18 @@
#define ART_RUNTIME_METHOD_REFERENCE_H_
#include <stdint.h>
+#include <string>
+#include "dex_file.h"
namespace art {
-class DexFile;
-
// A method is uniquely located by its DexFile and the method_ids_ table index into that DexFile
struct MethodReference {
MethodReference(const DexFile* file, uint32_t index) : dex_file(file), dex_method_index(index) {
}
+ std::string PrettyMethod(bool with_signature = true) {
+ return dex_file->PrettyMethod(dex_method_index, with_signature);
+ }
const DexFile* dex_file;
uint32_t dex_method_index;
};
diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h
index 3789081..b11dad8 100644
--- a/runtime/mirror/array-inl.h
+++ b/runtime/mirror/array-inl.h
@@ -168,7 +168,7 @@
// 32-bit.
if (UNLIKELY(size == 0)) {
self->ThrowOutOfMemoryError(StringPrintf("%s of length %d would overflow",
- PrettyDescriptor(array_class).c_str(),
+ array_class->PrettyDescriptor().c_str(),
component_count).c_str());
return nullptr;
}
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 14bd243..9992a9e 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -42,14 +42,14 @@
template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
inline uint32_t Class::GetObjectSize() {
// Note: Extra parentheses to avoid the comma being interpreted as macro parameter separator.
- DCHECK((!IsVariableSize<kVerifyFlags, kReadBarrierOption>())) << "class=" << PrettyTypeOf(this);
+ DCHECK((!IsVariableSize<kVerifyFlags, kReadBarrierOption>())) << "class=" << PrettyTypeOf();
return GetField32(ObjectSizeOffset());
}
template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
inline uint32_t Class::GetObjectSizeAllocFastPath() {
// Note: Extra parentheses to avoid the comma being interpreted as macro parameter separator.
- DCHECK((!IsVariableSize<kVerifyFlags, kReadBarrierOption>())) << "class=" << PrettyTypeOf(this);
+ DCHECK((!IsVariableSize<kVerifyFlags, kReadBarrierOption>())) << "class=" << PrettyTypeOf();
return GetField32(ObjectSizeAllocFastPathOffset());
}
@@ -218,7 +218,7 @@
inline ArtMethod* Class::GetVirtualMethod(size_t i, PointerSize pointer_size) {
CheckPointerSize(pointer_size);
DCHECK(IsResolved<kVerifyFlags>() || IsErroneous<kVerifyFlags>())
- << PrettyClass(this) << " status=" << GetStatus();
+ << Class::PrettyClass() << " status=" << GetStatus();
return GetVirtualMethodUnchecked(i, pointer_size);
}
@@ -308,7 +308,7 @@
inline bool Class::Implements(ObjPtr<Class> klass) {
DCHECK(klass != nullptr);
- DCHECK(klass->IsInterface()) << PrettyClass(this);
+ DCHECK(klass->IsInterface()) << PrettyClass();
// All interfaces implemented directly and by our superclass, and
// recursively all super-interfaces of those interfaces, are listed
// in iftable_, so we can just do a linear scan through that.
@@ -342,20 +342,20 @@
// Object[] = int[] --> false
//
inline bool Class::IsArrayAssignableFromArray(ObjPtr<Class> src) {
- DCHECK(IsArrayClass()) << PrettyClass(this);
- DCHECK(src->IsArrayClass()) << PrettyClass(src);
+ DCHECK(IsArrayClass()) << PrettyClass();
+ DCHECK(src->IsArrayClass()) << src->PrettyClass();
return GetComponentType()->IsAssignableFrom(src->GetComponentType());
}
inline bool Class::IsAssignableFromArray(ObjPtr<Class> src) {
- DCHECK(!IsInterface()) << PrettyClass(this); // handled first in IsAssignableFrom
- DCHECK(src->IsArrayClass()) << PrettyClass(src);
+ DCHECK(!IsInterface()) << PrettyClass(); // handled first in IsAssignableFrom
+ DCHECK(src->IsArrayClass()) << src->PrettyClass();
if (!IsArrayClass()) {
// If "this" is not also an array, it must be Object.
// src's super should be java_lang_Object, since it is an array.
ObjPtr<Class> java_lang_Object = src->GetSuperClass();
- DCHECK(java_lang_Object != nullptr) << PrettyClass(src);
- DCHECK(java_lang_Object->GetSuperClass() == nullptr) << PrettyClass(src);
+ DCHECK(java_lang_Object != nullptr) << src->PrettyClass();
+ DCHECK(java_lang_Object->GetSuperClass() == nullptr) << src->PrettyClass();
return this == java_lang_Object;
}
return IsArrayAssignableFromArray(src);
@@ -469,8 +469,8 @@
}
inline bool Class::IsSubClass(ObjPtr<Class> klass) {
- DCHECK(!IsInterface()) << PrettyClass(this);
- DCHECK(!IsArrayClass()) << PrettyClass(this);
+ DCHECK(!IsInterface()) << PrettyClass();
+ DCHECK(!IsArrayClass()) << PrettyClass();
ObjPtr<Class> current = this;
do {
if (current == klass) {
@@ -484,8 +484,8 @@
inline ArtMethod* Class::FindVirtualMethodForInterface(ArtMethod* method,
PointerSize pointer_size) {
ObjPtr<Class> declaring_class = method->GetDeclaringClass();
- DCHECK(declaring_class != nullptr) << PrettyClass(this);
- DCHECK(declaring_class->IsInterface()) << PrettyMethod(method);
+ DCHECK(declaring_class != nullptr) << PrettyClass();
+ DCHECK(declaring_class->IsInterface()) << method->PrettyMethod();
DCHECK(!method->IsCopied());
// TODO cache to improve lookup speed
const int32_t iftable_count = GetIfTableCount();
@@ -647,7 +647,7 @@
IsErroneous<static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis)>()
<< " IsString=" << (this == String::GetJavaLangString())
<< " status= " << GetStatus<kVerifyFlags>()
- << " descriptor=" << PrettyDescriptor(this);
+ << " descriptor=" << PrettyDescriptor();
return GetField32<kVerifyFlags>(AccessFlagsOffset());
}
@@ -687,20 +687,20 @@
inline void Class::CheckObjectAlloc() {
DCHECK(!IsArrayClass())
- << PrettyClass(this)
+ << PrettyClass()
<< "A array shouldn't be allocated through this "
<< "as it requires a pre-fence visitor that sets the class size.";
DCHECK(!IsClassClass())
- << PrettyClass(this)
+ << PrettyClass()
<< "A class object shouldn't be allocated through this "
<< "as it requires a pre-fence visitor that sets the class size.";
DCHECK(!IsStringClass())
- << PrettyClass(this)
+ << PrettyClass()
<< "A string shouldn't be allocated through this "
<< "as it requires a pre-fence visitor that sets the class size.";
- DCHECK(IsInstantiable()) << PrettyClass(this);
+ DCHECK(IsInstantiable()) << PrettyClass();
// TODO: decide whether we want this check. It currently fails during bootstrap.
- // DCHECK(!Runtime::Current()->IsStarted() || IsInitializing()) << PrettyClass(this);
+ // DCHECK(!Runtime::Current()->IsStarted() || IsInitializing()) << PrettyClass();
DCHECK_GE(this->object_size_, sizeof(Object));
}
@@ -840,8 +840,8 @@
inline void Class::AssertInitializedOrInitializingInThread(Thread* self) {
if (kIsDebugBuild && !IsInitialized()) {
- CHECK(IsInitializing()) << PrettyClass(this) << " is not initializing: " << GetStatus();
- CHECK_EQ(GetClinitThreadId(), self->GetTid()) << PrettyClass(this)
+ CHECK(IsInitializing()) << PrettyClass() << " is not initializing: " << GetStatus();
+ CHECK_EQ(GetClinitThreadId(), self->GetTid()) << PrettyClass()
<< " is initializing in a different thread";
}
}
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index f93f72f..6a357b3 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -59,7 +59,7 @@
}
inline void Class::SetVerifyError(ObjPtr<Object> error) {
- CHECK(error != nullptr) << PrettyClass(this);
+ CHECK(error != nullptr) << PrettyClass();
if (Runtime::Current()->IsActiveTransaction()) {
SetFieldObject<true>(OFFSET_OF_OBJECT_MEMBER(Class, verify_error_), error);
} else {
@@ -74,22 +74,22 @@
if (LIKELY(class_linker_initialized)) {
if (UNLIKELY(new_status <= old_status && new_status != kStatusError &&
new_status != kStatusRetired)) {
- LOG(FATAL) << "Unexpected change back of class status for " << PrettyClass(h_this.Get())
+ LOG(FATAL) << "Unexpected change back of class status for " << h_this->PrettyClass()
<< " " << old_status << " -> " << new_status;
}
if (new_status >= kStatusResolved || old_status >= kStatusResolved) {
// When classes are being resolved the resolution code should hold the lock.
CHECK_EQ(h_this->GetLockOwnerThreadId(), self->GetThreadId())
<< "Attempt to change status of class while not holding its lock: "
- << PrettyClass(h_this.Get()) << " " << old_status << " -> " << new_status;
+ << h_this->PrettyClass() << " " << old_status << " -> " << new_status;
}
}
if (UNLIKELY(new_status == kStatusError)) {
CHECK_NE(h_this->GetStatus(), kStatusError)
<< "Attempt to set as erroneous an already erroneous class "
- << PrettyClass(h_this.Get());
+ << h_this->PrettyClass();
if (VLOG_IS_ON(class_linker)) {
- LOG(ERROR) << "Setting " << PrettyDescriptor(h_this.Get()) << " to erroneous.";
+ LOG(ERROR) << "Setting " << h_this->PrettyDescriptor() << " to erroneous.";
if (self->IsExceptionPending()) {
LOG(ERROR) << "Exception: " << self->GetException()->Dump();
}
@@ -127,7 +127,7 @@
if (h_this->IsTemp()) {
// Class is a temporary one, ensure that waiters for resolution get notified of retirement
// so that they can grab the new version of the class from the class linker's table.
- CHECK_LT(new_status, kStatusResolved) << PrettyDescriptor(h_this.Get());
+ CHECK_LT(new_status, kStatusResolved) << h_this->PrettyDescriptor();
if (new_status == kStatusRetired || new_status == kStatusError) {
h_this->NotifyAll(self);
}
@@ -149,7 +149,7 @@
if (kIsDebugBuild && new_class_size < GetClassSize()) {
DumpClass(LOG_STREAM(FATAL_WITHOUT_ABORT), kDumpClassFullDetail);
LOG(FATAL_WITHOUT_ABORT) << new_class_size << " vs " << GetClassSize();
- LOG(FATAL) << "class=" << PrettyTypeOf(this);
+ LOG(FATAL) << "class=" << PrettyTypeOf();
}
// Not called within a transaction.
SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, class_size_), new_class_size);
@@ -196,7 +196,7 @@
void Class::DumpClass(std::ostream& os, int flags) {
if ((flags & kDumpClassFullDetail) == 0) {
- os << PrettyClass(this);
+ os << PrettyClass();
if ((flags & kDumpClassClassLoader) != 0) {
os << ' ' << GetClassLoader();
}
@@ -221,7 +221,7 @@
os << StringPrintf(" access=0x%04x.%04x\n",
GetAccessFlags() >> 16, GetAccessFlags() & kAccJavaFlagsMask);
if (h_super.Get() != nullptr) {
- os << " super='" << PrettyClass(h_super.Get()) << "' (cl=" << h_super->GetClassLoader()
+ os << " super='" << h_super->PrettyClass() << "' (cl=" << h_super->GetClassLoader()
<< ")\n";
}
if (IsArrayClass()) {
@@ -247,19 +247,20 @@
os << " vtable (" << h_this->NumVirtualMethods() << " entries, "
<< (h_super.Get() != nullptr ? h_super->NumVirtualMethods() : 0) << " in super):\n";
for (size_t i = 0; i < NumVirtualMethods(); ++i) {
- os << StringPrintf(" %2zd: %s\n", i, PrettyMethod(
+ os << StringPrintf(" %2zd: %s\n", i, ArtMethod::PrettyMethod(
h_this->GetVirtualMethodDuringLinking(i, image_pointer_size)).c_str());
}
os << " direct methods (" << h_this->NumDirectMethods() << " entries):\n";
for (size_t i = 0; i < h_this->NumDirectMethods(); ++i) {
- os << StringPrintf(" %2zd: %s\n", i, PrettyMethod(
+ os << StringPrintf(" %2zd: %s\n", i, ArtMethod::PrettyMethod(
h_this->GetDirectMethod(i, image_pointer_size)).c_str());
}
if (h_this->NumStaticFields() > 0) {
os << " static fields (" << h_this->NumStaticFields() << " entries):\n";
if (h_this->IsResolved() || h_this->IsErroneous()) {
for (size_t i = 0; i < h_this->NumStaticFields(); ++i) {
- os << StringPrintf(" %2zd: %s\n", i, PrettyField(h_this->GetStaticField(i)).c_str());
+ os << StringPrintf(" %2zd: %s\n", i,
+ ArtField::PrettyField(h_this->GetStaticField(i)).c_str());
}
} else {
os << " <not yet available>";
@@ -269,7 +270,8 @@
os << " instance fields (" << h_this->NumInstanceFields() << " entries):\n";
if (h_this->IsResolved() || h_this->IsErroneous()) {
for (size_t i = 0; i < h_this->NumInstanceFields(); ++i) {
- os << StringPrintf(" %2zd: %s\n", i, PrettyField(h_this->GetInstanceField(i)).c_str());
+ os << StringPrintf(" %2zd: %s\n", i,
+ ArtField::PrettyField(h_this->GetInstanceField(i)).c_str());
}
} else {
os << " <not yet available>";
@@ -690,7 +692,7 @@
break;
}
}
- CHECK_EQ(found, ret) << "Found " << PrettyField(found) << " vs " << PrettyField(ret);
+ CHECK_EQ(found, ret) << "Found " << found->PrettyField() << " vs " << ret->PrettyField();
}
return ret;
}
@@ -919,7 +921,7 @@
while (!common_super_class->IsAssignableFrom(klass.Get())) {
ObjPtr<Class> old_common = common_super_class;
common_super_class = old_common->GetSuperClass();
- DCHECK(common_super_class != nullptr) << PrettyClass(old_common);
+ DCHECK(common_super_class != nullptr) << old_common->PrettyClass();
}
return common_super_class;
}
@@ -953,7 +955,7 @@
void Class::PopulateEmbeddedVTable(PointerSize pointer_size) {
PointerArray* table = GetVTableDuringLinking();
- CHECK(table != nullptr) << PrettyClass(this);
+ CHECK(table != nullptr) << PrettyClass();
const size_t table_length = table->GetLength();
SetEmbeddedVTableLength(table_length);
for (size_t i = 0; i < table_length; i++) {
@@ -1239,5 +1241,50 @@
}
}
+std::string Class::PrettyDescriptor(ObjPtr<mirror::Class> klass) {
+ if (klass == nullptr) {
+ return "null";
+ }
+ return klass->PrettyDescriptor();
+}
+
+std::string Class::PrettyDescriptor() {
+ std::string temp;
+ return art::PrettyDescriptor(GetDescriptor(&temp));
+}
+
+std::string Class::PrettyClass(ObjPtr<mirror::Class> c) {
+ if (c == nullptr) {
+ return "null";
+ }
+ return c->PrettyClass();
+}
+
+std::string Class::PrettyClass() {
+ std::string result;
+ result += "java.lang.Class<";
+ result += PrettyDescriptor();
+ result += ">";
+ return result;
+}
+
+std::string Class::PrettyClassAndClassLoader(ObjPtr<mirror::Class> c) {
+ if (c == nullptr) {
+ return "null";
+ }
+ return c->PrettyClassAndClassLoader();
+}
+
+std::string Class::PrettyClassAndClassLoader() {
+ std::string result;
+ result += "java.lang.Class<";
+ result += PrettyDescriptor();
+ result += ",";
+ result += mirror::Object::PrettyTypeOf(GetClassLoader());
+ // TODO: add an identifying hash value for the loader
+ result += ">";
+ return result;
+}
+
} // namespace mirror
} // namespace art
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index a5b61fd..5793795 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -1120,7 +1120,7 @@
REQUIRES_SHARED(Locks::mutator_lock_);
pid_t GetClinitThreadId() REQUIRES_SHARED(Locks::mutator_lock_) {
- DCHECK(IsIdxLoaded() || IsErroneous()) << PrettyClass(this);
+ DCHECK(IsIdxLoaded() || IsErroneous()) << PrettyClass();
return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, clinit_thread_id_));
}
@@ -1288,6 +1288,22 @@
ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethodsSliceUnchecked(PointerSize pointer_size)
REQUIRES_SHARED(Locks::mutator_lock_);
+ static std::string PrettyDescriptor(ObjPtr<mirror::Class> klass)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ std::string PrettyDescriptor()
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ // Returns a human-readable form of the name of the given class.
+ // Given String.class, the output would be "java.lang.Class<java.lang.String>".
+ static std::string PrettyClass(ObjPtr<mirror::Class> c)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ std::string PrettyClass()
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ // Returns a human-readable form of the name of the given class with its class loader.
+ static std::string PrettyClassAndClassLoader(ObjPtr<mirror::Class> c)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ std::string PrettyClassAndClassLoader()
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
// Fix up all of the native pointers in the class by running them through the visitor. Only sets
// the corresponding entry in dest if visitor(obj) != obj to prevent dirty memory. Dest should be
// initialized to a copy of *this to prevent issues. Does not visit the ArtMethod and ArtField
diff --git a/runtime/mirror/method.cc b/runtime/mirror/method.cc
index 7ddadda..25cbdc1 100644
--- a/runtime/mirror/method.cc
+++ b/runtime/mirror/method.cc
@@ -53,7 +53,7 @@
template <PointerSize kPointerSize, bool kTransactionActive>
Method* Method::CreateFromArtMethod(Thread* self, ArtMethod* method) {
- DCHECK(!method->IsConstructor()) << PrettyMethod(method);
+ DCHECK(!method->IsConstructor()) << method->PrettyMethod();
ObjPtr<Method> ret = ObjPtr<Method>::DownCast(StaticClass()->AllocObject(self));
if (LIKELY(ret != nullptr)) {
ObjPtr<Executable>(ret)->
@@ -105,7 +105,7 @@
template <PointerSize kPointerSize, bool kTransactionActive>
Constructor* Constructor::CreateFromArtMethod(Thread* self, ArtMethod* method) {
- DCHECK(method->IsConstructor()) << PrettyMethod(method);
+ DCHECK(method->IsConstructor()) << method->PrettyMethod();
ObjPtr<Constructor> ret = ObjPtr<Constructor>::DownCast(StaticClass()->AllocObject(self));
if (LIKELY(ret != nullptr)) {
ObjPtr<Executable>(ret)->
diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h
index f555c80..2e70c9b 100644
--- a/runtime/mirror/object-inl.h
+++ b/runtime/mirror/object-inl.h
@@ -510,7 +510,7 @@
template GetObjectSize<kNewFlags, kReadBarrierOption>();
}
DCHECK_GE(result, sizeof(Object))
- << " class=" << PrettyClass(GetClass<kNewFlags, kReadBarrierOption>());
+ << " class=" << Class::PrettyClass(GetClass<kNewFlags, kReadBarrierOption>());
return result;
}
diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc
index 7e92c53..8cfb60e 100644
--- a/runtime/mirror/object.cc
+++ b/runtime/mirror/object.cc
@@ -266,7 +266,7 @@
}
}
LOG(FATAL) << "Failed to find field for assignment to " << reinterpret_cast<void*>(this)
- << " of type " << PrettyDescriptor(c) << " at offset " << field_offset;
+ << " of type " << c->PrettyDescriptor() << " at offset " << field_offset;
UNREACHABLE();
}
@@ -275,5 +275,24 @@
: ArtField::FindInstanceFieldWithOffset(GetClass(), offset.Uint32Value());
}
+std::string Object::PrettyTypeOf(ObjPtr<mirror::Object> obj) {
+ if (obj == nullptr) {
+ return "null";
+ }
+ return obj->PrettyTypeOf();
+}
+
+std::string Object::PrettyTypeOf() {
+ if (GetClass() == nullptr) {
+ return "(raw)";
+ }
+ std::string temp;
+ std::string result(PrettyDescriptor(GetClass()->GetDescriptor(&temp)));
+ if (IsClass()) {
+ result += "<" + PrettyDescriptor(AsClass()->GetDescriptor(&temp)) + ">";
+ }
+ return result;
+}
+
} // namespace mirror
} // namespace art
diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h
index 13f4028..f1ab72a 100644
--- a/runtime/mirror/object.h
+++ b/runtime/mirror/object.h
@@ -544,6 +544,15 @@
// Generate an identity hash code. Public for object test.
static uint32_t GenerateIdentityHashCode();
+ // Returns a human-readable form of the name of the *class* of the given object.
+ // So given an instance of java.lang.String, the output would
+ // be "java.lang.String". Given an array of int, the output would be "int[]".
+ // Given String.class, the output would be "java.lang.Class<java.lang.String>".
+ static std::string PrettyTypeOf(ObjPtr<mirror::Object> obj)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ std::string PrettyTypeOf()
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
protected:
// Accessors for non-Java type fields
template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h
index 3c2390b..5fb9459 100644
--- a/runtime/mirror/object_array-inl.h
+++ b/runtime/mirror/object_array-inl.h
@@ -238,8 +238,8 @@
}
Runtime::Current()->GetHeap()->WriteBarrierArray(this, dst_pos, count);
if (UNLIKELY(i != count)) {
- std::string actualSrcType(PrettyTypeOf(o));
- std::string dstType(PrettyTypeOf(this));
+ std::string actualSrcType(mirror::Object::PrettyTypeOf(o));
+ std::string dstType(PrettyTypeOf());
Thread* self = Thread::Current();
if (throw_exception) {
self->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc
index 60e2bf8..5bf254d 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -337,7 +337,7 @@
dims->Set<false>(0, -1);
multi = Array::CreateMultiArray(soa.Self(), c, dims);
EXPECT_TRUE(soa.Self()->IsExceptionPending());
- EXPECT_EQ(PrettyDescriptor(soa.Self()->GetException()->GetClass()),
+ EXPECT_EQ(mirror::Class::PrettyDescriptor(soa.Self()->GetException()->GetClass()),
"java.lang.NegativeArraySizeException");
soa.Self()->ClearException();
diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h
index cf902af..d42bb92 100644
--- a/runtime/mirror/string-inl.h
+++ b/runtime/mirror/string-inl.h
@@ -232,7 +232,7 @@
const size_t max_length = RoundDown(max_alloc_length, kObjectAlignment / block_size);
if (UNLIKELY(length > max_length)) {
self->ThrowOutOfMemoryError(StringPrintf("%s of length %d would overflow",
- PrettyDescriptor(string_class).c_str(),
+ Class::PrettyDescriptor(string_class).c_str(),
static_cast<int>(length)).c_str());
return nullptr;
}
diff --git a/runtime/mirror/string.cc b/runtime/mirror/string.cc
index ed1103f..ea2660b 100644
--- a/runtime/mirror/string.cc
+++ b/runtime/mirror/string.cc
@@ -365,5 +365,16 @@
return (IsCompressed()) ? (GetValueCompressed() == nullptr) : (GetValue() == nullptr);
}
+std::string String::PrettyStringDescriptor(ObjPtr<mirror::String> java_descriptor) {
+ if (java_descriptor == nullptr) {
+ return "null";
+ }
+ return java_descriptor->PrettyStringDescriptor();
+}
+
+std::string String::PrettyStringDescriptor() {
+ return PrettyDescriptor(ToModifiedUtf8().c_str());
+}
+
} // namespace mirror
} // namespace art
diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h
index cfb1153..a1b674a 100644
--- a/runtime/mirror/string.h
+++ b/runtime/mirror/string.h
@@ -204,6 +204,14 @@
static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
+ // Returns a human-readable equivalent of 'descriptor'. So "I" would be "int",
+ // "[[I" would be "int[][]", "[Ljava/lang/String;" would be
+ // "java.lang.String[]", and so forth.
+ static std::string PrettyStringDescriptor(ObjPtr<mirror::String> descriptor)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+ std::string PrettyStringDescriptor()
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
private:
void SetHashCode(int32_t new_hash_code) REQUIRES_SHARED(Locks::mutator_lock_) {
// Hash code is invariant so use non-transactional mode. Also disable check as we may run inside
diff --git a/runtime/mirror/throwable.cc b/runtime/mirror/throwable.cc
index 7aff3de..b866a63 100644
--- a/runtime/mirror/throwable.cc
+++ b/runtime/mirror/throwable.cc
@@ -83,7 +83,7 @@
}
std::string Throwable::Dump() {
- std::string result(PrettyTypeOf(this));
+ std::string result(PrettyTypeOf());
result += ": ";
ObjPtr<String> msg = GetDetailMessage();
if (msg != nullptr) {
@@ -112,7 +112,7 @@
uintptr_t dex_pc = method_trace->GetElementPtrSize<uintptr_t>(i + depth, ptr_size);
int32_t line_number = method->GetLineNumFromDexPC(dex_pc);
const char* source_file = method->GetDeclaringClassSourceFile();
- result += StringPrintf(" at %s (%s:%d)\n", PrettyMethod(method, true).c_str(),
+ result += StringPrintf(" at %s (%s:%d)\n", method->PrettyMethod(true).c_str(),
source_file, line_number);
}
}
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index debbdd5..eb74fcf 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -307,7 +307,7 @@
std::ostringstream oss;
oss << "monitor contention with owner " << owner_name << " (" << owner_tid << ")";
if (owners_method != nullptr) {
- oss << " at " << PrettyMethod(owners_method);
+ oss << " at " << owners_method->PrettyMethod();
oss << "(" << owners_filename << ":" << owners_line_number << ")";
}
oss << " waiters=" << num_waiters;
@@ -377,8 +377,8 @@
int32_t line_number;
TranslateLocation(m, pc, &filename, &line_number);
oss << " blocking from "
- << PrettyMethod(m) << "(" << (filename != nullptr ? filename : "null") << ":"
- << line_number << ")";
+ << ArtMethod::PrettyMethod(m) << "(" << (filename != nullptr ? filename : "null")
+ << ":" << line_number << ")";
ATRACE_BEGIN(oss.str().c_str());
}
monitor_contenders_.Wait(self); // Still contended so wait.
@@ -420,7 +420,8 @@
owners_method,
owners_dex_pc,
num_waiters)
- << " in " << PrettyMethod(m) << " for " << PrettyDuration(MsToNs(wait_ms));
+ << " in " << ArtMethod::PrettyMethod(m) << " for "
+ << PrettyDuration(MsToNs(wait_ms));
}
const char* owners_filename;
int32_t owners_line_number;
@@ -503,14 +504,14 @@
if (found_owner_thread_id == 0u) {
ThrowIllegalMonitorStateExceptionF("unlock of unowned monitor on object of type '%s'"
" on thread '%s'",
- PrettyTypeOf(o).c_str(),
+ mirror::Object::PrettyTypeOf(o).c_str(),
expected_owner_string.c_str());
} else {
// Race: the original read found an owner but now there is none
ThrowIllegalMonitorStateExceptionF("unlock of monitor owned by '%s' on object of type '%s'"
" (where now the monitor appears unowned) on thread '%s'",
found_owner_string.c_str(),
- PrettyTypeOf(o).c_str(),
+ mirror::Object::PrettyTypeOf(o).c_str(),
expected_owner_string.c_str());
}
} else {
@@ -519,7 +520,7 @@
ThrowIllegalMonitorStateExceptionF("unlock of monitor owned by '%s' on object of type '%s'"
" (originally believed to be unowned) on thread '%s'",
current_owner_string.c_str(),
- PrettyTypeOf(o).c_str(),
+ mirror::Object::PrettyTypeOf(o).c_str(),
expected_owner_string.c_str());
} else {
if (found_owner_thread_id != current_owner_thread_id) {
@@ -528,13 +529,13 @@
" owned by '%s') on object of type '%s' on thread '%s'",
found_owner_string.c_str(),
current_owner_string.c_str(),
- PrettyTypeOf(o).c_str(),
+ mirror::Object::PrettyTypeOf(o).c_str(),
expected_owner_string.c_str());
} else {
ThrowIllegalMonitorStateExceptionF("unlock of monitor owned by '%s' on object of type '%s'"
" on thread '%s",
current_owner_string.c_str(),
- PrettyTypeOf(o).c_str(),
+ mirror::Object::PrettyTypeOf(o).c_str(),
expected_owner_string.c_str());
}
}
@@ -1144,12 +1145,12 @@
// current thread, which isn't safe if this is the only runnable thread.
os << wait_message << StringPrintf("<@addr=0x%" PRIxPTR "> (a %s)",
reinterpret_cast<intptr_t>(pretty_object),
- PrettyTypeOf(pretty_object).c_str());
+ pretty_object->PrettyTypeOf().c_str());
} else {
// - waiting on <0x6008c468> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
// Call PrettyTypeOf before IdentityHashCode since IdentityHashCode can cause thread
// suspension and move pretty_object.
- const std::string pretty_type(PrettyTypeOf(pretty_object));
+ const std::string pretty_type(pretty_object->PrettyTypeOf());
os << wait_message << StringPrintf("<0x%08x> (a %s)", pretty_object->IdentityHashCode(),
pretty_type.c_str());
}
@@ -1201,7 +1202,7 @@
// Is there any reason to believe there's any synchronization in this method?
const DexFile::CodeItem* code_item = m->GetCodeItem();
- CHECK(code_item != nullptr) << PrettyMethod(m);
+ CHECK(code_item != nullptr) << m->PrettyMethod();
if (code_item->tries_size_ == 0) {
return; // No "tries" implies no synchronization, so no held locks to report.
}
@@ -1211,7 +1212,7 @@
// inconsistent stack anyways.
uint32_t dex_pc = stack_visitor->GetDexPc(abort_on_failure);
if (!abort_on_failure && dex_pc == DexFile::kDexNoIndex) {
- LOG(ERROR) << "Could not find dex_pc for " << PrettyMethod(m);
+ LOG(ERROR) << "Could not find dex_pc for " << m->PrettyMethod();
return;
}
@@ -1234,7 +1235,7 @@
uint32_t value;
bool success = stack_visitor->GetVReg(m, monitor_register, kReferenceVReg, &value);
CHECK(success) << "Failed to read v" << monitor_register << " of kind "
- << kReferenceVReg << " in method " << PrettyMethod(m);
+ << kReferenceVReg << " in method " << m->PrettyMethod();
mirror::Object* o = reinterpret_cast<mirror::Object*>(value);
callback(o, callback_context);
}
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index 888fddb..e6de097 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -356,7 +356,6 @@
if (field == nullptr) {
return;
}
- // LOG(INFO) << "VMRuntime.preloadDexCaches resolved field " << PrettyField(field);
dex_cache->SetResolvedField(field_idx, field, kRuntimePointerSize);
}
@@ -393,7 +392,6 @@
if (method == nullptr) {
return;
}
- // LOG(INFO) << "VMRuntime.preloadDexCaches resolved method " << PrettyMethod(method);
dex_cache->SetResolvedMethod(method_idx, method, kRuntimePointerSize);
}
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc
index ac5dbda..642826c 100644
--- a/runtime/native/java_lang_Class.cc
+++ b/runtime/native/java_lang_Class.cc
@@ -633,7 +633,8 @@
if (UNLIKELY(klass->GetPrimitiveType() != 0 || klass->IsInterface() || klass->IsArrayClass() ||
klass->IsAbstract())) {
soa.Self()->ThrowNewExceptionF("Ljava/lang/InstantiationException;",
- "%s cannot be instantiated", PrettyClass(klass.Get()).c_str());
+ "%s cannot be instantiated",
+ klass->PrettyClass().c_str());
return nullptr;
}
auto caller = hs.NewHandle<mirror::Class>(nullptr);
@@ -643,7 +644,7 @@
if (caller.Get() != nullptr && !caller->CanAccess(klass.Get())) {
soa.Self()->ThrowNewExceptionF(
"Ljava/lang/IllegalAccessException;", "%s is not accessible from %s",
- PrettyClass(klass.Get()).c_str(), PrettyClass(caller.Get()).c_str());
+ klass->PrettyClass().c_str(), caller->PrettyClass().c_str());
return nullptr;
}
}
@@ -654,7 +655,7 @@
if (UNLIKELY(constructor == nullptr)) {
soa.Self()->ThrowNewExceptionF("Ljava/lang/InstantiationException;",
"%s has no zero argument constructor",
- PrettyClass(klass.Get()).c_str());
+ klass->PrettyClass().c_str());
return nullptr;
}
// Invoke the string allocator to return an empty string for the string class.
@@ -684,7 +685,7 @@
caller.Get()))) {
soa.Self()->ThrowNewExceptionF(
"Ljava/lang/IllegalAccessException;", "%s is not accessible from %s",
- PrettyMethod(constructor).c_str(), PrettyClass(caller.Get()).c_str());
+ constructor->PrettyMethod().c_str(), caller->PrettyClass().c_str());
return nullptr;
}
}
diff --git a/runtime/native/java_lang_System.cc b/runtime/native/java_lang_System.cc
index eaf2d65..7f8da80 100644
--- a/runtime/native/java_lang_System.cc
+++ b/runtime/native/java_lang_System.cc
@@ -38,7 +38,7 @@
static void ThrowArrayStoreException_NotAnArray(const char* identifier,
ObjPtr<mirror::Object> array)
REQUIRES_SHARED(Locks::mutator_lock_) {
- std::string actualType(PrettyTypeOf(array));
+ std::string actualType(mirror::Object::PrettyTypeOf(array));
Thread* self = Thread::Current();
self->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
"%s of type %s is not an array", identifier, actualType.c_str());
@@ -128,15 +128,15 @@
return;
}
default:
- LOG(FATAL) << "Unknown array type: " << PrettyTypeOf(srcArray);
+ LOG(FATAL) << "Unknown array type: " << srcArray->PrettyTypeOf();
UNREACHABLE();
}
}
// If one of the arrays holds a primitive type the other array must hold the exact same type.
if (UNLIKELY((dstComponentPrimitiveType != Primitive::kPrimNot) ||
srcComponentType->IsPrimitive())) {
- std::string srcType(PrettyTypeOf(srcArray));
- std::string dstType(PrettyTypeOf(dstArray));
+ std::string srcType(srcArray->PrettyTypeOf());
+ std::string dstType(dstArray->PrettyTypeOf());
soa.Self()->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
"Incompatible types: src=%s, dst=%s",
srcType.c_str(), dstType.c_str());
diff --git a/runtime/native/java_lang_VMClassLoader.cc b/runtime/native/java_lang_VMClassLoader.cc
index 1fe89bf..ff08284 100644
--- a/runtime/native/java_lang_VMClassLoader.cc
+++ b/runtime/native/java_lang_VMClassLoader.cc
@@ -57,7 +57,7 @@
ObjPtr<mirror::Class> exception = self->GetException()->GetClass();
if (exception == eiie_class || exception == iae_class || exception == ncdfe_class) {
self->ThrowNewWrappedException("Ljava/lang/ClassNotFoundException;",
- PrettyDescriptor(c).c_str());
+ c->PrettyDescriptor().c_str());
}
return nullptr;
}
diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc
index a81ba7d..66a5359 100644
--- a/runtime/native/java_lang_reflect_Constructor.cc
+++ b/runtime/native/java_lang_reflect_Constructor.cc
@@ -66,7 +66,7 @@
if (UNLIKELY(c->IsAbstract())) {
soa.Self()->ThrowNewExceptionF("Ljava/lang/InstantiationException;", "Can't instantiate %s %s",
c->IsInterface() ? "interface" : "abstract class",
- PrettyDescriptor(c.Get()).c_str());
+ c->PrettyDescriptor().c_str());
return nullptr;
}
// Verify that we can access the class.
@@ -77,7 +77,7 @@
// If caller is null, then we called from JNI, just avoid the check since JNI avoids most
// access checks anyways. TODO: Investigate if this the correct behavior.
if (caller != nullptr && !caller->CanAccess(c.Get())) {
- if (PrettyDescriptor(c.Get()) == "dalvik.system.DexPathList$Element") {
+ if (c->PrettyDescriptor() == "dalvik.system.DexPathList$Element") {
// b/20699073.
LOG(WARNING) << "The dalvik.system.DexPathList$Element constructor is not accessible by "
"default. This is a temporary workaround for backwards compatibility "
@@ -85,7 +85,8 @@
} else {
soa.Self()->ThrowNewExceptionF(
"Ljava/lang/IllegalAccessException;", "%s is not accessible from %s",
- PrettyClass(c.Get()).c_str(), PrettyClass(caller).c_str());
+ c->PrettyClass().c_str(),
+ caller->PrettyClass().c_str());
return nullptr;
}
}
diff --git a/runtime/native/java_lang_reflect_Executable.cc b/runtime/native/java_lang_reflect_Executable.cc
index a0a6a12..1b128fb 100644
--- a/runtime/native/java_lang_reflect_Executable.cc
+++ b/runtime/native/java_lang_reflect_Executable.cc
@@ -102,7 +102,7 @@
if (UNLIKELY(names.Get() == nullptr || access_flags.Get() == nullptr)) {
ThrowIllegalArgumentException(
StringPrintf("Missing parameter metadata for names or access flags for %s",
- PrettyMethod(art_method).c_str()).c_str());
+ art_method->PrettyMethod().c_str()).c_str());
return nullptr;
}
@@ -113,7 +113,7 @@
ThrowIllegalArgumentException(
StringPrintf(
"Inconsistent parameter metadata for %s. names length: %d, access flags length: %d",
- PrettyMethod(art_method).c_str(),
+ art_method->PrettyMethod().c_str(),
names_count,
access_flags_count).c_str());
return nullptr;
diff --git a/runtime/native/java_lang_reflect_Field.cc b/runtime/native/java_lang_reflect_Field.cc
index 90def44..329aae9 100644
--- a/runtime/native/java_lang_reflect_Field.cc
+++ b/runtime/native/java_lang_reflect_Field.cc
@@ -39,9 +39,9 @@
ThrowIllegalAccessException(
StringPrintf("Cannot set %s field %s of class %s",
PrettyJavaAccessFlags(field->GetAccessFlags()).c_str(),
- PrettyField(field->GetArtField()).c_str(),
+ ArtField::PrettyField(field->GetArtField()).c_str(),
field->GetDeclaringClass() == nullptr ? "null" :
- PrettyClass(field->GetDeclaringClass()).c_str()).c_str());
+ field->GetDeclaringClass()->PrettyClass().c_str()).c_str());
return false;
}
ObjPtr<mirror::Class> calling_class;
@@ -53,11 +53,11 @@
1)) {
ThrowIllegalAccessException(
StringPrintf("Class %s cannot access %s field %s of class %s",
- calling_class == nullptr ? "null" : PrettyClass(calling_class).c_str(),
+ calling_class == nullptr ? "null" : calling_class->PrettyClass().c_str(),
PrettyJavaAccessFlags(field->GetAccessFlags()).c_str(),
- PrettyField(field->GetArtField()).c_str(),
+ ArtField::PrettyField(field->GetArtField()).c_str(),
field->GetDeclaringClass() == nullptr ? "null" :
- PrettyClass(field->GetDeclaringClass()).c_str()).c_str());
+ field->GetDeclaringClass()->PrettyClass().c_str()).c_str());
return false;
}
return true;
@@ -106,7 +106,8 @@
break;
}
ThrowIllegalArgumentException(
- StringPrintf("Not a primitive field: %s", PrettyField(f->GetArtField()).c_str()).c_str());
+ StringPrintf("Not a primitive field: %s",
+ ArtField::PrettyField(f->GetArtField()).c_str()).c_str());
return false;
}
@@ -306,8 +307,9 @@
FALLTHROUGH_INTENDED;
case Primitive::kPrimVoid:
// Never okay.
- ThrowIllegalArgumentException(StringPrintf("Not a primitive field: %s",
- PrettyField(f->GetArtField()).c_str()).c_str());
+ ThrowIllegalArgumentException(
+ StringPrintf("Not a primitive field: %s",
+ ArtField::PrettyField(f->GetArtField()).c_str()).c_str());
return;
}
}
@@ -362,8 +364,9 @@
}
Primitive::Type field_type = f->GetTypeAsPrimitiveType();
if (UNLIKELY(field_type == Primitive::kPrimNot)) {
- ThrowIllegalArgumentException(StringPrintf("Not a primitive field: %s",
- PrettyField(f->GetArtField()).c_str()).c_str());
+ ThrowIllegalArgumentException(
+ StringPrintf("Not a primitive field: %s",
+ ArtField::PrettyField(f->GetArtField()).c_str()).c_str());
return;
}
diff --git a/runtime/native/java_lang_reflect_Parameter.cc b/runtime/native/java_lang_reflect_Parameter.cc
index 6060b8a..16164d2 100644
--- a/runtime/native/java_lang_reflect_Parameter.cc
+++ b/runtime/native/java_lang_reflect_Parameter.cc
@@ -47,7 +47,7 @@
ThrowIllegalArgumentException(
StringPrintf("Illegal parameterIndex %d for %s, parameter_count is %d",
parameterIndex,
- PrettyMethod(method).c_str(),
+ method->PrettyMethod().c_str(),
parameter_count).c_str());
return nullptr;
}
diff --git a/runtime/native_bridge_art_interface.cc b/runtime/native_bridge_art_interface.cc
index 059dc5a..5ab6097 100644
--- a/runtime/native_bridge_art_interface.cc
+++ b/runtime/native_bridge_art_interface.cc
@@ -69,7 +69,8 @@
methods[count].fnPtr = m.GetEntryPointFromJni();
count++;
} else {
- LOG(WARNING) << "Output native method array too small. Skipping " << PrettyMethod(&m);
+ LOG(WARNING) << "Output native method array too small. Skipping "
+ << m.PrettyMethod();
}
}
}
diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc
index 6b9468d..00ab577 100644
--- a/runtime/native_stack_dump.cc
+++ b/runtime/native_stack_dump.cc
@@ -347,7 +347,7 @@
Locks::mutator_lock_->IsSharedHeld(Thread::Current()) &&
PcIsWithinQuickCode(current_method, it->pc)) {
const void* start_of_code = current_method->GetEntryPointFromQuickCompiledCode();
- os << JniLongName(current_method) << "+"
+ os << current_method->JniLongName() << "+"
<< (it->pc - reinterpret_cast<uintptr_t>(start_of_code));
} else {
os << "???";
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 64e5a63..68f71f7 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -297,7 +297,8 @@
// Unsupported class-loader?
if (soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_PathClassLoader) !=
class_loader->GetClass()) {
- VLOG(class_linker) << "Unsupported class-loader " << PrettyClass(class_loader->GetClass());
+ VLOG(class_linker) << "Unsupported class-loader "
+ << mirror::Class::PrettyClass(class_loader->GetClass());
return false;
}
@@ -367,7 +368,8 @@
} else if (dexfile_class == element->GetClass()) {
dex_file = element;
} else {
- LOG(WARNING) << "Unsupported element in dex_elements: " << PrettyClass(element->GetClass());
+ LOG(WARNING) << "Unsupported element in dex_elements: "
+ << mirror::Class::PrettyClass(element->GetClass());
continue;
}
@@ -455,7 +457,7 @@
GetDexFilesFromDexElementsArray(soa, h_dex_elements, &queue);
} else if (h_class_loader.Get() != nullptr) {
VLOG(class_linker) << "Something unsupported with "
- << PrettyClass(h_class_loader->GetClass());
+ << mirror::Class::PrettyClass(h_class_loader->GetClass());
}
}
diff --git a/runtime/oat_quick_method_header.cc b/runtime/oat_quick_method_header.cc
index a68d9f8..9c2378d 100644
--- a/runtime/oat_quick_method_header.cc
+++ b/runtime/oat_quick_method_header.cc
@@ -56,7 +56,7 @@
<< reinterpret_cast<void*>(sought_offset)
<< "(PC " << reinterpret_cast<void*>(pc) << ", entry_point=" << entry_point
<< " current entry_point=" << method->GetEntryPointFromQuickCompiledCode()
- << ") in " << PrettyMethod(method);
+ << ") in " << method->PrettyMethod();
}
return DexFile::kDexNoIndex;
}
@@ -85,7 +85,7 @@
if (abort_on_failure) {
ScopedObjectAccess soa(Thread::Current());
LOG(FATAL) << "Failed to find native offset for dex pc 0x" << std::hex << dex_pc
- << " in " << PrettyMethod(method);
+ << " in " << method->PrettyMethod();
}
return UINTPTR_MAX;
}
diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc
index 9056d96..a81458f 100644
--- a/runtime/quick_exception_handler.cc
+++ b/runtime/quick_exception_handler.cc
@@ -145,7 +145,7 @@
if (kDebugExceptionDelivery) {
mirror::String* msg = exception->GetDetailMessage();
std::string str_msg(msg != nullptr ? msg->ToModifiedUtf8() : "");
- self_->DumpStack(LOG_STREAM(INFO) << "Delivering exception: " << PrettyTypeOf(exception)
+ self_->DumpStack(LOG_STREAM(INFO) << "Delivering exception: " << exception->PrettyTypeOf()
<< ": " << str_msg << "\n");
}
StackHandleScope<1> hs(self_);
@@ -162,7 +162,8 @@
if (handler_method_ != nullptr) {
const DexFile* dex_file = handler_method_->GetDeclaringClass()->GetDexCache()->GetDexFile();
int line_number = annotations::GetLineNumFromPC(dex_file, handler_method_, handler_dex_pc_);
- LOG(INFO) << "Handler: " << PrettyMethod(handler_method_) << " (line: " << line_number << ")";
+ LOG(INFO) << "Handler: " << handler_method_->PrettyMethod() << " (line: "
+ << line_number << ")";
}
}
if (clear_exception_) {
@@ -262,8 +263,8 @@
vreg_kind,
&vreg_value);
CHECK(get_vreg_success) << "VReg " << vreg << " was optimized out ("
- << "method=" << PrettyMethod(stack_visitor->GetMethod()) << ", "
- << "dex_pc=" << stack_visitor->GetDexPc() << ", "
+ << "method=" << ArtMethod::PrettyMethod(stack_visitor->GetMethod())
+ << ", dex_pc=" << stack_visitor->GetDexPc() << ", "
<< "native_pc_offset=" << stack_visitor->GetNativePcOffset() << ")";
// Copy value to the catch phi's stack slot.
@@ -323,7 +324,7 @@
if (GetMethod() == nullptr) {
exception_handler_->SetFullFragmentDone(true);
} else {
- CHECK(callee_method_ != nullptr) << art::PrettyMethod(GetMethod(), false);
+ CHECK(callee_method_ != nullptr) << GetMethod()->PrettyMethod(false);
exception_handler_->SetHandlerQuickArg0(reinterpret_cast<uintptr_t>(callee_method_));
}
}
@@ -669,7 +670,7 @@
return true;
} else if (method->IsRuntimeMethod()) {
if (show_details_) {
- LOG(INFO) << "R " << PrettyMethod(method, true);
+ LOG(INFO) << "R " << method->PrettyMethod(true);
}
return true;
} else {
@@ -677,7 +678,7 @@
LOG(INFO) << (is_shadow ? "S" : "Q")
<< ((!is_shadow && IsInInlinedFrame()) ? "i" : " ")
<< " "
- << PrettyMethod(method, true);
+ << method->PrettyMethod(true);
return true; // Go on.
}
}
diff --git a/runtime/read_barrier-inl.h b/runtime/read_barrier-inl.h
index 92efa21..67e5a81 100644
--- a/runtime/read_barrier-inl.h
+++ b/runtime/read_barrier-inl.h
@@ -231,7 +231,7 @@
if (kEnableReadBarrierInvariantChecks) {
CHECK(rb_ptr_low_bits == white_ptr_ || rb_ptr_low_bits == gray_ptr_ ||
rb_ptr_low_bits == black_ptr_)
- << "obj=" << obj << " rb_ptr=" << rb_ptr << " " << PrettyTypeOf(obj);
+ << "obj=" << obj << " rb_ptr=" << rb_ptr << " " << obj->PrettyTypeOf();
}
bool is_gray = rb_ptr_low_bits == gray_ptr_;
// The high bits are supposed to be zero. We check this on the caller side.
diff --git a/runtime/reference_table.cc b/runtime/reference_table.cc
index a9f39d0..16ed7fb 100644
--- a/runtime/reference_table.cc
+++ b/runtime/reference_table.cc
@@ -88,7 +88,7 @@
return;
}
- std::string className(PrettyTypeOf(obj));
+ std::string className(obj->PrettyTypeOf());
if (obj->IsClass()) {
// We're summarizing multiple instances, so using the exemplar
// Class' type parameter here would be misleading.
@@ -178,7 +178,7 @@
continue;
}
- std::string className(PrettyTypeOf(ref));
+ std::string className(ref->PrettyTypeOf());
std::string extras;
size_t element_count = GetElementCount(ref);
@@ -197,7 +197,7 @@
if (referent == nullptr) {
extras = " (referent is null)";
} else {
- extras = StringPrintf(" (referent is a %s)", PrettyTypeOf(referent).c_str());
+ extras = StringPrintf(" (referent is a %s)", referent->PrettyTypeOf().c_str());
}
}
os << StringPrintf(" %5d: ", idx) << ref << " " << className << extras << "\n";
diff --git a/runtime/reflection.cc b/runtime/reflection.cc
index 72db827..661012c 100644
--- a/runtime/reflection.cc
+++ b/runtime/reflection.cc
@@ -233,10 +233,10 @@
if (UNLIKELY(arg == nullptr || !arg->InstanceOf(dst_class))) {
ThrowIllegalArgumentException(
StringPrintf("method %s argument %zd has type %s, got %s",
- PrettyMethod(m, false).c_str(),
+ m->PrettyMethod(false).c_str(),
args_offset + 1, // Humans don't count from 0.
- PrettyDescriptor(dst_class).c_str(),
- PrettyTypeOf(arg).c_str()).c_str());
+ mirror::Class::PrettyDescriptor(dst_class).c_str(),
+ mirror::Object::PrettyTypeOf(arg).c_str()).c_str());
return false;
}
}
@@ -261,10 +261,10 @@
} else { \
ThrowIllegalArgumentException(\
StringPrintf("method %s argument %zd has type %s, got %s", \
- PrettyMethod(m, false).c_str(), \
+ ArtMethod::PrettyMethod(m, false).c_str(), \
args_offset + 1, \
expected, \
- PrettyTypeOf(arg).c_str()).c_str()); \
+ mirror::Object::PrettyTypeOf(arg).c_str()).c_str()); \
} \
return false; \
} }
@@ -382,8 +382,8 @@
(reinterpret_cast<StackReference<mirror::Object>*>(&args[i + offset]))->AsMirrorPtr();
if (argument != nullptr && !argument->InstanceOf(param_type)) {
LOG(ERROR) << "JNI ERROR (app bug): attempt to pass an instance of "
- << PrettyTypeOf(argument) << " as argument " << (i + 1)
- << " to " << PrettyMethod(m);
+ << argument->PrettyTypeOf() << " as argument " << (i + 1)
+ << " to " << m->PrettyMethod();
++error_count;
}
} else if (param_type->IsPrimitiveLong() || param_type->IsPrimitiveDouble()) {
@@ -393,25 +393,25 @@
if (param_type->IsPrimitiveBoolean()) {
if (arg != JNI_TRUE && arg != JNI_FALSE) {
LOG(ERROR) << "JNI ERROR (app bug): expected jboolean (0/1) but got value of "
- << arg << " as argument " << (i + 1) << " to " << PrettyMethod(m);
+ << arg << " as argument " << (i + 1) << " to " << m->PrettyMethod();
++error_count;
}
} else if (param_type->IsPrimitiveByte()) {
if (arg < -128 || arg > 127) {
LOG(ERROR) << "JNI ERROR (app bug): expected jbyte but got value of "
- << arg << " as argument " << (i + 1) << " to " << PrettyMethod(m);
+ << arg << " as argument " << (i + 1) << " to " << m->PrettyMethod();
++error_count;
}
} else if (param_type->IsPrimitiveChar()) {
if (args[i + offset] > 0xFFFF) {
LOG(ERROR) << "JNI ERROR (app bug): expected jchar but got value of "
- << arg << " as argument " << (i + 1) << " to " << PrettyMethod(m);
+ << arg << " as argument " << (i + 1) << " to " << m->PrettyMethod();
++error_count;
}
} else if (param_type->IsPrimitiveShort()) {
if (arg < -32768 || arg > 0x7FFF) {
LOG(ERROR) << "JNI ERROR (app bug): expected jshort but got value of "
- << arg << " as argument " << (i + 1) << " to " << PrettyMethod(m);
+ << arg << " as argument " << (i + 1) << " to " << m->PrettyMethod();
++error_count;
}
}
@@ -421,7 +421,7 @@
// TODO: pass the JNI function name (such as "CallVoidMethodV") through so we can call JniAbort
// with an argument.
vm->JniAbortF(nullptr, "bad arguments passed to %s (see above for details)",
- PrettyMethod(m).c_str());
+ m->PrettyMethod().c_str());
}
}
@@ -634,11 +634,11 @@
num_frames)) {
ThrowIllegalAccessException(
StringPrintf("Class %s cannot access %s method %s of class %s",
- calling_class == nullptr ? "null" : PrettyClass(calling_class).c_str(),
+ calling_class == nullptr ? "null" : calling_class->PrettyClass().c_str(),
PrettyJavaAccessFlags(m->GetAccessFlags()).c_str(),
- PrettyMethod(m).c_str(),
+ m->PrettyMethod().c_str(),
m->GetDeclaringClass() == nullptr ? "null" :
- PrettyClass(m->GetDeclaringClass()).c_str()).c_str());
+ m->GetDeclaringClass()->PrettyClass().c_str()).c_str());
return nullptr;
}
@@ -747,7 +747,7 @@
static std::string UnboxingFailureKind(ArtField* f)
REQUIRES_SHARED(Locks::mutator_lock_) {
if (f != nullptr) {
- return "field " + PrettyField(f, false);
+ return "field " + f->PrettyField(false);
}
return "result";
}
@@ -761,14 +761,16 @@
if (!dst_class->IsPrimitive()) {
if (UNLIKELY(o != nullptr && !o->InstanceOf(dst_class))) {
if (!unbox_for_result) {
- ThrowIllegalArgumentException(StringPrintf("%s has type %s, got %s",
- UnboxingFailureKind(f).c_str(),
- PrettyDescriptor(dst_class).c_str(),
- PrettyTypeOf(o).c_str()).c_str());
+ ThrowIllegalArgumentException(
+ StringPrintf("%s has type %s, got %s",
+ UnboxingFailureKind(f).c_str(),
+ dst_class->PrettyDescriptor().c_str(),
+ o->PrettyTypeOf().c_str()).c_str());
} else {
- ThrowClassCastException(StringPrintf("Couldn't convert result of type %s to %s",
- PrettyTypeOf(o).c_str(),
- PrettyDescriptor(dst_class).c_str()).c_str());
+ ThrowClassCastException(
+ StringPrintf("Couldn't convert result of type %s to %s",
+ o->PrettyTypeOf().c_str(),
+ dst_class->PrettyDescriptor().c_str()).c_str());
}
return false;
}
@@ -782,13 +784,14 @@
}
if (UNLIKELY(o == nullptr)) {
if (!unbox_for_result) {
- ThrowIllegalArgumentException(StringPrintf("%s has type %s, got null",
- UnboxingFailureKind(f).c_str(),
- PrettyDescriptor(dst_class).c_str()).c_str());
+ ThrowIllegalArgumentException(
+ StringPrintf("%s has type %s, got null",
+ UnboxingFailureKind(f).c_str(),
+ dst_class->PrettyDescriptor().c_str()).c_str());
} else {
ThrowNullPointerException(
StringPrintf("Expected to unbox a '%s' primitive type but was returned null",
- PrettyDescriptor(dst_class).c_str()).c_str());
+ dst_class->PrettyDescriptor().c_str()).c_str());
}
return false;
}
@@ -826,7 +829,7 @@
std::string temp;
ThrowIllegalArgumentException(
StringPrintf("%s has type %s, got %s", UnboxingFailureKind(f).c_str(),
- PrettyDescriptor(dst_class).c_str(),
+ dst_class->PrettyDescriptor().c_str(),
PrettyDescriptor(o->GetClass()->GetDescriptor(&temp)).c_str()).c_str());
return false;
}
@@ -897,8 +900,8 @@
}
void InvalidReceiverError(ObjPtr<mirror::Object> o, ObjPtr<mirror::Class> c) {
- std::string expected_class_name(PrettyDescriptor(c));
- std::string actual_class_name(PrettyTypeOf(o));
+ std::string expected_class_name(mirror::Class::PrettyDescriptor(c));
+ std::string actual_class_name(mirror::Object::PrettyTypeOf(o));
ThrowIllegalArgumentException(StringPrintf("Expected receiver of type %s, but got %s",
expected_class_name.c_str(),
actual_class_name.c_str()).c_str());
diff --git a/runtime/stack.cc b/runtime/stack.cc
index 3b5360c..167a30b 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -49,7 +49,7 @@
return GetVRegReference(0);
} else {
const DexFile::CodeItem* code_item = m->GetCodeItem();
- CHECK(code_item != nullptr) << PrettyMethod(m);
+ CHECK(code_item != nullptr) << ArtMethod::PrettyMethod(m);
uint16_t reg = code_item->registers_size_ - code_item->ins_size_;
return GetVRegReference(reg);
}
@@ -190,14 +190,14 @@
const DexFile::CodeItem* code_item = m->GetCodeItem();
if (code_item == nullptr) {
UNIMPLEMENTED(ERROR) << "Failed to determine this object of abstract or proxy method: "
- << PrettyMethod(m);
+ << ArtMethod::PrettyMethod(m);
return nullptr;
} else {
uint16_t reg = code_item->registers_size_ - code_item->ins_size_;
uint32_t value = 0;
bool success = GetVReg(m, reg, kReferenceVReg, &value);
// We currently always guarantee the `this` object is live throughout the method.
- CHECK(success) << "Failed to read the this object in " << PrettyMethod(m);
+ CHECK(success) << "Failed to read the this object in " << ArtMethod::PrettyMethod(m);
return reinterpret_cast<mirror::Object*>(value);
}
}
@@ -257,8 +257,8 @@
uint32_t* val) const {
DCHECK_EQ(m, GetMethod());
const DexFile::CodeItem* code_item = m->GetCodeItem();
- DCHECK(code_item != nullptr) << PrettyMethod(m); // Can't be null or how would we compile
- // its instructions?
+ DCHECK(code_item != nullptr) << m->PrettyMethod(); // Can't be null or how would we compile
+ // its instructions?
uint16_t number_of_dex_registers = code_item->registers_size_;
DCHECK_LT(vreg, code_item->registers_size_);
const OatQuickMethodHeader* method_header = GetCurrentOatQuickMethodHeader();
@@ -606,7 +606,7 @@
if (m == nullptr) {
return "upcall";
}
- result += PrettyMethod(m);
+ result += m->PrettyMethod();
result += StringPrintf("' at dex PC 0x%04x", GetDexPc());
if (!IsShadowFrame()) {
result += StringPrintf(" (native PC %p)", reinterpret_cast<void*>(GetCurrentQuickFramePc()));
@@ -651,7 +651,7 @@
uint32_t code_size = OatQuickMethodHeader::FromEntryPoint(code)->code_size_;
uintptr_t code_start = reinterpret_cast<uintptr_t>(code);
CHECK(code_start <= pc && pc <= (code_start + code_size))
- << PrettyMethod(method)
+ << method->PrettyMethod()
<< " pc=" << std::hex << pc
<< " code_start=" << code_start
<< " code_size=" << code_size;
@@ -693,7 +693,7 @@
}
}
}
- CHECK(in_image) << PrettyMethod(method) << " not in linear alloc or image";
+ CHECK(in_image) << method->PrettyMethod() << " not in linear alloc or image";
}
}
if (cur_quick_frame_ != nullptr) {
@@ -709,7 +709,7 @@
// TODO: 083-compiler-regressions ManyFloatArgs shows this estimate is wrong.
// const size_t kMaxExpectedFrameSize = (256 + 2 + 3 + 3) * sizeof(word);
const size_t kMaxExpectedFrameSize = 2 * KB;
- CHECK_LE(frame_size, kMaxExpectedFrameSize) << PrettyMethod(method);
+ CHECK_LE(frame_size, kMaxExpectedFrameSize) << method->PrettyMethod();
size_t return_pc_offset = GetCurrentQuickFrameInfo().GetReturnPcOffset();
CHECK_LT(return_pc_offset, frame_size);
}
@@ -762,7 +762,7 @@
ClassLinker* class_linker = runtime->GetClassLinker();
const void* entry_point = runtime->GetInstrumentation()->GetQuickCodeFor(method,
kRuntimePointerSize);
- DCHECK(class_linker->IsQuickGenericJniStub(entry_point)) << PrettyMethod(method);
+ DCHECK(class_linker->IsQuickGenericJniStub(entry_point)) << method->PrettyMethod();
// Generic JNI frame.
uint32_t handle_refs = GetNumberOfReferenceArgsWithoutReceiver(method) + 1;
size_t scope_size = HandleScope::SizeOf(handle_refs);
@@ -851,12 +851,12 @@
} else if (instrumentation_frame.interpreter_entry_) {
ArtMethod* callee =
Runtime::Current()->GetCalleeSaveMethod(Runtime::kSaveRefsAndArgs);
- CHECK_EQ(GetMethod(), callee) << "Expected: " << PrettyMethod(callee) << " Found: "
- << PrettyMethod(GetMethod());
+ CHECK_EQ(GetMethod(), callee) << "Expected: " << ArtMethod::PrettyMethod(callee)
+ << " Found: " << ArtMethod::PrettyMethod(GetMethod());
} else {
CHECK_EQ(instrumentation_frame.method_, GetMethod())
- << "Expected: " << PrettyMethod(instrumentation_frame.method_)
- << " Found: " << PrettyMethod(GetMethod());
+ << "Expected: " << ArtMethod::PrettyMethod(instrumentation_frame.method_)
+ << " Found: " << ArtMethod::PrettyMethod(GetMethod());
}
if (num_frames_ != 0) {
// Check agreement of frame Ids only if num_frames_ is computed to avoid infinite
@@ -876,7 +876,7 @@
cur_quick_frame_ = reinterpret_cast<ArtMethod**>(next_frame);
if (kDebugStackWalk) {
- LOG(INFO) << PrettyMethod(method) << "@" << method << " size=" << frame_size
+ LOG(INFO) << ArtMethod::PrettyMethod(method) << "@" << method << " size=" << frame_size
<< std::boolalpha
<< " optimized=" << (cur_oat_quick_method_header_ != nullptr &&
cur_oat_quick_method_header_->IsOptimized())
@@ -999,7 +999,7 @@
self->ClearException();
self->ThrowNewExceptionF("Ljava/lang/IllegalMonitorStateException;",
"did not lock monitor on object of type '%s' before unlocking",
- PrettyTypeOf(const_cast<mirror::Object*>(obj)).c_str());
+ const_cast<mirror::Object*>(obj)->PrettyTypeOf().c_str());
}
}
@@ -1033,7 +1033,7 @@
mirror::Object* first = (*monitors_)[0];
self->ThrowNewExceptionF("Ljava/lang/IllegalMonitorStateException;",
"did not unlock monitor on object of type '%s'",
- PrettyTypeOf(first).c_str());
+ mirror::Object::PrettyTypeOf(first).c_str());
// To make sure this path is not triggered again, clean out the monitors.
monitors_->clear();
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 6acce27..39fe8d0 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -332,7 +332,7 @@
if (shadow_frame != nullptr) {
return shadow_frame;
}
- VLOG(deopt) << "Create pre-deopted ShadowFrame for " << PrettyMethod(method);
+ VLOG(deopt) << "Create pre-deopted ShadowFrame for " << ArtMethod::PrettyMethod(method);
shadow_frame = ShadowFrame::CreateDeoptimizedFrame(num_vregs, nullptr, method, dex_pc);
FrameIdToShadowFrame* record = FrameIdToShadowFrame::Create(frame_id,
shadow_frame,
@@ -1380,7 +1380,7 @@
last_method = m;
}
if (repetition_count < kMaxRepetition) {
- os << " at " << PrettyMethod(m, false);
+ os << " at " << m->PrettyMethod(false);
if (m->IsNative()) {
os << "(Native method)";
} else {
@@ -1420,11 +1420,11 @@
// Getting the identity hashcode here would result in lock inflation and suspension of the
// current thread, which isn't safe if this is the only runnable thread.
os << StringPrintf("<@addr=0x%" PRIxPTR "> (a %s)", reinterpret_cast<intptr_t>(o),
- PrettyTypeOf(o).c_str());
+ o->PrettyTypeOf().c_str());
} else {
// IdentityHashCode can cause thread suspension, which would invalidate o if it moved. So
// we get the pretty type beofre we call IdentityHashCode.
- const std::string pretty_type(PrettyTypeOf(o));
+ const std::string pretty_type(o->PrettyTypeOf());
os << StringPrintf("<0x%08x> (a %s)", o->IdentityHashCode(), pretty_type.c_str());
}
}
@@ -1668,7 +1668,7 @@
OVERRIDE NO_THREAD_SAFETY_ANALYSIS {
if (self_->HoldsLock(entered_monitor)) {
LOG(WARNING) << "Calling MonitorExit on object "
- << entered_monitor << " (" << PrettyTypeOf(entered_monitor) << ")"
+ << entered_monitor << " (" << entered_monitor->PrettyTypeOf() << ")"
<< " left locked by native thread "
<< *Thread::Current() << " which is detaching";
entered_monitor->MonitorExit(self_);
@@ -2697,7 +2697,7 @@
bool VisitFrame() REQUIRES_SHARED(Locks::mutator_lock_) {
if (false) {
- LOG(INFO) << "Visiting stack roots in " << PrettyMethod(GetMethod())
+ LOG(INFO) << "Visiting stack roots in " << ArtMethod::PrettyMethod(GetMethod())
<< StringPrintf("@ PC:%04x", GetDexPc());
}
ShadowFrame* shadow_frame = GetCurrentShadowFrame();
@@ -2759,7 +2759,8 @@
LOG(FATAL_WITHOUT_ABORT) << "Method@" << method->GetDexMethodIndex() << ":" << method
<< " klass@" << klass;
// Pretty info last in case it crashes.
- LOG(FATAL) << "Method " << PrettyMethod(method) << " klass " << PrettyClass(klass);
+ LOG(FATAL) << "Method " << method->PrettyMethod() << " klass "
+ << klass->PrettyClass();
}
}
}
diff --git a/runtime/trace.cc b/runtime/trace.cc
index f846746..f564de4 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -641,7 +641,7 @@
uint32_t tmid = ReadBytes(ptr + 2, sizeof(tmid));
ArtMethod* method = DecodeTraceMethod(tmid);
TraceAction action = DecodeTraceAction(tmid);
- LOG(INFO) << PrettyMethod(method) << " " << static_cast<int>(action);
+ LOG(INFO) << ArtMethod::PrettyMethod(method) << " " << static_cast<int>(action);
ptr += GetRecordSize(clock_source);
}
}
@@ -739,7 +739,8 @@
ArtMethod* method,
uint32_t new_dex_pc) {
// We're not recorded to listen to this kind of event, so complain.
- LOG(ERROR) << "Unexpected dex PC event in tracing " << PrettyMethod(method) << " " << new_dex_pc;
+ LOG(ERROR) << "Unexpected dex PC event in tracing " << ArtMethod::PrettyMethod(method)
+ << " " << new_dex_pc;
}
void Trace::FieldRead(Thread* thread ATTRIBUTE_UNUSED,
@@ -749,7 +750,8 @@
ArtField* field ATTRIBUTE_UNUSED)
REQUIRES_SHARED(Locks::mutator_lock_) {
// We're not recorded to listen to this kind of event, so complain.
- LOG(ERROR) << "Unexpected field read event in tracing " << PrettyMethod(method) << " " << dex_pc;
+ LOG(ERROR) << "Unexpected field read event in tracing " << ArtMethod::PrettyMethod(method)
+ << " " << dex_pc;
}
void Trace::FieldWritten(Thread* thread ATTRIBUTE_UNUSED,
@@ -760,7 +762,8 @@
const JValue& field_value ATTRIBUTE_UNUSED)
REQUIRES_SHARED(Locks::mutator_lock_) {
// We're not recorded to listen to this kind of event, so complain.
- LOG(ERROR) << "Unexpected field write event in tracing " << PrettyMethod(method) << " " << dex_pc;
+ LOG(ERROR) << "Unexpected field write event in tracing " << ArtMethod::PrettyMethod(method)
+ << " " << dex_pc;
}
void Trace::MethodEntered(Thread* thread, mirror::Object* this_object ATTRIBUTE_UNUSED,
@@ -800,7 +803,7 @@
void Trace::Branch(Thread* /*thread*/, ArtMethod* method,
uint32_t /*dex_pc*/, int32_t /*dex_pc_offset*/)
REQUIRES_SHARED(Locks::mutator_lock_) {
- LOG(ERROR) << "Unexpected branch event in tracing" << PrettyMethod(method);
+ LOG(ERROR) << "Unexpected branch event in tracing" << ArtMethod::PrettyMethod(method);
}
void Trace::InvokeVirtualOrInterface(Thread*,
@@ -808,7 +811,7 @@
ArtMethod* method,
uint32_t dex_pc,
ArtMethod*) {
- LOG(ERROR) << "Unexpected invoke event in tracing" << PrettyMethod(method)
+ LOG(ERROR) << "Unexpected invoke event in tracing" << ArtMethod::PrettyMethod(method)
<< " " << dex_pc;
}
diff --git a/runtime/utils.cc b/runtime/utils.cc
index a40e313..5557d5f 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -25,19 +25,11 @@
#include <unistd.h>
#include <memory>
-#include "art_field-inl.h"
-#include "art_method-inl.h"
#include "base/stl_util.h"
#include "base/unix_file/fd_file.h"
#include "dex_file-inl.h"
#include "dex_instruction.h"
-#include "mirror/class-inl.h"
-#include "mirror/class_loader.h"
-#include "mirror/object-inl.h"
-#include "mirror/object_array-inl.h"
-#include "mirror/string.h"
#include "oat_quick_method_header.h"
-#include "obj_ptr-inl.h"
#include "os.h"
#include "scoped_thread_state_change-inl.h"
#include "utf-inl.h"
@@ -271,21 +263,6 @@
}
}
-std::string PrettyStringDescriptor(ObjPtr<mirror::String> java_descriptor) {
- if (java_descriptor == nullptr) {
- return "null";
- }
- return PrettyDescriptor(java_descriptor->ToModifiedUtf8().c_str());
-}
-
-std::string PrettyDescriptor(ObjPtr<mirror::Class> klass) {
- if (klass == nullptr) {
- return "null";
- }
- std::string temp;
- return PrettyDescriptor(klass->GetDescriptor(&temp));
-}
-
std::string PrettyDescriptor(const char* descriptor) {
// Count the number of '['s to get the dimensionality.
const char* c = descriptor;
@@ -335,46 +312,6 @@
return result;
}
-std::string PrettyField(ArtField* f, bool with_type) {
- if (f == nullptr) {
- return "null";
- }
- std::string result;
- if (with_type) {
- result += PrettyDescriptor(f->GetTypeDescriptor());
- result += ' ';
- }
- std::string temp;
- result += PrettyDescriptor(f->GetDeclaringClass()->GetDescriptor(&temp));
- result += '.';
- result += f->GetName();
- return result;
-}
-
-std::string PrettyField(uint32_t field_idx, const DexFile& dex_file, bool with_type) {
- if (field_idx >= dex_file.NumFieldIds()) {
- return StringPrintf("<<invalid-field-idx-%d>>", field_idx);
- }
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx);
- std::string result;
- if (with_type) {
- result += dex_file.GetFieldTypeDescriptor(field_id);
- result += ' ';
- }
- result += PrettyDescriptor(dex_file.GetFieldDeclaringClassDescriptor(field_id));
- result += '.';
- result += dex_file.GetFieldName(field_id);
- return result;
-}
-
-std::string PrettyType(uint32_t type_idx, const DexFile& dex_file) {
- if (type_idx >= dex_file.NumTypeIds()) {
- return StringPrintf("<<invalid-type-idx-%d>>", type_idx);
- }
- const DexFile::TypeId& type_id = dex_file.GetTypeId(type_idx);
- return PrettyDescriptor(dex_file.GetTypeDescriptor(type_id));
-}
-
std::string PrettyArguments(const char* signature) {
std::string result;
result += '(';
@@ -412,91 +349,6 @@
return PrettyDescriptor(return_type);
}
-std::string PrettyMethod(ArtMethod* m, bool with_signature) {
- if (m == nullptr) {
- return "null";
- }
- if (!m->IsRuntimeMethod()) {
- m = m->GetInterfaceMethodIfProxy(Runtime::Current()->GetClassLinker()->GetImagePointerSize());
- }
- std::string result(PrettyDescriptor(m->GetDeclaringClassDescriptor()));
- result += '.';
- result += m->GetName();
- if (UNLIKELY(m->IsFastNative())) {
- result += "!";
- }
- if (with_signature) {
- const Signature signature = m->GetSignature();
- std::string sig_as_string(signature.ToString());
- if (signature == Signature::NoSignature()) {
- return result + sig_as_string;
- }
- result = PrettyReturnType(sig_as_string.c_str()) + " " + result +
- PrettyArguments(sig_as_string.c_str());
- }
- return result;
-}
-
-std::string PrettyMethod(uint32_t method_idx, const DexFile& dex_file, bool with_signature) {
- if (method_idx >= dex_file.NumMethodIds()) {
- return StringPrintf("<<invalid-method-idx-%d>>", method_idx);
- }
- const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx);
- std::string result(PrettyDescriptor(dex_file.GetMethodDeclaringClassDescriptor(method_id)));
- result += '.';
- result += dex_file.GetMethodName(method_id);
- if (with_signature) {
- const Signature signature = dex_file.GetMethodSignature(method_id);
- std::string sig_as_string(signature.ToString());
- if (signature == Signature::NoSignature()) {
- return result + sig_as_string;
- }
- result = PrettyReturnType(sig_as_string.c_str()) + " " + result +
- PrettyArguments(sig_as_string.c_str());
- }
- return result;
-}
-
-std::string PrettyTypeOf(ObjPtr<mirror::Object> obj) {
- if (obj == nullptr) {
- return "null";
- }
- if (obj->GetClass() == nullptr) {
- return "(raw)";
- }
- std::string temp;
- std::string result(PrettyDescriptor(obj->GetClass()->GetDescriptor(&temp)));
- if (obj->IsClass()) {
- result += "<" + PrettyDescriptor(obj->AsClass()->GetDescriptor(&temp)) + ">";
- }
- return result;
-}
-
-std::string PrettyClass(ObjPtr<mirror::Class> c) {
- if (c == nullptr) {
- return "null";
- }
- std::string result;
- result += "java.lang.Class<";
- result += PrettyDescriptor(c);
- result += ">";
- return result;
-}
-
-std::string PrettyClassAndClassLoader(ObjPtr<mirror::Class> c) {
- if (c == nullptr) {
- return "null";
- }
- std::string result;
- result += "java.lang.Class<";
- result += PrettyDescriptor(c);
- result += ",";
- result += PrettyTypeOf(c->GetClassLoader());
- // TODO: add an identifying hash value for the loader
- result += ">";
- return result;
-}
-
std::string PrettyJavaAccessFlags(uint32_t access_flags) {
std::string result;
if ((access_flags & kAccPublic) != 0) {
@@ -672,38 +524,6 @@
return descriptor;
}
-std::string JniShortName(ArtMethod* m) {
- std::string class_name(m->GetDeclaringClassDescriptor());
- // Remove the leading 'L' and trailing ';'...
- CHECK_EQ(class_name[0], 'L') << class_name;
- CHECK_EQ(class_name[class_name.size() - 1], ';') << class_name;
- class_name.erase(0, 1);
- class_name.erase(class_name.size() - 1, 1);
-
- std::string method_name(m->GetName());
-
- std::string short_name;
- short_name += "Java_";
- short_name += MangleForJni(class_name);
- short_name += "_";
- short_name += MangleForJni(method_name);
- return short_name;
-}
-
-std::string JniLongName(ArtMethod* m) {
- std::string long_name;
- long_name += JniShortName(m);
- long_name += "__";
-
- std::string signature(m->GetSignature().ToString());
- signature.erase(0, 1);
- signature.erase(signature.begin() + signature.find(')'), signature.end());
-
- long_name += MangleForJni(signature);
-
- return long_name;
-}
-
// Helper for IsValidPartOfMemberNameUtf8(), a bit vector indicating valid low ascii.
uint32_t DEX_MEMBER_VALID_LOW_ASCII[4] = {
0x00000000, // 00..1f low control characters; nothing valid
@@ -1309,7 +1129,7 @@
const DexFile::CodeItem* code_item,
std::ostream& os) {
os << "digraph {\n";
- os << " # /* " << PrettyMethod(dex_method_idx, *dex_file, true) << " */\n";
+ os << " # /* " << dex_file->PrettyMethod(dex_method_idx, true) << " */\n";
std::set<uint32_t> dex_pc_is_branch_target;
{
@@ -1627,13 +1447,6 @@
os << "}\n";
}
-void DumpMethodCFG(ArtMethod* method, std::ostream& os) {
- const DexFile* dex_file = method->GetDexFile();
- const DexFile::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
-
- DumpMethodCFGImpl(dex_file, method->GetDexMethodIndex(), code_item, os);
-}
-
void DumpMethodCFG(const DexFile* dex_file, uint32_t dex_method_idx, std::ostream& os) {
// This is painful, we need to find the code item. That means finding the class, and then
// iterating the table.
diff --git a/runtime/utils.h b/runtime/utils.h
index ea9e8f7..f96ddd7 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -40,16 +40,8 @@
namespace art {
-class ArtField;
-class ArtMethod;
class DexFile;
-namespace mirror {
-class Class;
-class Object;
-class String;
-} // namespace mirror
-
template <typename T>
bool ParseUint(const char *in, T* out) {
char* end;
@@ -136,44 +128,12 @@
// Returns a human-readable equivalent of 'descriptor'. So "I" would be "int",
// "[[I" would be "int[][]", "[Ljava/lang/String;" would be
// "java.lang.String[]", and so forth.
-std::string PrettyStringDescriptor(ObjPtr<mirror::String> descriptor)
- REQUIRES_SHARED(Locks::mutator_lock_);
std::string PrettyDescriptor(const char* descriptor);
-std::string PrettyDescriptor(ObjPtr<mirror::Class> klass)
- REQUIRES_SHARED(Locks::mutator_lock_);
std::string PrettyDescriptor(Primitive::Type type);
-// Returns a human-readable signature for 'f'. Something like "a.b.C.f" or
-// "int a.b.C.f" (depending on the value of 'with_type').
-std::string PrettyField(ArtField* f, bool with_type = true)
- REQUIRES_SHARED(Locks::mutator_lock_);
-std::string PrettyField(uint32_t field_idx, const DexFile& dex_file, bool with_type = true);
-
-// Returns a human-readable signature for 'm'. Something like "a.b.C.m" or
-// "a.b.C.m(II)V" (depending on the value of 'with_signature').
-std::string PrettyMethod(ArtMethod* m, bool with_signature = true)
- REQUIRES_SHARED(Locks::mutator_lock_);
-std::string PrettyMethod(uint32_t method_idx, const DexFile& dex_file, bool with_signature = true);
-
-// Returns a human-readable form of the name of the *class* of the given object.
-// So given an instance of java.lang.String, the output would
-// be "java.lang.String". Given an array of int, the output would be "int[]".
-// Given String.class, the output would be "java.lang.Class<java.lang.String>".
-std::string PrettyTypeOf(ObjPtr<mirror::Object> obj)
- REQUIRES_SHARED(Locks::mutator_lock_);
-
-// Returns a human-readable form of the type at an index in the specified dex file.
-// Example outputs: char[], java.lang.String.
-std::string PrettyType(uint32_t type_idx, const DexFile& dex_file);
-
-// Returns a human-readable form of the name of the given class.
-// Given String.class, the output would be "java.lang.Class<java.lang.String>".
-std::string PrettyClass(ObjPtr<mirror::Class> c)
- REQUIRES_SHARED(Locks::mutator_lock_);
-
-// Returns a human-readable form of the name of the given class with its class loader.
-std::string PrettyClassAndClassLoader(ObjPtr<mirror::Class> c)
- REQUIRES_SHARED(Locks::mutator_lock_);
+// Utilities for printing the types for method signatures.
+std::string PrettyArguments(const char* signature);
+std::string PrettyReturnType(const char* signature);
// Returns a human-readable version of the Java part of the access flags, e.g., "private static "
// (note the trailing whitespace).
@@ -206,13 +166,6 @@
// additionally allowing names that begin with '<' and end with '>'.
bool IsValidMemberName(const char* s);
-// Returns the JNI native function name for the non-overloaded method 'm'.
-std::string JniShortName(ArtMethod* m)
- REQUIRES_SHARED(Locks::mutator_lock_);
-// Returns the JNI native function name for the overloaded method 'm'.
-std::string JniLongName(ArtMethod* m)
- REQUIRES_SHARED(Locks::mutator_lock_);
-
bool ReadFileToString(const std::string& file_name, std::string* result);
bool PrintFileToLog(const std::string& file_name, LogSeverity level);
@@ -321,7 +274,6 @@
return pointer_size == 4 || pointer_size == 8;
}
-void DumpMethodCFG(ArtMethod* method, std::ostream& os) REQUIRES_SHARED(Locks::mutator_lock_);
void DumpMethodCFG(const DexFile* dex_file, uint32_t dex_method_idx, std::ostream& os);
static inline const void* EntryPointToCodePointer(const void* entry_point) {
diff --git a/runtime/utils_test.cc b/runtime/utils_test.cc
index ef42222..be4d394 100644
--- a/runtime/utils_test.cc
+++ b/runtime/utils_test.cc
@@ -109,51 +109,52 @@
TEST_F(UtilsTest, PrettyTypeOf) {
ScopedObjectAccess soa(Thread::Current());
- EXPECT_EQ("null", PrettyTypeOf(nullptr));
+ EXPECT_EQ("null", mirror::Object::PrettyTypeOf(nullptr));
StackHandleScope<2> hs(soa.Self());
Handle<mirror::String> s(hs.NewHandle(mirror::String::AllocFromModifiedUtf8(soa.Self(), "")));
- EXPECT_EQ("java.lang.String", PrettyTypeOf(s.Get()));
+ EXPECT_EQ("java.lang.String", mirror::Object::PrettyTypeOf(s.Get()));
Handle<mirror::ShortArray> a(hs.NewHandle(mirror::ShortArray::Alloc(soa.Self(), 2)));
- EXPECT_EQ("short[]", PrettyTypeOf(a.Get()));
+ EXPECT_EQ("short[]", mirror::Object::PrettyTypeOf(a.Get()));
mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/String;");
ASSERT_TRUE(c != nullptr);
mirror::Object* o = mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), c, 0);
- EXPECT_EQ("java.lang.String[]", PrettyTypeOf(o));
- EXPECT_EQ("java.lang.Class<java.lang.String[]>", PrettyTypeOf(o->GetClass()));
+ EXPECT_EQ("java.lang.String[]", mirror::Object::PrettyTypeOf(o));
+ EXPECT_EQ("java.lang.Class<java.lang.String[]>", mirror::Object::PrettyTypeOf(o->GetClass()));
}
TEST_F(UtilsTest, PrettyClass) {
ScopedObjectAccess soa(Thread::Current());
- EXPECT_EQ("null", PrettyClass(nullptr));
+ EXPECT_EQ("null", mirror::Class::PrettyClass(nullptr));
mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/String;");
ASSERT_TRUE(c != nullptr);
mirror::Object* o = mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), c, 0);
- EXPECT_EQ("java.lang.Class<java.lang.String[]>", PrettyClass(o->GetClass()));
+ EXPECT_EQ("java.lang.Class<java.lang.String[]>", mirror::Class::PrettyClass(o->GetClass()));
}
TEST_F(UtilsTest, PrettyClassAndClassLoader) {
ScopedObjectAccess soa(Thread::Current());
- EXPECT_EQ("null", PrettyClassAndClassLoader(nullptr));
+ EXPECT_EQ("null", mirror::Class::PrettyClassAndClassLoader(nullptr));
mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/String;");
ASSERT_TRUE(c != nullptr);
mirror::Object* o = mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), c, 0);
- EXPECT_EQ("java.lang.Class<java.lang.String[],null>", PrettyClassAndClassLoader(o->GetClass()));
+ EXPECT_EQ("java.lang.Class<java.lang.String[],null>",
+ mirror::Class::PrettyClassAndClassLoader(o->GetClass()));
}
TEST_F(UtilsTest, PrettyField) {
ScopedObjectAccess soa(Thread::Current());
- EXPECT_EQ("null", PrettyField(nullptr));
+ EXPECT_EQ("null", ArtField::PrettyField(nullptr));
mirror::Class* java_lang_String = class_linker_->FindSystemClass(soa.Self(),
"Ljava/lang/String;");
ArtField* f;
f = java_lang_String->FindDeclaredInstanceField("count", "I");
- EXPECT_EQ("int java.lang.String.count", PrettyField(f));
- EXPECT_EQ("java.lang.String.count", PrettyField(f, false));
+ EXPECT_EQ("int java.lang.String.count", f->PrettyField());
+ EXPECT_EQ("java.lang.String.count", f->PrettyField(false));
}
TEST_F(UtilsTest, PrettySize) {
@@ -192,18 +193,18 @@
m = c->FindVirtualMethod("charAt", "(I)C", kRuntimePointerSize);
ASSERT_TRUE(m != nullptr);
- EXPECT_EQ("Java_java_lang_String_charAt", JniShortName(m));
- EXPECT_EQ("Java_java_lang_String_charAt__I", JniLongName(m));
+ EXPECT_EQ("Java_java_lang_String_charAt", m->JniShortName());
+ EXPECT_EQ("Java_java_lang_String_charAt__I", m->JniLongName());
m = c->FindVirtualMethod("indexOf", "(Ljava/lang/String;I)I", kRuntimePointerSize);
ASSERT_TRUE(m != nullptr);
- EXPECT_EQ("Java_java_lang_String_indexOf", JniShortName(m));
- EXPECT_EQ("Java_java_lang_String_indexOf__Ljava_lang_String_2I", JniLongName(m));
+ EXPECT_EQ("Java_java_lang_String_indexOf", m->JniShortName());
+ EXPECT_EQ("Java_java_lang_String_indexOf__Ljava_lang_String_2I", m->JniLongName());
m = c->FindDirectMethod("copyValueOf", "([CII)Ljava/lang/String;", kRuntimePointerSize);
ASSERT_TRUE(m != nullptr);
- EXPECT_EQ("Java_java_lang_String_copyValueOf", JniShortName(m));
- EXPECT_EQ("Java_java_lang_String_copyValueOf___3CII", JniLongName(m));
+ EXPECT_EQ("Java_java_lang_String_copyValueOf", m->JniShortName());
+ EXPECT_EQ("Java_java_lang_String_copyValueOf___3CII", m->JniLongName());
}
TEST_F(UtilsTest, Split) {
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 181673c..97bc79c 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -141,13 +141,13 @@
failure_message = " that has no super class";
} else if (super != nullptr && super->IsFinal()) {
early_failure = true;
- failure_message = " that attempts to sub-class final class " + PrettyDescriptor(super);
+ failure_message = " that attempts to sub-class final class " + super->PrettyDescriptor();
} else if (class_def == nullptr) {
early_failure = true;
failure_message = " that isn't present in dex file " + dex_file.GetLocation();
}
if (early_failure) {
- *error = "Verifier rejected class " + PrettyDescriptor(klass) + failure_message;
+ *error = "Verifier rejected class " + klass->PrettyDescriptor() + failure_message;
if (callbacks != nullptr) {
ClassReference ref(&dex_file, klass->GetDexClassDefIndex());
callbacks->ClassRejected(ref);
@@ -395,7 +395,7 @@
if (verifier.failures_.size() != 0) {
if (VLOG_IS_ON(verifier)) {
verifier.DumpFailures(VLOG_STREAM(verifier) << "Soft verification failures in "
- << PrettyMethod(method_idx, *dex_file) << "\n");
+ << dex_file->PrettyMethod(method_idx) << "\n");
}
result.kind = kSoftFailure;
if (method != nullptr &&
@@ -441,7 +441,7 @@
UNREACHABLE();
}
verifier.DumpFailures(LOG_STREAM(severity) << "Verification error in "
- << PrettyMethod(method_idx, *dex_file)
+ << dex_file->PrettyMethod(method_idx)
<< "\n");
}
if (hard_failure_msg != nullptr) {
@@ -465,7 +465,7 @@
if (kTimeVerifyMethod) {
uint64_t duration_ns = NanoTime() - start_ns;
if (duration_ns > MsToNs(100)) {
- LOG(WARNING) << "Verification of " << PrettyMethod(method_idx, *dex_file)
+ LOG(WARNING) << "Verification of " << dex_file->PrettyMethod(method_idx)
<< " took " << PrettyDuration(duration_ns)
<< (IsLargeMethod(code_item) ? " (large method)" : "");
}
@@ -722,7 +722,7 @@
}
is_constructor_ = true;
} else if (constructor_by_name) {
- LOG(WARNING) << "Method " << PrettyMethod(dex_method_idx_, *dex_file_)
+ LOG(WARNING) << "Method " << dex_file_->PrettyMethod(dex_method_idx_)
<< " not marked as constructor.";
is_constructor_ = true;
}
@@ -935,7 +935,7 @@
}
}
failures_.push_back(error);
- std::string location(StringPrintf("%s: [0x%X] ", PrettyMethod(dex_method_idx_, *dex_file_).c_str(),
+ std::string location(StringPrintf("%s: [0x%X] ", dex_file_->PrettyMethod(dex_method_idx_).c_str(),
work_insn_idx_));
std::ostringstream* failure_message = new std::ostringstream(location, std::ostringstream::ate);
failure_messages_.push_back(failure_message);
@@ -943,7 +943,7 @@
}
std::ostream& MethodVerifier::LogVerifyInfo() {
- return info_messages_ << "VFY: " << PrettyMethod(dex_method_idx_, *dex_file_)
+ return info_messages_ << "VFY: " << dex_file_->PrettyMethod(dex_method_idx_)
<< '[' << reinterpret_cast<void*>(work_insn_idx_) << "] : ";
}
@@ -1589,7 +1589,7 @@
if (!SetTypesFromSignature()) {
DCHECK_NE(failures_.size(), 0U);
std::string prepend("Bad signature in ");
- prepend += PrettyMethod(dex_method_idx_, *dex_file_);
+ prepend += dex_file_->PrettyMethod(dex_method_idx_);
PrependToLastFailMessage(prepend);
return false;
}
@@ -1866,7 +1866,7 @@
if (work_line_->CompareLine(register_line) != 0) {
Dump(std::cout);
std::cout << info_messages_.str();
- LOG(FATAL) << "work_line diverged in " << PrettyMethod(dex_method_idx_, *dex_file_)
+ LOG(FATAL) << "work_line diverged in " << dex_file_->PrettyMethod(dex_method_idx_)
<< "@" << reinterpret_cast<void*>(work_insn_idx_) << "\n"
<< " work_line=" << work_line_->Dump(this) << "\n"
<< " expected=" << register_line->Dump(this);
@@ -1874,7 +1874,7 @@
}
}
if (!CodeFlowVerifyInstruction(&start_guess)) {
- std::string prepend(PrettyMethod(dex_method_idx_, *dex_file_));
+ std::string prepend(dex_file_->PrettyMethod(dex_method_idx_));
prepend += " failed to verify: ";
PrependToLastFailMessage(prepend);
return false;
@@ -1925,7 +1925,7 @@
<< "-" << reinterpret_cast<void*>(insn_idx - 1);
}
// To dump the state of the verify after a method, do something like:
- // if (PrettyMethod(dex_method_idx_, *dex_file_) ==
+ // if (dex_file_->PrettyMethod(dex_method_idx_) ==
// "boolean java.lang.String.equals(java.lang.Object)") {
// LOG(INFO) << info_messages_.str();
// }
@@ -2994,7 +2994,7 @@
mirror::Class* called_interface = abs_method->GetDeclaringClass();
if (!called_interface->IsInterface() && !called_interface->IsObjectClass()) {
Fail(VERIFY_ERROR_CLASS_CHANGE) << "expected interface class in invoke-interface '"
- << PrettyMethod(abs_method) << "'";
+ << abs_method->PrettyMethod() << "'";
break;
}
}
@@ -3278,7 +3278,7 @@
for (uint32_t i = 0, num_fields = klass->NumInstanceFields(); i < num_fields; ++i) {
if (klass->GetInstanceField(i)->IsFinal()) {
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "return-void-no-barrier not expected for "
- << PrettyField(klass->GetInstanceField(i));
+ << klass->GetInstanceField(i)->PrettyField();
break;
}
}
@@ -3787,7 +3787,7 @@
if (res_method == nullptr) {
Fail(VERIFY_ERROR_NO_METHOD) << "couldn't find method "
- << PrettyDescriptor(klass) << "."
+ << klass->PrettyDescriptor() << "."
<< dex_file_->GetMethodName(method_id) << " "
<< dex_file_->GetMethodSignature(method_id);
return nullptr;
@@ -3797,13 +3797,13 @@
// enforce them here.
if (res_method->IsConstructor() && method_type != METHOD_DIRECT) {
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "rejecting non-direct call to constructor "
- << PrettyMethod(res_method);
+ << res_method->PrettyMethod();
return nullptr;
}
// Disallow any calls to class initializers.
if (res_method->IsClassInitializer()) {
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "rejecting call to class initializer "
- << PrettyMethod(res_method);
+ << res_method->PrettyMethod();
return nullptr;
}
@@ -3821,15 +3821,15 @@
method_type != METHOD_DIRECT) &&
method_type != METHOD_SUPER) {
Fail(VERIFY_ERROR_CLASS_CHANGE)
- << "non-interface method " << PrettyMethod(dex_method_idx, *dex_file_)
- << " is in an interface class " << PrettyClass(klass);
+ << "non-interface method " << dex_file_->PrettyMethod(dex_method_idx)
+ << " is in an interface class " << klass->PrettyClass();
return nullptr;
}
} else {
if (method_type == METHOD_INTERFACE) {
Fail(VERIFY_ERROR_CLASS_CHANGE)
- << "interface method " << PrettyMethod(dex_method_idx, *dex_file_)
- << " is in a non-interface class " << PrettyClass(klass);
+ << "interface method " << dex_file_->PrettyMethod(dex_method_idx)
+ << " is in a non-interface class " << klass->PrettyClass();
return nullptr;
}
}
@@ -3841,14 +3841,15 @@
// Check if access is allowed.
if (!referrer.CanAccessMember(res_method->GetDeclaringClass(), res_method->GetAccessFlags())) {
- Fail(VERIFY_ERROR_ACCESS_METHOD) << "illegal method access (call " << PrettyMethod(res_method)
+ Fail(VERIFY_ERROR_ACCESS_METHOD) << "illegal method access (call "
+ << res_method->PrettyMethod()
<< " from " << referrer << ")";
return res_method;
}
// Check that invoke-virtual and invoke-super are not used on private methods of the same class.
if (res_method->IsPrivate() && (method_type == METHOD_VIRTUAL || method_type == METHOD_SUPER)) {
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "invoke-super/virtual can't be used on private method "
- << PrettyMethod(res_method);
+ << res_method->PrettyMethod();
return nullptr;
}
// See if the method type implied by the invoke instruction matches the access flags for the
@@ -3860,7 +3861,7 @@
method_type == METHOD_INTERFACE) && res_method->IsDirect())
) {
Fail(VERIFY_ERROR_CLASS_CHANGE) << "invoke type (" << method_type << ") does not match method "
- " type of " << PrettyMethod(res_method);
+ " type of " << res_method->PrettyMethod();
return nullptr;
}
return res_method;
@@ -4090,24 +4091,25 @@
return nullptr;
} else if (!reference_type.IsStrictlyAssignableFrom(GetDeclaringClass(), this)) {
Fail(VERIFY_ERROR_CLASS_CHANGE)
- << "invoke-super in " << PrettyClass(GetDeclaringClass().GetClass()) << " in method "
- << PrettyMethod(dex_method_idx_, *dex_file_) << " to method "
- << PrettyMethod(method_idx, *dex_file_) << " references "
- << "non-super-interface type " << PrettyClass(reference_type.GetClass());
+ << "invoke-super in " << mirror::Class::PrettyClass(GetDeclaringClass().GetClass())
+ << " in method "
+ << dex_file_->PrettyMethod(dex_method_idx_) << " to method "
+ << dex_file_->PrettyMethod(method_idx) << " references "
+ << "non-super-interface type " << mirror::Class::PrettyClass(reference_type.GetClass());
return nullptr;
}
} else {
const RegType& super = GetDeclaringClass().GetSuperClass(®_types_);
if (super.IsUnresolvedTypes()) {
Fail(VERIFY_ERROR_NO_METHOD) << "unknown super class in invoke-super from "
- << PrettyMethod(dex_method_idx_, *dex_file_)
- << " to super " << PrettyMethod(res_method);
+ << dex_file_->PrettyMethod(dex_method_idx_)
+ << " to super " << res_method->PrettyMethod();
return nullptr;
}
if (!reference_type.IsStrictlyAssignableFrom(GetDeclaringClass(), this) ||
(res_method->GetMethodIndex() >= super.GetClass()->GetVTableLength())) {
Fail(VERIFY_ERROR_NO_METHOD) << "invalid invoke-super from "
- << PrettyMethod(dex_method_idx_, *dex_file_)
+ << dex_file_->PrettyMethod(dex_method_idx_)
<< " to super " << super
<< "." << res_method->GetName()
<< res_method->GetSignature();
@@ -4172,7 +4174,7 @@
ArtMethod* MethodVerifier::VerifyInvokeVirtualQuickArgs(const Instruction* inst, bool is_range) {
DCHECK(Runtime::Current()->IsStarted() || verify_to_dump_)
- << PrettyMethod(dex_method_idx_, *dex_file_, true) << "@" << work_insn_idx_;
+ << dex_file_->PrettyMethod(dex_method_idx_, true) << "@" << work_insn_idx_;
ArtMethod* res_method = GetQuickInvokedMethod(inst, work_line_.get(), is_range, false);
if (res_method == nullptr) {
@@ -4242,7 +4244,8 @@
size_t actual_args = 1;
for (size_t param_index = 0; param_index < params_size; param_index++) {
if (actual_args >= expected_args) {
- Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Rejecting invalid call to '" << PrettyMethod(res_method)
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Rejecting invalid call to '"
+ << res_method->PrettyMethod()
<< "'. Expected " << expected_args
<< " arguments, processing argument " << actual_args
<< " (where longs/doubles count twice).";
@@ -4251,7 +4254,8 @@
const char* descriptor =
res_method->GetTypeDescriptorFromTypeIdx(params->GetTypeItem(param_index).type_idx_);
if (descriptor == nullptr) {
- Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Rejecting invocation of " << PrettyMethod(res_method)
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Rejecting invocation of "
+ << res_method->PrettyMethod()
<< " missing signature component";
return nullptr;
}
@@ -4263,8 +4267,9 @@
actual_args = reg_type.IsLongOrDoubleTypes() ? actual_args + 2 : actual_args + 1;
}
if (actual_args != expected_args) {
- Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Rejecting invocation of " << PrettyMethod(res_method)
- << " expected " << expected_args << " arguments, found " << actual_args;
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Rejecting invocation of "
+ << res_method->PrettyMethod() << " expected "
+ << expected_args << " arguments, found " << actual_args;
return nullptr;
} else {
return res_method;
@@ -4522,11 +4527,11 @@
return nullptr;
} else if (!GetDeclaringClass().CanAccessMember(field->GetDeclaringClass(),
field->GetAccessFlags())) {
- Fail(VERIFY_ERROR_ACCESS_FIELD) << "cannot access static field " << PrettyField(field)
+ Fail(VERIFY_ERROR_ACCESS_FIELD) << "cannot access static field " << field->PrettyField()
<< " from " << GetDeclaringClass();
return nullptr;
} else if (!field->IsStatic()) {
- Fail(VERIFY_ERROR_CLASS_CHANGE) << "expected field " << PrettyField(field) << " to be static";
+ Fail(VERIFY_ERROR_CLASS_CHANGE) << "expected field " << field->PrettyField() << " to be static";
return nullptr;
}
return field;
@@ -4581,9 +4586,9 @@
if (!obj_type.IsUninitializedThisReference() ||
!IsConstructor() ||
!field_klass.Equals(GetDeclaringClass())) {
- Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "cannot access instance field " << PrettyField(field)
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "cannot access instance field " << field->PrettyField()
<< " of a not fully initialized object within the context"
- << " of " << PrettyMethod(dex_method_idx_, *dex_file_);
+ << " of " << dex_file_->PrettyMethod(dex_method_idx_);
return nullptr;
}
} else if (!field_klass.IsAssignableFrom(obj_type, this)) {
@@ -4600,7 +4605,7 @@
// and still missing classes. This is a hard failure.
type = VerifyError::VERIFY_ERROR_BAD_CLASS_HARD;
}
- Fail(type) << "cannot access instance field " << PrettyField(field)
+ Fail(type) << "cannot access instance field " << field->PrettyField()
<< " from object of type " << obj_type;
return nullptr;
}
@@ -4609,11 +4614,11 @@
// Few last soft failure checks.
if (!GetDeclaringClass().CanAccessMember(field->GetDeclaringClass(),
field->GetAccessFlags())) {
- Fail(VERIFY_ERROR_ACCESS_FIELD) << "cannot access instance field " << PrettyField(field)
+ Fail(VERIFY_ERROR_ACCESS_FIELD) << "cannot access instance field " << field->PrettyField()
<< " from " << GetDeclaringClass();
return nullptr;
} else if (field->IsStatic()) {
- Fail(VERIFY_ERROR_CLASS_CHANGE) << "expected field " << PrettyField(field)
+ Fail(VERIFY_ERROR_CLASS_CHANGE) << "expected field " << field->PrettyField()
<< " to not be static";
return nullptr;
}
@@ -4649,12 +4654,12 @@
if (field == nullptr) {
Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "Might be accessing a superclass instance field prior "
<< "to the superclass being initialized in "
- << PrettyMethod(dex_method_idx_, *dex_file_);
+ << dex_file_->PrettyMethod(dex_method_idx_);
} else if (field->GetDeclaringClass() != GetDeclaringClass().GetClass()) {
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "cannot access superclass instance field "
- << PrettyField(field) << " of a not fully initialized "
+ << field->PrettyField() << " of a not fully initialized "
<< "object within the context of "
- << PrettyMethod(dex_method_idx_, *dex_file_);
+ << dex_file_->PrettyMethod(dex_method_idx_);
return;
}
}
@@ -4663,7 +4668,7 @@
if (field != nullptr) {
if (kAccType == FieldAccessType::kAccPut) {
if (field->IsFinal() && field->GetDeclaringClass() != GetDeclaringClass().GetClass()) {
- Fail(VERIFY_ERROR_ACCESS_FIELD) << "cannot modify final field " << PrettyField(field)
+ Fail(VERIFY_ERROR_ACCESS_FIELD) << "cannot modify final field " << field->PrettyField()
<< " from other class " << GetDeclaringClass();
// Keep hunting for possible hard fails.
}
@@ -4700,7 +4705,7 @@
// should have been consistent within the same file at compile time.
VerifyError error = field_type->IsReferenceTypes() ? VERIFY_ERROR_BAD_CLASS_SOFT
: VERIFY_ERROR_BAD_CLASS_HARD;
- Fail(error) << "expected field " << PrettyField(field)
+ Fail(error) << "expected field " << ArtField::PrettyField(field)
<< " to be compatible with type '" << insn_type
<< "' but found type '" << *field_type
<< "' in put-object";
@@ -4720,7 +4725,7 @@
// This is a global failure rather than a class change failure as the instructions and
// the descriptors for the type should have been consistent within the same file at
// compile time
- Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "expected field " << PrettyField(field)
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "expected field " << ArtField::PrettyField(field)
<< " to be of type '" << insn_type
<< "' but found type '" << *field_type << "' in get";
return;
@@ -4732,7 +4737,7 @@
// should have been consistent within the same file at compile time.
VerifyError error = field_type->IsReferenceTypes() ? VERIFY_ERROR_BAD_CLASS_SOFT
: VERIFY_ERROR_BAD_CLASS_HARD;
- Fail(error) << "expected field " << PrettyField(field)
+ Fail(error) << "expected field " << ArtField::PrettyField(field)
<< " to be compatible with type '" << insn_type
<< "' but found type '" << *field_type
<< "' in get-object";
@@ -4765,7 +4770,7 @@
DCHECK_EQ(f->GetOffset().Uint32Value(), field_offset);
if (f == nullptr) {
VLOG(verifier) << "Failed to find instance field at offset '" << field_offset
- << "' from '" << PrettyDescriptor(object_type.GetClass()) << "'";
+ << "' from '" << mirror::Class::PrettyDescriptor(object_type.GetClass()) << "'";
}
return f;
}
@@ -4784,7 +4789,7 @@
// For an IPUT_QUICK, we now test for final flag of the field.
if (kAccType == FieldAccessType::kAccPut) {
if (field->IsFinal() && field->GetDeclaringClass() != GetDeclaringClass().GetClass()) {
- Fail(VERIFY_ERROR_ACCESS_FIELD) << "cannot modify final field " << PrettyField(field)
+ Fail(VERIFY_ERROR_ACCESS_FIELD) << "cannot modify final field " << field->PrettyField()
<< " from other class " << GetDeclaringClass();
return;
}
@@ -4843,7 +4848,7 @@
// This is a global failure rather than a class change failure as the instructions and
// the descriptors for the type should have been consistent within the same file at
// compile time
- Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "expected field " << PrettyField(field)
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "expected field " << ArtField::PrettyField(field)
<< " to be of type '" << insn_type
<< "' but found type '" << *field_type
<< "' in put";
@@ -4853,12 +4858,12 @@
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "unexpected value in v" << vregA
<< " of type " << value_type
<< " but expected " << *field_type
- << " for store to " << PrettyField(field) << " in put";
+ << " for store to " << ArtField::PrettyField(field) << " in put";
return;
}
} else {
if (!insn_type.IsAssignableFrom(*field_type, this)) {
- Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "expected field " << PrettyField(field)
+ Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "expected field " << ArtField::PrettyField(field)
<< " to be compatible with type '" << insn_type
<< "' but found type '" << *field_type
<< "' in put-object";
@@ -4877,14 +4882,14 @@
// This is a global failure rather than a class change failure as the instructions and
// the descriptors for the type should have been consistent within the same file at
// compile time
- Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "expected field " << PrettyField(field)
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "expected field " << ArtField::PrettyField(field)
<< " to be of type '" << insn_type
<< "' but found type '" << *field_type << "' in Get";
return;
}
} else {
if (!insn_type.IsAssignableFrom(*field_type, this)) {
- Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "expected field " << PrettyField(field)
+ Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "expected field " << ArtField::PrettyField(field)
<< " to be compatible with type '" << insn_type
<< "' but found type '" << *field_type
<< "' in get-object";
diff --git a/runtime/verifier/reg_type.cc b/runtime/verifier/reg_type.cc
index 626d9cf..ab23773 100644
--- a/runtime/verifier/reg_type.cc
+++ b/runtime/verifier/reg_type.cc
@@ -355,26 +355,26 @@
std::string ReferenceType::Dump() const {
std::stringstream result;
- result << "Reference" << ": " << PrettyDescriptor(GetClass());
+ result << "Reference" << ": " << mirror::Class::PrettyDescriptor(GetClass());
return result.str();
}
std::string PreciseReferenceType::Dump() const {
std::stringstream result;
- result << "Precise Reference" << ": "<< PrettyDescriptor(GetClass());
+ result << "Precise Reference" << ": "<< mirror::Class::PrettyDescriptor(GetClass());
return result.str();
}
std::string UninitializedReferenceType::Dump() const {
std::stringstream result;
- result << "Uninitialized Reference" << ": " << PrettyDescriptor(GetClass());
+ result << "Uninitialized Reference" << ": " << mirror::Class::PrettyDescriptor(GetClass());
result << " Allocation PC: " << GetAllocationPc();
return result.str();
}
std::string UninitializedThisReferenceType::Dump() const {
std::stringstream result;
- result << "Uninitialized This Reference" << ": " << PrettyDescriptor(GetClass());
+ result << "Uninitialized This Reference" << ": " << mirror::Class::PrettyDescriptor(GetClass());
result << "Allocation PC: " << GetAllocationPc();
return result.str();
}
@@ -730,8 +730,8 @@
// See comment in reg_type.h
mirror::Class* RegType::ClassJoin(mirror::Class* s, mirror::Class* t) {
- DCHECK(!s->IsPrimitive()) << PrettyClass(s);
- DCHECK(!t->IsPrimitive()) << PrettyClass(t);
+ DCHECK(!s->IsPrimitive()) << s->PrettyClass();
+ DCHECK(!t->IsPrimitive()) << t->PrettyClass();
if (s == t) {
return s;
} else if (s->IsAssignableFrom(t)) {
diff --git a/runtime/verifier/register_line-inl.h b/runtime/verifier/register_line-inl.h
index 3823143..3da1680 100644
--- a/runtime/verifier/register_line-inl.h
+++ b/runtime/verifier/register_line-inl.h
@@ -168,8 +168,7 @@
verifier->Fail(VERIFY_ERROR_LOCKING);
if (kDumpLockFailures) {
VLOG(verifier) << "expected empty monitor stack in "
- << PrettyMethod(verifier->GetMethodReference().dex_method_index,
- *verifier->GetMethodReference().dex_file);
+ << verifier->GetMethodReference().PrettyMethod();
}
}
}
diff --git a/runtime/verifier/register_line.cc b/runtime/verifier/register_line.cc
index 823336c..4ec2da6 100644
--- a/runtime/verifier/register_line.cc
+++ b/runtime/verifier/register_line.cc
@@ -33,8 +33,7 @@
CHECK(!type.IsUninitializedThisReference() &&
!type.IsUnresolvedAndUninitializedThisReference())
<< i << ": " << type.IsUninitializedThisReference() << " in "
- << PrettyMethod(verifier->GetMethodReference().dex_method_index,
- *verifier->GetMethodReference().dex_file);
+ << verifier->GetMethodReference().PrettyMethod();
}
}
if (!this_initialized_) {
@@ -338,8 +337,7 @@
verifier->Fail(VERIFY_ERROR_LOCKING);
if (kDumpLockFailures) {
VLOG(verifier) << "monitor-enter stack overflow while verifying "
- << PrettyMethod(verifier->GetMethodReference().dex_method_index,
- *verifier->GetMethodReference().dex_file);
+ << verifier->GetMethodReference().PrettyMethod();
}
} else {
if (SetRegToLockDepth(reg_idx, monitors_.size())) {
@@ -354,8 +352,7 @@
verifier->Fail(VERIFY_ERROR_LOCKING);
if (kDumpLockFailures) {
VLOG(verifier) << "unexpected monitor-enter on register v" << reg_idx << " in "
- << PrettyMethod(verifier->GetMethodReference().dex_method_index,
- *verifier->GetMethodReference().dex_file);
+ << verifier->GetMethodReference().PrettyMethod();
}
}
}
@@ -369,8 +366,7 @@
verifier->Fail(VERIFY_ERROR_LOCKING);
if (kDumpLockFailures) {
VLOG(verifier) << "monitor-exit stack underflow while verifying "
- << PrettyMethod(verifier->GetMethodReference().dex_method_index,
- *verifier->GetMethodReference().dex_file);
+ << verifier->GetMethodReference().PrettyMethod();
}
} else {
monitors_.pop_back();
@@ -390,8 +386,7 @@
verifier->Fail(VERIFY_ERROR_LOCKING);
if (kDumpLockFailures) {
VLOG(verifier) << "monitor-exit not unlocking the top of the monitor stack while verifying "
- << PrettyMethod(verifier->GetMethodReference().dex_method_index,
- *verifier->GetMethodReference().dex_file);
+ << verifier->GetMethodReference().PrettyMethod();
}
} else {
// Record the register was unlocked. This clears all aliases, thus it will also clear the
@@ -445,8 +440,7 @@
if (kDumpLockFailures) {
VLOG(verifier) << "mismatched stack depths (depth=" << MonitorStackDepth()
<< ", incoming depth=" << incoming_line->MonitorStackDepth() << ") in "
- << PrettyMethod(verifier->GetMethodReference().dex_method_index,
- *verifier->GetMethodReference().dex_file);
+ << verifier->GetMethodReference().PrettyMethod();
}
} else if (reg_to_lock_depths_ != incoming_line->reg_to_lock_depths_) {
for (uint32_t idx = 0; idx < num_regs_; idx++) {
@@ -480,8 +474,7 @@
if (kDumpLockFailures) {
VLOG(verifier) << "mismatched stack depths for register v" << idx
<< ": " << depths << " != " << incoming_depths << " in "
- << PrettyMethod(verifier->GetMethodReference().dex_method_index,
- *verifier->GetMethodReference().dex_file);
+ << verifier->GetMethodReference().PrettyMethod();
}
break;
}
@@ -523,8 +516,7 @@
VLOG(verifier) << "mismatched lock levels for register v" << idx << ": "
<< std::hex << locked_levels << std::dec << " != "
<< std::hex << incoming_locked_levels << std::dec << " in "
- << PrettyMethod(verifier->GetMethodReference().dex_method_index,
- *verifier->GetMethodReference().dex_file);
+ << verifier->GetMethodReference().PrettyMethod();
}
break;
}
diff --git a/runtime/verifier/verifier_deps.cc b/runtime/verifier/verifier_deps.cc
index 3e1958f..3c7fb7a 100644
--- a/runtime/verifier/verifier_deps.cc
+++ b/runtime/verifier/verifier_deps.cc
@@ -118,7 +118,7 @@
// We could avoid recording dependencies on arrays with component types in
// the compiled DEX files but we choose to record them anyway so as to
// record the access flags VM sets for array classes.
- DCHECK(klass->IsArrayClass()) << PrettyDescriptor(klass);
+ DCHECK(klass->IsArrayClass()) << klass->PrettyDescriptor();
return true;
}