summaryrefslogtreecommitdiffstats
path: root/compiler/oat_writer.cc
diff options
context:
space:
mode:
authorJeff Hao <jeffhao@google.com>2015-01-27 11:22:04 -0800
committerJeff Hao <jeffhao@google.com>2015-02-05 11:39:07 -0800
commita0acc2d5dbf8764b346da3d9e6ce1a91427fc4b5 (patch)
treee5928f42b129c466f0c6ffb3ae58ee465971d859 /compiler/oat_writer.cc
parentca9a26859d2ca8e106316dd5f16b60a325f0533c (diff)
downloadart-a0acc2d5dbf8764b346da3d9e6ce1a91427fc4b5.zip
art-a0acc2d5dbf8764b346da3d9e6ce1a91427fc4b5.tar.gz
art-a0acc2d5dbf8764b346da3d9e6ce1a91427fc4b5.tar.bz2
Revert "Revert "Allow preopted apps to have sharpened calls for non-x86 architectures.""
Should really say it allows pre-linked calls instead of sharpened calls. Bug: 19100762 Change-Id: Ia2045a9eda92255e87a7f6187de18d6370b8f060
Diffstat (limited to 'compiler/oat_writer.cc')
-rw-r--r--compiler/oat_writer.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index 3c36ffa..7516811 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -1103,10 +1103,18 @@ class OatWriter::WriteCodeMethodVisitor : public OatDexMethodVisitor {
if (UNLIKELY(target_offset == 0)) {
mirror::ArtMethod* target = GetTargetMethod(patch);
DCHECK(target != nullptr);
- DCHECK_EQ(target->GetQuickOatCodeOffset(), 0u);
- target_offset = target->IsNative()
- ? writer_->oat_header_->GetQuickGenericJniTrampolineOffset()
- : writer_->oat_header_->GetQuickToInterpreterBridgeOffset();
+ size_t size = GetInstructionSetPointerSize(writer_->compiler_driver_->GetInstructionSet());
+ const void* oat_code_offset = target->GetEntryPointFromQuickCompiledCodePtrSize(size);
+ if (oat_code_offset != 0) {
+ DCHECK(!Runtime::Current()->GetClassLinker()->IsQuickResolutionStub(oat_code_offset));
+ DCHECK(!Runtime::Current()->GetClassLinker()->IsQuickToInterpreterBridge(oat_code_offset));
+ DCHECK(!Runtime::Current()->GetClassLinker()->IsQuickGenericJniStub(oat_code_offset));
+ target_offset = PointerToLowMemUInt32(oat_code_offset);
+ } else {
+ target_offset = target->IsNative()
+ ? writer_->oat_header_->GetQuickGenericJniTrampolineOffset()
+ : writer_->oat_header_->GetQuickToInterpreterBridgeOffset();
+ }
}
return target_offset;
}
@@ -1138,10 +1146,9 @@ class OatWriter::WriteCodeMethodVisitor : public OatDexMethodVisitor {
void PatchCodeAddress(std::vector<uint8_t>* code, uint32_t offset, uint32_t target_offset)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- // NOTE: Direct calls across oat files don't use linker patches.
- DCHECK(writer_->image_writer_ != nullptr);
- uint32_t address = PointerToLowMemUInt32(writer_->image_writer_->GetOatFileBegin() +
- writer_->oat_data_offset_ + target_offset);
+ uint32_t address = writer_->image_writer_ == nullptr ? target_offset :
+ PointerToLowMemUInt32(writer_->image_writer_->GetOatFileBegin() +
+ writer_->oat_data_offset_ + target_offset);
DCHECK_LE(offset + 4, code->size());
uint8_t* data = &(*code)[offset];
data[0] = address & 0xffu;