[vmkit-commits] [vmkit] r61497 - in /vmkit/trunk: include/mvm/JIT.h include/mvm/MvmMemoryManager.h lib/Mvm/Runtime/JIT.cpp lib/Mvm/Runtime/MvmMemoryManager.cpp lib/Mvm/Runtime/Object.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Tue Dec 30 07:25:37 PST 2008


Author: geoffray
Date: Tue Dec 30 09:25:26 2008
New Revision: 61497

URL: http://llvm.org/viewvc/llvm-project?rev=61497&view=rev
Log:
Finally, get rid of MvmMemoryManager.{cpp,h}.



Removed:
    vmkit/trunk/include/mvm/MvmMemoryManager.h
    vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp
Modified:
    vmkit/trunk/include/mvm/JIT.h
    vmkit/trunk/lib/Mvm/Runtime/JIT.cpp
    vmkit/trunk/lib/Mvm/Runtime/Object.cpp

Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=61497&r1=61496&r2=61497&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Tue Dec 30 09:25:26 2008
@@ -27,7 +27,6 @@
 namespace mvm {
 
 class LockNormal;
-class MvmMemoryManager;
 
 const double MaxDouble = +INFINITY; //1.0 / 0.0;
 const double MinDouble = -INFINITY;//-1.0 / 0.0;
@@ -161,13 +160,9 @@
 
   static llvm::Module *globalModule;
   static llvm::ExistingModuleProvider *globalModuleProvider;
-  static mvm::MvmMemoryManager *memoryManager;
 
   static int disassemble(unsigned int* addr);
 
-  static const llvm::Function* getCodeFromPointer(void* addr);
-  static void addMethodInfo(void* end, const llvm::Function* F);
-
 
 };
 

Removed: vmkit/trunk/include/mvm/MvmMemoryManager.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/MvmMemoryManager.h?rev=61496&view=auto

