diff options
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r-- | runtime/class_linker.cc | 49 |
1 files changed, 15 insertions, 34 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index e2ef7ac671..99e38d9fcf 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -498,10 +498,11 @@ bool ClassLinker::InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> b object_array_string->SetComponentType(java_lang_String.Get()); SetClassRoot(kJavaLangStringArrayClass, object_array_string.Get()); + LinearAlloc* linear_alloc = runtime->GetLinearAlloc(); // Create runtime resolution and imt conflict methods. runtime->SetResolutionMethod(runtime->CreateResolutionMethod()); - runtime->SetImtConflictMethod(runtime->CreateImtConflictMethod()); - runtime->SetImtUnimplementedMethod(runtime->CreateImtConflictMethod()); + runtime->SetImtConflictMethod(runtime->CreateImtConflictMethod(linear_alloc)); + runtime->SetImtUnimplementedMethod(runtime->CreateImtConflictMethod(linear_alloc)); // Setup boot_class_path_ and register class_path now that we can use AllocObjectArray to create // DexCache instances. Needs to be after String, Field, Method arrays since AllocDexCache uses @@ -760,7 +761,8 @@ static void SanityCheckArtMethod(ArtMethod* m, const std::vector<gc::space::ImageSpace*>& spaces) SHARED_REQUIRES(Locks::mutator_lock_) { if (m->IsRuntimeMethod()) { - CHECK(m->GetDeclaringClass() == nullptr) << PrettyMethod(m); + mirror::Class* declaring_class = m->GetDeclaringClassUnchecked(); + CHECK(declaring_class == nullptr) << declaring_class << " " << PrettyMethod(m); } else if (m->IsCopied()) { CHECK(m->GetDeclaringClass() != nullptr) << PrettyMethod(m); } else if (expected_class != nullptr) { @@ -5903,9 +5905,11 @@ static void SetIMTRef(ArtMethod* unimplemented_method, // Place method in imt if entry is empty, place conflict otherwise. if (*imt_ref == unimplemented_method) { *imt_ref = current_method; - } else if (*imt_ref != imt_conflict_method) { + } else if (!(*imt_ref)->IsRuntimeMethod()) { // If we are not a conflict and we have the same signature and name as the imt // entry, it must be that we overwrote a superclass vtable entry. + // Note that we have checked IsRuntimeMethod, as there may be multiple different + // conflict methods. MethodNameAndSignatureComparator imt_comparator( (*imt_ref)->GetInterfaceMethodIfProxy(image_pointer_size)); if (imt_comparator.HasSameNameAndSignature( @@ -5914,6 +5918,11 @@ static void SetIMTRef(ArtMethod* unimplemented_method, } else { *imt_ref = imt_conflict_method; } + } else { + // Place the default conflict method. Note that there may be an existing conflict + // method in the IMT, but it could be one tailored to the super class, with a + // specific ImtConflictTable. + *imt_ref = imt_conflict_method; } } @@ -7557,34 +7566,6 @@ const char* ClassLinker::GetClassRootDescriptor(ClassRoot class_root) { return descriptor; } -bool ClassLinker::MayBeCalledWithDirectCodePointer(ArtMethod* m) { - Runtime* const runtime = Runtime::Current(); - if (runtime->UseJit()) { - // JIT can have direct code pointers from any method to any other method. - return true; - } - // Non-image methods don't use direct code pointer. - if (!m->GetDeclaringClass()->IsBootStrapClassLoaded()) { - return false; - } - if (m->IsPrivate()) { - // The method can only be called inside its own oat file. Therefore it won't be called using - // its direct code if the oat file has been compiled in PIC mode. - const DexFile& dex_file = m->GetDeclaringClass()->GetDexFile(); - const OatFile::OatDexFile* oat_dex_file = dex_file.GetOatDexFile(); - if (oat_dex_file == nullptr) { - // No oat file: the method has not been compiled. - return false; - } - const OatFile* oat_file = oat_dex_file->GetOatFile(); - return oat_file != nullptr && !oat_file->IsPic(); - } else { - // The method can be called outside its own oat file. Therefore it won't be called using its - // direct code pointer only if all loaded oat files have been compiled in PIC mode. - return runtime->GetOatFileManager().HaveNonPicOatFile(); - } -} - jobject ClassLinker::CreatePathClassLoader(Thread* self, std::vector<const DexFile*>& dex_files) { // SOAAlreadyRunnable is protected, and we need something to add a global reference. // We could move the jobject to the callers, but all call-sites do this... @@ -7681,12 +7662,12 @@ jobject ClassLinker::CreatePathClassLoader(Thread* self, std::vector<const DexFi return soa.Env()->NewGlobalRef(local_ref.get()); } -ArtMethod* ClassLinker::CreateRuntimeMethod() { +ArtMethod* ClassLinker::CreateRuntimeMethod(LinearAlloc* linear_alloc) { const size_t method_alignment = ArtMethod::Alignment(image_pointer_size_); const size_t method_size = ArtMethod::Size(image_pointer_size_); LengthPrefixedArray<ArtMethod>* method_array = AllocArtMethodArray( Thread::Current(), - Runtime::Current()->GetLinearAlloc(), + linear_alloc, 1); ArtMethod* method = &method_array->At(0, method_size, method_alignment); CHECK(method != nullptr); |