[vmkit-commits] [vmkit] r88907 - in /vmkit/trunk/lib/JnJVM/Compiler: JavaJIT.cpp JavaJITOpcodes.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Nov 16 02:54:12 PST 2009
Author: geoffray
Date: Mon Nov 16 04:54:12 2009
New Revision: 88907
URL: http://llvm.org/viewvc/llvm-project?rev=88907&view=rev
Log:
Correctly type stack objects.
Modified:
vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp
Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp?rev=88907&r1=88906&r2=88907&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp Mon Nov 16 04:54:12 2009
@@ -203,9 +203,14 @@
}
if (retType != Type::getVoidTy(getGlobalContext())) {
- push(val, retTypedef->isUnsigned());
- if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
- push(module->constantZero, false);
+ if (retType == module->JavaObjectType) {
+ JnjvmClassLoader* JCL = compilingClass->classLoader;
+ push(val, false, signature->getReturnType()->assocClass(JCL));
+ } else {
+ push(val, retTypedef->isUnsigned());
+ if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
+ push(module->constantZero, false);
+ }
}
}
@@ -1316,20 +1321,20 @@
const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]);
JavaString* str = *(compilingClass->classLoader->UTF8ToStr(utf8));
Value* val = TheCompiler->getString(str);
- push(val, false);
+ push(val, false, upcalls->newString);
} else {
JavaString** str = (JavaString**)ctpInfo->ctpRes[index];
if (str) {
Value* val = TheCompiler->getStringPtr(str);
val = new LoadInst(val, "", currentBlock);
- push(val, false);
+ push(val, false, upcalls->newString);
} else {
// Lookup the constant pool cache
const llvm::Type* Ty = PointerType::getUnqual(module->JavaObjectType);
Value* val = getConstantPoolAt(index, module->StringLookupFunction,
Ty, 0, false);
val = new LoadInst(val, "", currentBlock);
- push(val, false);
+ push(val, false, upcalls->newString);
}
}
#endif
@@ -1351,7 +1356,7 @@
res = CallInst::Create(module->GetClassDelegateeFunction, res, "",
currentBlock);
- push(res, false);
+ push(res, false, upcalls->newClass);
} else {
fprintf(stderr, "I haven't verified your class file and it's malformed:"
" unknown ldc %d in %s.%s!\n", type,
@@ -1688,9 +1693,14 @@
const llvm::Type* retType = virtualType->getReturnType();
if (retType != Type::getVoidTy(getGlobalContext())) {
- push(val, signature->getReturnType()->isUnsigned());
- if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
- push(module->constantZero, false);
+ if (retType == module->JavaObjectType) {
+ JnjvmClassLoader* JCL = compilingClass->classLoader;
+ push(val, false, signature->getReturnType()->assocClass(JCL));
+ } else {
+ push(val, signature->getReturnType()->isUnsigned());
+ if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
+ push(module->constantZero, false);
+ }
}
}
@@ -1757,9 +1767,14 @@
const llvm::Type* retType = staticType->getReturnType();
if (retType != Type::getVoidTy(getGlobalContext())) {
- push(val, signature->getReturnType()->isUnsigned());
- if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
- push(module->constantZero, false);
+ if (retType == module->JavaObjectType) {
+ JnjvmClassLoader* JCL = compilingClass->classLoader;
+ push(val, false, signature->getReturnType()->assocClass(JCL));
+ } else {
+ push(val, signature->getReturnType()->isUnsigned());
+ if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
+ push(module->constantZero, false);
+ }
}
}
}
@@ -1900,7 +1915,7 @@
}
val = new BitCastInst(val, module->JavaObjectType, "", currentBlock);
- push(val, false);
+ push(val, false, cl ? cl : upcalls->OfObject);
}
Value* JavaJIT::ldResolved(uint16 index, bool stat, Value* object,
@@ -2062,19 +2077,24 @@
if (TheCompiler->isStaticCompiling()) {
JavaObject* val = field->getObjectField(Obj);
Value* V = TheCompiler->getFinalObject(val);
- push(V, false);
+ push(V, false, val->getClass());
} else {
Value* V = CallInst::Create(module->GetFinalObjectFieldFunction, ptr,
"", currentBlock);
-
- push(V, false);
+
+ JnjvmClassLoader* JCL = compilingClass->classLoader;
+ push(V, false, sign->assocClass(JCL));
}
}
}
}
#endif
- if (!final) push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned());
+ if (!final) {
+ JnjvmClassLoader* JCL = compilingClass->classLoader;
+ CommonClass* cl = sign->assocClass(JCL);
+ push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned(), cl);
+ }
if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) {
push(module->constantZero, false);
}
@@ -2103,6 +2123,9 @@
void JavaJIT::getVirtualField(uint16 index) {
Typedef* sign = compilingClass->ctpInfo->infoOfField(index);
+ JnjvmClassLoader* JCL = compilingClass->classLoader;
+ CommonClass* cl = sign->assocClass(JCL);
+
LLVMAssessorInfo& LAI = TheCompiler->getTypedefInfo(sign);
const Type* type = LAI.llvmType;
Value* obj = pop();
@@ -2112,6 +2135,8 @@
JnjvmBootstrapLoader* JBL = compilingClass->classLoader->bootstrapLoader;
bool final = false;
+
+ // 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);
@@ -2141,12 +2166,13 @@
} else {
F = module->GetFinalObjectFieldFunction;
}
- push(CallInst::Create(F, ptr, "", currentBlock), sign->isUnsigned());
+ push(CallInst::Create(F, ptr, "", currentBlock), sign->isUnsigned(), cl);
}
}
- if (!final) push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned());
- if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) {
+ if (!final) push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned(), cl);
+ if (type == Type::getInt64Ty(getGlobalContext()) ||
+ type == Type::getDoubleTy(getGlobalContext())) {
push(module->constantZero, false);
}
}
@@ -2255,10 +2281,15 @@
currentBlock = endBlock;
if (node) {
- push(node, signature->getReturnType()->isUnsigned());
- if (retType == Type::getDoubleTy(getGlobalContext()) ||
- retType == Type::getInt64Ty(getGlobalContext())) {
- push(module->constantZero, false);
+ if (node->getType() == module->JavaObjectType) {
+ JnjvmClassLoader* JCL = compilingClass->classLoader;
+ push(node, false, signature->getReturnType()->assocClass(JCL));
+ } else {
+ push(node, signature->getReturnType()->isUnsigned());
+ if (retType == Type::getDoubleTy(getGlobalContext()) ||
+ retType == Type::getInt64Ty(getGlobalContext())) {
+ push(module->constantZero, false);
+ }
}
}
}
Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp?rev=88907&r1=88906&r2=88907&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Mon Nov 16 04:54:12 2009
@@ -441,10 +441,13 @@
case AALOAD : {
Value* index = pop();
+ CommonClass* cl = topTypeInfo();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
module->JavaArrayObjectType);
- push(new LoadInst(ptr, "", currentBlock), false);
+
+ if (cl->isArray()) cl = cl->asArrayClass()->baseClass();
+ push(new LoadInst(ptr, "", currentBlock), false, cl);
break;
}
@@ -754,78 +757,95 @@
break;
case DUP :
- push(top(), false);
+ push(top(), false, topTypeInfo());
break;
case DUP_X1 : {
+ CommonClass* oneCl = topTypeInfo();
Value* one = pop();
+ CommonClass* twoCl = topTypeInfo();
Value* two = pop();
- push(one, false);
- push(two, false);
- push(one, false);
+ push(one, false, oneCl);
+ push(two, false, twoCl);
+ push(one, false, oneCl);
break;
}
case DUP_X2 : {
+ CommonClass* oneCl = topTypeInfo();
Value* one = pop();
+ CommonClass* twoCl = topTypeInfo();
Value* two = pop();
+ CommonClass* threeCl = topTypeInfo();
Value* three = pop();
- push(one, false);
- push(three, false);
- push(two, false);
- push(one, false);
+
+ push(one, false, oneCl);
+ push(three, false, threeCl);
+ push(two, false, twoCl);
+ push(one, false, oneCl);
break;
}
case DUP2 : {
+ CommonClass* oneCl = topTypeInfo();
Value* one = pop();
+ CommonClass* twoCl = topTypeInfo();
Value* two = pop();
- push(two, false);
- push(one, false);
- push(two, false);
- push(one, false);
+ push(two, false, twoCl);
+ push(one, false, oneCl);
+ push(two, false, twoCl);
+ push(one, false, oneCl);
break;
}
case DUP2_X1 : {
+ CommonClass* oneCl = topTypeInfo();
Value* one = pop();
+ CommonClass* twoCl = topTypeInfo();
Value* two = pop();
+ CommonClass* threeCl = topTypeInfo();
Value* three = pop();
- push(two, false);
- push(one, false);
+ push(two, false, twoCl);
+ push(one, false, oneCl);
- push(three, false);
- push(two, false);
- push(one, false);
+ push(three, false, threeCl);
+ push(two, false, twoCl);
+ push(one, false, oneCl);
break;
}
case DUP2_X2 : {
+ CommonClass* oneCl = topTypeInfo();
Value* one = pop();
+ CommonClass* twoCl = topTypeInfo();
Value* two = pop();
+ CommonClass* threeCl = topTypeInfo();
Value* three = pop();
+ CommonClass* fourCl = topTypeInfo();
Value* four = pop();
- push(two, false);
- push(one, false);
+ push(two, twoCl);
+ push(one, oneCl);
- push(four, false);
- push(three, false);
- push(two, false);
- push(one, false);
+ push(four, fourCl);
+ push(three, threeCl);
+ push(two, twoCl);
+ push(one, oneCl);
break;
}
case SWAP : {
+ CommonClass* oneCl = topTypeInfo();
Value* one = pop();
+ CommonClass* twoCl = topTypeInfo();
Value* two = pop();
- push(one, false);
- push(two, false);
+ push(one, false, oneCl);
+ push(two, false, twoCl);
break;
}
@@ -1919,6 +1939,7 @@
Constant* sizeElement = 0;
Value* TheVT = 0;
Value* valCl = 0;
+ UserClassArray* dcl = 0;
if (bytecodes[i] == NEWARRAY) {
uint8 id = bytecodes[++i];
@@ -1926,7 +1947,7 @@
#ifndef ISOLATE_SHARING
JnjvmBootstrapLoader* loader =
compilingClass->classLoader->bootstrapLoader;
- UserClassArray* dcl = loader->getArrayClass(id);
+ dcl = loader->getArrayClass(id);
valCl = TheCompiler->getNativeClass(dcl);
#else
Value* args[2] = { isolateLocal,
@@ -1955,7 +1976,7 @@
JnjvmClassLoader* JCL = cl->classLoader;
const UTF8* arrayName = JCL->constructArrayName(1, cl->name);
- UserClassArray* dcl = JCL->constructArray(arrayName);
+ dcl = JCL->constructArray(arrayName);
valCl = TheCompiler->getNativeClass(dcl);
// If we're static compiling and the class is not a class we
@@ -2029,7 +2050,7 @@
new StoreInst(arg1, GEP, currentBlock);
res = new BitCastInst(res, module->JavaObjectType, "", currentBlock);
- push(res, false);
+ push(res, false, dcl ? dcl : upcalls->ArrayOfObject);
break;
}
@@ -2163,8 +2184,8 @@
uint16 index = readU2(bytecodes, i);
uint8 dim = readU1(bytecodes, i);
-
- Value* valCl = getResolvedCommonClass(index, true, 0);
+ UserCommonClass* dcl = 0;
+ Value* valCl = getResolvedCommonClass(index, true, &dcl);
Value** args = (Value**)alloca(sizeof(Value*) * (dim + 2));
args[0] = valCl;
args[1] = ConstantInt::get(Type::getInt32Ty(*llvmContext), dim);
@@ -2177,7 +2198,7 @@
Args.push_back(args[v]);
}
push(invoke(module->MultiCallNewFunction, Args, "", currentBlock),
- false);
+ false, dcl ? dcl : upcalls->ArrayOfObject);
break;
}
More information about the vmkit-commits
mailing list