[vmkit-commits] [vmkit] r59295 - in /vmkit/trunk: include/mvm/ include/mvm/Threads/ lib/JnJVM/VMCore/ lib/Mvm/Runtime/ lib/N3/VMCore/
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Fri Nov 14 01:42:33 PST 2008
Author: geoffray
Date: Fri Nov 14 03:42:32 2008
New Revision: 59295
URL: http://llvm.org/viewvc/llvm-project?rev=59295&view=rev
Log:
Code cleanup: remove mvm/Method.h header and rely on llvm annotations
to do the mapping Function->VMMethod.
Removed:
vmkit/trunk/include/mvm/Method.h
Modified:
vmkit/trunk/include/mvm/JIT.h
vmkit/trunk/include/mvm/MvmMemoryManager.h
vmkit/trunk/include/mvm/Threads/Thread.h
vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
vmkit/trunk/lib/Mvm/Runtime/JIT.cpp
vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp
vmkit/trunk/lib/Mvm/Runtime/Object.cpp
vmkit/trunk/lib/N3/VMCore/BackTrace.cpp
vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
vmkit/trunk/lib/N3/VMCore/CLIJit.h
vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp
vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.h
vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
vmkit/trunk/lib/N3/VMCore/VMClass.h
vmkit/trunk/lib/N3/VMCore/VirtualMachine.cpp
vmkit/trunk/lib/N3/VMCore/VirtualMachine.h
Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Fri Nov 14 03:42:32 2008
@@ -10,7 +10,7 @@
#ifndef MVM_JIT_H
#define MVM_JIT_H
-#include <float.h>
+#include <cfloat>
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
@@ -25,7 +25,6 @@
#include "types.h"
#include "mvm/Allocator.h"
-#include "mvm/Method.h"
#include "mvm/MvmMemoryManager.h"
#include "mvm/Threads/Locks.h"
@@ -177,8 +176,8 @@
static int disassemble(unsigned int* addr);
static int getBacktrace(void** stack, int size);
- static Code* getCodeFromPointer(void* addr);
- static void addMethodInfo(void* end, Code* c);
+ static const llvm::Function* getCodeFromPointer(void* addr);
+ static void addMethodInfo(void* end, const llvm::Function* F);
static uint8 (*llvm_atomic_cmp_swap_i8) (uint8* ptr, uint8 cmp,
uint8 val);
Removed: vmkit/trunk/include/mvm/Method.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Method.h?rev=59294&view=auto
==============================================================================
--- vmkit/trunk/include/mvm/Method.h (original)
+++ vmkit/trunk/include/mvm/Method.h (removed)
@@ -1,81 +0,0 @@
-//===--------- Method.h - Meta information for methods --------------------===//
-//
-// The Micro Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MVM_METHOD_H
-#define MVM_METHOD_H
-
-extern "C" void __deregister_frame(void*);
-
-namespace mvm {
-
-/// Code - This class contains meta information of a dynamicall generated
-/// function.
-///
-class Code {
-private:
-
- /// metaInfo - A meta info field to store virtual machine informations.
- ///
- void* metaInfo;
-
-public:
-
- Code() {
- stubSize = 0;
- FunctionStart = 0;
- FunctionEnd = 0;
- stub = 0;
- frameRegister = 0;
- exceptionTable = 0;
- metaInfo = 0;
- }
-
- /// stubSize - The size of the stub that will generate the function.
- ///
- unsigned stubSize;
-
- /// FunctionStart - The starting address in memory of the generated function.
- ///
- unsigned char* FunctionStart;
-
- /// FunctionStart - The ending address in memory of the generated function.
- ///
- unsigned char* FunctionEnd;
-
- /// stub - The starting address of the stub.
- ///
- unsigned char* stub;
-
- /// exceptionTable - The exception table of this function.
- ///
- unsigned char* exceptionTable;
-
- /// frameRegister - The address where to register and unregister the
- /// exception table.
- unsigned char* frameRegister;
-
-
- /// getMetaInfo - Returns the virtual machine information related to this
- /// method.
- void* getMetaInfo() { return metaInfo; }
-
- /// setMetaInfo - Sets the virtual machine information of this method.
- ///
- void setMetaInfo(void* m) { metaInfo = m; }
-
- /// unregisterFrame - Unregisters the exception table of this method.
- ///
- inline void unregisterFrame() {
- __deregister_frame((unsigned char*)frameRegister);
- }
-};
-
-} // end namespace mvm
-
-#endif // MVM_METHOD_H
Modified: vmkit/trunk/include/mvm/MvmMemoryManager.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/MvmMemoryManager.h?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/MvmMemoryManager.h (original)
+++ vmkit/trunk/include/mvm/MvmMemoryManager.h Fri Nov 14 03:42:32 2008
@@ -19,18 +19,12 @@
namespace mvm {
-class Code;
-
/// 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 {
- /// currentMethod - Current method being compiled.
- ///
- Code* currentMethod;
-
/// realMemoryManager - The real allocator
JITMemoryManager* realMemoryManager;
@@ -47,7 +41,9 @@
/// 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);
+ 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
@@ -58,7 +54,9 @@
/// but should not be included in the 'actualsize' returned by
/// startFunctionBody.
virtual unsigned char *allocateStub(const GlobalValue* GV, unsigned StubSize,
- unsigned Alignment);
+ 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
@@ -71,28 +69,39 @@
/// 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);
+ 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();
+ 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;
+ 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);
+ 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);
+ unsigned char* FrameRegister) {
+ return realMemoryManager->endExceptionTable(F, TableStart, TableEnd,
+ FrameRegister);
+ }
virtual void setMemoryWritable() {
realMemoryManager->setMemoryWritable();
Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Fri Nov 14 03:42:32 2008
@@ -90,7 +90,7 @@
public:
- VirtualMachine* vm;
+ VirtualMachine* MyVM;
/// baseSP - The base stack pointer.
///
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp Fri Nov 14 03:42:32 2008
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include <stdarg.h>
-#include <stdlib.h>
+#include <cstdarg>
+#include <cstdlib>
#include "JavaArray.h"
#include "JavaClass.h"
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp Fri Nov 14 03:42:32 2008
@@ -7,28 +7,26 @@
//
//===----------------------------------------------------------------------===//
-#include <stdio.h>
+#include <cstdio>
#include <dlfcn.h>
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "mvm/Object.h"
#include "JavaClass.h"
#include "JavaJIT.h"
#include "JavaThread.h"
#include "Jnjvm.h"
+#include "JnjvmModule.h"
#include "JnjvmModuleProvider.h"
using namespace jnjvm;
JavaMethod* JavaJIT::IPToJavaMethod(void* begIp) {
- mvm::Code* code = mvm::MvmModule::getCodeFromPointer(begIp);
- if (code) {
- JavaMethod* meth = (JavaMethod*)code->getMetaInfo();
- if (meth) {
- return meth;
- }
+ const llvm::Function* F = mvm::MvmModule::getCodeFromPointer(begIp);
+ if (F) {
+ JavaMethod* meth = LLVMMethodInfo::get(F);
+ return meth;
}
return 0;
}
@@ -38,14 +36,9 @@
int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 100);
int n = 0;
while (n < real_size) {
- mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
- if (code) {
- JavaMethod* meth = (JavaMethod*)code->getMetaInfo();
- if (meth) {
- printf("; %p in %s\n", (void*)ips[n - 1], meth->printString());
- } else {
- printf("; %p in %s\n", (void*)ips[n - 1], "unknown");
- }
+ JavaMethod* meth = IPToJavaMethod(ips[n++]);
+ if (meth) {
+ printf("; %p in %s\n", (void*)ips[n - 1], meth->printString());
} else {
Dl_info info;
int res = dladdr(ips[n++], &info);
@@ -68,15 +61,12 @@
int n = 0;
int i = 0;
while (n < real_size) {
- mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
- if (code) {
- JavaMethod* meth = (JavaMethod*)code->getMetaInfo();
- if (meth) {
- if (i == 1) {
- return meth->classDef;
- } else {
- ++i;
- }
+ JavaMethod* meth = IPToJavaMethod(ips[n++]);
+ if (meth) {
+ if (i == 1) {
+ return meth->classDef;
+ } else {
+ ++i;
}
}
}
@@ -89,15 +79,12 @@
int n = 0;
int i = 0;
while (n < real_size) {
- mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
- if (code) {
- JavaMethod* meth = (JavaMethod*)code->getMetaInfo();
- if (meth) {
- if (i == 1) {
- return meth->classDef;
- } else {
- ++i;
- }
+ JavaMethod* meth = IPToJavaMethod(ips[n++]);
+ if (meth) {
+ if (i == 1) {
+ return meth->classDef;
+ } else {
+ ++i;
}
}
}
@@ -113,16 +100,13 @@
int n = 0;
int i = 0;
while (n < real_size) {
- mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
- if (code) {
- JavaMethod* meth = (JavaMethod*)code->getMetaInfo();
- if (meth) {
- if (i == 1) {
- res = meth->classDef;
- break;
- } else {
- ++i;
- }
+ JavaMethod* meth = IPToJavaMethod(ips[n++]);
+ if (meth) {
+ if (i == 1) {
+ res = meth->classDef;
+ break;
+ } else {
+ ++i;
}
}
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Fri Nov 14 03:42:32 2008
@@ -16,7 +16,6 @@
#include "mvm/Allocator.h"
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "mvm/Object.h"
#include "mvm/PrintBuffer.h"
#include "mvm/Threads/Cond.h"
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Fri Nov 14 03:42:32 2008
@@ -24,7 +24,6 @@
#include <llvm/Support/CFG.h>
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "debug.h"
#include "JavaArray.h"
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Fri Nov 14 03:42:32 2008
@@ -11,7 +11,7 @@
#define JNJVM_COMPILE 0
#define JNJVM_EXECUTE 0
-#include <string.h>
+#include <cstring>
#include <llvm/Constants.h>
#include <llvm/DerivedTypes.h>
@@ -21,7 +21,6 @@
#include <llvm/Type.h>
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "debug.h"
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Fri Nov 14 03:42:32 2008
@@ -7,11 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include <stdarg.h>
-#include <string.h>
+#include <cstdarg>
+#include <cstring>
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "debug.h"
#include "JavaArray.h"
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Fri Nov 14 03:42:32 2008
@@ -33,7 +33,7 @@
JavaThread::JavaThread(JavaObject* thread, JavaObject* vmth, Jnjvm* isolate) {
javaThread = thread;
vmThread = vmth;
- vm = isolate;
+ MyVM = isolate;
interruptFlag = 0;
state = StateRunning;
pendingException = 0;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Fri Nov 14 03:42:32 2008
@@ -54,7 +54,7 @@
}
Jnjvm* getJVM() {
- return (Jnjvm*)vm;
+ return (Jnjvm*)MyVM;
}
static JavaObject* currentThread() {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Fri Nov 14 03:42:32 2008
@@ -113,8 +113,6 @@
Function* func = parseFunction(meth);
void* res = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
- mvm::Code* m = mvm::MvmModule::getCodeFromPointer(res);
- if (m) m->setMetaInfo(meth);
func->deleteBody();
return res;
Modified: vmkit/trunk/lib/Mvm/Runtime/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/JIT.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/JIT.cpp Fri Nov 14 03:42:32 2008
@@ -15,10 +15,9 @@
#include "llvm/Support/MutexGuard.h"
#include "llvm/Target/TargetOptions.h"
-#include <stdio.h>
+#include <cstdio>
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "mvm/MvmMemoryManager.h"
#include "mvm/Object.h"
#include "mvm/Threads/Thread.h"
@@ -301,25 +300,25 @@
return cpt;
}
-LockNormal lock;
-std::map<void*, Code*> pointerMap;
+static LockNormal lock;
+static std::map<void*, const llvm::Function*> pointerMap;
-Code* MvmModule::getCodeFromPointer(void* Addr) {
+const llvm::Function* MvmModule::getCodeFromPointer(void* Addr) {
lock.lock();
- std::map<void*, Code*>::iterator I =
+ std::map<void*, const llvm::Function*>::iterator I =
pointerMap.lower_bound(Addr);
lock.unlock();
if (I != pointerMap.end()) {
- Code* m = I->second;
- if (Addr >= m->FunctionStart) return m;
+ const llvm::Function* F = I->second;
+ if (Addr >= executionEngine->getPointerToGlobal(F)) return F;
}
return 0;
}
-void MvmModule::addMethodInfo(void* Addr, Code* C) {
+void MvmModule::addMethodInfo(void* Addr, const llvm::Function* F) {
lock.lock();
- pointerMap.insert(std::make_pair(Addr, C));
+ pointerMap.insert(std::make_pair(Addr, F));
lock.unlock();
}
Modified: vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp Fri Nov 14 03:42:32 2008
@@ -7,10 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include <assert.h>
-
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "mvm/Object.h"
#include "mvm/MvmMemoryManager.h"
@@ -18,61 +15,9 @@
using namespace mvm;
using namespace llvm;
-unsigned char* MvmMemoryManager::startFunctionBody(const Function* F,
- uintptr_t &ActualSize) {
- Code* meth = new Code();
- currentMethod = meth;
- return realMemoryManager->startFunctionBody(F, ActualSize);
-}
-
-unsigned char *MvmMemoryManager::allocateStub(const GlobalValue* GV,
- unsigned StubSize,
- unsigned Alignment) {
- unsigned char* res = realMemoryManager->allocateStub(GV, StubSize, Alignment);
- Code* meth = new Code();
- MvmModule::addMethodInfo((void*)(res + StubSize), meth);
- currentMethod = meth;
- meth->FunctionStart = res;
- meth->FunctionEnd = res + StubSize;
- currentMethod = meth;
-
- return res;
-}
-
void MvmMemoryManager::endFunctionBody(const Function *F,
unsigned char *FunctionStart,
unsigned char *FunctionEnd) {
- MvmModule::addMethodInfo((void*)FunctionEnd, currentMethod);
- currentMethod->FunctionStart = FunctionStart;
- currentMethod->FunctionEnd = FunctionEnd;
+ MvmModule::addMethodInfo((void*)FunctionEnd, F);
realMemoryManager->endFunctionBody(F, FunctionStart, FunctionEnd);
}
-
-
-void MvmMemoryManager::deallocateMemForFunction(const Function *F) {
- realMemoryManager->deallocateMemForFunction(F);
-}
-
-void MvmMemoryManager::AllocateGOT() {
- realMemoryManager->AllocateGOT();
-}
-
-unsigned char *MvmMemoryManager::getGOTBase() const {
- return realMemoryManager->getGOTBase();
-}
-
-unsigned char *MvmMemoryManager::startExceptionTable(const Function* F,
- uintptr_t &ActualSize) {
- unsigned char* res = realMemoryManager->startExceptionTable(F, ActualSize);
-
- currentMethod->exceptionTable = res;
- return (unsigned char*)res;
-}
-
-void MvmMemoryManager::endExceptionTable(const Function *F,
- unsigned char *TableStart,
- unsigned char *TableEnd,
- unsigned char* FrameRegister) {
- realMemoryManager->endExceptionTable(F, TableStart, TableEnd, FrameRegister);
- currentMethod->frameRegister = FrameRegister;
-}
Modified: vmkit/trunk/lib/Mvm/Runtime/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/Object.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/Object.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/Object.cpp Fri Nov 14 03:42:32 2008
@@ -7,11 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include <stdlib.h>
+#include <cstdlib>
#include "MvmGC.h"
#include "mvm/Allocator.h"
-#include "mvm/Method.h"
#include "mvm/Object.h"
#include "mvm/PrintBuffer.h"
#include "mvm/Threads/Thread.h"
Modified: vmkit/trunk/lib/N3/VMCore/BackTrace.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/BackTrace.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/BackTrace.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/BackTrace.cpp Fri Nov 14 03:42:32 2008
@@ -8,11 +8,10 @@
//===----------------------------------------------------------------------===//
-#include <stdio.h>
+#include <cstdio>
#include <dlfcn.h>
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "mvm/Object.h"
#include "Assembly.h"
@@ -29,9 +28,9 @@
int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 100);
int n = 0;
while (n < real_size) {
- mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
- if (code) {
- VMMethod* meth = (VMMethod*)code->getMetaInfo();
+ const llvm::Function* F = mvm::MvmModule::getCodeFromPointer(ips[n++]);
+ if (F) {
+ VMMethod* meth = CLIJit::getMethod(F);
if (meth) {
printf("; %p in %s\n", (void*)ips[n - 1], meth->printString());
} else {
@@ -56,9 +55,9 @@
int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 5);
int n = 0;
while (n < real_size) {
- mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
- if (code) {
- VMMethod* meth = (VMMethod*)code->getMetaInfo();
+ const llvm::Function* F = mvm::MvmModule::getCodeFromPointer(ips[n++]);
+ if (F) {
+ VMMethod* meth = CLIJit::getMethod(F);
if (meth) {
return meth->classDef->assembly;
}
@@ -73,9 +72,9 @@
int n = 0;
int i = 0;
while (n < real_size) {
- mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
- if (code) {
- VMMethod* meth = (VMMethod*)code->getMetaInfo();
+ const llvm::Function* F = mvm::MvmModule::getCodeFromPointer(ips[n++]);
+ if (F) {
+ VMMethod* meth = CLIJit::getMethod(F);
if (meth && i >= 1) {
return meth->classDef->assembly;
} else {
Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Fri Nov 14 03:42:32 2008
@@ -29,7 +29,6 @@
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "Assembly.h"
#include "CLIAccess.h"
@@ -48,8 +47,6 @@
using namespace llvm;
using namespace n3;
-#include <iostream>
-
void Exception::print(mvm::PrintBuffer* buf) const {
buf->write("Exception<>");
}
@@ -1469,6 +1466,18 @@
return func;
}
+static AnnotationID CLIMethod_ID(
+ AnnotationManager::getID("CLI::VMMethod"));
+
+
+class N3Annotation: public llvm::Annotation {
+public:
+ VMMethod* meth;
+
+ N3Annotation(VMMethod* M) : llvm::Annotation(CLIMethod_ID), meth(M) {}
+};
+
+
llvm::Function *VMMethod::compiledPtr(VMGenericMethod* genMethod) {
if (methPtr != 0) return methPtr;
else {
@@ -1477,12 +1486,20 @@
methPtr = Function::Create(getSignature(genMethod), GlobalValue::GhostLinkage,
printString(), classDef->vm->module);
classDef->vm->functions->hash(methPtr, this);
+ N3Annotation* A = new N3Annotation(this);
+ methPtr->addAnnotation(A);
}
classDef->release();
return methPtr;
}
}
+VMMethod* CLIJit::getMethod(const llvm::Function* F) {
+ N3Annotation* A = (N3Annotation*)F->getAnnotation(CLIMethod_ID);
+ if (A) return A->meth;
+ return 0;
+}
+
void VMField::initField(VMObject* obj) {
VMField* field = this;
ConstantInt* offset = field->offset;
Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.h?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.h (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.h Fri Nov 14 03:42:32 2008
@@ -222,6 +222,7 @@
llvm::Instruction* invokeInline(VMMethod* meth,
std::vector<llvm::Value*>& args, VMGenericClass* genClass, VMGenericMethod* genMethod);
+ static VMMethod* getMethod(const llvm::Function* F);
};
enum Opcode {
Modified: vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp Fri Nov 14 03:42:32 2008
@@ -11,12 +11,10 @@
#include <llvm/ModuleProvider.h>
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "Assembly.h"
#include "CLIJit.h"
#include "N3ModuleProvider.h"
-
#include "VMClass.h"
using namespace llvm;
@@ -40,8 +38,6 @@
CLIJit::compile(meth->classDef, meth);
void* res = mvm::MvmModule::executionEngine->getPointerToGlobal(meth->methPtr);
meth->code = res;
- mvm::Code* code = mvm::MvmModule::getCodeFromPointer(res);
- code->setMetaInfo(meth);
}
meth->classDef->release();
meth->classDef->resolveStatic(true, NULL);
Modified: vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.h?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.h (original)
+++ vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.h Fri Nov 14 03:42:32 2008
@@ -29,6 +29,10 @@
bool materializeFunction(Function *F, std::string *ErrInfo = 0);
Module* materializeModule(std::string *ErrInfo = 0) { return TheModule; }
+
+ VMMethod* lookupFunction(Function* F) {
+ return functions->lookup(F);
+ }
};
} // End n3 namespace
Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Fri Nov 14 03:42:32 2008
@@ -11,7 +11,7 @@
#define N3_COMPILE 0
#define N3_EXECUTE 0
-#include <string.h>
+#include <cstring>
#include <llvm/Constants.h>
#include <llvm/DerivedTypes.h>
@@ -26,7 +26,6 @@
#include <llvm/Target/TargetOptions.h>
#include "mvm/JIT.h"
-#include "mvm/Method.h"
#include "debug.h"
Modified: vmkit/trunk/lib/N3/VMCore/VMClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.h?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.h Fri Nov 14 03:42:32 2008
@@ -12,7 +12,6 @@
#include "types.h"
-#include "mvm/Method.h"
#include "mvm/Object.h"
#include "mvm/Threads/Locks.h"
#include "mvm/Threads/Cond.h"
Modified: vmkit/trunk/lib/N3/VMCore/VirtualMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VirtualMachine.cpp?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VirtualMachine.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VirtualMachine.cpp Fri Nov 14 03:42:32 2008
@@ -159,3 +159,7 @@
module = 0;
TheModuleProvider = 0;
}
+
+VMMethod* VirtualMachine::lookupFunction(Function* F) {
+ return functions->lookup(F);
+}
Modified: vmkit/trunk/lib/N3/VMCore/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VirtualMachine.h?rev=59295&r1=59294&r2=59295&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VirtualMachine.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VirtualMachine.h Fri Nov 14 03:42:32 2008
@@ -29,6 +29,7 @@
class N3ModuleProvider;
class UTF8;
class UTF8Map;
+class VMMethod;
class VMObject;
class VMThread;
@@ -132,6 +133,8 @@
// Currently unimplemented.
}
+ VMMethod* lookupFunction(llvm::Function* F);
+
};
} // end namespace n3
More information about the vmkit-commits
mailing list