[vmkit-commits] [vmkit] r88925 - in /vmkit/trunk/lib/JnJVM/Compiler: JavaJIT.cpp JavaJIT.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Nov 16 09:33:50 PST 2009
Author: geoffray
Date: Mon Nov 16 11:33:49 2009
New Revision: 88925
URL: http://llvm.org/viewvc/llvm-project?rev=88925&view=rev
Log:
Add high-level metadata types to Store instructions.
Modified:
vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h
Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp?rev=88925&r1=88924&r2=88925&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp Mon Nov 16 11:33:49 2009
@@ -205,7 +205,7 @@
if (retType != Type::getVoidTy(getGlobalContext())) {
if (retType == module->JavaObjectType) {
JnjvmClassLoader* JCL = compilingClass->classLoader;
- push(val, false, signature->getReturnType()->assocClass(JCL));
+ push(val, false, signature->getReturnType()->findAssocClass(JCL));
} else {
push(val, retTypedef->isUnsigned());
if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
@@ -867,7 +867,8 @@
std::vector<Value*>::iterator i = args.begin();
if (isVirtual(compilingMethod->access)) {
- new StoreInst(*i, objectLocals[0], false, currentBlock);
+ Instruction* V = new StoreInst(*i, objectLocals[0], false, currentBlock);
+ addHighLevelType(V, compilingClass);
++i;
++index;
++count;
@@ -896,7 +897,8 @@
} else if (curType == Type::getFloatTy(getGlobalContext())) {
new StoreInst(*i, floatLocals[index], false, currentBlock);
} else {
- new StoreInst(*i, objectLocals[index], false, currentBlock);
+ Instruction* V = new StoreInst(*i, objectLocals[index], false, currentBlock);
+ addHighLevelType(V, cur->findAssocClass(compilingClass->classLoader));
}
}
@@ -1025,7 +1027,8 @@
uint32 type = 0;
if (isVirtual(compilingMethod->access)) {
- new StoreInst(i, objectLocals[0], false, currentBlock);
+ Instruction* V = new StoreInst(i, objectLocals[0], false, currentBlock);
+ addHighLevelType(V, compilingClass);
++i;
++index;
++count;
@@ -1053,7 +1056,8 @@
} else if (curType == Type::getFloatTy(getGlobalContext())) {
new StoreInst(i, floatLocals[index], false, currentBlock);
} else {
- new StoreInst(i, objectLocals[index], false, currentBlock);
+ Instruction* V = new StoreInst(i, objectLocals[index], false, currentBlock);
+ addHighLevelType(V, cur->findAssocClass(compilingClass->classLoader));
}
}
@@ -1455,41 +1459,6 @@
}
-void JavaJIT::addFakePHINodes(BasicBlock* dest, BasicBlock* insert) {
- if(dest->empty()) {
- for (std::vector<CommonClass*>::iterator i = stack.begin(),
- e = stack.end(); i!= e; ++i) {
- CommonClass* cl = *i;
- if (cl == upcalls->OfInt) {
- PHINode* node = PHINode::Create(Type::getInt32Ty(getGlobalContext()), "", dest);
- node->addIncoming(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())), insert);
- } else if (cl == upcalls->OfFloat) {
- PHINode* node = PHINode::Create(Type::getFloatTy(getGlobalContext()), "", dest);
- node->addIncoming(Constant::getNullValue(Type::getFloatTy(getGlobalContext())), insert);
- } else if (cl == upcalls->OfDouble) {
- PHINode* node = PHINode::Create(Type::getDoubleTy(getGlobalContext()), "", dest);
- node->addIncoming(Constant::getNullValue(Type::getDoubleTy(getGlobalContext())), insert);
- } else if (cl == upcalls->OfLong) {
- PHINode* node = PHINode::Create(Type::getInt64Ty(getGlobalContext()), "", dest);
- node->addIncoming(Constant::getNullValue(Type::getInt64Ty(getGlobalContext())), insert);
- } else {
- PHINode* node = PHINode::Create(module->JavaObjectType, "", dest);
- node->addIncoming(Constant::getNullValue(module->JavaObjectType),
- insert);
- }
- }
- } else {
- for (BasicBlock::iterator i = dest->begin(), e = dest->end(); i != e; ++i) {
- if (PHINode* node = dyn_cast<PHINode>(i)) {
- node->addIncoming(Constant::getNullValue(node->getType()), insert);
- } else {
- break;
- }
- }
- }
-}
-
-
Instruction* JavaJIT::lowerMathOps(const UTF8* name,
std::vector<Value*>& args) {
JnjvmBootstrapLoader* loader = compilingClass->classLoader->bootstrapLoader;
@@ -1695,7 +1664,7 @@
if (retType != Type::getVoidTy(getGlobalContext())) {
if (retType == module->JavaObjectType) {
JnjvmClassLoader* JCL = compilingClass->classLoader;
- push(val, false, signature->getReturnType()->assocClass(JCL));
+ push(val, false, signature->getReturnType()->findAssocClass(JCL));
} else {
push(val, signature->getReturnType()->isUnsigned());
if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
@@ -1769,7 +1738,7 @@
if (retType != Type::getVoidTy(getGlobalContext())) {
if (retType == module->JavaObjectType) {
JnjvmClassLoader* JCL = compilingClass->classLoader;
- push(val, false, signature->getReturnType()->assocClass(JCL));
+ push(val, false, signature->getReturnType()->findAssocClass(JCL));
} else {
push(val, signature->getReturnType()->isUnsigned());
if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
@@ -2083,7 +2052,7 @@
"", currentBlock);
JnjvmClassLoader* JCL = compilingClass->classLoader;
- push(V, false, sign->assocClass(JCL));
+ push(V, false, sign->findAssocClass(JCL));
}
}
}
@@ -2092,7 +2061,7 @@
if (!final) {
JnjvmClassLoader* JCL = compilingClass->classLoader;
- CommonClass* cl = sign->assocClass(JCL);
+ CommonClass* cl = sign->findAssocClass(JCL);
push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned(), cl);
}
if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) {
@@ -2124,7 +2093,7 @@
void JavaJIT::getVirtualField(uint16 index) {
Typedef* sign = compilingClass->ctpInfo->infoOfField(index);
JnjvmClassLoader* JCL = compilingClass->classLoader;
- CommonClass* cl = sign->assocClass(JCL);
+ CommonClass* cl = sign->findAssocClass(JCL);
LLVMAssessorInfo& LAI = TheCompiler->getTypedefInfo(sign);
const Type* type = LAI.llvmType;
@@ -2283,7 +2252,7 @@
if (node) {
if (node->getType() == module->JavaObjectType) {
JnjvmClassLoader* JCL = compilingClass->classLoader;
- push(node, false, signature->getReturnType()->assocClass(JCL));
+ push(node, false, signature->getReturnType()->findAssocClass(JCL));
} else {
push(node, signature->getReturnType()->isUnsigned());
if (retType == Type::getDoubleTy(getGlobalContext()) ||
Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h?rev=88925&r1=88924&r2=88925&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h Mon Nov 16 11:33:49 2009
@@ -17,6 +17,7 @@
#include "llvm/Function.h"
#include "llvm/Instructions.h"
#include "llvm/LLVMContext.h"
+#include "llvm/Metadata.h"
#include "llvm/Type.h"
#include "llvm/Value.h"
@@ -237,12 +238,21 @@
stack.push_back(upcalls->OfDouble);
} else {
assert(type == module->JavaObjectType && "Can't handle this type");
- new llvm::StoreInst(val, objectStack[currentStackIndex++], false,
- currentBlock);
+ llvm::Instruction* V = new
+ llvm::StoreInst(val, objectStack[currentStackIndex++], false,
+ currentBlock);
stack.push_back(cl ? cl : upcalls->OfObject);
+ addHighLevelType(V, topTypeInfo());
}
}
+ void addHighLevelType(llvm::Instruction* V, CommonClass* cl) {
+ llvm::Value* A[1] =
+ { TheCompiler->getNativeClass(cl ? cl : upcalls->OfObject) };
+ llvm::MDNode* Node = llvm::MDNode::get(*llvmContext, A, 1);
+ llvmContext->getMetadata().addMD(module->MetadataTypeKind, Node, V);
+ }
+
/// pop - Pop a value from the stack and return it.
llvm::Value* pop() {
llvm::Value* res = top();
@@ -326,7 +336,7 @@
return llvm::BasicBlock::Create(*llvmContext, name, llvmFunction);
}
- /// branch - Branch based on a boolean value. Update PHI nodes accordingly.
+ /// branch - Branch based on a boolean value.
void branch(llvm::Value* test, llvm::BasicBlock* ifTrue,
llvm::BasicBlock* ifFalse, llvm::BasicBlock* insert,
Opinfo& info) {
@@ -336,7 +346,7 @@
llvm::BranchInst::Create(ifTrue, ifFalse, test, insert);
}
- /// branch - Branch to a new block. Update PHI nodes accordingly.
+ /// branch - Branch to a new block.
void branch(Opinfo& info, llvm::BasicBlock* insert) {
if (stackSize())
if (!info.stack.size())
@@ -344,9 +354,6 @@
llvm::BranchInst::Create(info.newBlock, insert);
}
- /// testPHINodes - Update PHI nodes when branching to a new block.
- void addFakePHINodes(llvm::BasicBlock* dest, llvm::BasicBlock* insert);
-
//===-------------------------- Synchronization --------------------------===//
/// beginSynchronize - Emit synchronization code to acquire the instance
More information about the vmkit-commits
mailing list