diff options
author | 2018-07-18 10:58:13 +0100 | |
---|---|---|
committer | 2018-07-19 16:04:38 +0100 | |
commit | d93e374e273dd45f5d829399da1d4201bf46057e (patch) | |
tree | 280dc72b2aec4696bbc35ad39ca8d3479107380e | |
parent | 7f7f9d3991f3a55da8934a3b72890d4776373598 (diff) |
ObjPtr<>-ify ArtMethod and mirror::Method.
And clean up some forgotten things after old CLs.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 31113334
Change-Id: I8af0e845c24d674d0efab21d80c29949b1cc0593
28 files changed, 151 insertions, 136 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc index 70af49f8f0..f493b66cfd 100644 --- a/compiler/optimizing/instruction_simplifier.cc +++ b/compiler/optimizing/instruction_simplifier.cc @@ -2268,7 +2268,7 @@ void InstructionSimplifierVisitor::SimplifySystemArrayCopy(HInvoke* instruction) ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); PointerSize image_size = class_linker->GetImagePointerSize(); HInvokeStaticOrDirect* invoke = instruction->AsInvokeStaticOrDirect(); - mirror::Class* system = invoke->GetResolvedMethod()->GetDeclaringClass(); + ObjPtr<mirror::Class> system = invoke->GetResolvedMethod()->GetDeclaringClass(); ArtMethod* method = nullptr; switch (source_component_type) { case DataType::Type::kBool: diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc index f3fe62561f..0d622484ee 100644 --- a/compiler/optimizing/reference_type_propagation.cc +++ b/compiler/optimizing/reference_type_propagation.cc @@ -563,7 +563,7 @@ void ReferenceTypePropagation::RTPVisitor::SetClassAsTypeInfo(HInstruction* inst ArtMethod* method = cl->ResolveMethod<ClassLinker::ResolveMode::kNoChecks>( dex_method_index, dex_cache, loader, /* referrer */ nullptr, kDirect); DCHECK(method != nullptr); - mirror::Class* declaring_class = method->GetDeclaringClass(); + ObjPtr<mirror::Class> declaring_class = method->GetDeclaringClass(); DCHECK(declaring_class != nullptr); DCHECK(declaring_class->IsStringClass()) << "Expected String class: " << declaring_class->PrettyDescriptor(); @@ -572,7 +572,7 @@ void ReferenceTypePropagation::RTPVisitor::SetClassAsTypeInfo(HInstruction* inst } instr->SetReferenceTypeInfo( ReferenceTypeInfo::Create(handle_cache_->GetStringClassHandle(), /* is_exact */ true)); - } else if (IsAdmissible(klass.Ptr())) { + } else if (IsAdmissible(klass)) { ReferenceTypeInfo::TypeHandle handle = handle_cache_->NewHandle(klass); is_exact = is_exact || handle->CannotBeAssignedFromOtherTypes(); instr->SetReferenceTypeInfo(ReferenceTypeInfo::Create(handle, is_exact)); diff --git a/dex2oat/linker/image_writer.cc b/dex2oat/linker/image_writer.cc index de9c3d831d..467fa0f5d3 100644 --- a/dex2oat/linker/image_writer.cc +++ b/dex2oat/linker/image_writer.cc @@ -514,7 +514,7 @@ void ImageWriter::AddMethodPointerArray(mirror::PointerArray* arr) { for (size_t i = 0, len = arr->GetLength(); i < len; i++) { ArtMethod* method = arr->GetElementPtrSize<ArtMethod*>(i, target_ptr_size_); if (method != nullptr && !method->IsRuntimeMethod()) { - mirror::Class* klass = method->GetDeclaringClass(); + ObjPtr<mirror::Class> klass = method->GetDeclaringClass(); CHECK(klass == nullptr || KeepClass(klass)) << Class::PrettyClass(klass) << " should be a kept class"; } @@ -656,7 +656,7 @@ bool ImageWriter::WillMethodBeDirty(ArtMethod* m) const { if (m->IsNative()) { return true; } - mirror::Class* declaring_class = m->GetDeclaringClass(); + ObjPtr<mirror::Class> declaring_class = m->GetDeclaringClass(); // Initialized is highly unlikely to dirty since there's no entry points to mutate. return declaring_class == nullptr || declaring_class->GetStatus() != ClassStatus::kInitialized; } @@ -2617,7 +2617,7 @@ const uint8_t* ImageWriter::GetQuickCode(ArtMethod* method, method->GetEntryPointFromQuickCompiledCodePtrSize(target_ptr_size_); const uint8_t* quick_code; - if (UNLIKELY(IsInBootImage(method->GetDeclaringClass()))) { + if (UNLIKELY(IsInBootImage(method->GetDeclaringClass().Ptr()))) { DCHECK(method->IsCopied()); // If the code is not in the oat file corresponding to this image (e.g. default methods) quick_code = reinterpret_cast<const uint8_t*>(quick_oat_entry_point); diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc index 09a0d376e0..22e702415b 100644 --- a/dex2oat/linker/oat_writer.cc +++ b/dex2oat/linker/oat_writer.cc @@ -1570,7 +1570,9 @@ class OatWriter::InitImageMethodVisitor : public OatDexMethodVisitor { // Find origin method. Declaring class and dex_method_idx // in the copied method should be the same as in the origin // method. - mirror::Class* declaring_class = method.GetDeclaringClass(); + // FIXME: Cannot use ObjPtr<> for declaring class because origin->IsDirect() + // invalidates ObjPtr<> cookie for kCheckDeclaringClassState == true. + mirror::Class* declaring_class = method.GetDeclaringClass().Ptr(); ArtMethod* origin = declaring_class->FindClassMethod( declaring_class->GetDexCache(), method.GetDexMethodIndex(), diff --git a/imgdiag/imgdiag.cc b/imgdiag/imgdiag.cc index 24ee0892dc..f54c55153a 100644 --- a/imgdiag/imgdiag.cc +++ b/imgdiag/imgdiag.cc @@ -167,14 +167,15 @@ static std::vector<std::pair<V, K>> SortByValueDesc( // Fixup a remote pointer that we read from a foreign boot.art to point to our own memory. // Returned pointer will point to inside of remote_contents. template <typename T> -static T* FixUpRemotePointer(T* remote_ptr, - std::vector<uint8_t>& remote_contents, - const backtrace_map_t& boot_map) { +static ObjPtr<T> FixUpRemotePointer(ObjPtr<T> remote_ptr, + std::vector<uint8_t>& remote_contents, + const backtrace_map_t& boot_map) + REQUIRES_SHARED(Locks::mutator_lock_) { if (remote_ptr == nullptr) { return nullptr; } - uintptr_t remote = reinterpret_cast<uintptr_t>(remote_ptr); + uintptr_t remote = reinterpret_cast<uintptr_t>(remote_ptr.Ptr()); // In the case the remote pointer is out of range, it probably belongs to another image. // Just return null for this case. @@ -188,14 +189,15 @@ static T* FixUpRemotePointer(T* remote_ptr, } template <typename T> -static T* RemoteContentsPointerToLocal(T* remote_ptr, - std::vector<uint8_t>& remote_contents, - const ImageHeader& image_header) { +static ObjPtr<T> RemoteContentsPointerToLocal(ObjPtr<T> remote_ptr, + std::vector<uint8_t>& remote_contents, + const ImageHeader& image_header) + REQUIRES_SHARED(Locks::mutator_lock_) { if (remote_ptr == nullptr) { return nullptr; } - uint8_t* remote = reinterpret_cast<uint8_t*>(remote_ptr); + uint8_t* remote = reinterpret_cast<uint8_t*>(remote_ptr.Ptr()); ptrdiff_t boot_offset = remote - &remote_contents[0]; const uint8_t* local_ptr = reinterpret_cast<const uint8_t*>(&image_header) + boot_offset; @@ -534,9 +536,10 @@ class RegionSpecializedBase<mirror::Object> : public RegionCommon<mirror::Object os_ << " field contents:\n"; for (mirror::Object* object : class_data.dirty_objects) { // remote class object - auto remote_klass = reinterpret_cast<mirror::Class*>(object); + ObjPtr<mirror::Class> remote_klass = + ObjPtr<mirror::Class>::DownCast<mirror::Object>(object); // local class object - auto local_klass = + ObjPtr<mirror::Class> local_klass = RemoteContentsPointerToLocal(remote_klass, *RegionCommon<mirror::Object>::remote_contents_, RegionCommon<mirror::Object>::image_header_); @@ -797,12 +800,12 @@ class RegionSpecializedBase<ArtMethod> : public RegionCommon<ArtMethod> { // remote method auto art_method = reinterpret_cast<ArtMethod*>(method); // remote class - mirror::Class* remote_declaring_class = + ObjPtr<mirror::Class> remote_declaring_class = FixUpRemotePointer(art_method->GetDeclaringClass(), *RegionCommon<ArtMethod>::remote_contents_, RegionCommon<ArtMethod>::boot_map_); // local class - mirror::Class* declaring_class = + ObjPtr<mirror::Class> declaring_class = RemoteContentsPointerToLocal(remote_declaring_class, *RegionCommon<ArtMethod>::remote_contents_, RegionCommon<ArtMethod>::image_header_); @@ -815,7 +818,7 @@ class RegionSpecializedBase<ArtMethod> : public RegionCommon<ArtMethod> { os_ << " field contents:\n"; for (ArtMethod* method : false_dirty_entries_) { // local class - mirror::Class* declaring_class = method->GetDeclaringClass(); + ObjPtr<mirror::Class> declaring_class = method->GetDeclaringClass(); DumpOneArtMethod(method, declaring_class, nullptr); } } @@ -905,8 +908,8 @@ class RegionSpecializedBase<ArtMethod> : public RegionCommon<ArtMethod> { } void DumpOneArtMethod(ArtMethod* art_method, - mirror::Class* declaring_class, - mirror::Class* remote_declaring_class) + ObjPtr<mirror::Class> declaring_class, + ObjPtr<mirror::Class> remote_declaring_class) REQUIRES_SHARED(Locks::mutator_lock_) { PointerSize pointer_size = InstructionSetPointerSize(Runtime::Current()->GetInstructionSet()); os_ << " " << reinterpret_cast<const void*>(art_method) << " "; diff --git a/openjdkjvmti/ti_method.cc b/openjdkjvmti/ti_method.cc index 9f9dace4f7..87d832caec 100644 --- a/openjdkjvmti/ti_method.cc +++ b/openjdkjvmti/ti_method.cc @@ -384,7 +384,7 @@ jvmtiError MethodUtil::GetMethodDeclaringClass(jvmtiEnv* env ATTRIBUTE_UNUSED, // Note: No GetInterfaceMethodIfProxy, we want to actual class. art::ScopedObjectAccess soa(art::Thread::Current()); - art::mirror::Class* klass = art_method->GetDeclaringClass(); + art::ObjPtr<art::mirror::Class> klass = art_method->GetDeclaringClass(); *declaring_class_ptr = soa.AddLocalReference<jclass>(klass); return ERR(NONE); diff --git a/openjdkjvmti/ti_redefine.cc b/openjdkjvmti/ti_redefine.cc index 50d8dfeb70..4de42ac669 100644 --- a/openjdkjvmti/ti_redefine.cc +++ b/openjdkjvmti/ti_redefine.cc @@ -569,9 +569,10 @@ void DoAllocateObsoleteMethodsCallback(art::Thread* t, void* vdata) NO_THREAD_SA // This creates any ArtMethod* structures needed for obsolete methods and ensures that the stack is // updated so they will be run. // TODO Rewrite so we can do this only once regardless of how many redefinitions there are. -void Redefiner::ClassRedefinition::FindAndAllocateObsoleteMethods(art::mirror::Class* art_klass) { +void Redefiner::ClassRedefinition::FindAndAllocateObsoleteMethods( + art::ObjPtr<art::mirror::Class> art_klass) { art::ScopedAssertNoThreadSuspension ns("No thread suspension during thread stack walking"); - art::mirror::ClassExt* ext = art_klass->GetExtData(); + art::ObjPtr<art::mirror::ClassExt> ext = art_klass->GetExtData(); CHECK(ext->GetObsoleteMethods() != nullptr); art::ClassLinker* linker = driver_->runtime_->GetClassLinker(); // This holds pointers to the obsolete methods map fields which are updated as needed. @@ -873,73 +874,76 @@ class RedefinitionDataHolder { return arr_.IsNull(); } - art::mirror::ClassLoader* GetSourceClassLoader(jint klass_index) const + art::ObjPtr<art::mirror::ClassLoader> GetSourceClassLoader(jint klass_index) const REQUIRES_SHARED(art::Locks::mutator_lock_) { - return art::down_cast<art::mirror::ClassLoader*>(GetSlot(klass_index, kSlotSourceClassLoader)); + return art::ObjPtr<art::mirror::ClassLoader>::DownCast( + GetSlot(klass_index, kSlotSourceClassLoader)); } - art::mirror::Object* GetJavaDexFile(jint klass_index) const + art::ObjPtr<art::mirror::Object> GetJavaDexFile(jint klass_index) const REQUIRES_SHARED(art::Locks::mutator_lock_) { return GetSlot(klass_index, kSlotJavaDexFile); } - art::mirror::LongArray* GetNewDexFileCookie(jint klass_index) const + art::ObjPtr<art::mirror::LongArray> GetNewDexFileCookie(jint klass_index) const REQUIRES_SHARED(art::Locks::mutator_lock_) { - return art::down_cast<art::mirror::LongArray*>(GetSlot(klass_index, kSlotNewDexFileCookie)); + return art::ObjPtr<art::mirror::LongArray>::DownCast( + GetSlot(klass_index, kSlotNewDexFileCookie)); } - art::mirror::DexCache* GetNewDexCache(jint klass_index) const + art::ObjPtr<art::mirror::DexCache> GetNewDexCache(jint klass_index) const REQUIRES_SHARED(art::Locks::mutator_lock_) { - return art::down_cast<art::mirror::DexCache*>(GetSlot(klass_index, kSlotNewDexCache)); + return art::ObjPtr<art::mirror::DexCache>::DownCast(GetSlot(klass_index, kSlotNewDexCache)); } - art::mirror::Class* GetMirrorClass(jint klass_index) const + art::ObjPtr<art::mirror::Class> GetMirrorClass(jint klass_index) const REQUIRES_SHARED(art::Locks::mutator_lock_) { - return art::down_cast<art::mirror::Class*>(GetSlot(klass_index, kSlotMirrorClass)); + return art::ObjPtr<art::mirror::Class>::DownCast(GetSlot(klass_index, kSlotMirrorClass)); } - art::mirror::Object* GetOriginalDexFile(jint klass_index) const + art::ObjPtr<art::mirror::Object> GetOriginalDexFile(jint klass_index) const REQUIRES_SHARED(art::Locks::mutator_lock_) { - return art::down_cast<art::mirror::Object*>(GetSlot(klass_index, kSlotOrigDexFile)); + return art::ObjPtr<art::mirror::Object>::DownCast(GetSlot(klass_index, kSlotOrigDexFile)); } - art::mirror::PointerArray* GetOldObsoleteMethods(jint klass_index) const + art::ObjPtr<art::mirror::PointerArray> GetOldObsoleteMethods(jint klass_index) const REQUIRES_SHARED(art::Locks::mutator_lock_) { - return art::down_cast<art::mirror::PointerArray*>( + return art::ObjPtr<art::mirror::PointerArray>::DownCast( GetSlot(klass_index, kSlotOldObsoleteMethods)); } - art::mirror::ObjectArray<art::mirror::DexCache>* GetOldDexCaches(jint klass_index) const - REQUIRES_SHARED(art::Locks::mutator_lock_) { - return art::down_cast<art::mirror::ObjectArray<art::mirror::DexCache>*>( + art::ObjPtr<art::mirror::ObjectArray<art::mirror::DexCache>> GetOldDexCaches( + jint klass_index) const REQUIRES_SHARED(art::Locks::mutator_lock_) { + return art::ObjPtr<art::mirror::ObjectArray<art::mirror::DexCache>>::DownCast( GetSlot(klass_index, kSlotOldDexCaches)); } - void SetSourceClassLoader(jint klass_index, art::mirror::ClassLoader* loader) + void SetSourceClassLoader(jint klass_index, art::ObjPtr<art::mirror::ClassLoader> loader) REQUIRES_SHARED(art::Locks::mutator_lock_) { SetSlot(klass_index, kSlotSourceClassLoader, loader); } - void SetJavaDexFile(jint klass_index, art::mirror::Object* dexfile) + void SetJavaDexFile(jint klass_index, art::ObjPtr<art::mirror::Object> dexfile) REQUIRES_SHARED(art::Locks::mutator_lock_) { SetSlot(klass_index, kSlotJavaDexFile, dexfile); } - void SetNewDexFileCookie(jint klass_index, art::mirror::LongArray* cookie) + void SetNewDexFileCookie(jint klass_index, art::ObjPtr<art::mirror::LongArray> cookie) REQUIRES_SHARED(art::Locks::mutator_lock_) { SetSlot(klass_index, kSlotNewDexFileCookie, cookie); } - void SetNewDexCache(jint klass_index, art::mirror::DexCache* cache) + void SetNewDexCache(jint klass_index, art::ObjPtr<art::mirror::DexCache> cache) REQUIRES_SHARED(art::Locks::mutator_lock_) { SetSlot(klass_index, kSlotNewDexCache, cache); } - void SetMirrorClass(jint klass_index, art::mirror::Class* klass) + void SetMirrorClass(jint klass_index, art::ObjPtr<art::mirror::Class> klass) REQUIRES_SHARED(art::Locks::mutator_lock_) { SetSlot(klass_index, kSlotMirrorClass, klass); } - void SetOriginalDexFile(jint klass_index, art::mirror::Object* bytes) + void SetOriginalDexFile(jint klass_index, art::ObjPtr<art::mirror::Object> bytes) REQUIRES_SHARED(art::Locks::mutator_lock_) { SetSlot(klass_index, kSlotOrigDexFile, bytes); } - void SetOldObsoleteMethods(jint klass_index, art::mirror::PointerArray* methods) + void SetOldObsoleteMethods(jint klass_index, art::ObjPtr<art::mirror::PointerArray> methods) REQUIRES_SHARED(art::Locks::mutator_lock_) { SetSlot(klass_index, kSlotOldObsoleteMethods, methods); } - void SetOldDexCaches(jint klass_index, art::mirror::ObjectArray<art::mirror::DexCache>* caches) + void SetOldDexCaches(jint klass_index, + art::ObjPtr<art::mirror::ObjectArray<art::mirror::DexCache>> caches) REQUIRES_SHARED(art::Locks::mutator_lock_) { SetSlot(klass_index, kSlotOldDexCaches, caches); } @@ -970,8 +974,8 @@ class RedefinitionDataHolder { mutable art::Handle<art::mirror::ObjectArray<art::mirror::Object>> arr_; std::vector<Redefiner::ClassRedefinition>* redefinitions_; - art::mirror::Object* GetSlot(jint klass_index, - DataSlot slot) const REQUIRES_SHARED(art::Locks::mutator_lock_) { + art::ObjPtr<art::mirror::Object> GetSlot(jint klass_index, DataSlot slot) const + REQUIRES_SHARED(art::Locks::mutator_lock_) { DCHECK_LT(klass_index, Length()); return arr_->Get((kNumSlots * klass_index) + slot); } @@ -1036,31 +1040,35 @@ class RedefinitionDataIter { return holder_; } - art::mirror::ClassLoader* GetSourceClassLoader() const + art::ObjPtr<art::mirror::ClassLoader> GetSourceClassLoader() const REQUIRES_SHARED(art::Locks::mutator_lock_) { return holder_.GetSourceClassLoader(idx_); } - art::mirror::Object* GetJavaDexFile() const REQUIRES_SHARED(art::Locks::mutator_lock_) { + art::ObjPtr<art::mirror::Object> GetJavaDexFile() const + REQUIRES_SHARED(art::Locks::mutator_lock_) { return holder_.GetJavaDexFile(idx_); } - art::mirror::LongArray* GetNewDexFileCookie() const REQUIRES_SHARED(art::Locks::mutator_lock_) { + art::ObjPtr<art::mirror::LongArray> GetNewDexFileCookie() const + REQUIRES_SHARED(art::Locks::mutator_lock_) { return holder_.GetNewDexFileCookie(idx_); } - art::mirror::DexCache* GetNewDexCache() const REQUIRES_SHARED(art::Locks::mutator_lock_) { + art::ObjPtr<art::mirror::DexCache> GetNewDexCache() const + REQUIRES_SHARED(art::Locks::mutator_lock_) { return holder_.GetNewDexCache(idx_); } - art::mirror::Class* GetMirrorClass() const REQUIRES_SHARED(art::Locks::mutator_lock_) { + art::ObjPtr<art::mirror::Class> GetMirrorClass() const + REQUIRES_SHARED(art::Locks::mutator_lock_) { return holder_.GetMirrorClass(idx_); } - art::mirror::Object* GetOriginalDexFile() const + art::ObjPtr<art::mirror::Object> GetOriginalDexFile() const REQUIRES_SHARED(art::Locks::mutator_lock_) { return holder_.GetOriginalDexFile(idx_); } - art::mirror::PointerArray* GetOldObsoleteMethods() const + art::ObjPtr<art::mirror::PointerArray> GetOldObsoleteMethods() const REQUIRES_SHARED(art::Locks::mutator_lock_) { return holder_.GetOldObsoleteMethods(idx_); } - art::mirror::ObjectArray<art::mirror::DexCache>* GetOldDexCaches() const + art::ObjPtr<art::mirror::ObjectArray<art::mirror::DexCache>> GetOldDexCaches() const REQUIRES_SHARED(art::Locks::mutator_lock_) { return holder_.GetOldDexCaches(idx_); } @@ -1073,28 +1081,31 @@ class RedefinitionDataIter { REQUIRES_SHARED(art::Locks::mutator_lock_) { holder_.SetSourceClassLoader(idx_, loader); } - void SetJavaDexFile(art::mirror::Object* dexfile) REQUIRES_SHARED(art::Locks::mutator_lock_) { + void SetJavaDexFile(art::ObjPtr<art::mirror::Object> dexfile) + REQUIRES_SHARED(art::Locks::mutator_lock_) { holder_.SetJavaDexFile(idx_, dexfile); } - void SetNewDexFileCookie(art::mirror::LongArray* cookie) + void SetNewDexFileCookie(art::ObjPtr<art::mirror::LongArray> cookie) REQUIRES_SHARED(art::Locks::mutator_lock_) { holder_.SetNewDexFileCookie(idx_, cookie); } - void SetNewDexCache(art::mirror::DexCache* cache) REQUIRES_SHARED(art::Locks::mutator_lock_) { + void SetNewDexCache(art::ObjPtr<art::mirror::DexCache> cache) + REQUIRES_SHARED(art::Locks::mutator_lock_) { holder_.SetNewDexCache(idx_, cache); } - void SetMirrorClass(art::mirror::Class* klass) REQUIRES_SHARED(art::Locks::mutator_lock_) { + void SetMirrorClass(art::ObjPtr<art::mirror::Class> klass) + REQUIRES_SHARED(art::Locks::mutator_lock_) { holder_.SetMirrorClass(idx_, klass); } - void SetOriginalDexFile(art::mirror::Object* bytes) + void SetOriginalDexFile(art::ObjPtr<art::mirror::Object> bytes) REQUIRES_SHARED(art::Locks::mutator_lock_) { holder_.SetOriginalDexFile(idx_, bytes); } - void SetOldObsoleteMethods(art::mirror::PointerArray* methods) + void SetOldObsoleteMethods(art::ObjPtr<art::mirror::PointerArray> methods) REQUIRES_SHARED(art::Locks::mutator_lock_) { holder_.SetOldObsoleteMethods(idx_, methods); } - void SetOldDexCaches(art::mirror::ObjectArray<art::mirror::DexCache>* caches) + void SetOldDexCaches(art::ObjPtr<art::mirror::ObjectArray<art::mirror::DexCache>> caches) REQUIRES_SHARED(art::Locks::mutator_lock_) { holder_.SetOldDexCaches(idx_, caches); } @@ -1378,7 +1389,7 @@ jvmtiError Redefiner::Run() { if (data.GetSourceClassLoader() != nullptr) { ClassLoaderHelper::UpdateJavaDexFile(data.GetJavaDexFile(), data.GetNewDexFileCookie()); } - art::mirror::Class* klass = data.GetMirrorClass(); + art::ObjPtr<art::mirror::Class> klass = data.GetMirrorClass(); // TODO Rewrite so we don't do a stack walk for each and every class. redef.FindAndAllocateObsoleteMethods(klass); redef.UpdateClass(klass, data.GetNewDexCache(), data.GetOriginalDexFile()); @@ -1492,10 +1503,10 @@ void Redefiner::ClassRedefinition::UpdateClass( // obsolete methods). void Redefiner::ClassRedefinition::RestoreObsoleteMethodMapsIfUnneeded( const RedefinitionDataIter* cur_data) { - art::mirror::Class* klass = GetMirrorClass(); - art::mirror::ClassExt* ext = klass->GetExtData(); - art::mirror::PointerArray* methods = ext->GetObsoleteMethods(); - art::mirror::PointerArray* old_methods = cur_data->GetOldObsoleteMethods(); + art::ObjPtr<art::mirror::Class> klass = GetMirrorClass(); + art::ObjPtr<art::mirror::ClassExt> ext = klass->GetExtData(); + art::ObjPtr<art::mirror::PointerArray> methods = ext->GetObsoleteMethods(); + art::ObjPtr<art::mirror::PointerArray> old_methods = cur_data->GetOldObsoleteMethods(); int32_t old_length = old_methods == nullptr ? 0 : old_methods->GetLength(); int32_t expected_length = old_length + klass->NumDirectMethods() + klass->NumDeclaredVirtualMethods(); diff --git a/openjdkjvmti/ti_redefine.h b/openjdkjvmti/ti_redefine.h index e337491ae3..6d8f6bf0db 100644 --- a/openjdkjvmti/ti_redefine.h +++ b/openjdkjvmti/ti_redefine.h @@ -136,7 +136,7 @@ class Redefiner { /*out*/RedefinitionDataIter* cur_data) REQUIRES_SHARED(art::Locks::mutator_lock_); - void FindAndAllocateObsoleteMethods(art::mirror::Class* art_klass) + void FindAndAllocateObsoleteMethods(art::ObjPtr<art::mirror::Class> art_klass) REQUIRES(art::Locks::mutator_lock_); // Checks that the dex file contains only the single expected class and that the top-level class diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index 97b315e85c..9b9cfbaf90 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -1072,7 +1072,7 @@ void PatchOat::FixupMethod(ArtMethod* object, ArtMethod* copy) { copy->CopyFrom(object, pointer_size); // Just update the entry points if it looks like we should. // TODO: sanity check all the pointers' values - copy->SetDeclaringClass(RelocatedAddressOfPointer(object->GetDeclaringClass())); + copy->SetDeclaringClass(RelocatedAddressOfPointer(object->GetDeclaringClass().Ptr())); copy->SetEntryPointFromQuickCompiledCodePtrSize(RelocatedAddressOfPointer( object->GetEntryPointFromQuickCompiledCodePtrSize(pointer_size)), pointer_size); // No special handling for IMT conflict table since all pointers are moved by the same offset. diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h index 18595cf17a..9da4a39017 100644 --- a/runtime/art_method-inl.h +++ b/runtime/art_method-inl.h @@ -49,14 +49,14 @@ namespace art { template <ReadBarrierOption kReadBarrierOption> -inline mirror::Class* ArtMethod::GetDeclaringClassUnchecked() { +inline ObjPtr<mirror::Class> ArtMethod::GetDeclaringClassUnchecked() { GcRootSource gc_root_source(this); return declaring_class_.Read<kReadBarrierOption>(&gc_root_source); } template <ReadBarrierOption kReadBarrierOption> -inline mirror::Class* ArtMethod::GetDeclaringClass() { - mirror::Class* result = GetDeclaringClassUnchecked<kReadBarrierOption>(); +inline ObjPtr<mirror::Class> ArtMethod::GetDeclaringClass() { + ObjPtr<mirror::Class> result = GetDeclaringClassUnchecked<kReadBarrierOption>(); if (kIsDebugBuild) { if (!IsRuntimeMethod()) { CHECK(result != nullptr) << this; @@ -77,8 +77,8 @@ inline void ArtMethod::SetDeclaringClass(ObjPtr<mirror::Class> new_declaring_cla declaring_class_ = GcRoot<mirror::Class>(new_declaring_class); } -inline bool ArtMethod::CASDeclaringClass(mirror::Class* expected_class, - mirror::Class* desired_class) { +inline bool ArtMethod::CASDeclaringClass(ObjPtr<mirror::Class> expected_class, + ObjPtr<mirror::Class> desired_class) { GcRoot<mirror::Class> expected_root(expected_class); GcRoot<mirror::Class> desired_root(desired_class); auto atomic_root_class = reinterpret_cast<Atomic<GcRoot<mirror::Class>>*>(&declaring_class_); @@ -127,14 +127,14 @@ inline bool ArtMethod::CheckIncompatibleClassChange(InvokeType type) { case kVirtual: { // We have an error if we are direct or a non-copied (i.e. not part of a real class) interface // method. - mirror::Class* methods_class = GetDeclaringClass(); + ObjPtr<mirror::Class> methods_class = GetDeclaringClass(); return IsDirect() || (methods_class->IsInterface() && !IsCopied()); } case kSuper: // Constructors and static methods are called with invoke-direct. return IsConstructor() || IsStatic(); case kInterface: { - mirror::Class* methods_class = GetDeclaringClass(); + ObjPtr<mirror::Class> methods_class = GetDeclaringClass(); return IsDirect() || !(methods_class->IsInterface() || methods_class->IsObjectClass()); } default: @@ -509,7 +509,7 @@ template<ReadBarrierOption kReadBarrierOption, typename RootVisitorType> void ArtMethod::VisitRoots(RootVisitorType& visitor, PointerSize pointer_size) { if (LIKELY(!declaring_class_.IsNull())) { visitor.VisitRoot(declaring_class_.AddressWithoutBarrier()); - mirror::Class* klass = declaring_class_.Read<kReadBarrierOption>(); + ObjPtr<mirror::Class> klass = declaring_class_.Read<kReadBarrierOption>(); if (UNLIKELY(klass->IsProxyClass())) { // For normal methods, dex cache shortcuts will be visited through the declaring class. // However, for proxies we need to keep the interface method alive, so we visit its roots. @@ -522,8 +522,8 @@ void ArtMethod::VisitRoots(RootVisitorType& visitor, PointerSize pointer_size) { template <typename Visitor> inline void ArtMethod::UpdateObjectsForImageRelocation(const Visitor& visitor) { - mirror::Class* old_class = GetDeclaringClassUnchecked<kWithoutReadBarrier>(); - mirror::Class* new_class = visitor(old_class); + ObjPtr<mirror::Class> old_class = GetDeclaringClassUnchecked<kWithoutReadBarrier>(); + ObjPtr<mirror::Class> new_class = visitor(old_class.Ptr()); if (old_class != new_class) { SetDeclaringClass(new_class); } diff --git a/runtime/art_method.h b/runtime/art_method.h index 09debb0c50..f5ef3fa4c3 100644 --- a/runtime/art_method.h +++ b/runtime/art_method.h @@ -87,10 +87,10 @@ class ArtMethod FINAL { REQUIRES_SHARED(Locks::mutator_lock_); template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier> - ALWAYS_INLINE mirror::Class* GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_); + ALWAYS_INLINE ObjPtr<mirror::Class> GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_); template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier> - ALWAYS_INLINE mirror::Class* GetDeclaringClassUnchecked() + ALWAYS_INLINE ObjPtr<mirror::Class> GetDeclaringClassUnchecked() REQUIRES_SHARED(Locks::mutator_lock_); mirror::CompressedReference<mirror::Object>* GetDeclaringClassAddressWithoutBarrier() { @@ -100,7 +100,7 @@ class ArtMethod FINAL { void SetDeclaringClass(ObjPtr<mirror::Class> new_declaring_class) REQUIRES_SHARED(Locks::mutator_lock_); - bool CASDeclaringClass(mirror::Class* expected_class, mirror::Class* desired_class) + bool CASDeclaringClass(ObjPtr<mirror::Class> expected_class, ObjPtr<mirror::Class> desired_class) REQUIRES_SHARED(Locks::mutator_lock_); static MemberOffset DeclaringClassOffset() { @@ -395,10 +395,10 @@ class ArtMethod FINAL { dex_method_index_ = new_idx; } - // Lookup the Class* from the type index into this method's dex cache. + // Lookup the Class from the type index into this method's dex cache. ObjPtr<mirror::Class> LookupResolvedClassFromTypeIndex(dex::TypeIndex type_idx) REQUIRES_SHARED(Locks::mutator_lock_); - // Resolve the Class* from the type index into this method's dex cache. + // Resolve the Class from the type index into this method's dex cache. ObjPtr<mirror::Class> ResolveClassFromTypeIndex(dex::TypeIndex type_idx) REQUIRES_SHARED(Locks::mutator_lock_); diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 966d636f62..f80d34ca2f 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -7150,7 +7150,7 @@ ObjPtr<mirror::PointerArray> ClassLinker::LinkInterfaceMethodsHelper::UpdateVtab vtable->SetElementPtrSize(i, translated_method, pointer_size); } } - klass_->SetVTable(vtable.Ptr()); + klass_->SetVTable(vtable); return vtable; } @@ -8760,7 +8760,7 @@ void ClassLinker::VisitClassLoaders(ClassLoaderVisitor* visitor) const { ObjPtr<mirror::ClassLoader> class_loader = ObjPtr<mirror::ClassLoader>::DownCast( self->DecodeJObject(data.weak_root)); if (class_loader != nullptr) { - visitor->Visit(class_loader.Ptr()); + visitor->Visit(class_loader); } } } diff --git a/runtime/debugger.cc b/runtime/debugger.cc index f75f47c075..e607b31e68 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -1484,7 +1484,7 @@ void Dbg::SetJdwpLocation(JDWP::JdwpLocation* location, ArtMethod* m, uint32_t d if (m == nullptr) { memset(location, 0, sizeof(*location)); } else { - mirror::Class* c = m->GetDeclaringClass(); + ObjPtr<mirror::Class> c = m->GetDeclaringClass(); location->type_tag = GetTypeTag(c); location->class_id = gRegistry->AddRefType(c); // The RI Seems to return 0 for all obsolete methods. For compatibility we shall do the same. diff --git a/runtime/dex/dex_file_annotations.cc b/runtime/dex/dex_file_annotations.cc index 9358cbe5a9..b87bf8db1f 100644 --- a/runtime/dex/dex_file_annotations.cc +++ b/runtime/dex/dex_file_annotations.cc @@ -728,7 +728,7 @@ ObjPtr<mirror::Object> CreateAnnotationMember(const ClassData& klass, ObjPtr<mirror::Class> annotation_member_class = WellKnownClasses::ToClass(WellKnownClasses::libcore_reflect_AnnotationMember); Handle<mirror::Object> new_member(hs.NewHandle(annotation_member_class->AllocObject(self))); - mirror::Method* method_obj_ptr; + ObjPtr<mirror::Method> method_obj_ptr; DCHECK(!Runtime::Current()->IsActiveTransaction()); if (pointer_size == PointerSize::k64) { method_obj_ptr = mirror::Method::CreateFromArtMethod<PointerSize::k64, false>( diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h index 40ef10f904..0ed26d37c0 100644 --- a/runtime/entrypoints/entrypoint_utils-inl.h +++ b/runtime/entrypoints/entrypoint_utils-inl.h @@ -255,7 +255,7 @@ inline mirror::Class* CheckArrayAlloc(dex::TypeIndex type_idx, CHECK(klass->IsArrayClass()) << klass->PrettyClass(); } if (kAccessCheck) { - mirror::Class* referrer = method->GetDeclaringClass(); + ObjPtr<mirror::Class> referrer = method->GetDeclaringClass(); if (UNLIKELY(!referrer->CanAccess(klass))) { ThrowIllegalAccessErrorClass(referrer, klass); *slow_path = true; @@ -366,7 +366,7 @@ inline ArtField* FindFieldFromCode(uint32_t field_idx, ThrowIncompatibleClassChangeErrorField(resolved_field, is_static, referrer); return nullptr; } - mirror::Class* referring_class = referrer->GetDeclaringClass(); + ObjPtr<mirror::Class> referring_class = referrer->GetDeclaringClass(); if (UNLIKELY(!referring_class->CheckResolvedFieldAccess(fields_class, resolved_field, referrer->GetDexCache(), @@ -721,7 +721,7 @@ inline ObjPtr<mirror::Class> ResolveVerifyAndClinit(dex::TypeIndex type_idx, return nullptr; // Failure - Indicate to caller to deliver exception } // Perform access check if necessary. - mirror::Class* referring_class = referrer->GetDeclaringClass(); + ObjPtr<mirror::Class> referring_class = referrer->GetDeclaringClass(); if (verify_access && UNLIKELY(!referring_class->CanAccess(klass))) { ThrowIllegalAccessErrorClass(referring_class, klass); return nullptr; // Failure - Indicate to caller to deliver exception diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc index 505e183ced..9cae3aef1c 100644 --- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -2146,7 +2146,7 @@ class BuildGenericJniFrameVisitor FINAL : public QuickArgumentVisitor { sm_.AdvancePointer(self->GetJniEnv()); if (is_static) { - sm_.AdvanceHandleScope((**sp)->GetDeclaringClass()); + sm_.AdvanceHandleScope((**sp)->GetDeclaringClass().Ptr()); } // else "this" reference is already handled by QuickArgumentVisitor. } } diff --git a/runtime/fault_handler.cc b/runtime/fault_handler.cc index 671079b128..d0e78abf5f 100644 --- a/runtime/fault_handler.cc +++ b/runtime/fault_handler.cc @@ -70,7 +70,7 @@ static mirror::Class* SafeGetDeclaringClass(ArtMethod* method) CHECK_NE(-1, rc); if (kVerifySafeImpls) { - mirror::Class* actual_class = method->GetDeclaringClassUnchecked<kWithoutReadBarrier>(); + ObjPtr<mirror::Class> actual_class = method->GetDeclaringClassUnchecked<kWithoutReadBarrier>(); CHECK_EQ(actual_class, cls.AsMirrorPtr()); } diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc index c9e8426340..dc42cfa4fe 100644 --- a/runtime/hprof/hprof.cc +++ b/runtime/hprof/hprof.cc @@ -718,7 +718,7 @@ class Hprof : public SingleRootVisitor { source_file = ""; } __ AddStringId(LookupStringId(source_file)); - auto class_result = classes_.find(method->GetDeclaringClass()); + auto class_result = classes_.find(method->GetDeclaringClass().Ptr()); CHECK(class_result != classes_.end()); __ AddU4(class_result->second); __ AddU4(frame->ComputeLineNumber()); diff --git a/runtime/jni/check_jni.cc b/runtime/jni/check_jni.cc index 7919c32737..66bd74b504 100644 --- a/runtime/jni/check_jni.cc +++ b/runtime/jni/check_jni.cc @@ -1286,7 +1286,7 @@ class ScopedCheck { } ArtMethod* m = jni::DecodeArtMethod(mid); // TODO: Better check here. - if (!Runtime::Current()->GetHeap()->IsValidObjectAddress(m->GetDeclaringClass())) { + if (!Runtime::Current()->GetHeap()->IsValidObjectAddress(m->GetDeclaringClass().Ptr())) { Runtime::Current()->GetHeap()->DumpSpaces(LOG_STREAM(ERROR)); AbortF("invalid jmethodID: %p", mid); return nullptr; diff --git a/runtime/jni/java_vm_ext.cc b/runtime/jni/java_vm_ext.cc index 44679a5afa..fdf0feec14 100644 --- a/runtime/jni/java_vm_ext.cc +++ b/runtime/jni/java_vm_ext.cc @@ -1078,7 +1078,7 @@ static void* FindCodeForNativeMethodInAgents(ArtMethod* m) REQUIRES_SHARED(Locks void* JavaVMExt::FindCodeForNativeMethod(ArtMethod* m) { CHECK(m->IsNative()); - mirror::Class* c = m->GetDeclaringClass(); + ObjPtr<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() << " " << m->PrettyMethod(); std::string detail; diff --git a/runtime/jni/jni_internal.cc b/runtime/jni/jni_internal.cc index a02e76ae54..5200607e9b 100644 --- a/runtime/jni/jni_internal.cc +++ b/runtime/jni/jni_internal.cc @@ -501,7 +501,7 @@ class JNI { CHECK_NON_NULL_ARGUMENT(mid); ScopedObjectAccess soa(env); ArtMethod* m = jni::DecodeArtMethod(mid); - mirror::Executable* method; + ObjPtr<mirror::Executable> method; DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize); DCHECK(!Runtime::Current()->IsActiveTransaction()); if (m->IsConstructor()) { diff --git a/runtime/mirror/method.cc b/runtime/mirror/method.cc index cf03b95d5e..910a1fc821 100644 --- a/runtime/mirror/method.cc +++ b/runtime/mirror/method.cc @@ -20,32 +20,33 @@ #include "class_root.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" +#include "obj_ptr-inl.h" namespace art { namespace mirror { template <PointerSize kPointerSize, bool kTransactionActive> -Method* Method::CreateFromArtMethod(Thread* self, ArtMethod* method) { +ObjPtr<Method> Method::CreateFromArtMethod(Thread* self, ArtMethod* method) { DCHECK(!method->IsConstructor()) << method->PrettyMethod(); ObjPtr<Method> ret = ObjPtr<Method>::DownCast(GetClassRoot<Method>()->AllocObject(self)); if (LIKELY(ret != nullptr)) { ObjPtr<Executable>(ret)-> CreateFromArtMethod<kPointerSize, kTransactionActive>(method); } - return ret.Ptr(); + return ret; } -template Method* Method::CreateFromArtMethod<PointerSize::k32, false>(Thread* self, - ArtMethod* method); -template Method* Method::CreateFromArtMethod<PointerSize::k32, true>(Thread* self, - ArtMethod* method); -template Method* Method::CreateFromArtMethod<PointerSize::k64, false>(Thread* self, - ArtMethod* method); -template Method* Method::CreateFromArtMethod<PointerSize::k64, true>(Thread* self, - ArtMethod* method); +template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k32, false>( + Thread* self, ArtMethod* method); +template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k32, true>( + Thread* self, ArtMethod* method); +template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k64, false>( + Thread* self, ArtMethod* method); +template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k64, true>( + Thread* self, ArtMethod* method); template <PointerSize kPointerSize, bool kTransactionActive> -Constructor* Constructor::CreateFromArtMethod(Thread* self, ArtMethod* method) { +ObjPtr<Constructor> Constructor::CreateFromArtMethod(Thread* self, ArtMethod* method) { DCHECK(method->IsConstructor()) << method->PrettyMethod(); ObjPtr<Constructor> ret = ObjPtr<Constructor>::DownCast(GetClassRoot<Constructor>()->AllocObject(self)); @@ -53,16 +54,16 @@ Constructor* Constructor::CreateFromArtMethod(Thread* self, ArtMethod* method) { ObjPtr<Executable>(ret)-> CreateFromArtMethod<kPointerSize, kTransactionActive>(method); } - return ret.Ptr(); + return ret; } -template Constructor* Constructor::CreateFromArtMethod<PointerSize::k32, false>( +template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k32, false>( Thread* self, ArtMethod* method); -template Constructor* Constructor::CreateFromArtMethod<PointerSize::k32, true>( +template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k32, true>( Thread* self, ArtMethod* method); -template Constructor* Constructor::CreateFromArtMethod<PointerSize::k64, false>( +template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k64, false>( Thread* self, ArtMethod* method); -template Constructor* Constructor::CreateFromArtMethod<PointerSize::k64, true>( +template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k64, true>( Thread* self, ArtMethod* method); } // namespace mirror diff --git a/runtime/mirror/method.h b/runtime/mirror/method.h index aea15a7748..a73cd45ca4 100644 --- a/runtime/mirror/method.h +++ b/runtime/mirror/method.h @@ -20,6 +20,9 @@ #include "executable.h" namespace art { + +template<class MirrorType> class ObjPtr; + namespace mirror { class Class; @@ -28,7 +31,7 @@ class Class; class MANAGED Method : public Executable { public: template <PointerSize kPointerSize, bool kTransactionActive> - static Method* CreateFromArtMethod(Thread* self, ArtMethod* method) + static ObjPtr<Method> CreateFromArtMethod(Thread* self, ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); private: @@ -39,7 +42,7 @@ class MANAGED Method : public Executable { class MANAGED Constructor: public Executable { public: template <PointerSize kPointerSize, bool kTransactionActive> - static Constructor* CreateFromArtMethod(Thread* self, ArtMethod* method) + static ObjPtr<Constructor> CreateFromArtMethod(Thread* self, ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); private: diff --git a/runtime/mirror/var_handle.h b/runtime/mirror/var_handle.h index 48c9d74e30..0cfa51c042 100644 --- a/runtime/mirror/var_handle.h +++ b/runtime/mirror/var_handle.h @@ -197,11 +197,6 @@ class MANAGED FieldVarHandle : public VarHandle { ArtField* GetField() REQUIRES_SHARED(Locks::mutator_lock_); - static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_); - static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_); - static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_); - static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_); - private: static MemberOffset ArtFieldOffset() { return MemberOffset(OFFSETOF_MEMBER(FieldVarHandle, art_field_)); diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index 82e54e2f4c..5a5fb16d0c 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -544,8 +544,8 @@ static jobjectArray Class_getDeclaredConstructorsInternal( if (MethodMatchesConstructor(&m, public_only, enforce_hidden_api)) { DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize); DCHECK(!Runtime::Current()->IsActiveTransaction()); - auto* constructor = mirror::Constructor::CreateFromArtMethod<kRuntimePointerSize, false>( - soa.Self(), &m); + ObjPtr<mirror::Constructor> constructor = + mirror::Constructor::CreateFromArtMethod<kRuntimePointerSize, false>(soa.Self(), &m); if (UNLIKELY(constructor == nullptr)) { soa.Self()->AssertPendingOOMException(); return nullptr; @@ -605,7 +605,7 @@ static jobjectArray Class_getDeclaredMethodsUnchecked(JNIEnv* env, jobject javaT IsDiscoverable(public_only, enforce_hidden_api, &m)) { DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize); DCHECK(!Runtime::Current()->IsActiveTransaction()); - auto* method = + ObjPtr<mirror::Method> method = mirror::Method::CreateFromArtMethod<kRuntimePointerSize, false>(soa.Self(), &m); if (method == nullptr) { soa.Self()->AssertPendingException(); @@ -838,7 +838,7 @@ static jobject Class_newInstance(JNIEnv* env, jobject javaThis) { return nullptr; } // Verify that we can access the constructor. - auto* declaring_class = constructor->GetDeclaringClass(); + ObjPtr<mirror::Class> declaring_class = constructor->GetDeclaringClass(); if (!constructor->IsPublic()) { if (caller == nullptr) { caller.Assign(GetCallingClass(soa.Self(), 1)); diff --git a/runtime/stack.cc b/runtime/stack.cc index f58fc3b564..c4851e148b 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -597,7 +597,7 @@ static void AssertPcIsWithinQuickCode(ArtMethod* method, uintptr_t pc) void StackVisitor::SanityCheckFrame() const { if (kIsDebugBuild) { ArtMethod* method = GetMethod(); - mirror::Class* declaring_class = method->GetDeclaringClass(); + ObjPtr<mirror::Class> declaring_class = method->GetDeclaringClass(); // Runtime methods have null declaring class. if (!method->IsRuntimeMethod()) { CHECK(declaring_class != nullptr); @@ -613,7 +613,7 @@ void StackVisitor::SanityCheckFrame() const { // We get the canonical method as copied methods may have their declaring // class from another class loader. ArtMethod* canonical = method->GetCanonicalMethod(); - mirror::Class* klass = canonical->GetDeclaringClass(); + ObjPtr<mirror::Class> klass = canonical->GetDeclaringClass(); LinearAlloc* const class_linear_alloc = (klass != nullptr) ? runtime->GetClassLinker()->GetAllocatorForClassLoader(klass->GetClassLoader()) : linear_alloc; diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 47877bd195..1a61f2b7c8 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -157,7 +157,7 @@ FailureKind MethodVerifier::VerifyClass(Thread* self, std::string failure_message; const DexFile& dex_file = klass->GetDexFile(); const DexFile::ClassDef* class_def = klass->GetClassDef(); - mirror::Class* super = klass->GetSuperClass(); + ObjPtr<mirror::Class> super = klass->GetSuperClass(); std::string temp; if (super == nullptr && strcmp("Ljava/lang/Object;", klass->GetDescriptor(&temp)) != 0) { early_failure = true; @@ -2955,7 +2955,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { bool is_range = (inst->Opcode() == Instruction::INVOKE_INTERFACE_RANGE); ArtMethod* abs_method = VerifyInvocationArgs(inst, METHOD_INTERFACE, is_range); if (abs_method != nullptr) { - mirror::Class* called_interface = abs_method->GetDeclaringClass(); + ObjPtr<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 '" << abs_method->PrettyMethod() << "'"; @@ -3286,7 +3286,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { // Special instructions. case Instruction::RETURN_VOID_NO_BARRIER: if (IsConstructor() && !IsStatic()) { - auto& declaring_class = GetDeclaringClass(); + const RegType& declaring_class = GetDeclaringClass(); if (declaring_class.IsUnresolvedReference()) { // We must iterate over the fields, even if we cannot use mirror classes to do so. Do it // manually over the underlying dex file. @@ -3892,7 +3892,7 @@ ArtMethod* MethodVerifier::VerifyInvocationArgsFromIterator( // class. It would be wrong to use this for the type check (interface type checks are // postponed to runtime). if (res_method != nullptr && !res_method->IsMiranda()) { - mirror::Class* klass = res_method->GetDeclaringClass(); + ObjPtr<mirror::Class> klass = res_method->GetDeclaringClass(); std::string temp; res_method_class = &FromClass(klass->GetDescriptor(&temp), klass, klass->CannotBeAssignedFromOtherTypes()); @@ -4154,7 +4154,7 @@ ArtMethod* MethodVerifier::VerifyInvocationArgs( } bool MethodVerifier::CheckSignaturePolymorphicMethod(ArtMethod* method) { - mirror::Class* klass = method->GetDeclaringClass(); + ObjPtr<mirror::Class> klass = method->GetDeclaringClass(); const char* method_name = method->GetName(); const char* expected_return_descriptor; diff --git a/test/163-app-image-methods/src/Main.java b/test/163-app-image-methods/src/Main.java index c513470b7b..33590fc450 100644 --- a/test/163-app-image-methods/src/Main.java +++ b/test/163-app-image-methods/src/Main.java @@ -23,7 +23,7 @@ public class Main { String aaaDerivedName = "AAA.Derived"; System.out.println("Eating all memory."); // Resolve VMClassLoader before eating all the memory since we can not fail - // initializtaion of boot classpath classes. + // initialization of boot classpath classes. Class.forName("java.lang.VMClassLoader"); Object memory = eatAllMemory(); |