diff options
| author | 2019-07-17 10:15:22 +0100 | |
|---|---|---|
| committer | 2019-07-17 15:20:59 +0000 | |
| commit | 2a290e14fd10a5e494ee0a48e07bc238a7a271d6 (patch) | |
| tree | de4c64717ed359eafaf064face395d0569358949 | |
| parent | b45a435e25d69592f27084a615b351760f040875 (diff) | |
Cleanup and simplify ImageWriter::GetQuickCode.
- Remove unneeded parameter
- Fix a consistency bug where a static method of a non-initialized class
would get the interpreter bridge as entrypoint instead of the resolution
stub.
Test: test.py
Change-Id: I0c71db8b1897ae47cf228d112fbe24b9570b61fa
| -rw-r--r-- | dex2oat/linker/image_writer.cc | 34 | ||||
| -rw-r--r-- | dex2oat/linker/image_writer.h | 4 |
2 files changed, 14 insertions, 24 deletions
diff --git a/dex2oat/linker/image_writer.cc b/dex2oat/linker/image_writer.cc index f690a3b1ed..8a8ef4dd42 100644 --- a/dex2oat/linker/image_writer.cc +++ b/dex2oat/linker/image_writer.cc @@ -3334,9 +3334,7 @@ const uint8_t* ImageWriter::GetOatAddress(StubType type) const { return GetOatAddressForOffset(primary_image_info.GetStubOffset(type), primary_image_info); } -const uint8_t* ImageWriter::GetQuickCode(ArtMethod* method, - const ImageInfo& image_info, - bool* quick_is_interpreted) { +const uint8_t* ImageWriter::GetQuickCode(ArtMethod* method, const ImageInfo& image_info) { DCHECK(!method->IsResolutionMethod()) << method->PrettyMethod(); DCHECK_NE(method, Runtime::Current()->GetImtConflictMethod()) << method->PrettyMethod(); DCHECK(!method->IsImtUnimplementedMethod()) << method->PrettyMethod(); @@ -3360,22 +3358,17 @@ const uint8_t* ImageWriter::GetQuickCode(ArtMethod* method, quick_code = GetOatAddressForOffset(quick_oat_code_offset, image_info); } - *quick_is_interpreted = false; - if (quick_code != nullptr && (!method->IsStatic() || method->IsConstructor() || - method->GetDeclaringClass()->IsInitialized())) { - // We have code for a non-static or initialized method, just use the code. - } else if (quick_code == nullptr && method->IsNative() && - (!method->IsStatic() || method->GetDeclaringClass()->IsInitialized())) { - // Non-static or initialized native method missing compiled code, use generic JNI version. - quick_code = GetOatAddress(StubType::kQuickGenericJNITrampoline); - } else if (quick_code == nullptr && !method->IsNative()) { - // We don't have code at all for a non-native method, use the interpreter. - quick_code = GetOatAddress(StubType::kQuickToInterpreterBridge); - *quick_is_interpreted = true; - } else { - CHECK(!method->GetDeclaringClass()->IsInitialized()); - // We have code for a static method, but need to go through the resolution stub for class - // initialization. + if (quick_code == nullptr) { + // If we don't have code, use generic jni / interpreter bridge. + quick_code = method->IsNative() + ? GetOatAddress(StubType::kQuickGenericJNITrampoline) + : GetOatAddress(StubType::kQuickToInterpreterBridge); + } + + if (!method->GetDeclaringClass()->IsInitialized() && + method->IsStatic() && + !method->IsConstructor()) { + // We need to go through the resolution stub for class initialization. quick_code = GetOatAddress(StubType::kQuickResolutionTrampoline); } return quick_code; @@ -3434,9 +3427,8 @@ void ImageWriter::CopyAndFixupMethod(ArtMethod* orig, if (UNLIKELY(!orig->IsInvokable())) { quick_code = GetOatAddress(StubType::kQuickToInterpreterBridge); } else { - bool quick_is_interpreted; const ImageInfo& image_info = image_infos_[oat_index]; - quick_code = GetQuickCode(orig, image_info, &quick_is_interpreted); + quick_code = GetQuickCode(orig, image_info); // JNI entrypoint: if (orig->IsNative()) { diff --git a/dex2oat/linker/image_writer.h b/dex2oat/linker/image_writer.h index cdb9b507eb..8990d3290b 100644 --- a/dex2oat/linker/image_writer.h +++ b/dex2oat/linker/image_writer.h @@ -538,9 +538,7 @@ class ImageWriter final { REQUIRES_SHARED(Locks::mutator_lock_); // Get quick code for non-resolution/imt_conflict/abstract method. - const uint8_t* GetQuickCode(ArtMethod* method, - const ImageInfo& image_info, - bool* quick_is_interpreted) + const uint8_t* GetQuickCode(ArtMethod* method, const ImageInfo& image_info) REQUIRES_SHARED(Locks::mutator_lock_); // Return true if a method is likely to be dirtied at runtime. |