[vmkit-commits] [vmkit] r96122 - in /vmkit/trunk: include/j3/JnjvmModuleProvider.h include/j3/LLVMMaterializer.h lib/J3/Compiler/JITInfo.cpp lib/J3/Compiler/JavaJIT.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JnjvmModule.cpp lib/J3/Compiler/JnjvmModuleProvider.cpp lib/J3/Compiler/LLVMMaterializer.cpp tools/j3/Main.cpp tools/vmjc/vmjc.cpp tools/vmkit/Launcher.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sat Feb 13 13:48:31 PST 2010


Author: geoffray
Date: Sat Feb 13 15:48:31 2010
New Revision: 96122

URL: http://llvm.org/viewvc/llvm-project?rev=96122&view=rev
Log:
Rename JnjvmModuleProvider into LLVMMaterializer.


Added:
    vmkit/trunk/include/j3/LLVMMaterializer.h
      - copied, changed from r96100, vmkit/trunk/include/j3/JnjvmModuleProvider.h
    vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp
      - copied, changed from r96100, vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp
Removed:
    vmkit/trunk/include/j3/JnjvmModuleProvider.h
    vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp
Modified:
    vmkit/trunk/lib/J3/Compiler/JITInfo.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
    vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp
    vmkit/trunk/tools/j3/Main.cpp
    vmkit/trunk/tools/vmjc/vmjc.cpp
    vmkit/trunk/tools/vmkit/Launcher.cpp

Removed: vmkit/trunk/include/j3/JnjvmModuleProvider.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModuleProvider.h?rev=96121&view=auto

==============================================================================
--- vmkit/trunk/include/j3/JnjvmModuleProvider.h (original)
+++ vmkit/trunk/include/j3/JnjvmModuleProvider.h (removed)
@@ -1,38 +0,0 @@
-//===-------- JnjvmModuleProvider.h - LLVM Module Provider for J3 ---------===//
-//
-//                            The VMKit project
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef JNJVM_MODULE_PROVIDER_H
-#define JNJVM_MODULE_PROVIDER_H
-
-#include <llvm/GVMaterializer.h>
-
-namespace j3 {
-
-class JavaJITCompiler;
-
-class JnjvmModuleProvider : public llvm::GVMaterializer {
-public:
- 
-  JavaJITCompiler* Comp;
-  llvm::Module* TheModule;
-
-  JnjvmModuleProvider(llvm::Module* M, JavaJITCompiler* C);
-  ~JnjvmModuleProvider();
-
-  virtual bool Materialize(llvm::GlobalValue *GV, std::string *ErrInfo = 0);
-  virtual bool isMaterializable(const llvm::GlobalValue*) const;
-  virtual bool isDematerializable(const llvm::GlobalValue*) const {
-    return false;
-  }
-  virtual bool MaterializeModule(llvm::Module*, std::string*) { return true; }
-};
-
-} // End j3 namespace
-
-#endif

Copied: vmkit/trunk/include/j3/LLVMMaterializer.h (from r96100, vmkit/trunk/include/j3/JnjvmModuleProvider.h)
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMMaterializer.h?p2=vmkit/trunk/include/j3/LLVMMaterializer.h&p1=vmkit/trunk/include/j3/JnjvmModuleProvider.h&r1=96100&r2=96122&rev=96122&view=diff

==============================================================================
--- vmkit/trunk/include/j3/JnjvmModuleProvider.h (original)
+++ vmkit/trunk/include/j3/LLVMMaterializer.h Sat Feb 13 15:48:31 2010
@@ -1,4 +1,4 @@
-//===-------- JnjvmModuleProvider.h - LLVM Module Provider for J3 ---------===//
+//===---------- LLVMMaterializer.h - LLVM Materializer for J3 -------------===//
 //
 //                            The VMKit project
 //
@@ -16,14 +16,13 @@
 
 class JavaJITCompiler;
 
