diff options
| -rw-r--r-- | runtime/art_method.cc | 13 | ||||
| -rw-r--r-- | runtime/hidden_api.cc | 6 | ||||
| -rw-r--r-- | runtime/quick_exception_handler.cc | 2 | ||||
| -rw-r--r-- | runtime/thread.cc | 3 |
4 files changed, 14 insertions, 10 deletions
diff --git a/runtime/art_method.cc b/runtime/art_method.cc index abfdd5547d..882291f20b 100644 --- a/runtime/art_method.cc +++ b/runtime/art_method.cc @@ -70,7 +70,7 @@ ArtMethod* ArtMethod::GetCanonicalMethod(PointerSize pointer_size) { } else { ObjPtr<mirror::Class> declaring_class = GetDeclaringClass(); DCHECK(declaring_class->IsInterface()); - ArtMethod* ret = declaring_class->FindInterfaceMethod(declaring_class->GetDexCache(), + ArtMethod* ret = declaring_class->FindInterfaceMethod(GetDexCache(), GetDexMethodIndex(), pointer_size); DCHECK(ret != nullptr); @@ -79,10 +79,11 @@ ArtMethod* ArtMethod::GetCanonicalMethod(PointerSize pointer_size) { } ArtMethod* ArtMethod::GetNonObsoleteMethod() { - DCHECK_EQ(kRuntimePointerSize, Runtime::Current()->GetClassLinker()->GetImagePointerSize()); if (LIKELY(!IsObsolete())) { return this; - } else if (IsDirect()) { + } + DCHECK_EQ(kRuntimePointerSize, Runtime::Current()->GetClassLinker()->GetImagePointerSize()); + if (IsDirect()) { return &GetDeclaringClass()->GetDirectMethodsSlice(kRuntimePointerSize)[GetMethodIndex()]; } else { return GetDeclaringClass()->GetVTableEntry(GetMethodIndex(), kRuntimePointerSize); @@ -504,10 +505,10 @@ static const OatFile::OatMethod FindOatMethodFor(ArtMethod* method, << method->PrettyMethod(); } DCHECK_EQ(oat_method_index, - GetOatMethodIndexFromMethodIndex(*declaring_class->GetDexCache()->GetDexFile(), + GetOatMethodIndexFromMethodIndex(declaring_class->GetDexFile(), method->GetDeclaringClass()->GetDexClassDefIndex(), method->GetDexMethodIndex())); - OatFile::OatClass oat_class = OatFile::FindOatClass(*declaring_class->GetDexCache()->GetDexFile(), + OatFile::OatClass oat_class = OatFile::FindOatClass(declaring_class->GetDexFile(), declaring_class->GetDexClassDefIndex(), found); if (!(*found)) { @@ -543,7 +544,7 @@ bool ArtMethod::EqualParameters(Handle<mirror::ObjectArray<mirror::Class>> param } ArrayRef<const uint8_t> ArtMethod::GetQuickenedInfo() { - const DexFile& dex_file = GetDeclaringClass()->GetDexFile(); + const DexFile& dex_file = *GetDexFile(); const OatDexFile* oat_dex_file = dex_file.GetOatDexFile(); if (oat_dex_file == nullptr || (oat_dex_file->GetOatFile() == nullptr)) { return ArrayRef<const uint8_t>(); diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc index d3df7fd38d..6cdba73c30 100644 --- a/runtime/hidden_api.cc +++ b/runtime/hidden_api.cc @@ -280,11 +280,15 @@ uint32_t GetDexFlags(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) { uint32_t flags = kInvalidDexFlags; DCHECK(!AreValidDexFlags(flags)); + // Use the non-obsolete method to avoid DexFile mismatch between + // the method index and the declaring class. + uint32_t method_index = method->GetNonObsoleteMethod()->GetDexMethodIndex(); + ClassAccessor accessor(declaring_class->GetDexFile(), *class_def, /* parse_hiddenapi_class_data= */ true); auto fn_visit = [&](const ClassAccessor::Method& dex_method) { - if (dex_method.GetIndex() == method->GetDexMethodIndex()) { + if (dex_method.GetIndex() == method_index) { flags = dex_method.GetHiddenapiFlags(); } }; diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc index afdfefaffa..d23f3e8e11 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -238,7 +238,7 @@ void QuickExceptionHandler::FindCatch(ObjPtr<mirror::Throwable> exception) { LOG(INFO) << "Handler is upcall"; } if (handler_method_ != nullptr) { - const DexFile* dex_file = handler_method_->GetDeclaringClass()->GetDexCache()->GetDexFile(); + const DexFile* dex_file = handler_method_->GetDexFile(); int line_number = annotations::GetLineNumFromPC(dex_file, handler_method_, handler_dex_pc_); LOG(INFO) << "Handler: " << handler_method_->PrettyMethod() << " (line: " << line_number << ")"; diff --git a/runtime/thread.cc b/runtime/thread.cc index e9fed76d6f..1de1be4699 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -1952,8 +1952,7 @@ struct StackDumpVisitor : public MonitorObjectsStackVisitor { override REQUIRES_SHARED(Locks::mutator_lock_) { m = m->GetInterfaceMethodIfProxy(kRuntimePointerSize); - ObjPtr<mirror::Class> c = m->GetDeclaringClass(); - ObjPtr<mirror::DexCache> dex_cache = c->GetDexCache(); + ObjPtr<mirror::DexCache> dex_cache = m->GetDexCache(); int line_number = -1; if (dex_cache != nullptr) { // be tolerant of bad input const DexFile* dex_file = dex_cache->GetDexFile(); |