[vmkit-commits] [vmkit] r140617 - in /vmkit/trunk: include/j3/JavaAOTCompiler.h include/j3/JavaCompiler.h include/j3/JavaJITCompiler.h include/j3/JavaLLVMCompiler.h include/j3/LLVMInfo.h lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JavaJIT.cpp lib/J3/Compiler/JavaJIT.h lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JavaJITOpcodes.cpp lib/J3/Compiler/JavaLLVMCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.cpp lib/J3/VMCore/JavaClass.h lib/J3/VMCore/JavaRuntimeJIT.cpp lib/J3/VMCore/Jnjvm.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Tue Sep 27 11:28:55 PDT 2011


Author: geoffray
Date: Tue Sep 27 13:28:55 2011
New Revision: 140617

URL: http://llvm.org/viewvc/llvm-project?rev=140617&view=rev
Log:
Customize methods when jitting.


Modified:
    vmkit/trunk/include/j3/JavaAOTCompiler.h
    vmkit/trunk/include/j3/JavaCompiler.h
    vmkit/trunk/include/j3/JavaJITCompiler.h
    vmkit/trunk/include/j3/JavaLLVMCompiler.h
    vmkit/trunk/include/j3/LLVMInfo.h
    vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJIT.h
    vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
    vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp
    vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
    vmkit/trunk/lib/J3/VMCore/JavaClass.cpp
    vmkit/trunk/lib/J3/VMCore/JavaClass.h
    vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp
    vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp

Modified: vmkit/trunk/include/j3/JavaAOTCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaAOTCompiler.h?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/include/j3/JavaAOTCompiler.h (original)
+++ vmkit/trunk/include/j3/JavaAOTCompiler.h Tue Sep 27 13:28:55 2011
@@ -40,7 +40,7 @@
     return new JavaAOTCompiler(ModuleID);
   }
   
-  virtual void* materializeFunction(JavaMethod* meth) {
+  virtual void* materializeFunction(JavaMethod* meth, Class* customizeFor) {
     fprintf(stderr, "Can not materiale a function in AOT mode.");
     abort();
   }
@@ -52,7 +52,7 @@
   
   virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign,
                                    bool stat, llvm::BasicBlock* insert);
-  virtual llvm::Function* getMethod(JavaMethod* meth);
+  virtual llvm::Function* getMethod(JavaMethod* meth, Class* customizeFor);
   
   virtual void makeVT(Class* cl);
   virtual void makeIMT(Class* cl);
@@ -125,7 +125,7 @@
   std::map<const Class*, llvm::Constant*> virtualMethods;
   std::map<const JavaObject*, llvm::Constant*> finalObjects;
   std::map<const llvm::Constant*, JavaObject*> reverseFinalObjects;
-  std::vector<JavaMethod*> toCompile;
+  std::vector<std::pair<JavaMethod*, Class*> > toCompile;
   
   typedef std::map<const JavaObject*, llvm::Constant*>::iterator
     final_object_iterator;
@@ -201,7 +201,7 @@
 
 private:
   void compileAllStubs(Signdef* sign);
-  llvm::Function* getMethodOrStub(JavaMethod* meth);
+  llvm::Function* getMethodOrStub(JavaMethod* meth, Class* customizeFor);
 };
 
 } // end namespace j3

Modified: vmkit/trunk/include/j3/JavaCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaCompiler.h?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/include/j3/JavaCompiler.h (original)
+++ vmkit/trunk/include/j3/JavaCompiler.h Tue Sep 27 13:28:55 2011
@@ -40,7 +40,7 @@
     return this;
   }
   
