[vmkit-commits] [vmkit] r109977 - in /vmkit/trunk/lib/J3/Compiler: JavaJIT.cpp JavaJIT.h JavaJITOpcodes.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Aug 1 06:01:37 PDT 2010
Author: geoffray
Date: Sun Aug 1 08:01:37 2010
New Revision: 109977
URL: http://llvm.org/viewvc/llvm-project?rev=109977&view=rev
Log:
All loads on objects must be volatile, to cooperate with the GC (LLVM optimizations may delete these loads if they are not marked volatile).
Modified:
vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
vmkit/trunk/lib/J3/Compiler/JavaJIT.h
vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=109977&r1=109976&r2=109977&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sun Aug 1 08:01:37 2010
@@ -204,7 +204,7 @@
Args.push_back(GV);
Value* targetObject = getTarget(virtualType->param_end(),
signature->nbArguments + 1);
- Args.push_back(new LoadInst(targetObject, "", false, currentBlock));
+ Args.push_back(new LoadInst(targetObject, "", true, currentBlock));
load = invoke(intrinsics->VirtualLookupFunction, Args, "", currentBlock);
node->addIncoming(load, currentBlock);
BranchInst::Create(endResolveVirtual, currentBlock);
@@ -494,7 +494,7 @@
BranchInst::Create(endBlock, loadBlock, cmp, currentBlock);
currentBlock = loadBlock;
- result = new LoadInst(result, "", currentBlock);
+ result = new LoadInst(result, "", true, currentBlock);
new StoreInst(result, ResultObject, "", currentBlock);
endNode->addIncoming(result, currentBlock);
@@ -730,7 +730,7 @@
Value* obj = 0;
if (isVirtual(compilingMethod->access)) {
assert(thisObject != NULL && "beginSynchronize without this");
- obj = new LoadInst(thisObject, "", false, currentBlock);
+ obj = new LoadInst(thisObject, "", true, currentBlock);
} else {
obj = TheCompiler->getJavaClassPtr(compilingClass);
obj = new LoadInst(obj, "", false, currentBlock);
@@ -742,7 +742,7 @@
Value* obj = 0;
if (isVirtual(compilingMethod->access)) {
assert(thisObject != NULL && "endSynchronize without this");
- obj = new LoadInst(thisObject, "", false, currentBlock);
+ obj = new LoadInst(thisObject, "", true, currentBlock);
} else {
obj = TheCompiler->getJavaClassPtr(compilingClass);
obj = new LoadInst(obj, "", false, currentBlock);
@@ -1038,6 +1038,19 @@
opcodeInfos[i].exceptionBlock = endExceptionBlock;
}
+ Instruction* returnValue = NULL;
+ if (returnType == intrinsics->JavaObjectType &&
+ TheCompiler->useCooperativeGC()) {
+ returnValue = new AllocaInst(intrinsics->JavaObjectType, "",
+ currentBlock);
+ Instruction* cast =
+ new BitCastInst(returnValue, intrinsics->ptrPtrType, "", currentBlock);
+ Value* GCArgs[2] = { cast, intrinsics->constantPtrNull };
+
+ CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, GCArgs + 2, "",
+ currentBlock);
+ }
+
for (int i = 0; i < maxLocals; i++) {
intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), "", currentBlock));
new StoreInst(Constant::getNullValue(Type::getInt32Ty(*llvmContext)), intLocals.back(), false, currentBlock);
@@ -1208,8 +1221,9 @@
endNode = llvm::PHINode::Create(returnType, "", endBlock);
}
- if (isSynchro(compilingMethod->access))
+ if (isSynchro(compilingMethod->access)) {
beginSynchronize();
+ }
if (TheCompiler->useCooperativeGC()) {
Value* threadId = getCurrentThread(intrinsics->MutatorThreadType);
@@ -1280,26 +1294,14 @@
}
currentBlock = endBlock;
-
- Instruction* returnValue = NULL;
- if (returnType == intrinsics->JavaObjectType &&
- TheCompiler->useCooperativeGC()) {
- returnValue = new AllocaInst(intrinsics->JavaObjectType, "",
- func->begin()->begin());
- Instruction* cast =
- new BitCastInst(returnValue, intrinsics->ptrPtrType, "");
- cast->insertAfter(returnValue);
- Value* GCArgs[2] = { cast, intrinsics->constantPtrNull };
-
- Instruction* call =
- CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, GCArgs + 2, "");
- call->insertAfter(cast);
+ if (returnValue != NULL) {
new StoreInst(endNode, returnValue, currentBlock);
}
-
- if (isSynchro(compilingMethod->access))
+
+ if (isSynchro(compilingMethod->access)) {
endSynchronize();
+ }
#if JNJVM_EXECUTE > 0
{
@@ -1336,10 +1338,8 @@
currentBlock->eraseFromParent();
} 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);
+ if (returnValue != NULL) {
+ Value* obj = new LoadInst(returnValue, "", true, currentBlock);
ReturnInst::Create(*llvmContext, obj, currentBlock);
} else {
ReturnInst::Create(*llvmContext, endNode, currentBlock);
@@ -1388,7 +1388,7 @@
const UTF8* name =
compilingClass->ctpInfo->UTF8At(AR.AnnotationNameIndex);
if (name->equals(TheCompiler->InlinePragma)) {
- llvmFunction->addFnAttr(Attribute::AlwaysInline);
+ llvmFunction->addFnAttr(Attribute::NoInline);
} else if (name->equals(TheCompiler->NoInlinePragma)) {
llvmFunction->addFnAttr(Attribute::NoInline);
}
@@ -2057,7 +2057,7 @@
currentBlock);
#endif
} else {
- object = new LoadInst(object, false, currentBlock);
+ object = new LoadInst(object, "", true, currentBlock);
JITVerifyNull(object);
type = LCI->getVirtualType();
}
@@ -2086,7 +2086,7 @@
Value* ptr = getConstantPoolAt(index, func, returnType, 0, true);
if (!stat) {
- object = new LoadInst(object, false, currentBlock);
+ object = new LoadInst(object, "", true, currentBlock);
Value* tmp = new BitCastInst(object, Pty, "", currentBlock);
Value* args[2] = { zero, ptr };
ptr = GetElementPtrInst::Create(tmp, args, args + 2, "", currentBlock);
@@ -2194,9 +2194,9 @@
JavaObject::getClass(val) : NULL;
push(V, false, cl);
} else {
- Value* V = CallInst::Create(intrinsics->GetFinalObjectFieldFunction, ptr,
- "", currentBlock);
-
+ // Do not call getFinalObject, as the object may move in-between two
+ // loads of this static.
+ Value* V = new LoadInst(ptr, "", currentBlock);
JnjvmClassLoader* JCL = compilingClass->classLoader;
push(V, false, sign->findAssocClass(JCL));
}
@@ -2260,32 +2260,31 @@
// In init methods, the fields have not been set yet.
if (!compilingMethod->name->equals(JBL->initName)) {
JavaField* field = compilingClass->ctpInfo->lookupField(index, false);
- if (field) final = isFinal(field->access);
+ if (field) {
+ final = isFinal(field->access) && sign->isPrimitive();
+ }
if (final) {
Function* F = 0;
- if (sign->isPrimitive()) {
- const PrimitiveTypedef* prim = (PrimitiveTypedef*)sign;
- if (prim->isInt()) {
- F = intrinsics->GetFinalInt32FieldFunction;
- } else if (prim->isByte()) {
- F = intrinsics->GetFinalInt8FieldFunction;
- } else if (prim->isBool()) {
- F = intrinsics->GetFinalInt8FieldFunction;
- } else if (prim->isShort()) {
- F = intrinsics->GetFinalInt16FieldFunction;
- } else if (prim->isChar()) {
- F = intrinsics->GetFinalInt16FieldFunction;
- } else if (prim->isLong()) {
- F = intrinsics->GetFinalLongFieldFunction;
- } else if (prim->isFloat()) {
- F = intrinsics->GetFinalFloatFieldFunction;
- } else if (prim->isDouble()) {
- F = intrinsics->GetFinalDoubleFieldFunction;
- } else {
- abort();
- }
+ assert(sign->isPrimitive());
+ const PrimitiveTypedef* prim = (PrimitiveTypedef*)sign;
+ if (prim->isInt()) {
+ F = intrinsics->GetFinalInt32FieldFunction;
+ } else if (prim->isByte()) {
+ F = intrinsics->GetFinalInt8FieldFunction;
+ } else if (prim->isBool()) {
+ F = intrinsics->GetFinalInt8FieldFunction;
+ } else if (prim->isShort()) {
+ F = intrinsics->GetFinalInt16FieldFunction;
+ } else if (prim->isChar()) {
+ F = intrinsics->GetFinalInt16FieldFunction;
+ } else if (prim->isLong()) {
+ F = intrinsics->GetFinalLongFieldFunction;
+ } else if (prim->isFloat()) {
+ F = intrinsics->GetFinalFloatFieldFunction;
+ } else if (prim->isDouble()) {
+ F = intrinsics->GetFinalDoubleFieldFunction;
} else {
- F = intrinsics->GetFinalObjectFieldFunction;
+ abort();
}
push(CallInst::Create(F, ptr, "", currentBlock), sign->isUnsigned(), cl);
}
Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=109977&r1=109976&r2=109977&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Sun Aug 1 08:01:37 2010
@@ -314,19 +314,19 @@
llvm::Value* top() {
CommonClass* cl = stack.back();
if (cl == upcalls->OfInt) {
- return new llvm::LoadInst(intStack[currentStackIndex - 1], false,
+ return new llvm::LoadInst(intStack[currentStackIndex - 1], "", false,
currentBlock);
} else if (cl == upcalls->OfFloat) {
- return new llvm::LoadInst(floatStack[currentStackIndex - 1], false,
+ return new llvm::LoadInst(floatStack[currentStackIndex - 1], "", false,
currentBlock);
} else if (cl == upcalls->OfDouble) {
- return new llvm::LoadInst(doubleStack[currentStackIndex - 1], false,
+ return new llvm::LoadInst(doubleStack[currentStackIndex - 1], "", false,
currentBlock);
} else if (cl == upcalls->OfLong) {
- return new llvm::LoadInst(longStack[currentStackIndex - 1], false,
+ return new llvm::LoadInst(longStack[currentStackIndex - 1], "", false,
currentBlock);
} else {
- return new llvm::LoadInst(objectStack[currentStackIndex - 1], false,
+ return new llvm::LoadInst(objectStack[currentStackIndex - 1], "", true,
currentBlock);
}
}
Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=109977&r1=109976&r2=109977&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Sun Aug 1 08:01:37 2010
@@ -274,133 +274,133 @@
break;
case ILOAD :
- push(new LoadInst(intLocals[WREAD_U1(reader, false, i, wide)], "",
+ push(new LoadInst(intLocals[WREAD_U1(reader, false, i, wide)], "", false,
currentBlock), false);
break;
case LLOAD :
- push(new LoadInst(longLocals[WREAD_U1(reader, false, i, wide)], "",
+ push(new LoadInst(longLocals[WREAD_U1(reader, false, i, wide)], "", false,
currentBlock), false);
push(intrinsics->constantZero, false);
break;
case FLOAD :
- push(new LoadInst(floatLocals[WREAD_U1(reader, false, i, wide)], "",
+ push(new LoadInst(floatLocals[WREAD_U1(reader, false, i, wide)], "", false,
currentBlock), false);
break;
case DLOAD :
- push(new LoadInst(doubleLocals[WREAD_U1(reader, false, i, wide)], "",
+ push(new LoadInst(doubleLocals[WREAD_U1(reader, false, i, wide)], "", false,
currentBlock), false);
push(intrinsics->constantZero, false);
break;
case ALOAD :
- push(new LoadInst(objectLocals[WREAD_U1(reader, false, i, wide)], "",
+ push(new LoadInst(objectLocals[WREAD_U1(reader, false, i, wide)], "", true,
currentBlock), false);
break;
case ILOAD_0 :
- push(new LoadInst(intLocals[0], "", currentBlock), false);
+ push(new LoadInst(intLocals[0], "", false, currentBlock), false);
break;
case ILOAD_1 :
- push(new LoadInst(intLocals[1], "", currentBlock), false);
+ push(new LoadInst(intLocals[1], "", false, currentBlock), false);
break;
case ILOAD_2 :
- push(new LoadInst(intLocals[2], "", currentBlock), false);
+ push(new LoadInst(intLocals[2], "", false, currentBlock), false);
break;
case ILOAD_3 :
- push(new LoadInst(intLocals[3], "", currentBlock), false);
+ push(new LoadInst(intLocals[3], "", false, currentBlock), false);
break;
case LLOAD_0 :
- push(new LoadInst(longLocals[0], "", currentBlock),
+ push(new LoadInst(longLocals[0], "", false, currentBlock),
false);
push(intrinsics->constantZero, false);
break;
case LLOAD_1 :
- push(new LoadInst(longLocals[1], "", currentBlock),
+ push(new LoadInst(longLocals[1], "", false, currentBlock),
false);
push(intrinsics->constantZero, false);
break;
case LLOAD_2 :
- push(new LoadInst(longLocals[2], "", currentBlock),
+ push(new LoadInst(longLocals[2], "", false, currentBlock),
false);
push(intrinsics->constantZero, false);
break;
case LLOAD_3 :
- push(new LoadInst(longLocals[3], "", currentBlock),
+ push(new LoadInst(longLocals[3], "", false, currentBlock),
false);
push(intrinsics->constantZero, false);
break;
case FLOAD_0 :
- push(new LoadInst(floatLocals[0], "", currentBlock),
+ push(new LoadInst(floatLocals[0], "", false, currentBlock),
false);
break;
case FLOAD_1 :
- push(new LoadInst(floatLocals[1], "", currentBlock),
+ push(new LoadInst(floatLocals[1], "", false, currentBlock),
false);
break;
case FLOAD_2 :
- push(new LoadInst(floatLocals[2], "", currentBlock),
+ push(new LoadInst(floatLocals[2], "", false, currentBlock),
false);
break;
case FLOAD_3 :
- push(new LoadInst(floatLocals[3], "", currentBlock),
+ push(new LoadInst(floatLocals[3], "", false, currentBlock),
false);
break;
case DLOAD_0 :
- push(new LoadInst(doubleLocals[0], "", currentBlock),
+ push(new LoadInst(doubleLocals[0], "", false, currentBlock),
false);
push(intrinsics->constantZero, false);
break;
case DLOAD_1 :
- push(new LoadInst(doubleLocals[1], "", currentBlock),
+ push(new LoadInst(doubleLocals[1], "", false, currentBlock),
false);
push(intrinsics->constantZero, false);
break;
case DLOAD_2 :
- push(new LoadInst(doubleLocals[2], "", currentBlock),
+ push(new LoadInst(doubleLocals[2], "", false, currentBlock),
false);
push(intrinsics->constantZero, false);
break;
case DLOAD_3 :
- push(new LoadInst(doubleLocals[3], "", currentBlock),
+ push(new LoadInst(doubleLocals[3], "", false, currentBlock),
false);
push(intrinsics->constantZero, false);
break;
case ALOAD_0 :
- push(new LoadInst(objectLocals[0], "", currentBlock),
+ push(new LoadInst(objectLocals[0], "", true, currentBlock),
false);
break;
case ALOAD_1 :
- push(new LoadInst(objectLocals[1], "", currentBlock),
+ push(new LoadInst(objectLocals[1], "", true, currentBlock),
false);
break;
case ALOAD_2 :
- push(new LoadInst(objectLocals[2], "", currentBlock),
+ push(new LoadInst(objectLocals[2], "", true, currentBlock),
false);
break;
case ALOAD_3 :
- push(new LoadInst(objectLocals[3], "", currentBlock),
+ push(new LoadInst(objectLocals[3], "", true, currentBlock),
false);
break;
@@ -686,10 +686,10 @@
// Get val and object and don't pop them: IsAssignableFromFunction
// may go into runtime and we don't want values in registers at that
// point.
- Value* val = new LoadInst(objectStack[currentStackIndex - 1], false,
- currentBlock);
- Value* obj = new LoadInst(objectStack[currentStackIndex - 3], false,
- currentBlock);
+ Value* val = new LoadInst(objectStack[currentStackIndex - 1], "",
+ true, currentBlock);
+ Value* obj = new LoadInst(objectStack[currentStackIndex - 3], "",
+ true, currentBlock);
Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val,
intrinsics->JavaObjectNullConstant, "");
@@ -1868,7 +1868,7 @@
case RET : {
uint8 local = reader.readU1();
i += 1;
- Value* _val = new LoadInst(objectLocals[local], "", currentBlock);
+ Value* _val = new LoadInst(objectLocals[local], "", true, currentBlock);
Value* val = new PtrToIntInst(_val, Type::getInt32Ty(*llvmContext), "", currentBlock);
SwitchInst* inst = SwitchInst::Create(val, jsrs[0], jsrs.size(),
currentBlock);
More information about the vmkit-commits
mailing list