[llvm-commits] [vmkit] r49720 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathVMRuntime.cpp Classpath/ClasspathVMStackWalker.cpp Classpath/ClasspathVMThread.cpp Classpath/ClasspathVMThrowable.cpp VMCore/JavaBacktrace.cpp VMCore/JavaClass.cpp VMCore/JavaIsolate.cpp VMCore/Jnjvm.cpp VMCore/Jnjvm.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Tue Apr 15 03:22:23 PDT 2008
Author: geoffray
Date: Tue Apr 15 05:22:21 2008
New Revision: 49720
URL: http://llvm.org/viewvc/llvm-project?rev=49720&view=rev
Log:
Cooperate with multiple GCs.
Modified:
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp?rev=49720&r1=49719&r2=49720&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp Tue Apr 15 05:22:21 2008
@@ -88,7 +88,11 @@
jclass clazz,
#endif
) {
+#ifdef MULTIPLE_GC
+ mvm::Thread::get()->GC->collect();
+#else
Collector::collect();
+#endif
}
JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalization(
@@ -129,7 +133,11 @@
jclass clazz,
#endif
) {
+#ifdef MULTIPLE_GC
+ return (jlong)mvm::Thread::get()->GC->getFreeMemory();
+#else
return (jlong)Collector::getFreeMemory();
+#endif
}
JNIEXPORT jlong Java_java_lang_VMRuntime_totalMemory(
@@ -138,7 +146,11 @@
jclass clazz,
#endif
) {
+#ifdef MULTIPLE_GC
+ return (jlong)mvm::Thread::get()->GC->getTotalMemory();
+#else
return (jlong)Collector::getTotalMemory();
+#endif
}
JNIEXPORT jlong Java_java_lang_VMRuntime_maxMemory(
@@ -147,7 +159,11 @@
jclass clazz,
#endif
) {
+#ifdef MULTIPLE_GC
+ return (jlong)mvm::Thread::get()->GC->getMaxMemory();
+#else
return (jlong)Collector::getMaxMemory();
+#endif
}
}
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp?rev=49720&r1=49719&r2=49720&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp Tue Apr 15 05:22:21 2008
@@ -31,7 +31,11 @@
ArrayObject* recGetClassContext(int** stack, uint32 size, uint32 first, uint32 rec) {
if (size != first) {
+#ifdef MULTIPLE_GC
+ int *begIp = (int*)mvm::Thread::get()->GC->begOf(stack[first]);
+#else
int *begIp = (int*)Collector::begOf(stack[first]);
+#endif
JavaMethod* meth = ip_to_meth(begIp);
if (meth) {
ArrayObject* res = recGetClassContext(stack, size, first + 1, rec + 1);
@@ -59,7 +63,11 @@
CommonClass* cl = Classpath::vmStackWalker;
while (i < real_size) {
+#ifdef MULTIPLE_GC
+ int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[i++]);
+#else
int *begIp = (int*)Collector::begOf(ips[i++]);
+#endif
JavaMethod* meth = ip_to_meth(begIp);
if (meth && meth->classDef == cl) {
first = i;
@@ -88,7 +96,11 @@
int i = 0;
while (i < real_size) {
+#ifdef MULTIPLE_GC
+ int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[i++]);
+#else
int *begIp = (int*)Collector::begOf(ips[i++]);
+#endif
JavaMethod* meth = ip_to_meth(begIp);
if (meth) {
++n;
@@ -106,7 +118,11 @@
int i = 0;
while (i < real_size) {
+#ifdef MULTIPLE_GC
+ int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[i++]);
+#else
int *begIp = (int*)Collector::begOf(ips[i++]);
+#endif
JavaMethod* meth = ip_to_meth(begIp);
if (meth) {
++n;
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp?rev=49720&r1=49719&r2=49720&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Tue Apr 15 05:22:21 2008
@@ -46,11 +46,15 @@
static void start(arg_thread_t* arg) {
int argc;
- Collector::inject_my_thread(&argc);
JavaObject* vmThread = arg->vmThread;
JavaThread* intern = arg->intern;
free(arg);
mvm::Thread::threadKey->set(intern);
+#ifdef MULTIPLE_GC
+ intern->GC->inject_my_thread(&argc);
+#else
+ Collector::inject_my_thread(&argc);
+#endif
CommonClass* vmthClass = vmThread->classOf;
JavaObject* thread = (JavaObject*)((*ClasspathThread::assocThread)(vmThread).PointerVal);
JavaIsolate* isolate = (JavaIsolate*)(intern->isolate);
@@ -74,7 +78,12 @@
ts->nonDaemonVar->signal();
ts->nonDaemonLock->unlock();
}
+
+#ifdef MULTIPLE_GC
+ intern->GC->remove_my_thread();
+#else
Collector::remove_my_thread();
+#endif
}
JNIEXPORT void JNICALL Java_java_lang_VMThread_start(
@@ -93,6 +102,9 @@
arg_thread_t* arg = (arg_thread_t*)malloc(sizeof(arg_thread_t));
arg->intern = th;
arg->vmThread = vmThread;
+#ifdef MULTIPLE_GC
+ th->GC = mvm::Thread::get()->GC;
+#endif
mvm::Thread::start(&tid, (int (*)(void *))start, (void*)arg);
}
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp?rev=49720&r1=49719&r2=49720&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp Tue Apr 15 05:22:21 2008
@@ -83,7 +83,11 @@
ArrayObject* recGetStackTrace(int** stack, uint32 size, uint32 first, uint32 rec) {
Jnjvm* vm = JavaThread::get()->isolate;
if (size != first) {
+#ifdef MULTIPLE_GC
+ int *begIp = (int*)mvm::Thread::get()->GC->begOf(stack[first]);
+#else
int *begIp = (int*)Collector::begOf(stack[first]);
+#endif
JavaMethod* meth = ip_to_meth(begIp);
if (meth) {
ArrayObject* res = recGetStackTrace(stack, size, first + 1, rec + 1);
@@ -109,7 +113,11 @@
sint32 i = 0;
while (i < array->size) {
+#ifdef MULTIPLE_GC
+ int *begIp = (int*)mvm::Thread::get()->GC->begOf((void*)stack[i++]);
+#else
int *begIp = (int*)Collector::begOf((void*)stack[i++]);
+#endif
JavaMethod* meth = ip_to_meth(begIp);
if (meth && meth->classDef == cl) {
first = i;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp?rev=49720&r1=49719&r2=49720&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp Tue Apr 15 05:22:21 2008
@@ -120,7 +120,11 @@
fp = debug_frame_caller_from_first_fp(fp);
while ((!frame_end(fp)) && (debug_frame_ip(fp) != 0)) {
int * ip = debug_frame_ip(fp);
+#ifdef MULTIPLE_GC
+ int *begIp = (int*)mvm::Thread::get()->GC->begOf(ip);
+#else
int *begIp = (int*)Collector::begOf(ip);
+#endif
if (begIp) {
unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
const llvm::GlobalValue * glob =
@@ -148,7 +152,11 @@
int real_size = backtrace((void**)(void*)ips, 100);
int n = 0;
while (n < real_size) {
+#ifdef MULTIPLE_GC
+ int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[n++]);
+#else
int *begIp = (int*)Collector::begOf(ips[n++]);
+#endif
if (begIp) {
unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
const llvm::GlobalValue * glob =
@@ -186,7 +194,11 @@
int n = 0;
int i = 0;
while (n < real_size) {
+#ifdef MULTIPLE_GC
+ int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[n++]);
+#else
int *begIp = (int*)Collector::begOf(ips[n++]);
+#endif
if (begIp) {
unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
const llvm::GlobalValue * glob =
@@ -213,7 +225,11 @@
int n = 0;
int i = 0;
while (n < real_size) {
+#ifdef MULTIPLE_GC
+ int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[n++]);
+#else
int *begIp = (int*)Collector::begOf(ips[n++]);
+#endif
if (begIp) {
unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
const llvm::GlobalValue * glob =
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=49720&r1=49719&r2=49720&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Tue Apr 15 05:22:21 2008
@@ -225,7 +225,11 @@
}
// We can compile it, since if we're here, it's for a good reason
void* val = mvm::jit::executionEngine->getPointerToGlobal(methPtr);
+#ifndef MULTIPLE_GC
if (Collector::isObject(val)) {
+#else
+ if (classDef->isolate->GC->isObject(val)) {
+#endif
mvm::Code* temp = (mvm::Code*)((unsigned*)val - 2);
temp->method()->definition(this);
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=49720&r1=49719&r2=49720&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Tue Apr 15 05:22:21 2008
@@ -15,6 +15,7 @@
#include "llvm/Target/TargetData.h"
#include "mvm/JIT.h"
+#include "mvm/MvmMemoryManager.h"
#include "mvm/Threads/Locks.h"
#include "mvm/Threads/Cond.h"
@@ -411,7 +412,10 @@
JavaIsolate* JavaIsolate::allocateIsolate(Jnjvm* callingVM) {
JavaIsolate *isolate= vm_new(callingVM, JavaIsolate)();
-
+
+#ifdef MULTIPLE_GC
+ isolate->GC = Collector::allocate();
+#endif
isolate->classpath = getenv("CLASSPATH");
if (!(isolate->classpath)) {
isolate->classpath = ".";
@@ -437,10 +441,14 @@
isolate->bootstrapThread = vm_new(isolate, JavaThread)();
isolate->bootstrapThread->initialise(0, isolate);
+#ifndef MULTIPLE_GC
mvm::Thread* th = mvm::Thread::get();
isolate->bootstrapThread->GC = th->GC;
+#else
+ isolate->bootstrapThread->GC = isolate->GC;
+ mvm::jit::memoryManager->addGCForModule(isolate->module, isolate->GC);
+#endif
JavaThread::threadKey->set(isolate->bootstrapThread);
-
isolate->threadSystem = vm_new(isolate, ThreadSystem)();
isolate->threadSystem->initialise();
@@ -469,6 +477,10 @@
JavaIsolate* JavaIsolate::allocateBootstrap() {
JavaIsolate *isolate= gc_new(JavaIsolate)();
+#ifdef MULTIPLE_GC
+ isolate->GC = Collector::allocate();
+#endif
+
isolate->classpath = getenv("CLASSPATH");
if (!(isolate->classpath)) {
isolate->classpath = ".";
@@ -493,8 +505,13 @@
isolate->bootstrapThread = vm_new(isolate, JavaThread)();
isolate->bootstrapThread->initialise(0, isolate);
+#ifndef MULTIPLE_GC
mvm::Thread* th = mvm::Thread::get();
isolate->bootstrapThread->GC = th->GC;
+#else
+ isolate->bootstrapThread->GC = isolate->GC;
+ mvm::jit::memoryManager->addGCForModule(isolate->module, isolate->GC);
+#endif
JavaThread::threadKey->set(isolate->bootstrapThread);
isolate->name = "bootstrapVM";
@@ -515,7 +532,7 @@
#endif
#if defined(SERVICE_VM) || !defined(MULTIPLE_VM)
- isolate->threadSystem = vm_new(this, ThreadSystem)();
+ isolate->threadSystem = vm_new(isolate, ThreadSystem)();
isolate->threadSystem->initialise();
#endif
@@ -523,9 +540,5 @@
}
void JavaIsolate::destroyer(size_t sz) {
- mvm::jit::protectEngine->lock();
- mvm::jit::executionEngine->removeModuleProvider(TheModuleProvider);
- mvm::jit::protectEngine->unlock();
- delete TheModuleProvider;
- delete module;
+ Jnjvm::destroyer();
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=49720&r1=49719&r2=49720&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Tue Apr 15 05:22:21 2008
@@ -28,6 +28,7 @@
#include "JavaTypes.h"
#include "JavaUpcalls.h"
#include "Jnjvm.h"
+#include "JnjvmModuleProvider.h"
#include "LockedMap.h"
#include "Reader.h"
#ifdef SERVICE_VM
@@ -866,3 +867,17 @@
return val;
}
#endif
+
+void Jnjvm::destroyer() {
+#ifdef MULTIPLE_GC
+ GC->destroy();
+ delete GC;
+#endif
+ mvm::jit::protectEngine->lock();
+ mvm::jit::executionEngine->removeModuleProvider(TheModuleProvider);
+ mvm::jit::protectEngine->unlock();
+ delete globalRefsLock;
+ delete protectModule;
+ delete TheModuleProvider;
+ delete module;
+}
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h?rev=49720&r1=49719&r2=49720&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Tue Apr 15 05:22:21 2008
@@ -22,7 +22,11 @@
#include "types.h"
+#ifdef MULTIPLE_GC
+#define vm_new(vm, cl) collector_new(cl, vm->GC)
+#else
#define vm_new(vm, cl) gc_new(cl)
+#endif
namespace jnjvm {
@@ -218,6 +222,8 @@
virtual void print(mvm::PrintBuffer* buf) const {
buf->write("Jnjvm<>");
}
+
+ virtual void destroyer();
void addProperty(char* key, char* value);
@@ -249,6 +255,9 @@
DelegateeMap* delegatees;
#endif
+#ifdef MULTIPLE_GC
+ Collector* GC;
+#endif
mvm::Lock* protectModule;
llvm::Module* module;
More information about the llvm-commits
mailing list