-  virtual void* materializeFunction(JavaMethod* meth) {
+  virtual void* materializeFunction(JavaMethod* meth, Class* customizeFor) {
     fprintf(stderr, "Materializing a function in an empty compiler");
     abort();
     return 0;

Modified: vmkit/trunk/include/j3/JavaJITCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaJITCompiler.h?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/include/j3/JavaJITCompiler.h (original)
+++ vmkit/trunk/include/j3/JavaJITCompiler.h Tue Sep 27 13:28:55 2011
@@ -57,7 +57,7 @@
   virtual void makeVT(Class* cl);
   virtual void makeIMT(Class* cl);
   
-  virtual void* materializeFunction(JavaMethod* meth);
+  virtual void* materializeFunction(JavaMethod* meth, Class* customizeFor);
   
   virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl);
   virtual JavaObject* getFinalObject(llvm::Value* C);

Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaLLVMCompiler.h?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/include/j3/JavaLLVMCompiler.h (original)
+++ vmkit/trunk/include/j3/JavaLLVMCompiler.h Tue Sep 27 13:28:55 2011
@@ -75,9 +75,6 @@
   std::map<Class*, LLVMClassInfo*> class_infos;
   typedef std::map<Class*, LLVMClassInfo*>::iterator class_info_iterator;
 
-  std::map<llvm::MDNode*, JavaMethod*> DbgInfos;
-  typedef std::map<llvm::MDNode*, JavaMethod*>::iterator dbg_iterator;
-
   llvm::DenseMap<llvm::FunctionType*, llvm::Function*> virtualStubs;
   llvm::DenseMap<llvm::FunctionType*, llvm::Function*> specialStubs;
   llvm::DenseMap<llvm::FunctionType*, llvm::Function*> staticStubs;
@@ -131,11 +128,10 @@
   virtual ~JavaLLVMCompiler();
 
   JavaMethod* getJavaMethod(const llvm::Function&);
-  llvm::MDNode* GetDbgSubprogram(JavaMethod* meth);
 
   void resolveVirtualClass(Class* cl);
   void resolveStaticClass(Class* cl);
-  virtual llvm::Function* getMethod(JavaMethod* meth);
+  virtual llvm::Function* getMethod(JavaMethod* meth, Class* customizeFor);
 
   void initialiseAssessorInfo();
   std::map<const char, LLVMAssessorInfo> AssessorInfo;
@@ -209,8 +205,9 @@
   
   virtual void setMethod(llvm::Function* func, void* ptr, const char* name) = 0;
   
-  virtual void* materializeFunction(JavaMethod* meth) = 0;
-  llvm::Function* parseFunction(JavaMethod* meth);
+  virtual void* materializeFunction(JavaMethod* meth,
+                                    Class* customizeFor) = 0;
+  llvm::Function* parseFunction(JavaMethod* meth, Class* customizeFor);
    
   llvm::FunctionPassManager* JavaFunctionPasses;
   llvm::FunctionPassManager* JavaNativeFunctionPasses;

Modified: vmkit/trunk/include/j3/LLVMInfo.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMInfo.h?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/include/j3/LLVMInfo.h (original)
+++ vmkit/trunk/include/j3/LLVMInfo.h Tue Sep 27 13:28:55 2011
@@ -85,27 +85,28 @@
   llvm::Function* methodFunction;
   llvm::Constant* offsetConstant;
   llvm::FunctionType* functionType;
-  llvm::MDNode* DbgSubprogram;
+  std::map<Class*, llvm::Function*> customizedVersions;
   
 public:
-  llvm::Function* getMethod();
+  llvm::Function* getMethod(Class* customizeFor);
   llvm::Constant* getOffset();
   llvm::FunctionType* getFunctionType();
+  bool isCustomizable;
     
   LLVMMethodInfo(JavaMethod* M, JavaLLVMCompiler* comp) :  Compiler(comp),
     methodDef(M), methodFunction(0), offsetConstant(0), functionType(0),
-    DbgSubprogram(0) {}
+    isCustomizable(false) {}
  
-  void setDbgSubprogram(llvm::MDNode* node) { DbgSubprogram = node; }
-  llvm::MDNode* getDbgSubprogram() { return DbgSubprogram; }
-
   virtual void clear() {
     methodFunction = 0;
     offsetConstant = 0;
     functionType = 0;
-    DbgSubprogram = 0;
+    customizedVersions.clear();
+    isCustomizable = false;
   }
 
+  void setCustomizedVersion(Class* customizeFor, llvm::Function* F);
+
   friend class JavaAOTCompiler;
 };
 

Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Tue Sep 27 13:28:55 2011
@@ -1047,13 +1047,13 @@
   MethodElts.push_back(getUTF8(method.type));
   
   // canBeInlined
-  MethodElts.push_back(ConstantInt::get(Type::getInt8Ty(getLLVMContext()), method.canBeInlined));
+  MethodElts.push_back(ConstantInt::get(Type::getInt8Ty(getLLVMContext()), method.isCustomizable));
 
   // code
   if (getMethodInfo(&method)->methodFunction == NULL) {
     MethodElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType));
   } else {
-    Function* func = getMethod(&method);
+    Function* func = getMethod(&method, NULL);
     MethodElts.push_back(ConstantExpr::getCast(Instruction::BitCast, func,
                                                JavaIntrinsics.ptrType));
   }
@@ -1567,22 +1567,51 @@
   }
 }
 
