[vmkit-commits] [vmkit] r64303 - in /vmkit/trunk/lib/JnJVM/VMCore: ExceptionsCheck.inc JavaJIT.cpp JavaUpcalls.cpp JavaUpcalls.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed Feb 11 07:34:47 PST 2009
Author: geoffray
Date: Wed Feb 11 09:34:45 2009
New Revision: 64303
URL: http://llvm.org/viewvc/llvm-project?rev=64303&view=rev
Log:
Inline very small methods, and don't call Object.init since it is known to
be empty.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/ExceptionsCheck.inc
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h
Modified: vmkit/trunk/lib/JnJVM/VMCore/ExceptionsCheck.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ExceptionsCheck.inc?rev=64303&r1=64302&r2=64303&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/ExceptionsCheck.inc (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/ExceptionsCheck.inc Wed Feb 11 09:34:45 2009
@@ -148,9 +148,8 @@
BranchInst::Create(currentExceptionBlock, currentBlock);
} else {
if (endNode) {
- const FunctionType *funcType = llvmFunction->getFunctionType();
- const Type* returnType = funcType->getReturnType();
- endNode->addIncoming(Constant::getNullValue(returnType), currentBlock);
+ endNode->addIncoming(Constant::getNullValue(endNode->getType()),
+ currentBlock);
}
BranchInst::Create(endBlock, currentBlock);
}
@@ -172,9 +171,8 @@
BranchInst::Create(currentExceptionBlock, currentBlock);
} else {
if (endNode) {
- const FunctionType *funcType = llvmFunction->getFunctionType();
- const Type* returnType = funcType->getReturnType();
- endNode->addIncoming(Constant::getNullValue(returnType), currentBlock);
+ endNode->addIncoming(Constant::getNullValue(endNode->getType()),
+ currentBlock);
}
BranchInst::Create(endBlock, currentBlock);
}
@@ -190,9 +188,8 @@
BranchInst::Create(currentExceptionBlock, currentBlock);
} else {
if (endNode) {
- const FunctionType *funcType = llvmFunction->getFunctionType();
- const Type* returnType = funcType->getReturnType();
- endNode->addIncoming(Constant::getNullValue(returnType), currentBlock);
+ endNode->addIncoming(Constant::getNullValue(endNode->getType()),
+ currentBlock);
}
BranchInst::Create(endBlock, currentBlock);
}
@@ -484,9 +481,7 @@
endExceptionBlock->eraseFromParent();
} else {
if (endNode) {
- const FunctionType *funcType = llvmFunction->getFunctionType();
- const Type* returnType = funcType->getReturnType();
- endNode->addIncoming(Constant::getNullValue(returnType),
+ endNode->addIncoming(Constant::getNullValue(endNode->getType()),
endExceptionBlock);
}
BranchInst::Create(endBlock, endExceptionBlock);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=64303&r1=64302&r2=64303&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Wed Feb 11 09:34:45 2009
@@ -62,9 +62,11 @@
}
bool JavaJIT::canBeInlined(JavaMethod* meth) {
+ JnjvmClassLoader* loader = meth->classDef->classLoader;
return (meth->canBeInlined &&
meth != compilingMethod && inlineMethods[meth] == 0 &&
- meth->classDef->classLoader == compilingClass->classLoader);
+ (loader == compilingClass->classLoader ||
+ loader == compilingClass->classLoader->bootstrapLoader));
}
void JavaJIT::invokeVirtual(uint16 index) {
@@ -98,10 +100,14 @@
JITVerifyNull(args[0]);
BasicBlock* endBlock = 0;
PHINode* node = 0;
- if (meth && !isAbstract(meth->access) && canBeInlined(meth)) {
+#if 0
+ if (meth && !isAbstract(meth->access)) {
Value* cl = CallInst::Create(module->GetClassFunction, args[0], "",
currentBlock);
Value* cl2 = module->getNativeClass(meth->classDef);
+ if (cl2->getType() != module->JavaCommonClassType) {
+ cl2 = new BitCastInst(cl2, module->JavaCommonClassType, "", currentBlock);
+ }
Value* test = new ICmpInst(ICmpInst::ICMP_EQ, cl, cl2, "", currentBlock);
@@ -110,7 +116,13 @@
endBlock = createBasicBlock("end virtual invoke");
BranchInst::Create(trueBlock, falseBlock, test, currentBlock);
currentBlock = trueBlock;
- Value* res = invokeInline(meth, args);
+ Value* res = 0;
+ if (canBeInlined(meth)) {
+ res = invokeInline(meth, args);
+ } else {
+ Function* func = module->getMethod(meth);
+ res = invoke(func, args, "", currentBlock);
+ }
BranchInst::Create(endBlock, currentBlock);
if (retType != Type::VoidTy) {
node = PHINode::Create(virtualType->getReturnType(), "", endBlock);
@@ -118,7 +130,7 @@
}
currentBlock = falseBlock;
}
-
+#endif
Value* VT = CallInst::Create(module->GetVTFunction, args[0], "",
currentBlock);
@@ -486,8 +498,7 @@
std::vector<Value*>& args) {
PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "inline compile %s\n",
compilingMethod->printString());
-
-
+
Attribut* codeAtt = compilingMethod->lookupAttribut(Attribut::codeAttribut);
if (!codeAtt) {
@@ -512,7 +523,7 @@
endBlock = createBasicBlock("end");
currentBlock = curBB;
- endExceptionBlock = 0;
+ endExceptionBlock = endExBlock;
opcodeInfos = (Opinfo*)alloca(codeLen * sizeof(Opinfo));
memset(opcodeInfos, 0, codeLen * sizeof(Opinfo));
@@ -574,6 +585,8 @@
new StoreInst(*i, objectLocals[index], false, currentBlock);
}
}
+
+ readExceptionTable(reader, codeLen);
exploreOpcodes(&compilingClass->bytes->elements[start], codeLen);
nbEnveloppes = 0;
@@ -751,7 +764,7 @@
}
#endif
- unsigned nbe = readExceptionTable(reader, codeLen);
+ readExceptionTable(reader, codeLen);
exploreOpcodes(&compilingClass->bytes->elements[start], codeLen);
compilingMethod->enveloppes =
@@ -844,8 +857,10 @@
PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "--> end compiling %s\n",
compilingMethod->printString());
- if (nbe == 0 && codeLen < 50 && !callsStackWalker)
- compilingMethod->canBeInlined = false;
+#ifndef DWARF_EXCEPTIONS
+ if (codeLen < 5 && !callsStackWalker)
+ compilingMethod->canBeInlined = true;
+#endif
return llvmFunction;
}
@@ -1193,6 +1208,7 @@
Signdef* signature = 0;
const UTF8* name = 0;
const UTF8* cl = 0;
+
ctpInfo->nameOfStaticOrSpecialMethod(index, cl, name, signature);
LLVMSignatureInfo* LSI = module->getSignatureInfo(signature);
const llvm::FunctionType* virtualType = LSI->getVirtualType();
@@ -1201,6 +1217,14 @@
std::vector<Value*> args;
FunctionType::param_iterator it = virtualType->param_end();
makeArgs(it, index, args, signature->nbArguments + 1);
+
+ Function* func =
+ (Function*)ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_VIRTUAL,
+ signature, meth);
+
+ if (meth == compilingClass->classLoader->bootstrapLoader->upcalls->InitObject)
+ return;
+
JITVerifyNull(args[0]);
#if defined(ISOLATE_SHARING)
@@ -1228,9 +1252,6 @@
currentBlock = trueCl;
args.push_back(node);
#endif
- Function* func =
- (Function*)ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_VIRTUAL,
- signature, meth);
if (!meth) {
// Make sure the class is loaded before materializing the method.
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp?rev=64303&r1=64302&r2=64303&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp Wed Feb 11 09:34:45 2009
@@ -172,6 +172,7 @@
JavaMethod* Classpath::InitStackOverflowError;
JavaMethod* Classpath::InitUnknownError;
JavaMethod* Classpath::InitClassNotFoundException;
+JavaMethod* Classpath::InitObject;
JavaMethod* Classpath::ErrorWithExcpNoClassDefFoundError;
JavaMethod* Classpath::ErrorWithExcpExceptionInInitializerError;
@@ -573,6 +574,8 @@
UPCALL_METHOD_WITH_EXCEPTION(loader, ExceptionInInitializerError);
UPCALL_METHOD_WITH_EXCEPTION(loader, InvocationTargetException);
+ InitObject = UPCALL_METHOD(loader, "java/lang/Object", "<init>", "()V",
+ ACC_VIRTUAL);
newThread =
UPCALL_CLASS(loader, "java/lang/Thread");
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h?rev=64303&r1=64302&r2=64303&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h Wed Feb 11 09:34:45 2009
@@ -205,6 +205,8 @@
ISOLATE_STATIC JavaMethod* InitUnknownError;
ISOLATE_STATIC JavaMethod* InitClassNotFoundException;
+ ISOLATE_STATIC JavaMethod* InitObject;
+
ISOLATE_STATIC JavaMethod* ErrorWithExcpNoClassDefFoundError;
ISOLATE_STATIC JavaMethod* ErrorWithExcpExceptionInInitializerError;
ISOLATE_STATIC JavaMethod* ErrorWithExcpInvocationTargetException;
More information about the vmkit-commits
mailing list