[vmkit-commits] [vmkit] r109352 - /vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sat Jul 24 12:32:17 PDT 2010
Author: geoffray
Date: Sat Jul 24 14:32:17 2010
New Revision: 109352
URL: http://llvm.org/viewvc/llvm-project?rev=109352&view=rev
Log:
If the return value is an object, save it in a stack slot before calling endSynchronize.
Modified:
vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=109352&r1=109351&r2=109352&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Jul 24 14:32:17 2010
@@ -1280,6 +1280,22 @@
}
currentBlock = endBlock;
+
+ Instruction* returnValue = NULL;
+ if (returnType == intrinsics->JavaObjectType &&
+ TheCompiler->useCooperativeGC()) {
+ returnValue = new AllocaInst(intrinsics->JavaObjectType, "",
+ func->begin()->getTerminator());
+ Value* GCArgs[2] = {
+ new BitCastInst(returnValue, intrinsics->ptrPtrType, "",
+ func->begin()->getTerminator()),
+ intrinsics->constantPtrNull
+ };
+
+ CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, GCArgs + 2, "",
+ func->begin()->getTerminator());
+ new StoreInst(endNode, returnValue, currentBlock);
+ }
if (isSynchro(compilingMethod->access))
endSynchronize();
@@ -1318,10 +1334,18 @@
if (PI == PE) {
currentBlock->eraseFromParent();
} else {
- if (returnType != Type::getVoidTy(*llvmContext))
- ReturnInst::Create(*llvmContext, endNode, currentBlock);
- else
+ if (returnType != Type::getVoidTy(*llvmContext)) {
+ if (returnType == intrinsics->JavaObjectType &&
+ TheCompiler->useCooperativeGC()) {
+ assert(returnValue && "No return value set");
+ Value* obj = new LoadInst(returnValue, "", false, currentBlock);
+ ReturnInst::Create(*llvmContext, obj, currentBlock);
+ } else {
+ ReturnInst::Create(*llvmContext, endNode, currentBlock);
+ }
+ } else {
ReturnInst::Create(*llvmContext, currentBlock);
+ }
}
currentBlock = endExceptionBlock;
More information about the vmkit-commits
mailing list