diff options
author | 2016-10-13 09:12:37 -0700 | |
---|---|---|
committer | 2016-10-18 14:10:04 -0700 | |
commit | 709b070044354d9f47641f273edacaeeb0240ab7 (patch) | |
tree | 3a8ac051d7c35076303984d0d892cdd396b60427 | |
parent | 1a4de6a2453a3ad0310aca1a44e7e2d3b6f53bc1 (diff) |
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
118 files changed, 1202 insertions, 1099 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index bc8facdb41..51bf9ea3bd 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -86,7 +86,7 @@ void CommonCompilerTest::MakeExecutable(ArtMethod* method) { 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 16263177d8..c500921ab3 100644 --- a/compiler/compiler.cc +++ b/compiler/compiler.cc @@ -47,12 +47,12 @@ bool Compiler::IsPathologicalCase(const DexFile::CodeItem& code_item, 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 045edddd77..af9f091529 100644 --- a/compiler/debug/elf_symtab_writer.h +++ b/compiler/debug/elf_symtab_writer.h @@ -69,7 +69,7 @@ static void WriteDebugSymbols(ElfBuilder<ElfTypes>* builder, 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 236a3b24ed..9c1d72b9be 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -212,7 +212,7 @@ void DexCompiler::CompileReturnVoid(Instruction* inst, uint32_t dex_pc) { 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 @@ Instruction* DexCompiler::CompileCheckCast(Instruction* inst, uint32_t dex_pc) { 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 @@ void DexCompiler::CompileInstanceFieldAccess(Instruction* inst, << " 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 @@ void DexCompiler::CompileInvokeVirtual(Instruction* inst, uint32_t dex_pc, 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 d87762d417..511a787878 100644 --- a/compiler/dex/verification_results.cc +++ b/compiler/dex/verification_results.cc @@ -58,8 +58,7 @@ void VerificationResults::ProcessVerifiedMethod(verifier::MethodVerifier* method 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 afaec52c7b..7d2abdfab8 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -617,7 +617,7 @@ static void CompileMethod(Thread* self, 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 @@ static void CompileMethod(Thread* self, 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 @@ bool CompilerDriver::IsMethodToCompile(const MethodReference& method_ref) const 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 @@ bool CompilerDriver::ShouldCompileBasedOnProfile(const MethodReference& method_r 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 @@ static bool SkipClass(jobject class_loader, const DexFile& dex_file, mirror::Cla 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 @@ class VerifyClassVisitor : public CompilationVisitor { 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 @@ class VerifyClassVisitor : public CompilationVisitor { } 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 @@ void CompilerDriver::AddCompiledMethod(const MethodReference& method_ref, 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 e323b1684a..20f0e5ee31 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -216,7 +216,7 @@ TEST_F(CompilerDriverMethodsTest, Selection) { 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 @@ class CompilerDriverProfileTest : public CompilerDriverTest { 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 3c920d9601..4eb695493b 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 b0ee448ea6..64fd9e7f0f 100644 --- a/compiler/driver/dex_compilation_unit.cc +++ b/compiler/driver/dex_compilation_unit.cc @@ -45,7 +45,7 @@ DexCompilationUnit::DexCompilationUnit(jobject class_loader, 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 8f15ea4a05..b19a95bb65 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -114,7 +114,7 @@ bool ImageWriter::IsInBootOatFile(const void* ptr) const { 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 @@ void ImageWriter::AddMethodPointerArray(mirror::PointerArray* arr) { 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 @@ bool ImageWriter::PruneAppImageClassInternal( 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 @@ void ImageWriter::PruneNonImageClasses() { } 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 @@ void ImageWriter::CheckNonImageClassesRemovedCallback(Object* obj, void* arg) { image_writer->DumpImageClasses(); std::string temp; CHECK(image_writer->KeepClass(klass)) << klass->GetDescriptor(&temp) - << " " << PrettyDescriptor(klass); + << " " << klass->PrettyDescriptor(); } } } @@ -1100,7 +1100,7 @@ mirror::Object* ImageWriter::TryAssignBinSlot(WorkStack& work_stack, 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 @@ mirror::Object* ImageWriter::TryAssignBinSlot(WorkStack& work_stack, 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 @@ void ImageWriter::AssignMethodOffset(ArtMethod* method, 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 @@ void ImageWriter::EnsureBinSlotAssignedCallback(mirror::Object* obj, void* arg) 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 @@ void ImageWriter::CreateHeader(size_t oat_index) { 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::CopyAndFixupObjectsCallback(Object* obj, void* arg) { 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 @@ void ImageWriter::FixupPointerArray(mirror::Object* dst, mirror::PointerArray* a 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 @@ std::string PrettyPrint(T* ptr) REQUIRES_SHARED(Locks::mutator_lock_) { 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::GetOatAddress(OatAddress type) const { 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 @@ void ImageWriter::CopyAndFixupMethod(ArtMethod* orig, 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 4ef2db8b91..c398703bb8 100644 --- a/compiler/jit/jit_compiler.cc +++ b/compiler/jit/jit_compiler.cc @@ -208,7 +208,7 @@ bool JitCompiler::CompileMethod(Thread* self, ArtMethod* method, bool osr) { // 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 @@ bool JitCompiler::CompileMethod(Thread* self, ArtMethod* method, bool osr) { << " " << 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 13d8c166cc..e17144192a 100644 --- a/compiler/jni/quick/jni_compiler.cc +++ b/compiler/jni/quick/jni_compiler.cc @@ -96,24 +96,24 @@ static CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver* driver, 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 @@ static CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver* driver, 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 b4c60d15da..593d8e92f9 100644 --- a/compiler/oat_test.cc +++ b/compiler/oat_test.cc @@ -65,14 +65,14 @@ class OatTest : public CommonCompilerTest { 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 @@ class OatTest : public CommonCompilerTest { 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 44c26edd71..52134e8b9b 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -759,7 +759,7 @@ class OatWriter::InitCodeMethodVisitor : public OatDexMethodVisitor { 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 @@ class OatWriter::InitImageMethodVisitor : public OatDexMethodVisitor { 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 @@ class OatWriter::WriteCodeMethodVisitor : public OatDexMethodVisitor { 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 @@ class OatWriter::WriteCodeMethodVisitor : public OatDexMethodVisitor { 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 @@ class OatWriter::WriteMapMethodVisitor : public OatDexMethodVisitor { 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 @@ class OatWriter::WriteMapMethodVisitor : public OatDexMethodVisitor { 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 86742e6526..2927e1f7c0 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -51,7 +51,7 @@ bool HGraphBuilder::SkipCompilation(size_t number_of_branches) { 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 @@ bool HGraphBuilder::SkipCompilation(size_t number_of_branches) { 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 912ee29cdb..09dcefa02c 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -441,8 +441,8 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { 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 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { } 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 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { : 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 6080551900..9faa98a388 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -90,14 +90,14 @@ void HInliner::Run() { 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 @@ static uint32_t FindClassIndexIn(mirror::Class* cls, 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 @@ bool HInliner::TryInline(HInvoke* invoke_instruction) { 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 @@ bool HInliner::TryInline(HInvoke* invoke_instruction) { 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 @@ bool HInliner::TryInline(HInvoke* invoke_instruction) { } 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 @@ bool HInliner::TryInline(HInvoke* invoke_instruction) { } 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 @@ bool HInliner::TryInlineMonomorphicCall(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryInlinePolymorphicCall(HInvoke* invoke_instruction, } 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 @@ bool HInliner::TryInlinePolymorphicCallToSameTarget(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryBuildAndInline(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryBuildAndInline(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryBuildAndInline(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryBuildAndInline(HInvoke* invoke_instruction, } 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 @@ bool HInliner::TryBuildAndInline(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryBuildAndInline(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryBuildAndInline(HInvoke* invoke_instruction, return false; } - VLOG(compiler) << "Successfully inlined " << PrettyMethod(method); + VLOG(compiler) << "Successfully inlined " << method->PrettyMethod(); MaybeRecordStat(kInlinedInvoke); return true; } @@ -1143,14 +1144,14 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, // 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 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, } } 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 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, !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 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, 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 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, 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 f7d67db5b2..613e00843f 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -1065,7 +1065,7 @@ bool HInstructionBuilder::SetupInvokeArguments(HInvoke* invoke, // 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 @@ bool HInstructionBuilder::SetupInvokeArguments(HInvoke* invoke, 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 @@ bool HInstructionBuilder::ProcessDexInstruction(const Instruction& instruction, 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 412ccfcf4f..8327a4c244 100644 --- a/compiler/optimizing/intrinsics.cc +++ b/compiler/optimizing/intrinsics.cc @@ -146,7 +146,7 @@ void IntrinsicsRecognizer::Run() { 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 1e69966b98..59cc0091bf 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -2295,7 +2295,7 @@ std::ostream& operator<<(std::ostream& os, const ReferenceTypeInfo& rhs) { 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 4370a84bd2..6ba0963720 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -173,7 +173,7 @@ class PassObserver : public ValueObject { 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 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, 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 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, // 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 @@ bool OptimizingCompiler::JitCompile(Thread* self, 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 8fb539661f..a4df9e5503 100644 --- a/compiler/optimizing/prepare_for_register_allocation.cc +++ b/compiler/optimizing/prepare_for_register_allocation.cc @@ -44,7 +44,7 @@ void PrepareForRegisterAllocation::VisitBoundsCheck(HBoundsCheck* check) { // 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 83698adba4..b16c3eaac7 100644 --- a/compiler/optimizing/reference_type_propagation.cc +++ b/compiler/optimizing/reference_type_propagation.cc @@ -448,9 +448,9 @@ void ReferenceTypePropagation::RTPVisitor::SetClassAsTypeInfo(HInstruction* inst 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 7a424a23f5..da4ac798c7 100644 --- a/compiler/utils/test_dex_file_builder_test.cc +++ b/compiler/utils/test_dex_file_builder_test.cc @@ -66,14 +66,14 @@ TEST(TestDexFileBuilderTest, SimpleTest) { } 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 ace21aa45b..f197fc110f 100644 --- a/imgdiag/imgdiag.cc +++ b/imgdiag/imgdiag.cc @@ -222,9 +222,9 @@ class ImgDiagDumper { // 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 @@ class ImgDiagDumper { 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 @@ class ImgDiagDumper { 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 ImgDiagDumper { 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 @@ class ImgDiagDumper { 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 @@ class ImgDiagDumper { 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 2fcc0cfc89..c7bf231e03 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -940,7 +940,7 @@ class OatDumper { 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 @@ class ImageDumper { 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 @@ class ImageDumper { 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 @@ class ImageDumper { 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 @@ class ImageDumper { 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 @@ class ImageDumper { 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 @@ class ImageDumper { 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 @@ class ImageDumper { 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 @@ class ImageDumper { 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 @@ class ImageDumper { << " 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 @@ class IMTDumper { return; } table_index++; - std::cerr << " " << PrettyMethod(ptr, true) << std::endl; + std::cerr << " " << ptr->PrettyMethod(true) << std::endl; } } @@ -2850,7 +2852,7 @@ class IMTDumper { PrintTable(current_table, pointer_size); } } else { - std::cerr << " " << PrettyMethod(ptr, true) << std::endl; + std::cerr << " " << ptr->PrettyMethod(true) << std::endl; } } @@ -2867,7 +2869,7 @@ class IMTDumper { 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 @@ class IMTDumper { } 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 @@ class IMTDumper { } } } 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 @@ class IMTDumper { 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 432ba36587..4638c3fc55 100644 --- a/runtime/arch/stub_test.cc +++ b/runtime/arch/stub_test.cc @@ -1168,7 +1168,7 @@ TEST_F(StubTest, AllocObjectArray) { 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 @@ TEST_F(StubTest, DISABLED_IMT) { 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 24bbcfbf0b..b9f688de57 100644 --- a/runtime/art_field-inl.h +++ b/runtime/art_field-inl.h @@ -62,7 +62,7 @@ inline MemberOffset ArtField::GetOffsetDuringLinking() { } 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 @@ inline uint32_t ArtField::Get32(ObjPtr<mirror::Object> object) { 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 void ArtField::Set32(ObjPtr<mirror::Object> object, uint32_t new_value) { } 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 @@ inline uint64_t ArtField::Get64(ObjPtr<mirror::Object> object) { 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 @@ inline void ArtField::Set64(ObjPtr<mirror::Object> object, uint64_t new_value) { 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 @@ inline ObjPtr<MirrorType> ArtField::GetObj(ObjPtr<mirror::Object> object) { 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 @@ inline void ArtField::SetObj(ObjPtr<mirror::Object> object, ObjPtr<mirror::Objec } #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 @@ inline void ArtField::SetObj(ObjPtr<mirror::Object> object, ObjPtr<mirror::Objec 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 void ArtField::SetShort(ObjPtr<mirror::Object> object, int16_t s) { 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 @@ template<bool kTransactionActive> 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 void ArtField::SetInt(ObjPtr<mirror::Object> object, int32_t i) { 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 @@ template<bool kTransactionActive> 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 @@ inline float ArtField::GetFloat(ObjPtr<mirror::Object> object) { 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 @@ inline double ArtField::GetDouble(ObjPtr<mirror::Object> object) { 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 78c62d6f37..b46b058b16 100644 --- a/runtime/art_field.cc +++ b/runtime/art_field.cc @@ -62,4 +62,25 @@ ObjPtr<mirror::String> ArtField::ResolveGetStringName(Thread* self, 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 8ba383c007..7c2f490706 100644 --- a/runtime/art_field.h +++ b/runtime/art_field.h @@ -201,6 +201,13 @@ class ArtField FINAL { 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 1aa6a00495..499b7fe8fb 100644 --- a/runtime/art_method-inl.h +++ b/runtime/art_method-inl.h @@ -55,7 +55,7 @@ inline mirror::Class* ArtMethod::GetDeclaringClass() { 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 937dcee473..3065f68fc4 100644 --- a/runtime/art_method.cc +++ b/runtime/art_method.cc @@ -276,7 +276,7 @@ void ArtMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* 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 @@ void ArtMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* ? 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 @@ void ArtMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* 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::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* } 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::RegisterNative(const void* native_method, bool is_fast) { } 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 @@ static const OatFile::OatMethod FindOatMethodFor(ArtMethod* method, 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 @@ const OatQuickMethodHeader* ArtMethod::GetOatQuickMethodHeader(uintptr_t pc) { 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 @@ const OatQuickMethodHeader* ArtMethod::GetOatQuickMethodHeader(uintptr_t pc) { 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 OatQuickMethodHeader* ArtMethod::GetOatQuickMethodHeader(uintptr_t pc) { } 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 @@ const OatQuickMethodHeader* ArtMethod::GetOatQuickMethodHeader(uintptr_t pc) { } 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 @@ bool ArtMethod::IsImagePointerSize(PointerSize pointer_size) { 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 0d0bf2056a..b68e099c3a 100644 --- a/runtime/art_method.h +++ b/runtime/art_method.h @@ -614,6 +614,20 @@ class ArtMethod FINAL { // 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 5ec989831e..a1ce30b3fc 100644 --- a/runtime/check_jni.cc +++ b/runtime/check_jni.cc @@ -289,7 +289,7 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { } 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 @@ class ScopedCheck { } 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { } 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 @@ class ScopedCheck { 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 ab712f99be..93fdaa6161 100644 --- a/runtime/check_reference_map_visitor.h +++ b/runtime/check_reference_map_visitor.h @@ -41,10 +41,10 @@ class CheckReferenceMapVisitor : public StackVisitor { 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 126187f092..3e842d2a29 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -260,8 +260,8 @@ ArtMethod* ClassLinker::FindMethodForProxy(mirror::Class* proxy_class, ArtMethod } } } - 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 63de76ccb7..733bd30468 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -149,7 +149,7 @@ static void HandleEarlierVerifyError(Thread* self, ClassLinker* class_linker, mi 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 @@ void ClassLinker::ThrowEarlierClassFailure(mirror::Class* c, bool wrap_in_no_cla 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 @@ void ClassLinker::ThrowEarlierClassFailure(mirror::Class* c, bool wrap_in_no_cla // 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 @@ static void ShuffleForward(size_t* current_field_idx, *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 @@ static void SanityCheckArtMethod(ArtMethod* m, 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 @@ bool ClassLinker::InitFromBootImage(std::string* error_msg) { 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 @@ static mirror::String* GetDexPathListElementName(ScopedObjectAccessUnchecked& so 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 @@ static bool FlattenPathClassLoader(mirror::ClassLoader* class_loader, 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 @@ class VerifyClassInTableArtMethodVisitor : public ArtMethodVisitor { 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 @@ bool ClassLinker::UpdateAppImageClassLoadersAndDexCaches( !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 @@ bool ClassLinker::UpdateAppImageClassLoadersAndDexCaches( !IsQuickGenericJniStub(code) && !IsQuickToInterpreterBridge(code) && !m.IsNative()) { - DCHECK_EQ(code, oat_code) << PrettyMethod(&m); + DCHECK_EQ(code, oat_code) << m.PrettyMethod(); } } } @@ -1466,7 +1468,7 @@ class UpdateClassLoaderAndResolvedStringsVisitor { 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 @@ mirror::Class* ClassLinker::EnsureResolved(Thread* self, 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 @@ uint32_t ClassLinker::SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file, // 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 @@ bool ClassLinker::ShouldUseInterpreterEntrypoint(ArtMethod* method, const void* } 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 @@ void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) { 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 @@ void ClassLinker::LoadClassMembers(Thread* self, } 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 @@ void ClassLinker::LoadMethod(const DexFile& dex_file, } 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 @@ bool ClassLinker::AttemptSupertypeVerification(Thread* self, // 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 @@ void ClassLinker::VerifyClass(Thread* self, 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 @@ void ClassLinker::VerifyClass(Thread* self, 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 @@ void ClassLinker::VerifyClass(Thread* self, 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 @@ void ClassLinker::VerifyClass(Thread* self, } } } 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 @@ bool ClassLinker::VerifyClassUsingOatFile(const DexFile& dex_file, } 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 @@ mirror::Class* ClassLinker::CreateProxyClass(ScopedObjectAccessAlreadyRunnable& // 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 @@ mirror::Class* ClassLinker::CreateProxyClass(ScopedObjectAccessAlreadyRunnable& 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 @@ bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass, 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 @@ bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass, 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 @@ bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass, } 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 @@ bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass, // 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 @@ bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass, } 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 @@ bool ClassLinker::WaitForInitializeClass(Handle<mirror::Class> klass, // 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 @@ static void ThrowSignatureCheckResolveReturnTypeException(Handle<mirror::Class> 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 @@ static void ThrowSignatureCheckResolveArgException(Handle<mirror::Class> klass, 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 @@ static void ThrowSignatureMismatch(Handle<mirror::Class> klass, 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 @@ static bool HasSameSignatureWithDifferentClassLoaders(Thread* self, 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 @@ static bool HasSameSignatureWithDifferentClassLoaders(Thread* self, 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 @@ static bool HasSameSignatureWithDifferentClassLoaders(Thread* self, 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 @@ static bool HasSameSignatureWithDifferentClassLoaders(Thread* self, 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 @@ static bool HasSameSignatureWithDifferentClassLoaders(Thread* self, 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 @@ bool ClassLinker::EnsureInitialized(Thread* self, Handle<mirror::Class> c, bool 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 @@ bool ClassLinker::LinkClass(Thread* self, 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 @@ static bool CheckSuperClassChange(Handle<mirror::Class> klass, 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 @@ bool ClassLinker::LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexF 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 @@ bool ClassLinker::LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexF // 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 @@ bool ClassLinker::LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexF // 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 @@ bool ClassLinker::LinkSuperClass(Handle<mirror::Class> klass) { } 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 @@ bool ClassLinker::LinkSuperClass(Handle<mirror::Class> klass) { 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 @@ class MethodNameAndSignatureComparator FINAL : public ValueObject { 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 @@ class MethodNameAndSignatureComparator FINAL : public ValueObject { 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 @@ X86_OPTNONE bool ClassLinker::LinkVirtualMethods( } 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 @@ X86_OPTNONE bool ClassLinker::LinkVirtualMethods( 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 @@ X86_OPTNONE bool ClassLinker::LinkVirtualMethods( // 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 @@ ClassLinker::DefaultMethodSearchResult ClassLinker::FindDefaultMethodImplementat // 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 @@ ClassLinker::DefaultMethodSearchResult ClassLinker::FindDefaultMethodImplementat 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 @@ ClassLinker::DefaultMethodSearchResult ClassLinker::FindDefaultMethodImplementat // 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::SetIMTRef(ArtMethod* unimplemented_method, } 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 @@ static size_t FillIfTable(mirror::IfTable* iftable, 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 @@ static size_t FillIfTable(mirror::IfTable* iftable, 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 @@ bool ClassLinker::SetupInterfaceLookupTable(Thread* self, Handle<mirror::Class> 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 @@ static void CheckClassOwnsVTableEntries(Thread* self, 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 @@ static void CheckVTableHasNoDuplicates(Thread* self, !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 @@ bool ClassLinker::LinkInterfaceMethods( 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 @@ bool ClassLinker::LinkInterfaceMethods( // 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 @@ bool ClassLinker::LinkInterfaceMethods( 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 @@ bool ClassLinker::LinkInterfaceMethods( 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 @@ bool ClassLinker::LinkInterfaceMethods( 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 @@ bool ClassLinker::LinkInterfaceMethods( 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 @@ bool ClassLinker::LinkInterfaceMethods( [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 @@ bool ClassLinker::LinkFields(Thread* self, 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 @@ bool ClassLinker::LinkFields(Thread* self, 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 @@ bool ClassLinker::LinkFields(Thread* self, 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 @@ bool ClassLinker::LinkFields(Thread* self, 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 @@ mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file, } } DCHECK((resolved == nullptr) || resolved->IsResolved() || resolved->IsErroneous()) - << PrettyDescriptor(resolved) << " " << resolved->GetStatus(); + << resolved->PrettyDescriptor() << " " << resolved->GetStatus(); return resolved; } @@ -7513,7 +7529,7 @@ ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, 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 @@ ArtMethod* ClassLinker::ResolveMethodWithoutInvokeType(const DexFile& dex_file, 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 4fac830d16..ab18627236 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -332,9 +332,9 @@ class ClassLinkerTest : public CommonRuntimeTest { 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 @@ class ClassLinkerTest : public CommonRuntimeTest { 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 @@ static void CheckMethod(ArtMethod* method, bool verified) 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 0aa33c644e..b0aba59b6d 100644 --- a/runtime/common_throws.cc +++ b/runtime/common_throws.cc @@ -42,8 +42,8 @@ static void AddReferrerLocation(std::ostream& os, ObjPtr<mirror::Class> referrer 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 @@ static void ThrowWrappedException(const char* exception_descriptor, 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 @@ void ThrowArrayStoreException(ObjPtr<mirror::Class> element_class, 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 ThrowArrayStoreException(ObjPtr<mirror::Class> element_class, 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 ThrowClassCastException(const char* msg) { 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 ThrowClassFormatError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) 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 @@ void ThrowIllegalAccessErrorClassForMethodDispatch(ObjPtr<mirror::Class> referre 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 ThrowIllegalArgumentException(const char* msg) { 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 @@ void ThrowIncompatibleClassChangeErrorClassForInterfaceSuper(ArtMethod* method, // 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 @@ void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(ArtMethod* inter // 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 ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(ArtMethod* inter 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 @@ void ThrowIncompatibleClassChangeErrorForMethodConflict(ArtMethod* method) { 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 ThrowNoSuchMethodError(InvokeType type, ObjPtr<mirror::Class> c, const Stri 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 @@ static void ThrowNullPointerExceptionForMethodAccessImpl(uint32_t method_idx, 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 @@ void ThrowNullPointerExceptionFromDexPC(bool check_address, uintptr_t addr) { << ", at " << instr->DumpString(dex_file) << " in " - << PrettyMethod(method); + << method->PrettyMethod(); } switch (instr->Opcode()) { @@ -666,7 +667,7 @@ void ThrowNullPointerExceptionFromDexPC(bool check_address, uintptr_t addr) { 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 3977e4926a..23fb79d035 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -134,7 +134,8 @@ class Breakpoint : public ValueObject { 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 @@ class DebugInstrumentationListener FINAL : public instrumentation::Instrumentati 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 @@ class DebugInstrumentationListener FINAL : public instrumentation::Instrumentati // 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 @@ class DebugInstrumentationListener FINAL : public instrumentation::Instrumentati 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 @@ JDWP::JdwpError Dbg::CreateObject(JDWP::RefTypeId class_id, JDWP::ObjectId* new_ 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 @@ JDWP::JdwpError Dbg::CreateArrayObject(JDWP::RefTypeId array_class_id, uint32_t 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 @@ static uint16_t MangleSlot(uint16_t slot, ArtMethod* m) 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 @@ static uint16_t DemangleSlot(uint16_t slot, ArtMethod* m, JDWP::JdwpError* error 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 @@ static uint16_t DemangleSlot(uint16_t slot, ArtMethod* m, JDWP::JdwpError* error } // 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 @@ static JDWP::JdwpError GetFieldValueImpl(JDWP::RefTypeId ref_type_id, JDWP::Obje // 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 @@ static JDWP::JdwpError GetFieldValueImpl(JDWP::RefTypeId ref_type_id, JDWP::Obje } 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 @@ static JDWP::JdwpError SetFieldValueImpl(JDWP::ObjectId object_id, JDWP::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. @@ -1924,7 +1929,7 @@ static JDWP::JdwpError SetFieldValueImpl(JDWP::ObjectId object_id, JDWP::FieldId } 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 @@ constexpr JDWP::JdwpError kStackFrameLocalAccessError = JDWP::ERR_ABSENT_INFORMA 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 @@ void Dbg::ProcessDeoptimizationRequest(const DeoptimizationRequest& request) { 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 @@ void Dbg::RequestDeoptimizationLocked(const DeoptimizationRequest& req) { 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 @@ static DeoptimizationRequest::Kind GetRequiredDeoptimizationKind(Thread* self, 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 @@ static DeoptimizationRequest::Kind GetRequiredDeoptimizationKind(Thread* self, 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 @@ class NeedsDeoptimizationVisitor : public StackVisitor { 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 @@ JDWP::JdwpError Dbg::ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize 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 @@ void Dbg::ExecuteMethodWithoutPendingException(ScopedObjectAccess& soa, DebugInv 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 @@ void Dbg::DumpRecentAllocations() { 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 0af086c896..b3317a5dc8 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -933,7 +933,7 @@ bool DexFile::DecodeDebugLocalInfo(const CodeItem* code_item, bool is_static, ui } 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 @@ uint64_t DexFile::ReadUnsignedLong(const uint8_t* ptr, int zwidth, bool fill_on_ 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 29b8c3adef..20f3a9caea 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -1016,6 +1016,13 @@ class DexFile { 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 e5383341fb..0765465db4 100644 --- a/runtime/dex_file_annotations.cc +++ b/runtime/dex_file_annotations.cc @@ -247,8 +247,7 @@ mirror::Object* ProcessEncodedAnnotation(Handle<mirror::Class> klass, const uint 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 @@ int32_t GetLineNumFromPC(const DexFile* dex_file, ArtMethod* method, uint32_t re } 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 c31d236dc7..c766b54c0a 100644 --- a/runtime/dex_instruction.cc +++ b/runtime/dex_instruction.cc @@ -209,7 +209,7 @@ std::string Instruction::DumpString(const DexFile* file) const { 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 @@ std::string Instruction::DumpString(const DexFile* file) const { 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 @@ std::string Instruction::DumpString(const DexFile* file) const { 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 @@ std::string Instruction::DumpString(const DexFile* file) const { 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 @@ std::string Instruction::DumpString(const DexFile* file) const { 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 @@ std::string Instruction::DumpString(const DexFile* file) const { 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 @@ std::string Instruction::DumpString(const DexFile* file) const { 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 @@ std::string Instruction::DumpString(const DexFile* file) const { } 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 @@ std::string Instruction::DumpString(const DexFile* file) const { 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 9f28c8c803..cd8c39096d 100644 --- a/runtime/dex_method_iterator_test.cc +++ b/runtime/dex_method_iterator_test.cc @@ -40,7 +40,7 @@ TEST_F(DexMethodIteratorTest, Basic) { 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 8077c21bdc..31811fb96a 100644 --- a/runtime/entrypoints/entrypoint_utils-inl.h +++ b/runtime/entrypoints/entrypoint_utils-inl.h @@ -148,12 +148,13 @@ inline mirror::Class* CheckObjectAlloc(uint32_t type_idx, } 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 @@ inline mirror::Class* CheckArrayAlloc(uint32_t type_idx, 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 @@ inline ArtField* FindFieldFromCode(uint32_t field_idx, "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 @@ inline ArtMethod* FindMethodFromCode(uint32_t method_idx, 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 @@ inline ArtMethod* FindMethodFromCode(uint32_t method_idx, 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 f8deb8f7a3..cbefbbac5d 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -61,12 +61,12 @@ static inline mirror::Class* CheckFilledNewArrayAlloc(uint32_t type_idx, 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 @@ static inline mirror::Class* CheckFilledNewArrayAlloc(uint32_t type_idx, return nullptr; // Failure } } - DCHECK(klass->IsArrayClass()) << PrettyClass(klass); + DCHECK(klass->IsArrayClass()) << klass->PrettyClass(); return klass; } @@ -131,8 +131,8 @@ void CheckReferenceResult(Handle<mirror::Object> o, Thread* self) { 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 fec7373d27..aa547bf04e 100644 --- a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc @@ -44,7 +44,7 @@ extern "C" const void* artInstrumentationMethodEntryFromCode(ArtMethod* method, 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 383cdd256d..b25f447e4b 100644 --- a/runtime/entrypoints/quick/quick_jni_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_jni_entrypoints.cc @@ -47,7 +47,7 @@ extern uint32_t JniMethodFastStart(Thread* self) { 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 @@ extern void JniMethodFastEnd(uint32_t saved_local_ref_cookie, Thread* self) { 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 750efac977..0bb65815bf 100644 --- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -660,11 +660,11 @@ extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self, 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 @@ extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self, 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 @@ extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self, 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 @@ void BuildQuickArgumentVisitor::FixupReferences() { 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 @@ extern "C" uint64_t artQuickProxyInvokeHandler( // 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 @@ extern "C" const void* artQuickResolutionTrampoline( 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 @@ extern "C" const void* artQuickResolutionTrampoline( } } - 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 @@ static void artQuickGenericJniEndJNINonRef(Thread* self, 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 @@ static TwoWordReturn artInvokeCommon(uint32_t method_idx, mirror::Object* this_o 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 @@ extern "C" TwoWordReturn artInvokeInterfaceTrampoline(uint32_t deadbeef ATTRIBUT 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 @@ extern "C" TwoWordReturn artInvokeInterfaceTrampoline(uint32_t deadbeef ATTRIBUT 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 3b6750ebdb..14f59977d6 100644 --- a/runtime/gc/accounting/mod_union_table.cc +++ b/runtime/gc/accounting/mod_union_table.cc @@ -276,8 +276,9 @@ class CheckReferenceVisitor { 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 a7f2aa0c71..40186f8f26 100644 --- a/runtime/gc/allocator/rosalloc.cc +++ b/runtime/gc/allocator/rosalloc.cc @@ -1966,7 +1966,7 @@ void RosAlloc::Run::Verify(Thread* self, RosAlloc* rosalloc, bool running_on_mem 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 3dee974bed..1931caf65e 100644 --- a/runtime/gc/collector/concurrent_copying.cc +++ b/runtime/gc/collector/concurrent_copying.cc @@ -396,8 +396,8 @@ class ConcurrentCopying::VerifyGrayImmuneObjectsVisitor { 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::ExpandGcMarkStack() { 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 @@ class ConcurrentCopying::VerifyNoFromSpaceRefsVisitor : public SingleRootVisitor 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 @@ void ConcurrentCopying::CheckEmptyMarkStack() { 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 @@ void ConcurrentCopying::AssertToSpaceInvariant(mirror::Object* obj, MemberOffset 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 @@ void ConcurrentCopying::AssertToSpaceInvariant(GcRootSource* gc_root_source, // 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 @@ void ConcurrentCopying::AssertToSpaceInvariant(GcRootSource* gc_root_source, 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::AssertToSpaceInvariant(GcRootSource* gc_root_source, 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 c05719d2c1..77d7274a53 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -423,7 +423,7 @@ class MarkSweep::MarkObjectSlowPath { << (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 f4a3aeaabc..ba18699168 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -2926,7 +2926,7 @@ class VerifyReferenceVisitor : public SingleRootVisitor { 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 @@ class VerifyReferenceVisitor : public SingleRootVisitor { 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 @@ class VerifyReferenceVisitor : public SingleRootVisitor { 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 @@ class VerifyReferenceVisitor : public SingleRootVisitor { 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 @@ class VerifyReferenceCardVisitor { 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 @@ class VerifyReferenceCardVisitor { 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 4b8f38d709..798ecd3d87 100644 --- a/runtime/gc/reference_processor.cc +++ b/runtime/gc/reference_processor.cc @@ -211,7 +211,7 @@ void ReferenceProcessor::DelayReferenceReferent(ObjPtr<mirror::Class> klass, } 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 e9c8b9520c..6035406dd0 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -398,7 +398,7 @@ void ImageSpace::VerifyImageAllocations() { 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 ecb2157833..0fde38072b 100644 --- a/runtime/hprof/hprof.cc +++ b/runtime/hprof/hprof.cc @@ -654,7 +654,7 @@ class Hprof : public SingleRootVisitor { } 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 36e860837d..d059b97181 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -234,8 +234,8 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) 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 @@ static void InstrumentationRestoreStack(Thread* thread, void* arg) 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 @@ static void InstrumentationRestoreStack(Thread* thread, void* arg) 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 @@ void Instrumentation::Deoptimize(ArtMethod* method) { { 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 @@ void Instrumentation::Undeoptimize(ArtMethod* method) { { 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 @@ void Instrumentation::PushInstrumentationStackFrame(Thread* self, mirror::Object 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 @@ TwoWordReturn Instrumentation::PopInstrumentationStackFrame(Thread* self, uintpt 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 @@ TwoWordReturn Instrumentation::PopInstrumentationStackFrame(Thread* self, uintpt 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 @@ uintptr_t Instrumentation::PopMethodForUnwind(Thread* self, bool is_deoptimizati 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 @@ uintptr_t Instrumentation::PopMethodForUnwind(Thread* self, bool is_deoptimizati 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 f3cd25cd73..2e0077056e 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -178,7 +178,7 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s 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 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s 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 @@ void EnterInterpreterFromDeoptimize(Thread* self, } 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 191ffcc776..09d11678f2 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -1046,11 +1046,11 @@ bool DoFilledNewArray(const Instruction* inst, const ShadowFrame& shadow_frame, 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 bdb6bd39a1..40d6f036a2 100644 --- a/runtime/interpreter/interpreter_common.h +++ b/runtime/interpreter/interpreter_common.h @@ -438,7 +438,7 @@ static inline void TraceExecution(const ShadowFrame& shadow_frame, const Instruc 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 @@ static inline void TraceExecution(const ShadowFrame& shadow_frame, const Instruc !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 295cdec9b9..78afe56104 100644 --- a/runtime/interpreter/interpreter_switch_impl.cc +++ b/runtime/interpreter/interpreter_switch_impl.cc @@ -495,7 +495,7 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, // 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 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, 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 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, 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 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, } 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 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, } 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 4347c37f62..25ce5cc4e4 100644 --- a/runtime/interpreter/unstarted_runtime.cc +++ b/runtime/interpreter/unstarted_runtime.cc @@ -127,7 +127,8 @@ static void UnstartedRuntimeFindClass(Thread* self, Handle<mirror::String> class 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 @@ static void CheckExceptionGenerateClassNotFound(Thread* self) 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 @@ void UnstartedRuntime::UnstartedClassNewInstance( 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 @@ void UnstartedRuntime::UnstartedClassNewInstance( } 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 @@ void UnstartedRuntime::UnstartedClassGetDeclaredField( 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 @@ void UnstartedRuntime::UnstartedClassLoaderGetResourceAsStream( 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 @@ void UnstartedRuntime::UnstartedVmClassLoaderFindLoadedClass( // 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 @@ static void PrimitiveArrayCopy(Thread* self, 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 @@ void UnstartedRuntime::UnstartedSystemArraycopy( 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 @@ void UnstartedRuntime::UnstartedSystemArraycopy( 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::UnstartedSystemGetPropertyWithDefault( 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 @@ void UnstartedRuntime::UnstartedReferenceGetReferent( // 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 @@ void UnstartedRuntime::Invoke(Thread* self, const DexFile::CodeItem* code_item, // 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 @@ void UnstartedRuntime::Invoke(Thread* self, const DexFile::CodeItem* code_item, // 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 @@ void UnstartedRuntime::Jni(Thread* self, ArtMethod* method, mirror::Object* rece 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 f2bda05b94..29dda888e6 100644 --- a/runtime/java_vm_ext.cc +++ b/runtime/java_vm_ext.cc @@ -235,8 +235,8 @@ class Libraries { 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 @@ class Libraries { 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 @@ void JavaVMExt::JniAbort(const char* jni_function_name, const char* msg) { } // 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 @@ void* JavaVMExt::FindCodeForNativeMethod(ArtMethod* m) { 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 6aebe9f9d1..85bfd17ef5 100644 --- a/runtime/jdwp/jdwp_event.cc +++ b/runtime/jdwp/jdwp_event.cc @@ -1142,7 +1142,7 @@ void JdwpState::PostException(const EventLocation* pThrowLoc, mirror::Throwable* 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 afa52ca2c4..aa9a78bc52 100644 --- a/runtime/jit/jit.cc +++ b/runtime/jit/jit.cc @@ -246,14 +246,14 @@ bool Jit::CompileMethod(ArtMethod* method, Thread* self, bool osr) { // 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 @@ bool Jit::CompileMethod(ArtMethod* method, Thread* self, bool osr) { } 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 @@ bool Jit::MaybeDoOnStackReplacement(Thread* thread, // 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 @@ void Jit::AddMemoryUsage(ArtMethod* method, size_t bytes) { 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 @@ class JitCompileTask FINAL : public Task { } 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 @@ void Jit::AddSamples(Thread* self, ArtMethod* method, uint16_t count, bool with_ (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 35656cd6f6..d3178b0b37 100644 --- a/runtime/jit/jit.h +++ b/runtime/jit/jit.h @@ -34,6 +34,11 @@ class ClassLinker; 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 2c6b249302..a26d8502a3 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -368,7 +368,7 @@ uint8_t* JitCodeCache::CommitCodeInternal(Thread* self, 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 @@ uint8_t* JitCodeCache::CommitCodeInternal(Thread* self, LOG(INFO) << "JIT allocated " << PrettySize(code_size) << " for compiled code of " - << PrettyMethod(method); + << ArtMethod::PrettyMethod(method); } } @@ -434,7 +434,7 @@ uint8_t* JitCodeCache::ReserveData(Thread* self, size_t size, ArtMethod* method) LOG(INFO) << "JIT allocated " << PrettySize(size) << " for stack maps of " - << PrettyMethod(method); + << ArtMethod::PrettyMethod(method); } return result; } @@ -806,7 +806,8 @@ OatQuickMethodHeader* JitCodeCache::LookupMethodHeader(uintptr_t pc, ArtMethod* } 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 @@ bool JitCodeCache::NotifyCompilationOf(ArtMethod* method, Thread* self, bool osr 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 aa606a26d3..f535151d38 100644 --- a/runtime/jit/offline_profiling_info.cc +++ b/runtime/jit/offline_profiling_info.cc @@ -629,7 +629,7 @@ std::string ProfileCompilationInfo::DumpInfo(const std::vector<const DexFile*>* 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 6ba187ec73..9ec46f0795 100644 --- a/runtime/jit/profiling_info.cc +++ b/runtime/jit/profiling_info.cc @@ -99,7 +99,7 @@ InlineCache* ProfilingInfo::GetInlineCache(uint32_t dex_pc) { 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 2cc7342ff8..004f824b9d 100644 --- a/runtime/jni_env_ext-inl.h +++ b/runtime/jni_env_ext-inl.h @@ -36,7 +36,7 @@ inline T JNIEnvExt::AddLocalReference(ObjPtr<mirror::Object> obj) { 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 3c749d0471..bae1567a1b 100644 --- a/runtime/jni_env_ext.cc +++ b/runtime/jni_env_ext.cc @@ -183,11 +183,11 @@ static std::string ComputeMonitorDescription(Thread* self, // 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 305a7e8d23..8238f3a556 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -110,7 +110,7 @@ static void ReportInvalidJNINativeMethod(const ScopedObjectAccess& soa, 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 jfieldID FindFieldID(const ScopedObjectAccess& soa, jclass jni_class, con 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 @@ int ThrowNewException(JNIEnv* env, jclass exception_class, const char* msg, jobj 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 @@ class JNI { 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 @@ class JNI { 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 @@ class JNI { 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 @@ class JNI { 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 @@ class JNI { 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 @@ class JNI { 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 @@ class JNI { 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 @@ class JNI { 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 @@ class JNI { 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 @@ class JNI { 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 @@ class JNI { 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 fbd670c048..61208e13ca 100644 --- a/runtime/jni_internal_test.cc +++ b/runtime/jni_internal_test.cc @@ -58,7 +58,7 @@ class JniInternalTest : public CommonCompilerTest { 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 f4fe9b20bd..0b0afe64a6 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 3789081c59..b11dad8203 100644 --- a/runtime/mirror/array-inl.h +++ b/runtime/mirror/array-inl.h @@ -168,7 +168,7 @@ inline Array* Array::Alloc(Thread* self, // 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 14bd243795..9992a9e29f 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -42,14 +42,14 @@ namespace mirror { 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 @@ template<VerifyObjectFlags kVerifyFlags> 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 void Class::SetEmbeddedVTableEntry(uint32_t i, ArtMethod* method, Pointer 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 @@ inline bool Class::Implements(ObjPtr<Class> klass) { // 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::CheckResolvedMethodAccess(ObjPtr<Class> access_to, } 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 bool Class::IsSubClass(ObjPtr<Class> klass) { 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 @@ inline uint32_t Class::GetAccessFlags() { 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 size_t Class::GetPrimitiveTypeSizeShift() { 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 bool Class::DescriptorEquals(const char* match) { 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 f93f72ff8b..6a357b3595 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -59,7 +59,7 @@ void Class::VisitRoots(RootVisitor* visitor) { } 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 @@ void Class::SetStatus(Handle<Class> h_this, Status new_status, Thread* self) { 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 @@ void Class::SetStatus(Handle<Class> h_this, Status new_status, Thread* self) { 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 @@ void Class::SetClassSize(uint32_t new_class_size) { 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 @@ String* Class::ComputeName(Handle<Class> h_this) { 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 @@ void Class::DumpClass(std::ostream& os, int flags) { 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 @@ void Class::DumpClass(std::ostream& os, int flags) { 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 @@ void Class::DumpClass(std::ostream& os, int flags) { 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 @@ static ArtField* FindFieldByNameAndType(LengthPrefixedArray<ArtField>* fields, 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 @@ ObjPtr<Class> Class::GetCommonSuperClass(Handle<Class> klass) { 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 @@ const DexFile::TypeList* Class::GetInterfaceTypeList() { 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 @@ void Class::SetObjectSizeAllocFastPath(uint32_t new_object_size) { } } +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 a5b61fdad3..57937950a6 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -1120,7 +1120,7 @@ class MANAGED Class FINAL : public Object { 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 @@ class MANAGED Class FINAL : public Object { 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 7ddadda06b..25cbdc131b 100644 --- a/runtime/mirror/method.cc +++ b/runtime/mirror/method.cc @@ -53,7 +53,7 @@ void Method::ResetArrayClass() { 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 @@ void Constructor::VisitRoots(RootVisitor* visitor) { 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 f555c80f50..2e70c9b43f 100644 --- a/runtime/mirror/object-inl.h +++ b/runtime/mirror/object-inl.h @@ -510,7 +510,7 @@ inline size_t Object::SizeOf() { 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 7e92c53a09..8cfb60e60e 100644 --- a/runtime/mirror/object.cc +++ b/runtime/mirror/object.cc @@ -266,7 +266,7 @@ void Object::CheckFieldAssignmentImpl(MemberOffset field_offset, ObjPtr<Object> } } 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* Object::FindFieldByOffset(MemberOffset offset) { : 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 13f402829c..f1ab72a989 100644 --- a/runtime/mirror/object.h +++ b/runtime/mirror/object.h @@ -544,6 +544,15 @@ class MANAGED LOCKABLE Object { // 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 3c2390b08d..5fb945958d 100644 --- a/runtime/mirror/object_array-inl.h +++ b/runtime/mirror/object_array-inl.h @@ -238,8 +238,8 @@ inline void ObjectArray<T>::AssignableCheckingMemcpy(int32_t dst_pos, } 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 60e2bf81e6..5bf254d961 100644 --- a/runtime/mirror/object_test.cc +++ b/runtime/mirror/object_test.cc @@ -337,7 +337,7 @@ TEST_F(ObjectTest, CreateMultiArray) { 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 cf902af0c0..d42bb9291b 100644 --- a/runtime/mirror/string-inl.h +++ b/runtime/mirror/string-inl.h @@ -232,7 +232,7 @@ inline String* String::Alloc(Thread* self, int32_t utf16_length_with_flag, 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 ed1103f46d..ea2660b967 100644 --- a/runtime/mirror/string.cc +++ b/runtime/mirror/string.cc @@ -365,5 +365,16 @@ bool String::IsValueNull() { 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 cfb1153bb3..a1b674a025 100644 --- a/runtime/mirror/string.h +++ b/runtime/mirror/string.h @@ -204,6 +204,14 @@ class MANAGED String FINAL : public Object { 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 7aff3deaa8..b866a63aef 100644 --- a/runtime/mirror/throwable.cc +++ b/runtime/mirror/throwable.cc @@ -83,7 +83,7 @@ int32_t Throwable::GetStackDepth() { } 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 @@ std::string Throwable::Dump() { 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 debbdd508d..eb74fcf7f4 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -307,7 +307,7 @@ std::string Monitor::PrettyContentionInfo(const std::string& owner_name, 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 @@ void Monitor::Lock(Thread* self) { 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 @@ void Monitor::Lock(Thread* self) { 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 @@ void Monitor::FailedUnlock(mirror::Object* o, 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 @@ void Monitor::FailedUnlock(mirror::Object* o, 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 @@ void Monitor::FailedUnlock(mirror::Object* o, " 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 @@ void Monitor::DescribeWait(std::ostream& os, const Thread* thread) { // 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 @@ void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::O // 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 @@ void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::O // 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 @@ void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::O 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 888fddb4fa..e6de097423 100644 --- a/runtime/native/dalvik_system_VMRuntime.cc +++ b/runtime/native/dalvik_system_VMRuntime.cc @@ -356,7 +356,6 @@ static void PreloadDexCachesResolveField(Handle<mirror::DexCache> dex_cache, uin if (field == nullptr) { return; } - // LOG(INFO) << "VMRuntime.preloadDexCaches resolved field " << PrettyField(field); dex_cache->SetResolvedField(field_idx, field, kRuntimePointerSize); } @@ -393,7 +392,6 @@ static void PreloadDexCachesResolveMethod(Handle<mirror::DexCache> dex_cache, ui 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 ac5dbdabf7..642826c621 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -633,7 +633,8 @@ static jobject Class_newInstance(JNIEnv* env, jobject javaThis) { 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 @@ static jobject Class_newInstance(JNIEnv* env, jobject javaThis) { 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 @@ static jobject Class_newInstance(JNIEnv* env, jobject javaThis) { 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 @@ static jobject Class_newInstance(JNIEnv* env, jobject javaThis) { 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 eaf2d65bab..7f8da80ff8 100644 --- a/runtime/native/java_lang_System.cc +++ b/runtime/native/java_lang_System.cc @@ -38,7 +38,7 @@ namespace art { 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 @@ static void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos, 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 1fe89bf2f8..ff082845e1 100644 --- a/runtime/native/java_lang_VMClassLoader.cc +++ b/runtime/native/java_lang_VMClassLoader.cc @@ -57,7 +57,7 @@ static jclass VMClassLoader_findLoadedClass(JNIEnv* env, jclass, jobject javaLoa 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 a81ba7d4fc..66a5359132 100644 --- a/runtime/native/java_lang_reflect_Constructor.cc +++ b/runtime/native/java_lang_reflect_Constructor.cc @@ -66,7 +66,7 @@ static jobject Constructor_newInstance0(JNIEnv* env, jobject javaMethod, jobject 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 @@ static jobject Constructor_newInstance0(JNIEnv* env, jobject javaMethod, jobject // 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 @@ static jobject Constructor_newInstance0(JNIEnv* env, jobject javaMethod, jobject } 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 a0a6a12505..1b128fb187 100644 --- a/runtime/native/java_lang_reflect_Executable.cc +++ b/runtime/native/java_lang_reflect_Executable.cc @@ -102,7 +102,7 @@ static jobjectArray Executable_getParameters0(JNIEnv* env, jobject javaMethod) { 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 @@ static jobjectArray Executable_getParameters0(JNIEnv* env, jobject javaMethod) { 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 90def4438f..329aae96ea 100644 --- a/runtime/native/java_lang_reflect_Field.cc +++ b/runtime/native/java_lang_reflect_Field.cc @@ -39,9 +39,9 @@ ALWAYS_INLINE inline static bool VerifyFieldAccess(Thread* self, 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 @@ ALWAYS_INLINE inline static bool VerifyFieldAccess(Thread* self, 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 @@ ALWAYS_INLINE inline static bool GetFieldValue(ObjPtr<mirror::Object> o, 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 @@ ALWAYS_INLINE inline static void SetFieldValue(ObjPtr<mirror::Object> o, 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 @@ static void SetPrimitiveField(JNIEnv* env, } 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 6060b8a2f6..16164d2f9b 100644 --- a/runtime/native/java_lang_reflect_Parameter.cc +++ b/runtime/native/java_lang_reflect_Parameter.cc @@ -47,7 +47,7 @@ static jobject Parameter_getAnnotationNative(JNIEnv* env, 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 059dc5adcb..5ab6097aa4 100644 --- a/runtime/native_bridge_art_interface.cc +++ b/runtime/native_bridge_art_interface.cc @@ -69,7 +69,8 @@ static uint32_t GetNativeMethods(JNIEnv* env, jclass clazz, JNINativeMethod* met 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 6b9468d3e1..00ab5771da 100644 --- a/runtime/native_stack_dump.cc +++ b/runtime/native_stack_dump.cc @@ -347,7 +347,7 @@ void DumpNativeStack(std::ostream& os, 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 64e5a638ab..68f71f77e6 100644 --- a/runtime/oat_file_manager.cc +++ b/runtime/oat_file_manager.cc @@ -297,7 +297,8 @@ static bool GetDexFilesFromClassLoader( // 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 @@ static void GetDexFilesFromDexElementsArray( } 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 @@ bool OatFileManager::HasCollisions(const OatFile* oat_file, 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 a68d9f8811..9c2378d42d 100644 --- a/runtime/oat_quick_method_header.cc +++ b/runtime/oat_quick_method_header.cc @@ -56,7 +56,7 @@ uint32_t OatQuickMethodHeader::ToDexPc(ArtMethod* method, << 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 @@ uintptr_t OatQuickMethodHeader::ToNativeQuickPc(ArtMethod* method, 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 9056d96f79..a81458fded 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -145,7 +145,7 @@ void QuickExceptionHandler::FindCatch(mirror::Throwable* exception) { 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 @@ void QuickExceptionHandler::FindCatch(mirror::Throwable* exception) { 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 @@ void QuickExceptionHandler::SetCatchEnvironmentForOptimizedHandler(StackVisitor* 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 @@ class DeoptimizeStackVisitor FINAL : public StackVisitor { 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 @@ class DumpFramesWithTypeStackVisitor FINAL : public StackVisitor { 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 @@ class DumpFramesWithTypeStackVisitor FINAL : public StackVisitor { 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 92efa211ce..67e5a81b29 100644 --- a/runtime/read_barrier-inl.h +++ b/runtime/read_barrier-inl.h @@ -231,7 +231,7 @@ inline bool ReadBarrier::HasGrayReadBarrierPointer(mirror::Object* obj, 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 a9f39d09b4..16ed7fb7ee 100644 --- a/runtime/reference_table.cc +++ b/runtime/reference_table.cc @@ -88,7 +88,7 @@ static void DumpSummaryLine(std::ostream& os, ObjPtr<mirror::Object> obj, size_t 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 @@ void ReferenceTable::Dump(std::ostream& os, Table& entries) { continue; } - std::string className(PrettyTypeOf(ref)); + std::string className(ref->PrettyTypeOf()); std::string extras; size_t element_count = GetElementCount(ref); @@ -197,7 +197,7 @@ void ReferenceTable::Dump(std::ostream& os, Table& entries) { 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 72db8272f2..661012c5d4 100644 --- a/runtime/reflection.cc +++ b/runtime/reflection.cc @@ -233,10 +233,10 @@ class ArgArray { 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 @@ class ArgArray { } 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 @@ static void CheckMethodArguments(JavaVMExt* vm, ArtMethod* m, uint32_t* args) (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 @@ static void CheckMethodArguments(JavaVMExt* vm, ArtMethod* m, uint32_t* args) 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 @@ static void CheckMethodArguments(JavaVMExt* vm, ArtMethod* m, uint32_t* args) // 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 @@ jobject InvokeMethod(const ScopedObjectAccessAlreadyRunnable& soa, jobject javaM 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 @@ ObjPtr<mirror::Object> BoxPrimitive(Primitive::Type src_class, const JValue& val 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 @@ static bool UnboxPrimitive(ObjPtr<mirror::Object> o, 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 @@ static bool UnboxPrimitive(ObjPtr<mirror::Object> o, } 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 @@ static bool UnboxPrimitive(ObjPtr<mirror::Object> o, 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 @@ bool VerifyAccess(ObjPtr<mirror::Object> obj, } 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 3b5360c61f..167a30ba2b 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -49,7 +49,7 @@ mirror::Object* ShadowFrame::GetThisObject() const { 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 @@ mirror::Object* StackVisitor::GetThisObject() const { 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 @@ bool StackVisitor::GetVRegFromOptimizedCode(ArtMethod* m, uint16_t vreg, VRegKin 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 @@ std::string StackVisitor::DescribeLocation() const { 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 @@ static void AssertPcIsWithinQuickCode(ArtMethod* method, uintptr_t pc) 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 @@ void StackVisitor::SanityCheckFrame() const { } } } - 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 @@ void StackVisitor::SanityCheckFrame() const { // 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 @@ QuickMethodFrameInfo StackVisitor::GetCurrentQuickFrameInfo() const { 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 @@ void StackVisitor::WalkStack(bool include_transitions) { } 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 @@ void StackVisitor::WalkStack(bool include_transitions) { 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 @@ void LockCountData::RemoveMonitorOrThrow(Thread* self, const mirror::Object* obj 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 @@ bool LockCountData::CheckAllMonitorsReleasedOrThrow(Thread* self) { 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 6acce273c9..39fe8d09c1 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -332,7 +332,7 @@ ShadowFrame* Thread::FindOrCreateDebuggerShadowFrame(size_t frame_id, 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 @@ struct StackDumpVisitor : public StackVisitor { 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 @@ struct StackDumpVisitor : public StackVisitor { // 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 @@ class MonitorExitVisitor : public SingleRootVisitor { 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 @@ class ReferenceMapVisitor : public StackVisitor { 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 @@ class ReferenceMapVisitor : public StackVisitor { 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 f846746779..f564de4952 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -641,7 +641,7 @@ void Trace::DumpBuf(uint8_t* buf, size_t buf_size, TraceClockSource clock_source 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 @@ void Trace::DexPcMoved(Thread* thread ATTRIBUTE_UNUSED, 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 @@ void Trace::FieldRead(Thread* thread ATTRIBUTE_UNUSED, 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 @@ void Trace::FieldWritten(Thread* thread ATTRIBUTE_UNUSED, 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::ExceptionCaught(Thread* thread ATTRIBUTE_UNUSED, 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 @@ void Trace::InvokeVirtualOrInterface(Thread*, 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 a40e313118..5557d5f950 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 @@ bool PrintFileToLog(const std::string& file_name, LogSeverity level) { } } -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 @@ std::string PrettyDescriptor(const char* descriptor) { 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 @@ std::string PrettyReturnType(const char* signature) { 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 @@ std::string DescriptorToName(const char* descriptor) { 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 @@ static void DumpMethodCFGImpl(const DexFile* dex_file, 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 @@ static void DumpMethodCFGImpl(const DexFile* dex_file, 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 ea9e8f7e32..f96ddd7829 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -40,16 +40,8 @@ class BacktraceMap; 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 @@ bool EndsWith(const std::string& s, const char* suffix); // 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 @@ bool IsValidDescriptor(const char* s); // "Ljava/lang/String;" // 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 @@ static inline constexpr bool ValidPointerSize(size_t pointer_size) { 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 ef4222285d..be4d394464 100644 --- a/runtime/utils_test.cc +++ b/runtime/utils_test.cc @@ -109,51 +109,52 @@ TEST_F(UtilsTest, PrettyReturnType) { 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 @@ TEST_F(UtilsTest, JniShortName_JniLongName) { 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 181673c27b..97bc79cfcc 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -141,13 +141,13 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(Thread* self, 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 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self, 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 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self, 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 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self, 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 @@ bool MethodVerifier::Verify() { } 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 @@ std::ostream& MethodVerifier::Fail(VerifyError error) { } } 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::Fail(VerifyError error) { } 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 @@ bool MethodVerifier::VerifyCodeFlow() { 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 @@ bool MethodVerifier::CodeFlowVerifyMethod() { 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 @@ bool MethodVerifier::CodeFlowVerifyMethod() { } } 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 @@ bool MethodVerifier::CodeFlowVerifyMethod() { << "-" << 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 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { 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 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { 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 @@ ArtMethod* MethodVerifier::ResolveMethodAndCheckAccess( 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 @@ ArtMethod* MethodVerifier::ResolveMethodAndCheckAccess( // 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 @@ ArtMethod* MethodVerifier::ResolveMethodAndCheckAccess( 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 @@ ArtMethod* MethodVerifier::ResolveMethodAndCheckAccess( // 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 @@ ArtMethod* MethodVerifier::ResolveMethodAndCheckAccess( 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 @@ ArtMethod* MethodVerifier::VerifyInvocationArgs( 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::GetQuickInvokedMethod(const Instruction* inst, Regist 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 @@ ArtMethod* MethodVerifier::VerifyInvokeVirtualQuickArgs(const Instruction* inst, 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 @@ ArtMethod* MethodVerifier::VerifyInvokeVirtualQuickArgs(const Instruction* inst, 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 @@ ArtMethod* MethodVerifier::VerifyInvokeVirtualQuickArgs(const Instruction* inst, 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 @@ ArtField* MethodVerifier::GetStaticField(int field_idx) { 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 @@ ArtField* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_id 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 @@ ArtField* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_id // 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 @@ ArtField* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_id // 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 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType& 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 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType& 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 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType& // 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 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType& // 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 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType& // 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 @@ ArtField* MethodVerifier::GetQuickFieldAccess(const Instruction* inst, 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 @@ void MethodVerifier::VerifyQuickFieldAccess(const Instruction* inst, const RegTy // 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 @@ void MethodVerifier::VerifyQuickFieldAccess(const Instruction* inst, const RegTy // 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 @@ void MethodVerifier::VerifyQuickFieldAccess(const Instruction* inst, const RegTy 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 @@ void MethodVerifier::VerifyQuickFieldAccess(const Instruction* inst, const RegTy // 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 626d9cf189..ab23773bc4 100644 --- a/runtime/verifier/reg_type.cc +++ b/runtime/verifier/reg_type.cc @@ -355,26 +355,26 @@ std::string UnresolvedUninitializedThisRefType::Dump() const { 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 @@ const RegType& RegType::Merge(const RegType& incoming_type, // 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 382314393f..3da1680c80 100644 --- a/runtime/verifier/register_line-inl.h +++ b/runtime/verifier/register_line-inl.h @@ -168,8 +168,7 @@ inline void RegisterLine::VerifyMonitorStackEmpty(MethodVerifier* verifier) cons 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 823336c3a7..4ec2da6e5a 100644 --- a/runtime/verifier/register_line.cc +++ b/runtime/verifier/register_line.cc @@ -33,8 +33,7 @@ bool RegisterLine::CheckConstructorReturn(MethodVerifier* verifier) const { 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 @@ void RegisterLine::PushMonitor(MethodVerifier* verifier, uint32_t reg_idx, int32 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 @@ void RegisterLine::PushMonitor(MethodVerifier* verifier, uint32_t reg_idx, int32 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 @@ void RegisterLine::PopMonitor(MethodVerifier* verifier, uint32_t reg_idx) { 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 @@ void RegisterLine::PopMonitor(MethodVerifier* verifier, uint32_t reg_idx) { 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 @@ bool RegisterLine::MergeRegisters(MethodVerifier* verifier, const RegisterLine* 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 @@ bool RegisterLine::MergeRegisters(MethodVerifier* verifier, const RegisterLine* 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 @@ bool RegisterLine::MergeRegisters(MethodVerifier* verifier, const RegisterLine* 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 3e1958f2ce..3c7fb7a26a 100644 --- a/runtime/verifier/verifier_deps.cc +++ b/runtime/verifier/verifier_deps.cc @@ -118,7 +118,7 @@ bool VerifierDeps::IsInClassPath(ObjPtr<mirror::Class> klass) { // 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; } |