summaryrefslogtreecommitdiff
path: root/lib/Target/X86/X86JITInfo.cpp
diff options
context:
space:
mode:
authorNicolas Geoffray <nicolas.geoffray@lip6.fr>2008-04-16 20:46:05 +0000
committerNicolas Geoffray <nicolas.geoffray@lip6.fr>2008-04-16 20:46:05 +0000
commit51cc3c13eac78da242f0518fc42580e48dd5304f (patch)
tree8cabb5d8c03920e8df85546c5c76465ae2dc131e /lib/Target/X86/X86JITInfo.cpp
parente20bbc81012e636cb59bbbe3a114895a2f7fa0da (diff)
downloadllvm-51cc3c13eac78da242f0518fc42580e48dd5304f.tar.gz
llvm-51cc3c13eac78da242f0518fc42580e48dd5304f.tar.bz2
llvm-51cc3c13eac78da242f0518fc42580e48dd5304f.tar.xz
Correlate stubs with functions in JIT: when emitting a stub, the JIT tells the memory manager which function
the stub will resolve. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49814 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86JITInfo.cpp')
-rw-r--r--lib/Target/X86/X86JITInfo.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp
index 5d942a1768..7f72bd473e 100644
--- a/lib/Target/X86/X86JITInfo.cpp
+++ b/lib/Target/X86/X86JITInfo.cpp
@@ -15,6 +15,7 @@
#include "X86JITInfo.h"
#include "X86Relocations.h"
#include "X86Subtarget.h"
+#include "llvm/Function.h"
#include "llvm/CodeGen/MachineCodeEmitter.h"
#include "llvm/Config/alloca.h"
#include <cstdlib>
@@ -391,19 +392,21 @@ X86JITInfo::getLazyResolverFunction(JITCompilerFn F) {
return X86CompilationCallback;
}
-void *X86JITInfo::emitGlobalValueLazyPtr(void *GV, MachineCodeEmitter &MCE) {
+void *X86JITInfo::emitGlobalValueLazyPtr(const GlobalValue* GV, void *ptr,
+ MachineCodeEmitter &MCE) {
#if defined (X86_64_JIT)
MCE.startFunctionStub(8, 8);
- MCE.emitWordLE(((unsigned *)&GV)[0]);
- MCE.emitWordLE(((unsigned *)&GV)[1]);
+ MCE.emitWordLE(((unsigned *)&ptr)[0]);
+ MCE.emitWordLE(((unsigned *)&ptr)[1]);
#else
- MCE.startFunctionStub(4, 4);
- MCE.emitWordLE((intptr_t)GV);
+ MCE.startFunctionStub(GV, 4, 4);
+ MCE.emitWordLE((intptr_t)ptr);
#endif
- return MCE.finishFunctionStub(0);
+ return MCE.finishFunctionStub(GV);
}
-void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
+void *X86JITInfo::emitFunctionStub(const Function* F, void *Fn,
+ MachineCodeEmitter &MCE) {
// Note, we cast to intptr_t here to silence a -pedantic warning that
// complains about casting a function pointer to a normal pointer.
#if defined (X86_32_JIT) && !defined (_MSC_VER)
@@ -414,7 +417,7 @@ void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
#endif
if (NotCC) {
#if defined (X86_64_JIT)
- MCE.startFunctionStub(13, 4);
+ MCE.startFunctionStub(F, 13, 4);
MCE.emitByte(0x49); // REX prefix
MCE.emitByte(0xB8+2); // movabsq r10
MCE.emitWordLE(((unsigned *)&Fn)[0]);
@@ -423,15 +426,15 @@ void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
MCE.emitByte(0xFF); // jmpq *r10
MCE.emitByte(2 | (4 << 3) | (3 << 6));
#else
- MCE.startFunctionStub(5, 4);
+ MCE.startFunctionStub(F, 5, 4);
MCE.emitByte(0xE9);
MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4);
#endif
- return MCE.finishFunctionStub(0);
+ return MCE.finishFunctionStub(F);
}
#if defined (X86_64_JIT)
- MCE.startFunctionStub(14, 4);
+ MCE.startFunctionStub(F, 14, 4);
MCE.emitByte(0x49); // REX prefix
MCE.emitByte(0xB8+2); // movabsq r10
MCE.emitWordLE(((unsigned *)&Fn)[0]);
@@ -440,14 +443,14 @@ void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
MCE.emitByte(0xFF); // callq *r10
MCE.emitByte(2 | (2 << 3) | (3 << 6));
#else
- MCE.startFunctionStub(6, 4);
+ MCE.startFunctionStub(F, 6, 4);
MCE.emitByte(0xE8); // Call with 32 bit pc-rel destination...
MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4);
#endif
MCE.emitByte(0xCD); // Interrupt - Just a marker identifying the stub!
- return MCE.finishFunctionStub(0);
+ return MCE.finishFunctionStub(F);
}
/// getPICJumpTableEntry - Returns the value of the jumptable entry for the