summaryrefslogtreecommitdiffstats
path: root/compiler/trampolines/trampoline_compiler.cc
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-03-06 01:13:39 -0800
committerIan Rogers <irogers@google.com>2014-03-06 01:34:07 -0800
commitbefbd5731ecca08f08780ee28a913d08ffb14656 (patch)
treeee359fc38671950afa91d96bf8c29232a799b628 /compiler/trampolines/trampoline_compiler.cc
parent97c3d61e46a3678dac848578c686c724ec3397fa (diff)
downloadandroid_art-befbd5731ecca08f08780ee28a913d08ffb14656.tar.gz
android_art-befbd5731ecca08f08780ee28a913d08ffb14656.tar.bz2
android_art-befbd5731ecca08f08780ee28a913d08ffb14656.zip
Fix host architecture for 64bit.
Also, hack x86 assembler for use as a x86-64 trampoline compiler's assembler. Implement missing x86-64 quick resolution trampoline. Add x86-64 to the quick elf writer. Change-Id: I08216c67014a83492ada12898ab8000218ba7bb4
Diffstat (limited to 'compiler/trampolines/trampoline_compiler.cc')
-rw-r--r--compiler/trampolines/trampoline_compiler.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/compiler/trampolines/trampoline_compiler.cc b/compiler/trampolines/trampoline_compiler.cc
index 32ae5583ac..3e13e44397 100644
--- a/compiler/trampolines/trampoline_compiler.cc
+++ b/compiler/trampolines/trampoline_compiler.cc
@@ -100,6 +100,23 @@ static const std::vector<uint8_t>* CreateTrampoline(ThreadOffset offset) {
}
} // namespace x86
+namespace x86_64 {
+static const std::vector<uint8_t>* CreateTrampoline(ThreadOffset offset) {
+ UniquePtr<x86::X86Assembler> assembler(static_cast<x86::X86Assembler*>(Assembler::Create(kX86_64)));
+
+ // All x86 trampolines call via the Thread* held in gs.
+ __ gs()->jmp(x86::Address::Absolute(offset, true));
+ __ int3();
+
+ size_t cs = assembler->CodeSize();
+ UniquePtr<std::vector<uint8_t> > entry_stub(new std::vector<uint8_t>(cs));
+ MemoryRegion code(&(*entry_stub)[0], entry_stub->size());
+ assembler->FinalizeInstructions(code);
+
+ return entry_stub.release();
+}
+} // namespace x86_64
+
const std::vector<uint8_t>* CreateTrampoline(InstructionSet isa, EntryPointCallingConvention abi,
ThreadOffset offset) {
switch (isa) {
@@ -110,6 +127,8 @@ const std::vector<uint8_t>* CreateTrampoline(InstructionSet isa, EntryPointCalli
return mips::CreateTrampoline(abi, offset);
case kX86:
return x86::CreateTrampoline(offset);
+ case kX86_64:
+ return x86_64::CreateTrampoline(offset);
default:
LOG(FATAL) << "Unknown InstructionSet: " << isa;
return NULL;