[vmkit-commits] [vmkit] r58186 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp JavaInitialise.cpp JavaJIT.cpp JavaJIT.h Jnjvm.cpp Jnjvm.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Oct 26 09:25:28 PDT 2008


Author: geoffray
Date: Sun Oct 26 11:25:28 2008
New Revision: 58186

URL: http://llvm.org/viewvc/llvm-project?rev=58186&view=rev
Log:
Don't inline functions that call the VMStackWalker.


Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=58186&r1=58185&r2=58186&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Sun Oct 26 11:25:28 2008
@@ -663,6 +663,7 @@
   method.canBeInlined = false;
   method.offset = 0;
   method.JInfo = 0;
+  method.enveloppes = 0;
   return &method;
 }
 

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=58186&r1=58185&r2=58186&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Sun Oct 26 11:25:28 2008
@@ -194,6 +194,7 @@
   Jnjvm::postlib = JCL->asciizConstructUTF8(".so");
 #endif
   Jnjvm::mathName = JCL->asciizConstructUTF8("java/lang/Math");
+  Jnjvm::stackWalkerName = JCL->asciizConstructUTF8("gnu/classpath/VMStackWalker");
   Jnjvm::NoClassDefFoundError = 
     JCL->asciizConstructUTF8("java/lang/NoClassDefFoundError");
 

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=58186&r1=58185&r2=58186&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Sun Oct 26 11:25:28 2008
@@ -50,6 +50,12 @@
 using namespace jnjvm;
 using namespace llvm;
 
+bool JavaJIT::canBeInlined(JavaMethod* meth) {
+  return (meth->canBeInlined &&
+          meth != compilingMethod && inlineMethods[meth] == 0 &&
+          meth->classDef->classLoader == compilingClass->classLoader);
+}
+
 void JavaJIT::invokeVirtual(uint16 index) {
   
   JavaConstantPool* ctpInfo = compilingClass->ctpInfo;
@@ -75,8 +81,7 @@
   JITVerifyNull(args[0]); 
   BasicBlock* endBlock = 0;
   PHINode* node = 0;
-  if (meth && !isAbstract(meth->access) && meth->canBeInlined &&
-      meth != compilingMethod && inlineMethods[meth] == 0) {
+  if (meth && !isAbstract(meth->access) && canBeInlined(meth)) {
     Value* cl = CallInst::Create(module->GetClassFunction, args[0], "",
                                   currentBlock);
     Value* cl2 = module->getNativeClass((Class*)cl, this);
@@ -644,7 +649,7 @@
 #endif
   
   exploreOpcodes(&compilingClass->bytes->elements[start], codeLen);
-  
+  nbEnveloppes = 0;
 
   if (returnType != Type::VoidTy) {
     endNode = llvm::PHINode::Create(returnType, "", endBlock);
@@ -684,7 +689,7 @@
   PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "compiling %s\n",
               compilingMethod->printString());
 
-
+  
   Attribut* codeAtt = compilingMethod->lookupAttribut(Attribut::codeAttribut);
   
   if (!codeAtt) {
@@ -916,7 +921,7 @@
   PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "--> end compiling %s\n",
               compilingMethod->printString());
   
-  if (nbe == 0 && codeLen < 50)
+  if (nbe == 0 && codeLen < 50 && !callsStackWalker)
     compilingMethod->canBeInlined = false;
 
   return llvmFunction;
@@ -1539,6 +1544,7 @@
   jit.unifiedUnreachable = unifiedUnreachable;
   jit.inlineMethods = inlineMethods;
   jit.inlineMethods[meth] = true;
+  jit.inlining = true;
   Instruction* ret = jit.inlineCompile(currentBlock, 
                                        currentExceptionBlock, args);
   inlineMethods[meth] = false;
@@ -1596,8 +1602,7 @@
       (Function*)ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_VIRTUAL,
                                                       signature, meth);
 
-    if (meth && meth->canBeInlined && meth != compilingMethod && 
-        inlineMethods[meth] == 0) {
+    if (meth && canBeInlined(meth)) {
       val = invokeInline(meth, args);
     } else {
       val = invoke(func, args, "", currentBlock);
@@ -1635,6 +1640,10 @@
     val = lowerMathOps(name, args);
   }
 
+  if (cl->equals(Jnjvm::stackWalkerName)) {
+    callsStackWalker = true;
+  }
+
   if (!val) {
     Function* func = (Function*)
       ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_STATIC,
@@ -1648,8 +1657,7 @@
     args.push_back(newCtpCache);
 #endif
 
-    if (meth && meth->canBeInlined && meth != compilingMethod && 
-        inlineMethods[meth] == 0) {
+    if (meth && canBeInlined(meth)) {
       val = invokeInline(meth, args);
     } else {
       val = invoke(func, args, "", currentBlock);
@@ -2050,7 +2058,8 @@
 #ifndef ISOLATE_SHARING
   // ok now the cache
   Enveloppe& enveloppe = compilingMethod->enveloppes[nbEnveloppes++];
-  enveloppe.initialise(compilingClass->ctpInfo, index);
+  if (!inlining)
+    enveloppe.initialise(compilingClass->ctpInfo, index);
    
   Value* llvmEnv = module->getEnveloppe(&enveloppe, this);
 #else

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=58186&r1=58185&r2=58186&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Sun Oct 26 11:25:28 2008
@@ -70,6 +70,8 @@
     compilingClass = meth->classDef;
     module = compilingClass->classLoader->TheModule;
     llvmFunction = func;
+    inlining = false;
+    callsStackWalker = false;
   }
 
   JnjvmModule* module;
@@ -87,6 +89,7 @@
                                    std::vector<llvm::Value*>& args);
 
   std::map<JavaMethod*, bool> inlineMethods;
+  bool inlining;
 
   Class* compilingClass;
   JavaMethod* compilingMethod;
@@ -277,6 +280,9 @@
   /// nbEnveloppes - Number of enveloppes (ie invokeinterface) in this
   /// method.
   uint32 nbEnveloppes;
+
+  bool canBeInlined(JavaMethod* meth);
+  bool callsStackWalker;
 };
 
 enum Opcode {

Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=58186&r1=58185&r2=58186&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Sun Oct 26 11:25:28 2008
@@ -51,6 +51,7 @@
   DEF_UTF8(prelib);
   DEF_UTF8(postlib);
   DEF_UTF8(mathName);
+  DEF_UTF8(stackWalkerName);
   DEF_UTF8(abs);
   DEF_UTF8(sqrt);
   DEF_UTF8(sin);

Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h?rev=58186&r1=58185&r2=58186&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Sun Oct 26 11:25:28 2008
@@ -183,6 +183,7 @@
   static const UTF8* prelib; 
   static const UTF8* postlib; 
   static const UTF8* mathName;
+  static const UTF8* stackWalkerName;
   static const UTF8* abs;
   static const UTF8* sqrt;
   static const UTF8* sin;





More information about the vmkit-commits mailing list