-Function* JavaAOTCompiler::getMethodOrStub(JavaMethod* meth) {
+Function* JavaAOTCompiler::getMethodOrStub(JavaMethod* meth, Class* customizeFor) {
   assert(!isStatic(meth->access));
-  if (precompile
-      && (meth->code == NULL)
-      && (getMethodInfo(meth)->methodFunction == NULL)) {
-    LLVMSignatureInfo* LSI = getSignatureInfo(meth->getSignature());
-    return LSI->getVirtualStub();
+  LLVMMethodInfo* LMI = getMethodInfo(meth);
+  LLVMSignatureInfo* LSI = getSignatureInfo(meth->getSignature());
+  if (precompile) {
+    if (customizeFor != NULL) {
+      if (LMI->isCustomizable) {
+        if (LMI->customizedVersions[customizeFor] != NULL) {
+          // We have a customized version, get it.
+          return getMethod(meth, customizeFor);
+        } else {
+          // No customized version, even if there is an uncustomized version,
+          // we return the stub, so that we get a customized version at
+          // runtime.
+          return LSI->getVirtualStub();
+        }
+      } else {
+        // If we have created a method for it, we know the method is not customizable,
+        // and we can use the 'general' method.
+        if (LMI->methodFunction) {
+          return getMethod(meth, NULL);
+        } else {
+          // Otherwise, no method has been created for it.
+          return LSI->getVirtualStub();
+        }
+      }
+    } else {
+      // If we have created a method for it, take it.
+      if (LMI->methodFunction) {
+        return getMethod(meth, NULL);
+      } else {
+        // Otherwise, no method has been created for it.
+        return LSI->getVirtualStub();
+      }
+    }
   } else {
-    return getMethod(meth);
+    // We're not precompiling, get the method.
+    return getMethod(meth, customizeFor);
   }
 }
 
-Function* JavaAOTCompiler::getMethod(JavaMethod* meth) {
-  Function* func = getMethodInfo(meth)->getMethod();
+Function* JavaAOTCompiler::getMethod(JavaMethod* meth, Class* customizeFor) {
+  Function* func = getMethodInfo(meth)->getMethod(customizeFor);
   if (func->hasExternalWeakLinkage()) {
-    toCompile.push_back(meth);
+    toCompile.push_back(std::make_pair(meth, customizeFor));
   }
   return func;
 }
@@ -1594,6 +1623,8 @@
   JavaVirtualTable* RealVT = classDef->isClass() ? 
     VT : ClassArray::SuperArray->virtualVT;
 
+  Class* maybeCustomize = classDef->isClass() ? classDef->asClass() : NULL;
+
   ArrayType* ATy = 
     dyn_cast<ArrayType>(JavaIntrinsics.VTType->getContainedType(0));
   PointerType* PTy = dyn_cast<PointerType>(ATy->getContainedType(0));
@@ -1606,7 +1637,7 @@
   Function* Finalizer = NULL;
   if (VT->hasDestructor()) {
     JavaMethod* meth = (JavaMethod*)(RealVT->destructor);
-    Finalizer = getMethodOrStub(meth);
+    Finalizer = getMethodOrStub(meth, maybeCustomize);
   } else {
     Finalizer = EmptyDestructorFunction;
   }
@@ -1729,7 +1760,7 @@
                                                      Imeth->type,
                                                      false, true, 0);
         assert(meth && "No method found");
-        Function* func = getMethodOrStub(meth);
+        Function* func = getMethodOrStub(meth, maybeCustomize);
         IElemts.push_back(ConstantExpr::getBitCast(func, PTy));
       } else if (size > 1) {
         std::vector<JavaMethod*> methods;
@@ -1750,7 +1781,7 @@
 
         if (SameMethod) {
           assert(methods[0] && "No method found");
-          Function* func = getMethodOrStub(methods[0]);
+          Function* func = getMethodOrStub(methods[0], maybeCustomize);
           IElemts.push_back(ConstantExpr::getBitCast(func, PTy));
         } else {
 
@@ -1769,7 +1800,7 @@
             JavaMethod* Cmeth = *it;
             assert(Cmeth && "No method found");
 
-            Function* func = getMethodOrStub(Cmeth);
+            Function* func = getMethodOrStub(Cmeth, maybeCustomize);
             InternalElemts.push_back(
               ConstantExpr::getBitCast(getMethodInClass(Imeth), PTy));
             InternalElemts.push_back(ConstantExpr::getBitCast(func, PTy));
@@ -1804,10 +1835,10 @@
   // methods
   for (uint32 i = JavaVirtualTable::getFirstJavaMethodIndex(); i < size; ++i) {
     JavaMethod* meth = ((JavaMethod**)RealVT)[i];
-    Function* F = getMethodOrStub(meth);
     if (isAbstract(meth->access)) {
       Elemts.push_back(Constant::getNullValue(PTy));
     } else {
+      Function* F = getMethodOrStub(meth, maybeCustomize);
       Elemts.push_back(ConstantExpr::getCast(Instruction::BitCast, F, PTy));
     }
   }
@@ -2054,13 +2085,13 @@
 
   for (uint32 i = 0; i < cl->nbVirtualMethods; ++i) {
     JavaMethod& meth = cl->virtualMethods[i];
-    if (!isAbstract(meth.access)) parseFunction(&meth);
+    if (!isAbstract(meth.access)) parseFunction(&meth, NULL);
     if (generateStubs) compileAllStubs(meth.getSignature());
   }
   
   for (uint32 i = 0; i < cl->nbStaticMethods; ++i) {
     JavaMethod& meth = cl->staticMethods[i];
-    if (!isAbstract(meth.access)) parseFunction(&meth);
+    if (!isAbstract(meth.access)) parseFunction(&meth, NULL);
     if (generateStubs) compileAllStubs(meth.getSignature());
   }
 }
@@ -2158,11 +2189,11 @@
       cl->setOwnerClass(JavaThread::get());
       
       for (uint32 i = 0; i < cl->nbVirtualMethods; ++i) {
-        M->getMethod(&cl->virtualMethods[i]);
+        M->getMethod(&cl->virtualMethods[i], NULL);
       }
 
       for (uint32 i = 0; i < cl->nbStaticMethods; ++i) {
-        M->getMethod(&cl->staticMethods[i]);
+        M->getMethod(&cl->staticMethods[i], NULL);
       }
     }
 
@@ -2182,7 +2213,7 @@
                      magic.length() - 1)) {
           for (uint32 i = 0; i < cl->nbVirtualMethods; ++i) {
             if (!isAbstract(cl->virtualMethods[i].access)) {
-              Function* F = M->getMethod(&cl->virtualMethods[i]);
+              Function* F = M->getMethod(&cl->virtualMethods[i], NULL);
               M->setMethod(F, ptr, F->getName().data());
               cl->virtualMethods[i].compiledPtr();
               // Set native so that we don't try to inline it.
@@ -2192,7 +2223,7 @@
 
           for (uint32 i = 0; i < cl->nbStaticMethods; ++i) {
             if (!isAbstract(cl->staticMethods[i].access)) {
-              Function* F = M->getMethod(&cl->staticMethods[i]);
+              Function* F = M->getMethod(&cl->staticMethods[i], NULL);
               M->setMethod(F, ptr, F->getName().data());
               cl->staticMethods[i].compiledPtr();
               // Set native so that we don't try to inline it.
@@ -2338,15 +2369,26 @@
 
   for (method_info_iterator I = jitCompiler->method_infos.begin(),
        E = jitCompiler->method_infos.end(); I != E; I++) {
-    if (!isAbstract(I->first->access)) parseFunction(I->first);
+    if (!isAbstract(I->first->access)) {
+      LLVMMethodInfo* LMI = I->second;
+      if (LMI->methodFunction) {
+        parseFunction(I->first, NULL);
+      }
+      for (std::map<Class*, Function*>::iterator
+           CI = LMI->customizedVersions.begin(),
+           CE = LMI->customizedVersions.end(); CI != CE; CI++) {
+        parseFunction(I->first, NULL);
+      }
+    }
   }
 
   while (!toCompile.empty()) {
-    JavaMethod* meth = toCompile.back();
+    JavaMethod* meth = toCompile.back().first;
+    // Class* customizeFor = toCompile.back().second;
     // parseFunction may introduce new functions to compile, so
     // pop toCompile before calling parseFunction.
     toCompile.pop_back();
-    parseFunction(meth);
+    parseFunction(meth, NULL);
   }
 
   // Make sure classes and arrays already referenced in constant pools
@@ -2368,6 +2410,8 @@
     gv->setInitializer(CreateConstantFromVT(VT));
   }
 
+  assert(toCompile.size() == 0);
+
   // Add used stubs to the image.
   for (SignMap::iterator i = loader->javaSignatures->map.begin(),
        e = loader->javaSignatures->map.end(); i != e; i++) {

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Tue Sep 27 13:28:55 2011
@@ -21,6 +21,7 @@
 #include <llvm/Module.h>
 #include <llvm/Type.h>
 #include <llvm/Analysis/DebugInfo.h>
+#include "llvm/Analysis/DIBuilder.h"
 #include <llvm/Support/CFG.h>
 
 #include "mvm/JIT.h"
@@ -44,6 +45,20 @@
 using namespace j3;
 using namespace llvm;
 
+void JavaJIT::updateStackInfo(Opinfo& info) {
+  if (stackSize()) {
+    if (!info.stack.size()) {
+      info.stack = stack;
+    } else {
+      int size = stack.size();
+      info.stack.clear();
+      for (int i = 0 ; i < size; i++) {
+        info.stack.push_back(MetaInfo(stack[i].type, NOP));
+      }
+    }
+  }
+}
+
 bool JavaJIT::needsInitialisationCheck(Class* cl) {
   if (cl->isReadyForCompilation() || 
       (!cl->isInterface() && compilingClass->isAssignableFrom(cl))) {
@@ -60,7 +75,7 @@
   return true;
 }
 
-bool JavaJIT::canBeInlined(JavaMethod* meth) {
+bool JavaJIT::canBeInlined(JavaMethod* meth, bool customizing) {
   if (inlineMethods[meth]) return false;
   if (isSynchro(meth->access)) return false;
   if (isNative(meth->access)) return false;
@@ -78,7 +93,7 @@
   if (nbHandlers != 0) return false;
   reader.cursor = start;
 
-  JavaJIT jit(TheCompiler, meth, llvmFunction);
+  JavaJIT jit(TheCompiler, meth, llvmFunction, customizing ? customizeFor : NULL);
   jit.inlineMethods = inlineMethods;
   jit.inlineMethods[meth] = true;
   if (!jit.analyzeForInlining(reader, codeLen)) return false;
@@ -94,20 +109,39 @@
   ctpInfo->infoOfMethod(index, ACC_VIRTUAL, cl, meth);
   bool canBeDirect = false;
   Value* val = NULL;  // The return from the method.
+  const UTF8* name = 0;
+  Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index, name);
  
   if ((cl && isFinal(cl->access)) || 
       (meth && (isFinal(meth->access) || isPrivate(meth->access)))) {
     canBeDirect = true;
   }
 
+  bool customized = false;
+  if (!canBeDirect) {
+    if (!overridesThis
+        && (stack[stackSize() - signature->nbArguments - 1].bytecode == ALOAD_0)
+        && !isStatic(compilingMethod->access)) {
+      assert(meth != NULL);
+      isCustomizable = true;
+      if (customizeFor != NULL) {
+        meth = customizeFor->lookupMethodDontThrow(
+            meth->name, meth->type, false, true, NULL);
+        assert(meth);
+        canBeDirect = true;
+        customized = true;
+        assert(!meth->classDef->isInterface());
+        assert(!isAbstract(meth->access));
+      }
+    }
+  }
+
   if (meth && isInterface(meth->classDef->access)) {
     // This can happen because we compute miranda methods before resolving
     // interfaces.
 		return invokeInterface(index);
 	}
  
-  const UTF8* name = 0;
-  Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index, name);
  
   if (TheCompiler->isStaticCompiling()) {
     Value* obj = objectStack[stack.size() - signature->nbArguments - 1];
@@ -137,14 +171,14 @@
   llvm::Type* retType = virtualType->getReturnType();
 
   bool needsInit = false;
-  if (canBeDirect && canBeInlined(meth)) {
+  if (canBeDirect && canBeInlined(meth, customized)) {
     makeArgs(it, index, args, signature->nbArguments + 1);
     JITVerifyNull(args[0]);
-    val = invokeInline(meth, args);
+    val = invokeInline(meth, args, customized);
   } else if (canBeDirect && !TheCompiler->needsCallback(meth, &needsInit)) {
     makeArgs(it, index, args, signature->nbArguments + 1);
     JITVerifyNull(args[0]);
-    val = invoke(TheCompiler->getMethod(meth), args, "", currentBlock);
+    val = invoke(TheCompiler->getMethod(meth, NULL), args, "", currentBlock);
   } else {
 
     BasicBlock* endBlock = 0;
@@ -900,7 +934,8 @@
               UTF8Buffer(compilingClass->name).cString(),
               UTF8Buffer(compilingMethod->name).cString());
 
-  DbgSubprogram = TheCompiler->GetDbgSubprogram(compilingMethod);
+  DbgSubprogram = TheCompiler->getDebugFactory()->createFunction(
+      DIDescriptor(), "", "", DIFile(), 0, DIType(), false, false);
 
   Attribut* codeAtt = compilingMethod->lookupAttribut(Attribut::codeAttribut);
   
@@ -1480,8 +1515,9 @@
 
 
 Instruction* JavaJIT::invokeInline(JavaMethod* meth, 
-                                   std::vector<Value*>& args) {
-  JavaJIT jit(TheCompiler, meth, llvmFunction);
+                                   std::vector<Value*>& args,
+                                   bool customized) {
+  JavaJIT jit(TheCompiler, meth, llvmFunction, customized ? customizeFor : NULL);
   jit.unifiedUnreachable = unifiedUnreachable;
   jit.inlineMethods = inlineMethods;
   jit.inlineMethods[meth] = true;
@@ -1489,12 +1525,13 @@
   jit.DbgSubprogram = DbgSubprogram;
 #if DEBUG
   static int inlineNb = 0;
-  fprintf(stderr, "inline compile %d %s.%s%s from %s.%s\n", inlineNb++,
+  fprintf(stderr, "inline compile %d %s.%s%s from %s.%s (%d)\n", inlineNb++,
               UTF8Buffer(meth->classDef->name).cString(),
               UTF8Buffer(meth->name).cString(),
               UTF8Buffer(meth->getSignature()->keyName).cString(),
               UTF8Buffer(compilingClass->name).cString(),
-              UTF8Buffer(compilingMethod->name).cString());
+              UTF8Buffer(compilingMethod->name).cString(),
+              customized);
 #endif
   
   Instruction* ret = jit.inlineCompile(currentBlock, 
@@ -1531,7 +1568,7 @@
     func = TheCompiler->addCallback(compilingClass, index, signature, false,
                                     currentBlock);
   } else {
-    func = TheCompiler->getMethod(meth);
+    func = TheCompiler->getMethod(meth, NULL);
   }
 
   std::vector<Value*> args;
@@ -1544,8 +1581,8 @@
   }
 
   llvm::Instruction* val = 0;
-  if (meth && canBeInlined(meth)) {
-    val = invokeInline(meth, args);
+  if (meth && canBeInlined(meth, false)) {
+    val = invokeInline(meth, args, false);
   } else {
     val = invoke(func, args, "", currentBlock);
   }
@@ -1599,7 +1636,7 @@
     func = TheCompiler->addCallback(compilingClass, index, signature,
                                     true, currentBlock);
   } else {
-    func = TheCompiler->getMethod(meth);
+    func = TheCompiler->getMethod(meth, NULL);
   }
 
   std::vector<Value*> args; // size = [signature->nbIn + 2]; 
@@ -1615,8 +1652,8 @@
   }
     
   if (val == NULL) {
-    if (meth != NULL && canBeInlined(meth)) {
-      val = invokeInline(meth, args);
+    if (meth != NULL && canBeInlined(meth, false)) {
+      val = invokeInline(meth, args, false);
     } else {
       val = invoke(func, args, "", currentBlock);
     }
@@ -2209,7 +2246,7 @@
 }
 
 void JavaJIT::lowerArraycopy(std::vector<Value*>& args) {
-  Function* meth = TheCompiler->getMethod(upcalls->VMSystemArraycopy);
+  Function* meth = TheCompiler->getMethod(upcalls->VMSystemArraycopy, NULL);
 
   Value* ptr_src = args[0];
   Value* int32_start = args[1];

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Tue Sep 27 13:28:55 2011
@@ -36,6 +36,12 @@
 class JavaMethod;
 class Reader;
 
+struct MetaInfo {
+  MetaInfo(CommonClass* t, uint8 b) : type(t), bytecode(b) {}
+  CommonClass* type;
+  uint8 bytecode;
+};
+
 /// Opinfo - This class gives for each opcode if it starts a new block and
 /// its exception destination.
 ///
@@ -57,10 +63,9 @@
 
   /// stack - The stack at this location if there is a new block
   ///
-  std::vector<CommonClass*> stack;
+  std::vector<MetaInfo> stack;
 };
 
-
 /// JavaJIT - The compilation engine of J3. Parses the bycode and returns
 /// its LLVM representation.
 ///
@@ -68,7 +73,10 @@
 public:
  
   /// JavaJIT - Default constructor.
-  JavaJIT(JavaLLVMCompiler* C, JavaMethod* meth, llvm::Function* func) {
+  JavaJIT(JavaLLVMCompiler* C,
+          JavaMethod* meth,
+          llvm::Function* func,
+          Class* customized) {
     compilingMethod = meth;
     compilingClass = meth->classDef;
     upcalls = compilingClass->classLoader->bootstrapLoader->upcalls;
@@ -81,7 +89,11 @@
     endNode = 0;
     currentStackIndex = 0;
     currentBytecodeIndex = 0;
+    currentBytecode = 0;
     thisObject = NULL;
+    customizeFor = customized;
+    isCustomizable = false;
+    overridesThis = false;
   }
 
   /// javaCompile - Compile the Java method.
@@ -89,8 +101,16 @@
   
   /// nativeCompile - Compile the native method.
   llvm::Function* nativeCompile(intptr_t natPtr = 0);
+  
+  /// isCustomizable - Whether we found the method to be customizable.
+  bool isCustomizable;
 
 private:
+  /// Whether the method overrides 'this'.
+  bool overridesThis;
+  
+  /// currentBytecode - The current bytecode being processed.
+  uint16 currentBytecode;
   
   /// compilingClass - The class that is defining the method being compiled.
   Class* compilingClass;
@@ -98,6 +118,9 @@
   /// compilingMethod - The method being compiled.
   JavaMethod* compilingMethod;
 
+  /// customizeFor - The class we're currently customizing this method for.
+  Class* customizeFor;
+
   /// upcalls - Upcalls used tp type the stack and locals.
   Classpath* upcalls;
 
@@ -188,7 +211,7 @@
   bool inlining;
   
   /// canBeInlined - Can this method's body be inlined?
-  bool canBeInlined(JavaMethod* meth);
+  bool canBeInlined(JavaMethod* meth, bool customizing);
 
   /// callsStackWalker - Is the method calling a stack walker method? If it is,
   /// then this method can not be inlined.
@@ -232,7 +255,7 @@
 //===------------------------- Stack manipulation -------------------------===//
 
   /// stack - The compiler stack.
-  std::vector<CommonClass*> stack;
+  std::vector<MetaInfo> stack;
   uint32 currentStackIndex;
   std::vector<llvm::AllocaInst*> objectStack;
   std::vector<llvm::AllocaInst*> intStack;
@@ -247,36 +270,36 @@
       val = new llvm::ZExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "", currentBlock);
       new llvm::StoreInst(val, intStack[currentStackIndex++], false,
                           currentBlock);
-      stack.push_back(upcalls->OfInt);
+      stack.push_back(MetaInfo(upcalls->OfInt, currentBytecode));
     } else if (type == llvm::Type::getInt8Ty(*llvmContext) ||
                type == llvm::Type::getInt16Ty(*llvmContext)) {
       val = new llvm::SExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "",
                                currentBlock);
       new llvm::StoreInst(val, intStack[currentStackIndex++], false,
                           currentBlock);
-      stack.push_back(upcalls->OfInt);
+      stack.push_back(MetaInfo(upcalls->OfInt, currentBytecode));
     } else if (type == llvm::Type::getInt32Ty(*llvmContext)) {
       new llvm::StoreInst(val, intStack[currentStackIndex++], false,
                           currentBlock);
-      stack.push_back(upcalls->OfInt);
+      stack.push_back(MetaInfo(upcalls->OfInt, currentBytecode));
     } else if (type == llvm::Type::getInt64Ty(*llvmContext)) {
       new llvm::StoreInst(val, longStack[currentStackIndex++], false,
                           currentBlock);
-      stack.push_back(upcalls->OfLong);
+      stack.push_back(MetaInfo(upcalls->OfLong, currentBytecode));
     } else if (type == llvm::Type::getFloatTy(*llvmContext)) {
       new llvm::StoreInst(val, floatStack[currentStackIndex++], false,
                           currentBlock);
-      stack.push_back(upcalls->OfFloat);
+      stack.push_back(MetaInfo(upcalls->OfFloat, currentBytecode));
     } else if (type == llvm::Type::getDoubleTy(*llvmContext)) {
       new llvm::StoreInst(val, doubleStack[currentStackIndex++], false,
                           currentBlock);
-      stack.push_back(upcalls->OfDouble);
+      stack.push_back(MetaInfo(upcalls->OfDouble, currentBytecode));
     } else {
       assert(type == intrinsics->JavaObjectType && "Can't handle this type");
       llvm::Instruction* V = new 
         llvm::StoreInst(val, objectStack[currentStackIndex++], false,
                         currentBlock);
-      stack.push_back(cl ? cl : upcalls->OfObject);
+      stack.push_back(MetaInfo(cl ? cl : upcalls->OfObject, currentBytecode));
       addHighLevelType(V, topTypeInfo());
       if (llvm::Instruction* I = llvm::dyn_cast<llvm::Instruction>(val)) {
         addHighLevelType(I, topTypeInfo());
@@ -305,7 +328,7 @@
 
   /// top - Return the value on top of the stack.
   llvm::Value* top() {
-    CommonClass* cl = stack.back();
+    CommonClass* cl = stack.back().type;
     if (cl == upcalls->OfInt) {
       return new llvm::LoadInst(intStack[currentStackIndex - 1], "", false,
                                 currentBlock);
@@ -326,6 +349,10 @@
   
   /// topTypeInfo - Return the type of the value on top of the stack.
   CommonClass* topTypeInfo() {
+    return stack.back().type;
+  }
+
+  MetaInfo topInfo() {
     return stack.back();
   }
  
@@ -378,22 +405,20 @@
   llvm::BasicBlock* createBasicBlock(const char* name = "") {
     return llvm::BasicBlock::Create(*llvmContext, name, llvmFunction);
   }
+
+  void updateStackInfo(Opinfo& info);
  
   /// branch - Branch based on a boolean value.
   void branch(llvm::Value* test, llvm::BasicBlock* ifTrue, 
               llvm::BasicBlock* ifFalse, llvm::BasicBlock* insert,
               Opinfo& info) {
-    if (stackSize())
-      if (!info.stack.size())
-        info.stack = stack;
+    updateStackInfo(info);
     llvm::BranchInst::Create(ifTrue, ifFalse, test, insert);
   }
 
   /// branch - Branch to a new block.
   void branch(Opinfo& info, llvm::BasicBlock* insert) {
-    if (stackSize())
-      if (!info.stack.size())
-        info.stack = stack;
+    updateStackInfo(info);
     llvm::BranchInst::Create(info.newBlock, insert);
   }
   
@@ -484,7 +509,8 @@
 
   /// invokeInline - Instead of calling the method, inline it.
   llvm::Instruction* invokeInline(JavaMethod* meth, 
-                                  std::vector<llvm::Value*>& args);
+                                  std::vector<llvm::Value*>& args,
+                                  bool customized);
 
   /// lowerMathOps - Map Java Math operations to LLVM intrinsics.
   llvm::Instruction* lowerMathOps(const UTF8* name, 

Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Tue Sep 27 13:28:55 2011
@@ -185,33 +185,19 @@
     // is nothing left to do!
     return;
   }
-  
-  if (cl->super) {
-    // Copy the super VT into the current VT.
-    uint32 size = cl->super->virtualTableSize - 
-        JavaVirtualTable::getFirstJavaMethodIndex();
-    memcpy(VT->getFirstJavaMethod(), cl->super->virtualVT->getFirstJavaMethod(),
-           size * sizeof(uintptr_t));
-    VT->destructor = cl->super->virtualVT->destructor;
-  }
-
-
-  // Fill the virtual table with function pointers.
-  for (uint32 i = 0; i < cl->nbVirtualMethods; ++i) {
-    JavaMethod& meth = cl->virtualMethods[i];
-
-    // Special handling for finalize method. Don't put a finalizer
-    // if there is none, or if it is empty.
-    if (meth.offset == 0) {
-      if (cl->super != NULL) {
-        VT->destructor = getPointerOrStub(meth, JavaMethod::Virtual);
+ 
+  Class* current = cl;
+  uintptr_t* functions = VT->getFunctions();
+  while (current != NULL) {
+    // Fill the virtual table with function pointers.
+    for (uint32 i = 0; i < current->nbVirtualMethods; ++i) {
+      JavaMethod& meth = current->virtualMethods[i];
+      if (meth.offset != 0 || current->super != NULL) {
+        functions[meth.offset] = getPointerOrStub(meth, JavaMethod::Virtual);
       }
-    } else {
-      VT->getFunctions()[meth.offset] = getPointerOrStub(meth,
-                                                         JavaMethod::Virtual);
     }
+    current = current->super;
   }
-
 }
 
 extern "C" void ThrowUnfoundInterface() {
@@ -322,9 +308,9 @@
   executionEngine->updateGlobalMapping(func, ptr);
 }
 
-void* JavaJITCompiler::materializeFunction(JavaMethod* meth) {
+void* JavaJITCompiler::materializeFunction(JavaMethod* meth, Class* customizeFor) {
   mvm::MvmModule::protectIR();
-  Function* func = parseFunction(meth);
+  Function* func = parseFunction(meth, customizeFor);
   void* res = executionEngine->getPointerToGlobal(func);
  
   if (!func->isDeclaration()) {
@@ -337,6 +323,9 @@
     func->deleteBody();
   }
   mvm::MvmModule::unprotectIR();
+  if (customizeFor == NULL || !getMethodInfo(meth)->isCustomizable) {
+    meth->code = res;
+  }
   return res;
 }
 

Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Tue Sep 27 13:28:55 2011
@@ -136,7 +136,7 @@
         assert(isa<PHINode>(I) && "Handler marlformed");
         // If it's a handler, put the exception object in the stack.
         new StoreInst(I, objectStack[0], "", currentBlock);
-        stack.push_back(upcalls->OfObject);
+        stack.push_back(MetaInfo(upcalls->OfObject, NOP));
         currentStackIndex = 1;
       } else {
         stack = opinfo->stack;
@@ -147,6 +147,7 @@
     currentExceptionBlock = opinfo->exceptionBlock;
     
     currentBytecodeIndex = i;
+    currentBytecode = bytecode;
 
     // To prevent a gcj bug with useless goto
     if (currentBlock->getTerminator() != 0) { 
@@ -786,6 +787,7 @@
         break;
 
       case DUP :
+        // TODO: The following bytecodes should push a MetaInfo.
         push(top(), false, topTypeInfo());
         break;
 
@@ -2464,7 +2466,6 @@
       case DSTORE_1 :
       case DSTORE_2 :
       case DSTORE_3 :
-      case ASTORE_0 :
       case ASTORE_1 :
       case ASTORE_2 :
       case ASTORE_3 :
@@ -2521,6 +2522,10 @@
       case LOR :
       case IXOR :
       case LXOR : break;
+      
+      case ASTORE_0 :
+        if (!isStatic(compilingMethod->access)) overridesThis = true;
+        break;
 
       case IINC :
         i += WCALC(2, wide);
@@ -3327,8 +3332,17 @@
         i += 2;
         if (meth == NULL) return false;
         if (getReceiver(stack, meth->getSignature()) != ALOAD_0) return false;
-        if (!(isFinal(cl->access) || isFinal(meth->access))) return false;
-        if (!canBeInlined(meth)) return false;
+        bool customized = false;
+        if (!(isFinal(cl->access) || isFinal(meth->access))) {
+          if (customizeFor == NULL) return false;
+          meth = customizeFor->lookupMethodDontThrow(
+              meth->name, meth->type, false, true, NULL);
+          assert(meth);
+          assert(!meth->classDef->isInterface());
+          assert(!isAbstract(meth->access));
+          customized = true;
+        }
+        if (!canBeInlined(meth, customized)) return false;
         updateStack(stack, meth->getSignature(), bytecode);
         break;
       }
@@ -3342,7 +3356,7 @@
         i += 2;
         if (meth == NULL) return false;
         if (getReceiver(stack, meth->getSignature()) != ALOAD_0) return false;
-        if (!canBeInlined(meth)) return false;
+        if (!canBeInlined(meth, false)) return false;
         updateStack(stack, meth->getSignature(), bytecode);
         break;
       }
@@ -3354,7 +3368,7 @@
         ctpInfo->infoOfMethod(index, ACC_STATIC, cl, meth);
         i += 2;
         if (meth == NULL) return false;
-        if (!canBeInlined(meth)) return false;
+        if (!canBeInlined(meth, false)) return false;
         if (needsInitialisationCheck(cl->asClass())) return false;
         updateStack(stack, meth->getSignature(), bytecode);
         break;

Modified: vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Tue Sep 27 13:28:55 2011
@@ -48,18 +48,18 @@
   mvm::MvmModule::unprotectIR();
 }
 
-Function* JavaLLVMCompiler::getMethod(JavaMethod* meth) {
-  return getMethodInfo(meth)->getMethod();
+Function* JavaLLVMCompiler::getMethod(JavaMethod* meth, Class* customizeFor) {
+  return getMethodInfo(meth)->getMethod(customizeFor);
 }
 
-Function* JavaLLVMCompiler::parseFunction(JavaMethod* meth) {
+Function* JavaLLVMCompiler::parseFunction(JavaMethod* meth, Class* customizeFor) {
   LLVMMethodInfo* LMI = getMethodInfo(meth);
-  Function* func = LMI->getMethod();
+  Function* func = LMI->getMethod(customizeFor);
   
   // We are jitting. Take the lock.
   mvm::MvmModule::protectIR();
   if (func->getLinkage() == GlobalValue::ExternalWeakLinkage) {
-    JavaJIT jit(this, meth, func);
+    JavaJIT jit(this, meth, func, customizeFor);
     if (isNative(meth->access)) {
       jit.nativeCompile();
       mvm::MvmModule::runPasses(func, JavaNativeFunctionPasses);
@@ -68,6 +68,15 @@
       mvm::MvmModule::runPasses(func, JavaFunctionPasses);
     }
     func->setLinkage(GlobalValue::ExternalLinkage);
+    if (!LMI->isCustomizable && jit.isCustomizable) {
+      // It's the first time we parsed the method and we just found
+      // out it can be customized.
+      meth->isCustomizable = true;
+      LMI->isCustomizable = true;
+      if (customizeFor != NULL) {
+        LMI->setCustomizedVersion(customizeFor, func);
+      }
+    }
   }
   mvm::MvmModule::unprotectIR();
 
@@ -81,18 +90,6 @@
   return I->second;
 }
 
-MDNode* JavaLLVMCompiler::GetDbgSubprogram(JavaMethod* meth) {
-  if (getMethodInfo(meth)->getDbgSubprogram() == NULL) {
-    MDNode* node = DebugFactory->createFunction(DIDescriptor(), "",
-                                                "", DIFile(), 0,
-                                                DIType(), false,
-                                                false);
-    DbgInfos.insert(std::make_pair(node, meth));
-    getMethodInfo(meth)->setDbgSubprogram(node);
-  }
-  return getMethodInfo(meth)->getDbgSubprogram();
-}
-
 JavaLLVMCompiler::~JavaLLVMCompiler() {
   LLVMContext* Context = &(TheModule->getContext());
   delete TheModule;

Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Tue Sep 27 13:28:55 2011
@@ -140,8 +140,17 @@
   extern bool JITEmitDebugInfo;
 }
 
-Function* LLVMMethodInfo::getMethod() {
-  if (!methodFunction) {
+Function* LLVMMethodInfo::getMethod(Class* customizeFor) {
+  bool customizing = false;
+  Function* result = NULL;
+  if (customizeFor != NULL && isCustomizable) {
+    customizing = true;
+    result = customizedVersions[customizeFor];
+  } else {
+    result = methodFunction;
+  }
+
+  if (result == NULL) {
     if (Compiler->emitFunctionName() || JITEmitDebugInfo) {
       const UTF8* jniConsClName = methodDef->classDef->name;
       const UTF8* jniConsName = methodDef->name;
@@ -157,25 +166,37 @@
       methodDef->jniConsFromMethOverloaded(buf + 1);
       memcpy(buf, "JnJVM", 5);
 
-      methodFunction = Function::Create(getFunctionType(), 
-                                        GlobalValue::ExternalWeakLinkage, buf,
-                                        Compiler->getLLVMModule());
+      result = Function::Create(getFunctionType(), 
+                                GlobalValue::ExternalWeakLinkage, buf,
+                                Compiler->getLLVMModule());
     } else {
-      methodFunction = Function::Create(getFunctionType(), 
-                                        GlobalValue::ExternalWeakLinkage,
-                                        "", Compiler->getLLVMModule());
+      result = Function::Create(getFunctionType(), 
+                                GlobalValue::ExternalWeakLinkage,
+                                "", Compiler->getLLVMModule());
     }
     
-    methodFunction->setGC("vmkit");
-    methodFunction->addFnAttr(Attribute::NoInline);
-    methodFunction->addFnAttr(Attribute::NoUnwind);
+    result->setGC("vmkit");
+    result->addFnAttr(Attribute::NoInline);
+    result->addFnAttr(Attribute::NoUnwind);
     
-    Compiler->functions.insert(std::make_pair(methodFunction, methodDef));
-    if (!Compiler->isStaticCompiling() && methodDef->code) {
-      Compiler->setMethod(methodFunction, methodDef->code, methodFunction->getName().data());
+    Compiler->functions.insert(std::make_pair(result, methodDef));
+    if (!Compiler->isStaticCompiling() && !customizing && methodDef->code) {
+      Compiler->setMethod(result, methodDef->code, result->getName().data());
     }
   }
-  return methodFunction;
+
+  if (customizing) {
+    customizedVersions[customizeFor] = result;
+  } else {
+    methodFunction = result;
+  }
+  return result;
+}
+
+void LLVMMethodInfo::setCustomizedVersion(Class* cl, llvm::Function* F) {
+  assert(customizedVersions.size() == 0);
+  methodFunction = NULL;
+  customizedVersions[cl] = F;
 }
 
 FunctionType* LLVMMethodInfo::getFunctionType() {

Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Tue Sep 27 13:28:55 2011
@@ -269,9 +269,9 @@
   return res;
 }
 
-void* JavaMethod::compiledPtr() {
-  if (code == 0) {
-    code = classDef->classLoader->getCompiler()->materializeFunction(this);
+void* JavaMethod::compiledPtr(Class* customizeFor) {
+  if ((isCustomizable && customizeFor != NULL) || code == 0) {
+    return classDef->classLoader->getCompiler()->materializeFunction(this, customizeFor);
   }
   return code;
 }
@@ -633,7 +633,7 @@
   _signature = 0;
   code = 0;
   access = A;
-  canBeInlined = false;
+  isCustomizable = false;
   offset = 0;
 }
 

Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Tue Sep 27 13:28:55 2011
@@ -845,7 +845,7 @@
   /// compiledPtr - Return a pointer to the compiled code of this Java method,
   /// compiling it if necessary.
   ///
-  void* compiledPtr();
+  void* compiledPtr(Class* customizeFor = NULL);
 
   /// setNative - Set the method as native.
   ///
@@ -880,9 +880,9 @@
   ///
   const UTF8* type;
 
-  /// canBeInlined - Can the method be inlined?
+  /// isCustomizable - Can the method be customizable?
   ///
-  bool canBeInlined;
+  bool isCustomizable;
 
   /// code - Pointer to the compiled code of this method.
   ///

Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Tue Sep 27 13:28:55 2011
@@ -584,7 +584,7 @@
   }
 
   // Compile the found method.
-  result = Virt->compiledPtr();
+  result = Virt->compiledPtr(lookup);
 
   // Update the virtual table.
   assert(lookup->isResolved() && "Class not resolved");

Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=140617&r1=140616&r2=140617&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Tue Sep 27 13:28:55 2011
@@ -1267,7 +1267,7 @@
   } END_CATCH;
 
   if (exc != NULL) {
-    fprintf(stderr, "Exception %s while bootstrapping VM.",
+    fprintf(stderr, "Exception %s while bootstrapping VM.\n",
         UTF8Buffer(JavaObject::getClass(exc)->name).cString());
   } else {
     ClArgumentsInfo& info = vm->argumentsInfo;





More information about the vmkit-commits mailing list