-class JnjvmModuleProvider : public llvm::GVMaterializer {
+class LLVMMaterializer : public llvm::GVMaterializer {
 public:
  
   JavaJITCompiler* Comp;
   llvm::Module* TheModule;
 
-  JnjvmModuleProvider(llvm::Module* M, JavaJITCompiler* C);
-  ~JnjvmModuleProvider();
+  LLVMMaterializer(llvm::Module* M, JavaJITCompiler* C);
 
   virtual bool Materialize(llvm::GlobalValue *GV, std::string *ErrInfo = 0);
   virtual bool isMaterializable(const llvm::GlobalValue*) const;

Modified: vmkit/trunk/lib/J3/Compiler/JITInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JITInfo.cpp?rev=96122&r1=96121&r2=96122&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JITInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JITInfo.cpp Sat Feb 13 15:48:31 2010
@@ -29,7 +29,6 @@
 #include "Reader.h"
 
 #include "j3/JnjvmModule.h"
-#include "j3/JnjvmModuleProvider.h"
 
 #include <cstdio>
 

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96122&r1=96121&r2=96122&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Feb 13 15:48:31 2010
@@ -38,7 +38,6 @@
 #include "Reader.h"
 
 #include "j3/JnjvmModule.h"
-#include "j3/JnjvmModuleProvider.h"
 
 using namespace j3;
 using namespace llvm;

Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96122&r1=96121&r2=96122&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sat Feb 13 15:48:31 2010
@@ -31,7 +31,7 @@
 #include "Jnjvm.h"
 
 #include "j3/JnjvmModule.h"
-#include "j3/JnjvmModuleProvider.h"
+#include "j3/LLVMMaterializer.h"
 
 using namespace j3;
 using namespace llvm;
@@ -210,7 +210,12 @@
 #else
   EmitFunctionName = false;
 #endif
-  TheModuleProvider = new JnjvmModuleProvider(TheModule, this);
+  TheModuleProvider = new LLVMMaterializer(TheModule, this);
+  
+  JnjvmModule::protectEngine.lock();
+  JnjvmModule::executionEngine->addModule(TheModule);
+  JnjvmModule::protectEngine.unlock();
+  
   addJavaPasses();
 
   if (!JITListener) {

Modified: vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp?rev=96122&r1=96121&r2=96122&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp Sat Feb 13 15:48:31 2010
@@ -25,7 +25,7 @@
 #include "JavaTypes.h"
 
 #include "j3/JnjvmModule.h"
-#include "j3/JnjvmModuleProvider.h"
+#include "j3/LLVMMaterializer.h"
 
 using namespace j3;
 using namespace llvm;

Removed: vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp?rev=96121&view=auto

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp (removed)
@@ -1,164 +0,0 @@
-//===--- JnjvmModuleProvider.cpp - LLVM Module Provider for Jnjvm ---------===//
-//
-//                            The VMKit project
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Constants.h"
-#include "llvm/Module.h"
-#include "llvm/ExecutionEngine/ExecutionEngine.h"
-
-#include "mvm/JIT.h"
-
-#include "JavaAccess.h"
-#include "JavaClass.h"
-#include "JavaConstantPool.h"
-#include "JavaThread.h"
-#include "JavaTypes.h"
-#include "Jnjvm.h"
-
-#include "j3/JnjvmModule.h"
-#include "j3/JnjvmModuleProvider.h"
-
-using namespace llvm;
-using namespace j3;
-
-
-static JavaMethod* staticLookup(CallbackInfo& F) {
-  Class* caller = F.cl;
-  uint16 index = F.index; 
-  bool isStatic = F.stat;
-  JavaConstantPool* ctpInfo = caller->getConstantPool();
-
-  CommonClass* cl = 0;
-  const UTF8* utf8 = 0;
-  Signdef* sign = 0;
-
-  ctpInfo->resolveMethod(index, cl, utf8, sign);
-  UserClass* lookup = cl->isArray() ? cl->super : cl->asClass();
-  JavaMethod* meth = lookup->lookupMethod(utf8, sign->keyName, isStatic, true,
-                                          0);
-
-  assert(lookup->isInitializing() && "Class not ready");
- 
-  return meth;
-}
-
-
-Value* JavaJITCompiler::addCallback(Class* cl, uint16 index,
-                                    Signdef* sign, bool stat) {
-  
-  Function* F = 0;
-  LLVMSignatureInfo* LSI = getSignatureInfo(sign);
-  
-  const UTF8* name = cl->name;
-  char* key = (char*)alloca(name->size + 16);
-  for (sint32 i = 0; i < name->size; ++i)
-    key[i] = name->elements[i];
-  sprintf(key + name->size, "%d", index);
-  F = TheModule->getFunction(key);
-  if (F) return F;
-  
-  const FunctionType* type = stat ? LSI->getStaticType() : 
-                                    LSI->getVirtualType();
-  
-  F = Function::Create(type, GlobalValue::ExternalWeakLinkage, key, TheModule);
-  
-  CallbackInfo A(cl, index, stat);
-  callbacks.insert(std::make_pair(F, A));
-  
-  return F;
-}
-
-
-bool JnjvmModuleProvider::Materialize(GlobalValue *GV,
-                                      std::string *ErrInfo) {
-  
-  Function* F = dyn_cast<Function>(GV);
-  assert(F && "Not a function");
-  if (F->getLinkage() == GlobalValue::ExternalLinkage) return false;
-
-  // The caller of materializeFunction *must* always hold the JIT lock.
-  // Because we are materializing a function here, we must release the
-  // JIT lock and get the global vmkit lock to be thread-safe.
-  // This prevents jitting the function while someone else is doing it.
-  mvm::MvmModule::executionEngine->lock.release(); 
-  mvm::MvmModule::protectIR();
-
-  // Don't use hasNotBeenReadFromBitcode: materializeFunction is called
-  // by the pass manager, and we don't want another thread to JIT the
-  // function while all passes have not been run.
-  if (!(F->isDeclaration())) {
-    mvm::MvmModule::unprotectIR(); 
-    // Reacquire and go back to the JIT function.
-    mvm::MvmModule::executionEngine->lock.acquire();
-    return false;
-  }
-
-  if (mvm::MvmModule::executionEngine->getPointerToGlobalIfAvailable(F)) {
-    mvm::MvmModule::unprotectIR(); 
-    // Reacquire and go back to the JIT function.
-    mvm::MvmModule::executionEngine->lock.acquire();
-    return false;
-  }
-  
-  JavaMethod* meth = Comp->getJavaMethod(F);
-  
-  if (!meth) {
-    // It's a callback
-    JavaJITCompiler::callback_iterator I = Comp->callbacks.find(F);
-    assert(I != Comp->callbacks.end() && "No callbacks found");
-    meth = staticLookup(I->second);
-  }
-  
-  void* val = meth->compiledPtr();
-
-  if (isVirtual(meth->access)) {
-    LLVMMethodInfo* LMI = JavaLLVMCompiler::getMethodInfo(meth);
-    uint64_t offset = dyn_cast<ConstantInt>(LMI->getOffset())->getZExtValue();
-    assert(meth->classDef->isResolved() && "Class not resolved");
-#if !defined(ISOLATE_SHARING) && !defined(SERVICE)
-    assert(meth->classDef->isInitializing() && "Class not ready");
-#endif
-    assert(meth->classDef->virtualVT && "Class has no VT");
-    assert(meth->classDef->virtualTableSize > offset && 
-        "The method's offset is greater than the virtual table size");
-    ((void**)meth->classDef->virtualVT)[offset] = val;
-  } else {
-    assert(meth->classDef->isInitializing() && "Class not ready");
-  }
-
-  mvm::MvmModule::unprotectIR();
-  
-  // Reacquire to go back to the JIT function.
-  mvm::MvmModule::executionEngine->lock.acquire();
-  
-  if (F->isDeclaration())
-    mvm::MvmModule::executionEngine->updateGlobalMapping(F, val);
-  
-  return false;
-}
-
-bool JnjvmModuleProvider::isMaterializable(const llvm::GlobalValue* GV) const {
-  return GV->getLinkage() == GlobalValue::ExternalWeakLinkage;
-}
-
-
-JnjvmModuleProvider::JnjvmModuleProvider(llvm::Module* m,
-                                         JavaJITCompiler* C) {
-  Comp = C;
-  TheModule = m;
-  m->setMaterializer(this);
-  JnjvmModule::protectEngine.lock();
-  JnjvmModule::executionEngine->addModule(TheModule);
-  JnjvmModule::protectEngine.unlock();
-}
-
-JnjvmModuleProvider::~JnjvmModuleProvider() {
-  JnjvmModule::protectEngine.lock();
-  JnjvmModule::executionEngine->removeModule(TheModule);
-  JnjvmModule::protectEngine.unlock();
-}

Copied: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (from r96100, vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp)
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?p2=vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp&p1=vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp&r1=96100&r2=96122&rev=96122&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sat Feb 13 15:48:31 2010
@@ -1,4 +1,4 @@
-//===--- JnjvmModuleProvider.cpp - LLVM Module Provider for Jnjvm ---------===//
+//===-------- LLVMMaterializer.cpp - LLVM Materializer for J3 -------------===//
 //
 //                            The VMKit project
 //
@@ -21,7 +21,7 @@
 #include "Jnjvm.h"
 
 #include "j3/JnjvmModule.h"
-#include "j3/JnjvmModuleProvider.h"
+#include "j3/LLVMMaterializer.h"
 
 using namespace llvm;
 using namespace j3;
@@ -74,8 +74,7 @@
 }
 
 
-bool JnjvmModuleProvider::Materialize(GlobalValue *GV,
-                                      std::string *ErrInfo) {
+bool LLVMMaterializer::Materialize(GlobalValue *GV, std::string *ErrInfo) {
   
   Function* F = dyn_cast<Function>(GV);
   assert(F && "Not a function");
@@ -142,23 +141,13 @@
   return false;
 }
 
-bool JnjvmModuleProvider::isMaterializable(const llvm::GlobalValue* GV) const {
+bool LLVMMaterializer::isMaterializable(const llvm::GlobalValue* GV) const {
   return GV->getLinkage() == GlobalValue::ExternalWeakLinkage;
 }
 
 
-JnjvmModuleProvider::JnjvmModuleProvider(llvm::Module* m,
-                                         JavaJITCompiler* C) {
+LLVMMaterializer::LLVMMaterializer(llvm::Module* m, JavaJITCompiler* C) {
   Comp = C;
   TheModule = m;
   m->setMaterializer(this);
-  JnjvmModule::protectEngine.lock();
-  JnjvmModule::executionEngine->addModule(TheModule);
-  JnjvmModule::protectEngine.unlock();
-}
-
-JnjvmModuleProvider::~JnjvmModuleProvider() {
-  JnjvmModule::protectEngine.lock();
-  JnjvmModule::executionEngine->removeModule(TheModule);
-  JnjvmModule::protectEngine.unlock();
 }

Modified: vmkit/trunk/tools/j3/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/j3/Main.cpp?rev=96122&r1=96121&r2=96122&view=diff

==============================================================================
--- vmkit/trunk/tools/j3/Main.cpp (original)
+++ vmkit/trunk/tools/j3/Main.cpp Sat Feb 13 15:48:31 2010
@@ -14,7 +14,6 @@
 #include "mvm/Threads/Thread.h"
 
 #include "j3/JnjvmModule.h"
-#include "j3/JnjvmModuleProvider.h"
 
 #include "llvm/Support/ManagedStatic.h"
 

Modified: vmkit/trunk/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=96122&r1=96121&r2=96122&view=diff

==============================================================================
--- vmkit/trunk/tools/vmjc/vmjc.cpp (original)
+++ vmkit/trunk/tools/vmjc/vmjc.cpp Sat Feb 13 15:48:31 2010
@@ -43,7 +43,6 @@
 #include "mvm/Threads/Thread.h"
 
 #include "j3/JnjvmModule.h"
-#include "j3/JnjvmModuleProvider.h"
 
 #include "../../lib/J3/VMCore/JnjvmClassLoader.h"
 #include "../../lib/J3/VMCore/Jnjvm.h"

Modified: vmkit/trunk/tools/vmkit/Launcher.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=96122&r1=96121&r2=96122&view=diff

==============================================================================
--- vmkit/trunk/tools/vmkit/Launcher.cpp (original)
+++ vmkit/trunk/tools/vmkit/Launcher.cpp Sat Feb 13 15:48:31 2010
@@ -26,7 +26,6 @@
 #include "mvm/Threads/Thread.h"
 
 #include "j3/JnjvmModule.h"
-#include "j3/JnjvmModuleProvider.h"
 
 #include "CommandLine.h"
 





More information about the vmkit-commits mailing list