summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/image_writer.cc18
-rw-r--r--compiler/oat_writer.cc11
2 files changed, 13 insertions, 16 deletions
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index 69e09509f3..e3114eb80d 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -635,15 +635,19 @@ void ImageWriter::FixupMethod(ArtMethod* orig, ArtMethod* copy) {
// Use original code if it exists. Otherwise, set the code pointer to the resolution
// trampoline.
const byte* quick_code = GetOatAddress(orig->GetQuickOatCodeOffset());
- if (quick_code != nullptr) {
+ if (quick_code != nullptr &&
+ (!orig->IsStatic() || orig->IsConstructor() || orig->GetDeclaringClass()->IsInitialized())) {
+ // We have code for a non-static or initialized method, just use the code.
copy->SetEntryPointFromQuickCompiledCode<kVerifyNone>(quick_code);
+ } else if (quick_code == nullptr && orig->IsNative() && !orig->IsStatic()) {
+ // Non-static native method missing compiled code, use generic JNI version.
+ copy->SetEntryPointFromQuickCompiledCode<kVerifyNone>(GetOatAddress(quick_generic_jni_trampoline_offset_));
+ } else if (quick_code == nullptr && !orig->IsNative()) {
+ // We don't have code at all for a non-native method, use the interpreter.
+ copy->SetEntryPointFromQuickCompiledCode<kVerifyNone>(GetOatAddress(quick_to_interpreter_bridge_offset_));
} else {
- if (orig->IsNative() && !orig->IsStatic()) {
- // non-static native method missing compiled code, use generic JNI version
- copy->SetEntryPointFromQuickCompiledCode<kVerifyNone>(GetOatAddress(quick_generic_jni_trampoline_offset_));
- } else {
- copy->SetEntryPointFromQuickCompiledCode<kVerifyNone>(GetOatAddress(quick_resolution_trampoline_offset_));
- }
+ // We have code for a static method, but need to go through the resolution stub for class initialization.
+ copy->SetEntryPointFromQuickCompiledCode<kVerifyNone>(GetOatAddress(quick_resolution_trampoline_offset_));
}
const byte* portable_code = GetOatAddress(orig->GetPortableOatCodeOffset());
if (portable_code != nullptr) {
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index 181240ead3..186ab38f86 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -506,15 +506,8 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index,
method->SetCoreSpillMask(core_spill_mask);
method->SetFpSpillMask(fp_spill_mask);
method->SetOatMappingTableOffset(mapping_table_offset);
- // Don't overwrite static method trampoline
- if (!method->IsStatic() || method->IsConstructor() ||
- method->GetDeclaringClass()->IsInitialized()) {
- // TODO: record portable code offsets: method->SetPortableOatCodeOffset(portable_code_offset);
- method->SetQuickOatCodeOffset(quick_code_offset);
- } else {
- method->SetEntryPointFromPortableCompiledCode(nullptr);
- method->SetEntryPointFromQuickCompiledCode(nullptr);
- }
+ // Portable code offsets are set by ElfWriterMclinker::FixupCompiledCodeOffset after linking.
+ method->SetQuickOatCodeOffset(quick_code_offset);
method->SetOatVmapTableOffset(vmap_table_offset);
method->SetOatNativeGcMapOffset(gc_map_offset);
}