[vmkit-commits] [vmkit] r99091 - /vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sat Mar 20 14:33:26 PDT 2010
Author: geoffray
Date: Sat Mar 20 16:33:26 2010
New Revision: 99091
URL: http://llvm.org/viewvc/llvm-project?rev=99091&view=rev
Log:
Attach gc info to stubs.
Modified:
vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=99091&r1=99090&r2=99091&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Sat Mar 20 16:33:26 2010
@@ -62,7 +62,7 @@
} else {
virtualType = Compiler->getIntrinsics()->JavaObjectType;
- assert(virtualType && "intrinsics not iniitalized");
+ assert(virtualType && "intrinsics not initalized");
structType = dyn_cast<const StructType>(virtualType->getContainedType(0));
sl = targetData->getStructLayout(structType);
@@ -409,7 +409,7 @@
ReturnInst::Create(context, val, currentBlock);
else
ReturnInst::Create(context, currentBlock);
-
+
return res;
}
@@ -487,6 +487,10 @@
else
ReturnInst::Create(context, currentBlock);
+ if (Compiler->useCooperativeGC()) {
+ res->setGC("vmkit");
+ }
+
return res;
}
@@ -494,6 +498,7 @@
std::vector<Value*> Args;
std::vector<Value*> FunctionArgs;
+ std::vector<Value*> TempArgs;
J3Intrinsics& Intrinsics = *Compiler->getIntrinsics();
std::string name;
@@ -518,26 +523,28 @@
node = PHINode::Create(stub->getReturnType(), "", endBlock);
}
- Function::arg_iterator arg = stub->arg_begin();
- Value *obj = NULL;
- if (virt) {
- obj = arg;
- Args.push_back(obj);
- }
- for (; arg != stub->arg_end() ; ++arg) {
- FunctionArgs.push_back(arg);
- if (Compiler->useCooperativeGC()) {
- if (arg->getType() == Intrinsics.JavaObjectType) {
- Value* GCArgs[2] = {
- new BitCastInst(arg, Intrinsics.ptrPtrType, "", currentBlock),
- Intrinsics.constantPtrNull
- };
+ for (Function::arg_iterator arg = stub->arg_begin();
+ arg != stub->arg_end(); ++arg) {
+ Value* temp = arg;
+ if (Compiler->useCooperativeGC() &&
+ arg->getType() == Intrinsics.JavaObjectType) {
+ temp = new AllocaInst(Intrinsics.JavaObjectType, "", currentBlock);
+ new StoreInst(arg, temp, "", currentBlock);
+ Value* GCArgs[2] = {
+ new BitCastInst(temp, Intrinsics.ptrPtrType, "", currentBlock),
+ Intrinsics.constantPtrNull
+ };
- CallInst::Create(Intrinsics.llvm_gc_gcroot, GCArgs, GCArgs + 2, "",
- currentBlock);
- }
+ CallInst::Create(Intrinsics.llvm_gc_gcroot, GCArgs, GCArgs + 2, "",
+ currentBlock);
}
+
+ TempArgs.push_back(temp);
+ }
+
+ if (virt && Compiler->useCooperativeGC()) {
+ Args.push_back(new LoadInst(TempArgs[0], "", false, currentBlock));
}
Value* val = CallInst::Create(virt ? Intrinsics.ResolveVirtualStubFunction :
@@ -554,6 +561,17 @@
currentBlock = callBlock;
Value* Func = new BitCastInst(val, stub->getType(), "", currentBlock);
+
+ int i = 0;
+ for (Function::arg_iterator arg = stub->arg_begin();
+ arg != stub->arg_end(); ++arg, ++i) {
+ Value* temp = arg;
+ if (Compiler->useCooperativeGC() &&
+ arg->getType() == Intrinsics.JavaObjectType) {
+ temp = new LoadInst(TempArgs[i], "", false, currentBlock);
+ }
+ FunctionArgs.push_back(temp);
+ }
Value* res = CallInst::Create(Func, FunctionArgs.begin(), FunctionArgs.end(),
"", currentBlock);
if (node) node->addIncoming(res, currentBlock);
@@ -566,6 +584,10 @@
ReturnInst::Create(context, currentBlock);
}
+ if (Compiler->useCooperativeGC()) {
+ stub->setGC("vmkit");
+ }
+
return stub;
}
More information about the vmkit-commits
mailing list