==============================================================================
--- vmkit/trunk/include/mvm/MvmMemoryManager.h (original)
+++ vmkit/trunk/include/mvm/MvmMemoryManager.h (removed)
@@ -1,122 +0,0 @@
-//===------- MvmMemoryManager.h - LLVM Memory manager for Mvm -------------===//
-//
-//                              Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-
-#ifndef MVM_MEMORY_MANAGER_H
-#define MVM_MEMORY_MANAGER_H
-
-#include <map>
-
-#include <llvm/ExecutionEngine/JITMemoryManager.h>
-
-using namespace llvm;
-
-namespace mvm {
-
-/// MvmMemoryManager - This class is a wrapper to the default JITMemoryManager
-/// in LLVM. It creates Code objects for backtraces and getting virtual machine
-/// information out of dynamically generated native code.
-///
-class MvmMemoryManager : public JITMemoryManager {
-  
-  /// realMemoryManager - The real allocator 
-  JITMemoryManager* realMemoryManager;
-
-public:
-  
-  MvmMemoryManager() : JITMemoryManager() { 
-    realMemoryManager = JITMemoryManager::CreateDefaultMemManager();
-  }
-  
-  /// startFunctionBody - When we start JITing a function, the JIT calls this 
-  /// method to allocate a block of free RWX memory, which returns a pointer to
-  /// it.  The JIT doesn't know ahead of time how much space it will need to
-  /// emit the function, so it doesn't pass in the size.  Instead, this method
-  /// is required to pass back a "valid size".  The JIT will be careful to not
-  /// write more than the returned ActualSize bytes of memory. 
-  virtual unsigned char *startFunctionBody(const Function *F, 
-                                           uintptr_t &ActualSize) {
-    return realMemoryManager->startFunctionBody(F, ActualSize);
-  }
-  
-  /// allocateStub - This method is called by the JIT to allocate space for a
-  /// function stub (used to handle limited branch displacements) while it is
-  /// JIT compiling a function.  For example, if foo calls bar, and if bar
-  /// either needs to be lazily compiled or is a native function that exists too
-  /// far away from the call site to work, this method will be used to make a
-  /// thunk for it.  The stub should be "close" to the current function body,
-  /// but should not be included in the 'actualsize' returned by
-  /// startFunctionBody.
-  virtual unsigned char *allocateStub(const GlobalValue* GV, unsigned StubSize,
-                                      unsigned Alignment) {
-    return realMemoryManager->allocateStub(GV, StubSize, Alignment);
-  }
-  
-  /// endFunctionBody - This method is called when the JIT is done codegen'ing
-  /// the specified function.  At this point we know the size of the JIT
-  /// compiled function.  This passes in FunctionStart (which was returned by
-  /// the startFunctionBody method) and FunctionEnd which is a pointer to the 
-  /// actual end of the function.  This method should mark the space allocated
-  /// and remember where it is in case the client wants to deallocate it.
-  virtual void endFunctionBody(const Function *F, unsigned char *FunctionStart,
-                               unsigned char *FunctionEnd);
-  
-  /// deallocateMemForFunction - Free JIT memory for the specified function.
-  /// This is never called when the JIT is currently emitting a function.
-  virtual void deallocateMemForFunction(const Function *F) {
-    return realMemoryManager->deallocateMemForFunction(F);
-  }
-  
-  /// AllocateGOT - If the current table requires a Global Offset Table, this
-  /// method is invoked to allocate it.  This method is required to set HasGOT
-  /// to true.
-  virtual void AllocateGOT() {
-    return realMemoryManager->AllocateGOT();
-  }
-
-  /// getGOTBase - If this is managing a Global Offset Table, this method should
-  /// return a pointer to its base.
-  virtual unsigned char *getGOTBase() const {
-    return realMemoryManager->getGOTBase();
-  }
-  
-
-  /// startExceptionTable - When we finished JITing the function, if exception
-  /// handling is set, we emit the exception table.
-  virtual unsigned char* startExceptionTable(const Function* F,
-                                             uintptr_t &ActualSize) {
-    return realMemoryManager->startExceptionTable(F, ActualSize);
-  }
-  
-  /// endExceptionTable - This method is called when the JIT is done emitting
-  /// the exception table.
-  virtual void endExceptionTable(const Function *F, unsigned char *TableStart,
-                               unsigned char *TableEnd, 
-                               unsigned char* FrameRegister) {
-    return realMemoryManager->endExceptionTable(F, TableStart, TableEnd,
-                                                FrameRegister);
-  }
-  
-  virtual void setMemoryWritable() {
-    realMemoryManager->setMemoryWritable();
-  }
-  
-  virtual void setMemoryExecutable() {
-    realMemoryManager->setMemoryExecutable();
-  }
-
-  virtual unsigned char* allocateSpace(intptr_t Size, unsigned int Align) {
-    return realMemoryManager->allocateSpace(Size, Align);
-  }
-
-};
-
-} // End mvm namespace
-
-#endif

Modified: vmkit/trunk/lib/Mvm/Runtime/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/JIT.cpp?rev=61497&r1=61496&r2=61497&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/JIT.cpp Tue Dec 30 09:25:26 2008
@@ -19,11 +19,8 @@
 #include "llvm/Target/TargetOptions.h"
 
 
-#include <cstdio>
-
 #include "mvm/CompilationUnit.h"
 #include "mvm/JIT.h"
-#include "mvm/MvmMemoryManager.h"
 #include "mvm/Object.h"
 #include "mvm/Threads/Locks.h"
 #include "mvm/Threads/Thread.h"
@@ -32,26 +29,6 @@
 using namespace llvm;
 
 
