[llvm-commits] [vmkit] r50041 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaJIT.cpp JavaJIT.h JavaJITInitialise.cpp JavaJITOpcodes.cpp JavaRuntimeJIT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Apr 21 07:23:16 PDT 2008
Author: geoffray
Date: Mon Apr 21 09:23:15 2008
New Revision: 50041
URL: http://llvm.org/viewvc/llvm-project?rev=50041&view=rev
Log:
Do not resolve classes on readExceptionTable, and do not clinit classes on INSTANCEOF and CHECKCAST opcodes execution.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50041&r1=50040&r2=50041&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Mon Apr 21 09:23:15 2008
@@ -381,7 +381,7 @@
compilingClass->isolate->module);
compilingClass->isolate->protectModule->unlock();
- currentBlock = createBasicBlock("start");
+ BasicBlock* startBlock = currentBlock = createBasicBlock("start");
endExceptionBlock = createBasicBlock("endExceptionBlock");
unifiedUnreachable = createBasicBlock("unifiedUnreachable");
@@ -404,6 +404,8 @@
unsigned nbe = readExceptionTable(reader);
+ currentBlock = startBlock;
+
for (int i = 0; i < maxLocals; i++) {
intLocals.push_back(new AllocaInst(Type::Int32Ty, "", currentBlock));
doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "", currentBlock));
@@ -602,10 +604,11 @@
ex->endpc = reader->readU2();
ex->handlerpc = reader->readU2();
- uint16 catche = reader->readU2();
+ ex->catche = reader->readU2();
- if (catche) {
- ex->catchClass = (Class*)ctpInfo->loadClass(catche);
+ if (ex->catche) {
+ Class* cl = (Class*)(ctpInfo->getMethodClassIfLoaded(ex->catche));
+ ex->catchClass = cl;
} else {
ex->catchClass = Classpath::newThrowable;
}
@@ -664,6 +667,8 @@
Exception* next = 0;
BasicBlock* bbNext = 0;
PHINode* nodeNext = 0;
+ currentExceptionBlock = opcodeInfos[cur->handlerpc].exceptionBlock;
+
if (i + 1 != e) {
next = *(i + 1);
if (!(cur->startpc >= next->startpc && cur->endpc <= next->endpc)) {
@@ -695,17 +700,22 @@
}
Module* M = compilingClass->isolate->module;
- Value* cl = new LoadInst(cur->catchClass->llvmVar(M), "", cur->realTest);
+ Value* cl = 0;
+ currentBlock = cur->realTest;
+ if (cur->catchClass)
+ cl = new LoadInst(cur->catchClass->llvmVar(M), "", currentBlock);
+ else
+ cl = getResolvedClass(cur->catche, false);
Value* cmp = llvm::CallInst::Create(compareExceptionLLVM, cl, "",
- cur->realTest);
- llvm::BranchInst::Create(cur->handler, bbNext, cmp, cur->realTest);
+ currentBlock);
+ llvm::BranchInst::Create(cur->handler, bbNext, cmp, currentBlock);
if (nodeNext)
- nodeNext->addIncoming(cur->exceptionPHI, cur->realTest);
+ nodeNext->addIncoming(cur->exceptionPHI, currentBlock);
if (cur->handler->empty()) {
cur->handlerPHI = llvm::PHINode::Create(mvm::jit::ptrType, "",
cur->handler);
- cur->handlerPHI->addIncoming(cur->exceptionPHI, cur->realTest);
+ cur->handlerPHI->addIncoming(cur->exceptionPHI, currentBlock);
Value* exc = llvm::CallInst::Create(getJavaExceptionLLVM, "",
cur->handler);
llvm::CallInst::Create(clearExceptionLLVM, "", cur->handler);
@@ -718,7 +728,7 @@
new StoreInst(exc, supplLocal, false, cur->handler);
} else {
Instruction* insn = cur->handler->begin();
- ((PHINode*)insn)->addIncoming(cur->exceptionPHI, cur->realTest);
+ ((PHINode*)insn)->addIncoming(cur->exceptionPHI, currentBlock);
}
}
@@ -1298,7 +1308,7 @@
}
}
-Value* JavaJIT::getInitializedClass(uint16 index) {
+Value* JavaJIT::getResolvedClass(uint16 index, bool clinit) {
const Type* PtrTy = mvm::jit::ptrType;
compilingClass->isolate->protectModule->lock();
GlobalVariable * gv =
@@ -1331,6 +1341,11 @@
mvm::jit::unprotectConstants();
Args.push_back(CI);
Args.push_back(gv);
+ if (clinit) {
+ Args.push_back(mvm::jit::constantOne);
+ } else {
+ Args.push_back(mvm::jit::constantZero);
+ }
Value* res = invoke(newLookupLLVM, Args, "", currentBlock);
node->addIncoming(res, currentBlock);
@@ -1355,7 +1370,7 @@
#endif
Value* val = 0;
if (!cl || !cl->isReady()) {
- Value* node = getInitializedClass(index);
+ Value* node = getResolvedClass(index, true);
#ifndef MULTIPLE_VM
val = invoke(doNewUnknownLLVM, node, "", currentBlock);
#else
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=50041&r1=50040&r2=50041&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Mon Apr 21 09:23:15 2008
@@ -48,7 +48,7 @@
uint32 startpc;
uint32 endpc;
uint32 handlerpc;
- uint16 index;
+ uint16 catche;
Class* catchClass;
llvm::BasicBlock* test;
llvm::BasicBlock* realTest;
@@ -171,7 +171,7 @@
llvm::Value* ldResolved(uint16 index, bool stat, llvm::Value* object,
const llvm::Type* fieldType,
const llvm::Type* fieldTypePtr);
- llvm::Value* getInitializedClass(uint16 index);
+ llvm::Value* getResolvedClass(uint16 index, bool clinit);
// methods invoke
void makeArgs(llvm::FunctionType::param_iterator it,
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=50041&r1=50040&r2=50041&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Mon Apr 21 09:23:15 2008
@@ -313,6 +313,7 @@
args.push_back(mvm::jit::ptrType);
args.push_back(Type::Int32Ty);
args.push_back(PointerType::getUnqual(mvm::jit::ptrType));
+ args.push_back(Type::Int32Ty);
const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args,
false);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=50041&r1=50040&r2=50041&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Mon Apr 21 09:23:15 2008
@@ -1852,7 +1852,7 @@
if (dcl && dcl->isReady()) {
clVar = new LoadInst(dcl->llvmVar(compilingClass->isolate->module), "", ifFalse);
} else {
- clVar = getInitializedClass(index);
+ clVar = getResolvedClass(index, false);
}
std::vector<Value*> args;
args.push_back(obj);
@@ -1889,7 +1889,7 @@
if (dcl && dcl->isReady()) {
clVar = new LoadInst(dcl->llvmVar(compilingClass->isolate->module), "", currentBlock);
} else {
- clVar = getInitializedClass(index);
+ clVar = getResolvedClass(index, false);
}
std::vector<Value*> args;
args.push_back(pop());
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=50041&r1=50040&r2=50041&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Mon Apr 21 09:23:15 2008
@@ -228,10 +228,11 @@
p = (void*)&runtimeUTF8ToStr;
}
-extern "C" Class* newLookup(Class* caller, uint32 index, Class** toAlloc) {
+extern "C" Class* newLookup(Class* caller, uint32 index, Class** toAlloc,
+ uint32 clinit) {
JavaCtpInfo* ctpInfo = caller->ctpInfo;
Class* cl = (Class*)ctpInfo->loadClass(index);
- cl->resolveClass(true);
+ cl->resolveClass(clinit);
*toAlloc = cl;
return cl;
More information about the llvm-commits
mailing list