[vmkit-commits] [vmkit] r141882 - in /vmkit/trunk: include/j3/JavaLLVMCompiler.h lib/J3/Compiler/JavaJIT.cpp lib/J3/Compiler/JavaJIT.h lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JavaLLVMCompiler.cpp lib/Mvm/Compiler/JIT.cpp lib/Mvm/MMTk/MvmGC.cpp lib/Mvm/MMTk/MvmGC.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Oct 13 12:52:28 PDT 2011


Author: geoffray
Date: Thu Oct 13 14:52:28 2011
New Revision: 141882

URL: http://llvm.org/viewvc/llvm-project?rev=141882&view=rev
Log:
Set the native code of write barriers initially, so that we don't try to JIT them. Also add some info when Jitting about how many catch handlers are in the method.


Modified:
    vmkit/trunk/include/j3/JavaLLVMCompiler.h
    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/JavaLLVMCompiler.cpp
    vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
    vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
    vmkit/trunk/lib/Mvm/MMTk/MvmGC.h

Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaLLVMCompiler.h?rev=141882&r1=141881&r2=141882&view=diff
==============================================================================
--- vmkit/trunk/include/j3/JavaLLVMCompiler.h (original)
+++ vmkit/trunk/include/j3/JavaLLVMCompiler.h Thu Oct 13 14:52:28 2011
@@ -210,6 +210,7 @@
   llvm::Function* parseFunction(JavaMethod* meth, Class* customizeFor);
    
   llvm::FunctionPassManager* JavaFunctionPasses;
+  llvm::FunctionPassManager* J3FunctionPasses;
   llvm::FunctionPassManager* JavaNativeFunctionPasses;
   
   virtual bool needsCallback(JavaMethod* meth,

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=141882&r1=141881&r2=141882&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Thu Oct 13 14:52:28 2011
@@ -89,8 +89,8 @@
   uint32 codeLen = reader.readU4();
   uint32 start = reader.cursor; 
   reader.seek(codeLen, Reader::SeekCur);
-  uint16 nbHandlers = reader.readU2();
-  if (nbHandlers != 0) return false;
+  uint16 handlers = reader.readU2();
+  if (handlers != 0) return false;
   reader.cursor = start;
 
   JavaJIT jit(TheCompiler, meth, llvmFunction, customizing ? customizeFor : NULL);
@@ -556,8 +556,10 @@
   nativeArgs[0] = nativeFunc;
 
   // Synchronize before saying we're entering native
-  if (isSynchro(compilingMethod->access))
+  if (isSynchro(compilingMethod->access)) {
+    nbHandlers = 1;
     beginSynchronize();
+  }
   
   Value* Args4[3] = { temp, oldCLIN, Frame };
 
@@ -897,7 +899,7 @@
     }
   }
   
-  readExceptionTable(reader, codeLen);
+  nbHandlers = readExceptionTable(reader, codeLen);
   
   reader.cursor = start;
   exploreOpcodes(reader, codeLen);
@@ -1068,7 +1070,7 @@
     }
 #endif
 
-  readExceptionTable(reader, codeLen);
+  nbHandlers = readExceptionTable(reader, codeLen);
   
   reader.cursor = start;
   exploreOpcodes(reader, codeLen);

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=141882&r1=141881&r2=141882&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Thu Oct 13 14:52:28 2011
@@ -94,6 +94,7 @@
     customizeFor = customized;
     isCustomizable = false;
     overridesThis = false;
+    nbHandlers = 0;
   }
 
   /// javaCompile - Compile the Java method.
@@ -105,6 +106,9 @@
   /// isCustomizable - Whether we found the method to be customizable.
   bool isCustomizable;
 
+  // The number of handlers in that method.
+  uint32_t nbHandlers;
+
 private:
   /// Whether the method overrides 'this'.
   bool overridesThis;
@@ -394,6 +398,7 @@
   /// finishExceptions - Emit code to unwind the current function if an
   /// exception is thrown.
   void finishExceptions();
+
 //===--------------------------- Control flow  ----------------------------===//
 
   /// opcodeInfos - The informations for each instruction.

Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=141882&r1=141881&r2=141882&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Thu Oct 13 14:52:28 2011
@@ -168,6 +168,17 @@
   initialiseAssessorInfo();  
 
   addJavaPasses();
