[vmkit-commits] [vmkit] r84995 - in /vmkit/trunk: include/mvm/VirtualMachine.h lib/JnJVM/Compiler/JavaJITCompiler.cpp lib/JnJVM/VMCore/JavaThread.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sat Oct 24 02:38:19 PDT 2009
Author: geoffray
Date: Sat Oct 24 04:38:14 2009
New Revision: 84995
URL: http://llvm.org/viewvc/llvm-project?rev=84995&view=rev
Log:
Handle JIT-generated functions of .bc files.
Modified:
vmkit/trunk/include/mvm/VirtualMachine.h
vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
Modified: vmkit/trunk/include/mvm/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/VirtualMachine.h?rev=84995&r1=84994&r2=84995&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/VirtualMachine.h (original)
+++ vmkit/trunk/include/mvm/VirtualMachine.h Sat Oct 24 04:38:14 2009
@@ -397,13 +397,13 @@
protected:
- /// JavaFunctionMap - Map of Java method to function pointers. This map is
- /// used when walking the stack so that VMKit knows which Java method is
- /// executing on the stack.
+ /// Functions - Map of applicative methods to function pointers. This map is
+ /// used when walking the stack so that VMKit knows which applicative method
+ /// is executing on the stack.
///
std::map<void*, void*> Functions;
- /// FunctionMapLock - Spin lock to protect the JavaFunctionMap.
+ /// FunctionMapLock - Spin lock to protect the Functions map.
///
mvm::SpinLock FunctionMapLock;
@@ -444,6 +444,42 @@
return scanner;
}
+protected:
+
+ /// InternalFunctions - Map of internal methods to function pointers. This
+ /// map is used when walking the stack so that VMKit knows which
+ /// JIT-generated internal method is executing on the stack.
+ ///
+ std::map<void*, const char*> InternalFunctions;
+
+ /// FunctionMapLock - Spin lock to protect the Functions map.
+ ///
+ mvm::SpinLock InternalFunctionMapLock;
+
+public:
+ /// addMethodInFunctionMap - A new method pointer in the function map.
+ ///
+ void addInternalMethodInFunctionMap(const char* meth, void* start, void* end) {
+ InternalFunctionMapLock.acquire();
+ InternalFunctions.insert(std::make_pair(start, meth));
+ InternalFunctions.insert(std::make_pair(end, meth));
+ InternalFunctionMapLock.release();
+ }
+
+ /// IPToJavaMethod - Map an instruction pointer to the Java method.
+ ///
+ const char* IPToInternalMethod(void* ip) {
+ InternalFunctionMapLock.acquire();
+ std::map<void*, const char*>::iterator I = InternalFunctions.upper_bound(ip);
+ const char* res = 0;
+ if (I != InternalFunctions.end() && I != InternalFunctions.begin()) {
+ res = I->second;
+ assert ((--I)->second == res && "Malformed map");
+ }
+ InternalFunctionMapLock.release();
+ return res;
+ }
+
#ifdef ISOLATE
size_t IsolateID;
#endif
Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp?rev=84995&r1=84994&r2=84995&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp Sat Oct 24 04:38:14 2009
@@ -44,6 +44,10 @@
"Method mismatch");
Jnjvm* vm = JavaThread::get()->getJVM();
vm->addMethodInFunctionMap(currentCompiledMethod, Code);
+ } else {
+ Jnjvm* vm = JavaThread::get()->getJVM();
+ vm->addInternalMethodInFunctionMap(F.getName().data(), Code,
+ (void*)((uintptr_t)Code + Size));
}
}
@@ -312,7 +316,7 @@
void* JavaJITCompiler::loadMethod(void* handle, const char* symbol) {
Function* F = mvm::MvmModule::globalModule->getFunction(symbol);
if (F) {
- void* res = mvm::MvmModule::executionEngine->getPointerToFunction(F);
+ void* res = mvm::MvmModule::executionEngine->getPointerToFunctionOrStub(F);
return res;
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp?rev=84995&r1=84994&r2=84995&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Sat Oct 24 04:38:14 2009
@@ -280,13 +280,18 @@
#include <dlfcn.h>
-static void printFunctionInfo(void* ip) {
+static void printFunctionInfo(Jnjvm* vm, void* ip) {
Dl_info info;
int res = dladdr(ip, &info);
if (res != 0) {
fprintf(stderr, "; %p in %s\n", ip, info.dli_sname);
} else {
- fprintf(stderr, "; %p in Native to Java Frame\n", ip);
+ const char* name = vm->IPToInternalMethod(ip);
+ if (name) {
+ fprintf(stderr, "; %p in %s LLVM method\n", ip, name);
+ } else {
+ fprintf(stderr, "; %p in Unknown method\n", ip);
+ }
}
}
@@ -304,7 +309,7 @@
// Until we hit the last Java frame.
do {
void* ip = FRAME_IP(addr);
- printFunctionInfo(ip);
+ printFunctionInfo(vm, ip);
oldAddr = addr;
addr = (void**)addr[0];
} while (oldAddr != (void**)*it && addr != (void**)*it);
@@ -319,7 +324,7 @@
--it;
if (*it == 0) {
void* ip = FRAME_IP(addr);
- printFunctionInfo(ip);
+ printFunctionInfo(vm, ip);
addr = (void**)addr[0];
continue;
}
@@ -345,7 +350,7 @@
while (addr < baseSP && addr < addr[0]) {
void* ip = FRAME_IP(addr);
- printFunctionInfo(ip);
+ printFunctionInfo(vm, ip);
addr = (void**)addr[0];
}
More information about the vmkit-commits
mailing list