[vmkit-commits] [vmkit] r63196 - /vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed Jan 28 02:59:53 PST 2009
Author: geoffray
Date: Wed Jan 28 04:59:35 2009
New Revision: 63196
URL: http://llvm.org/viewvc/llvm-project?rev=63196&view=rev
Log:
Makre sure the frame pointer is emitted in memory when calling native
methods, otherwise the callee may overwrite it.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=63196&r1=63195&r2=63196&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Wed Jan 28 04:59:35 2009
@@ -253,10 +253,10 @@
uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0);
std::vector<Value*> nativeArgs;
- Value* threadId = CallInst::Create(module->llvm_frameaddress,
- module->constantZero, "", currentBlock);
- threadId = new PtrToIntInst(threadId, module->pointerSizeType, "",
- currentBlock);
+ Value* FrameAddr = CallInst::Create(module->llvm_frameaddress,
+ module->constantZero, "", currentBlock);
+ Value* threadId = new PtrToIntInst(FrameAddr, module->pointerSizeType, "",
+ currentBlock);
threadId = BinaryOperator::CreateAnd(threadId, module->constantThreadIDMask,
"", currentBlock);
threadId = new IntToPtrInst(threadId, module->JavaThreadType, "",
@@ -320,6 +320,13 @@
nativeFunc = node;
}
+ // When calling a native method, it may do whatever it wants with the
+ // frame pointer. Therefore make sure it's on the stack. x86_64 has
+ // this problem because it passes first arguments in registers.
+ // Therefore, it was overwriting the frame pointer when entering the
+ // native method.
+ Value* Temp = new AllocaInst(module->ptrType, "", currentBlock);
+ new StoreInst(FrameAddr, Temp, currentBlock);
Value* result = llvm::CallInst::Create(nativeFunc, nativeArgs.begin(),
nativeArgs.end(), "", currentBlock);
More information about the vmkit-commits
mailing list