+
+  // Set the pointer to methods that will be inlined, so that these methods
+  // do not get compiled by the JIT.
+  executionEngine->updateGlobalMapping(
+      JavaIntrinsics.AllocateFunction, (void*)(word_t)gcmalloc);
+  executionEngine->updateGlobalMapping(
+      JavaIntrinsics.ArrayWriteBarrierFunction, (void*)(word_t)arrayWriteBarrier);
+  executionEngine->updateGlobalMapping(
+      JavaIntrinsics.FieldWriteBarrierFunction, (void*)(word_t)fieldWriteBarrier);
+  executionEngine->updateGlobalMapping(
+      JavaIntrinsics.NonHeapWriteBarrierFunction, (void*)(word_t)nonHeapWriteBarrier);
 }
 
 JavaJITCompiler::~JavaJITCompiler() {

Modified: vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp?rev=141882&r1=141881&r2=141882&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Thu Oct 13 14:52:28 2011
@@ -64,9 +64,11 @@
     if (isNative(meth->access)) {
       jit.nativeCompile();
       mvm::MvmModule::runPasses(func, JavaNativeFunctionPasses);
+      mvm::MvmModule::runPasses(func, J3FunctionPasses);
     } else {
       jit.javaCompile();
       mvm::MvmModule::runPasses(func, JavaFunctionPasses);
+      mvm::MvmModule::runPasses(func, J3FunctionPasses);
     }
     func->setLinkage(GlobalValue::ExternalLinkage);
     if (!LMI->isCustomizable && jit.isCustomizable) {
@@ -96,12 +98,12 @@
   delete TheModule;
   delete DebugFactory;
   delete JavaFunctionPasses;
+  delete J3FunctionPasses;
   delete JavaNativeFunctionPasses;
   delete Context;
 }
 
 namespace mvm {
-  llvm::FunctionPass* createEscapeAnalysisPass();
   llvm::LoopPass* createLoopSafePointsPass();
 }
 
@@ -112,20 +114,15 @@
 void JavaLLVMCompiler::addJavaPasses() {
   JavaNativeFunctionPasses = new FunctionPassManager(TheModule);
   JavaNativeFunctionPasses->add(new TargetData(TheModule));
-  // Lower constant calls to lower things like getClass used
-  // on synchronized methods.
-  JavaNativeFunctionPasses->add(createLowerConstantCallsPass(this));
+  J3FunctionPasses = new FunctionPassManager(TheModule);
+  J3FunctionPasses->add(createLowerConstantCallsPass(this));
   
-  JavaFunctionPasses = new FunctionPassManager(TheModule);
   if (cooperativeGC)
-    JavaFunctionPasses->add(mvm::createLoopSafePointsPass());
+    J3FunctionPasses->add(mvm::createLoopSafePointsPass());
+
   // Add other passes after the loop pass, because safepoints may move objects.
   // Moving objects disable many optimizations.
+  JavaFunctionPasses = new FunctionPassManager(TheModule);
   JavaFunctionPasses->add(new TargetData(TheModule));
   mvm::MvmModule::addCommandLinePasses(JavaFunctionPasses);
-
-  // Re-enable this when the pointers in stack-allocated objects can
-  // be given to the GC.
-  //JavaFunctionPasses->add(mvm::createEscapeAnalysisPass());
-  JavaFunctionPasses->add(createLowerConstantCallsPass(this));
 }

Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=141882&r1=141881&r2=141882&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Thu Oct 13 14:52:28 2011
@@ -357,9 +357,6 @@
 
   unconditionalSafePoint = module->getFunction("unconditionalSafePoint");
   conditionalSafePoint = module->getFunction("conditionalSafePoint");
-  AllocateFunction = module->getFunction("gcmalloc");
-  AllocateFunction->setGC("vmkit");
-  assert(AllocateFunction && "No allocate function");
   AllocateUnresolvedFunction = module->getFunction("gcmallocUnresolved");
   assert(AllocateUnresolvedFunction && "No allocateUnresolved function");
   AddFinalizationCandidate = module->getFunction("addFinalizationCandidate");
@@ -368,6 +365,12 @@
   ArrayWriteBarrierFunction = module->getFunction("arrayWriteBarrier");
   FieldWriteBarrierFunction = module->getFunction("fieldWriteBarrier");
   NonHeapWriteBarrierFunction = module->getFunction("nonHeapWriteBarrier");
+  AllocateFunction = module->getFunction("gcmalloc");
+
+  AllocateFunction->setGC("vmkit");
+  ArrayWriteBarrierFunction->setGC("vmkit");
+  FieldWriteBarrierFunction->setGC("vmkit");
+  NonHeapWriteBarrierFunction->setGC("vmkit");
 }
 
 

Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp?rev=141882&r1=141881&r2=141882&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp Thu Oct 13 14:52:28 2011
@@ -109,15 +109,15 @@
   return NULL;
 }
 
-extern "C" void arrayWriteBarrier(gc* ref, gc** ptr, gc* value) {
+extern "C" void arrayWriteBarrier(void* ref, void** ptr, void* value) {
   *ptr = value;
 }
 
-extern "C" void fieldWriteBarrier(gc* ref, gc** ptr, gc* value) {
+extern "C" void fieldWriteBarrier(void* ref, void** ptr, void* value) {
   *ptr = value;
 }
 
-extern "C" void nonHeapWriteBarrier(gc** ptr, gc* value) {
+extern "C" void nonHeapWriteBarrier(void** ptr, void* value) {
   *ptr = value;
 }
 

Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.h?rev=141882&r1=141881&r2=141882&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.h Thu Oct 13 14:52:28 2011
@@ -53,6 +53,7 @@
 };
 
 extern "C" void* gcmallocUnresolved(uint32_t sz, VirtualTable* VT);
+extern "C" void* gcmalloc(uint32_t sz, void* VT);
 
 class gc : public gcRoot {
 public:
@@ -65,9 +66,12 @@
   void* operator new(size_t sz, VirtualTable *VT) {
     return gcmallocUnresolved(sz, VT);
   }
-
 };
 
+extern "C" void arrayWriteBarrier(void* ref, void** ptr, void* value);
+extern "C" void fieldWriteBarrier(void* ref, void** ptr, void* value);
+extern "C" void nonHeapWriteBarrier(void** ptr, void* value);
+
 namespace mvm {
   
 class Collector {





More information about the vmkit-commits mailing list