-extern "C" void printFloat(float f) {
-  fprintf(stderr, "%f\n", f);
-}
-
-extern "C" void printDouble(double d) {
-  fprintf(stderr, "%f\n", d);
-}
-
-extern "C" void printLong(sint64 l) {
-  fprintf(stderr, "%lld\n", (long long int)l);
-}
-
-extern "C" void printInt(sint32 i) {
-  fprintf(stderr, "%d\n", i);
-}
-
-extern "C" void printObject(mvm::Object* obj) {
-  fprintf(stderr, "%s\n", obj->printString());
-}
-
 namespace mvm {
   namespace llvm_runtime {
     #include "LLVMRuntime.inc"
@@ -63,12 +40,11 @@
   llvm::ExceptionHandling = true;
   globalModule = new llvm::Module("bootstrap module");
   globalModuleProvider = new ExistingModuleProvider (globalModule);
-  memoryManager = new MvmMemoryManager();
   
 
 
   executionEngine = ExecutionEngine::createJIT(globalModuleProvider, 0,
-                                               memoryManager, Fast);
+                                               0, Fast);
   
   std::string str = 
     executionEngine->getTargetData()->getStringRepresentation();
@@ -254,7 +230,6 @@
 
 llvm::Module *MvmModule::globalModule;
 llvm::ExistingModuleProvider *MvmModule::globalModuleProvider;
-mvm::MvmMemoryManager *MvmModule::memoryManager;
 
 
 uint64 MvmModule::getTypeSize(const llvm::Type* type) {
@@ -266,31 +241,6 @@
   pm->run(*func);
 }
 
-static LockNormal lock;
-static std::map<void*, const llvm::Function*> pointerMap;
-
-const llvm::Function* MvmModule::getCodeFromPointer(void* Addr) {
-  lock.lock();
-  std::map<void*, const llvm::Function*>::iterator I =
-    pointerMap.lower_bound(Addr);
-  
-  lock.unlock();
-  if (I != pointerMap.end()) {
-    const llvm::Function* F = I->second;
-    if (Addr >= executionEngine->getPointerToGlobal(F)) return F;
-  }
-
-  return 0;
-}
-
-void MvmModule::addMethodInfo(void* Addr, const llvm::Function* F) {
-  lock.lock();
-  pointerMap.insert(std::make_pair(Addr, F));
-  lock.unlock();
-}
-
-
-
 static void addPass(FunctionPassManager *PM, Pass *P) {
   // Add the pass to the pass manager...
   PM->add(P);

Removed: vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp?rev=61496&view=auto

==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp (removed)
@@ -1,23 +0,0 @@
-//===----- MvmMemoryManager.cpp - LLVM Memory manager for Mvm -------------===//
-//
-//                              Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mvm/JIT.h"
-#include "mvm/Object.h"
-
-#include "mvm/MvmMemoryManager.h"
-
-using namespace mvm;
-using namespace llvm;
-
-void MvmMemoryManager::endFunctionBody(const Function *F, 
-                                       unsigned char *FunctionStart,
-                                       unsigned char *FunctionEnd) {
-  MvmModule::addMethodInfo((void*)FunctionEnd, F);
-  realMemoryManager->endFunctionBody(F, FunctionStart, FunctionEnd);
-}

Modified: vmkit/trunk/lib/Mvm/Runtime/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/Object.cpp?rev=61497&r1=61496&r2=61497&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/Object.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/Object.cpp Tue Dec 30 09:25:26 2008
@@ -7,6 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <cstdio>
 #include <cstdlib>
 
 #include "MvmGC.h"
@@ -21,6 +22,26 @@
 VirtualTable *NativeString::VT = 0;
 VirtualTable *PrintBuffer::VT = 0;
 
+extern "C" void printFloat(float f) {
+  fprintf(stderr, "%f\n", f);
+}
+
+extern "C" void printDouble(double d) {
+  fprintf(stderr, "%f\n", d);
+}
+
+extern "C" void printLong(sint64 l) {
+  fprintf(stderr, "%lld\n", (long long int)l);
+}
+
+extern "C" void printInt(sint32 i) {
+  fprintf(stderr, "%d\n", i);
+}
+
+extern "C" void printObject(mvm::Object* obj) {
+  fprintf(stderr, "%s\n", obj->printString());
+}
+
 
 void Object::initialise() {
 # define INIT(X) { \





More information about the vmkit-commits mailing list