[llvm-commits] [vmkit] r50061 - in /vmkit/trunk: configure.ac include/mvm/Object.h lib/Mvm/BoehmGC/MvmGC.h lib/Mvm/GCMmap2/MvmGC.h lib/Mvm/GCMmap2/gc.cpp lib/Mvm/GCMmap2/gccollector.cpp lib/Mvm/GCMmap2/gccollector.h lib/Mvm/GCMmap2/gcinit.cpp lib/Mvm/GCMmap2/gcthread.h lib/Mvm/GCMmap2/main.cpp lib/Mvm/MvmMemoryManager.cpp lib/Mvm/Object.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Apr 21 14:29:10 PDT 2008
Author: geoffray
Date: Mon Apr 21 16:29:09 2008
New Revision: 50061
URL: http://llvm.org/viewvc/llvm-project?rev=50061&view=rev
Log:
Improvements for a service environment. The configure script can now configure the vms to be in a single, mutli, or service environment.
Modified:
vmkit/trunk/configure.ac
vmkit/trunk/include/mvm/Object.h
vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h
vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h
vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h
vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp
vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h
vmkit/trunk/lib/Mvm/GCMmap2/main.cpp
vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp
vmkit/trunk/lib/Mvm/Object.cpp
Modified: vmkit/trunk/configure.ac
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/configure.ac?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/configure.ac (original)
+++ vmkit/trunk/configure.ac Mon Apr 21 16:29:09 2008
@@ -217,6 +217,28 @@
AC_SUBST([GC_LIBS])
dnl **************************************************************************
+dnl Virtual Machine type
+dnl **************************************************************************
+AC_ARG_WITH(vm-type,
+ [AS_HELP_STRING(--with-vm-type=something,
+ [VM type ('single' 'multi' or 'service')])],
+ [[vm=$withval]],
+ [[ echo Using single as vm type.
+ vm-type=single
+ ]]
+)
+
+if test "x${vm-type}" = "xmulti"; then
+ CFLAGS="$CFLAGS -DMULTIPLE_VM"
+ CXXFLAGS="$CXXFLAGS -DMULTIPLE_VM"
+else
+ if test "x${vm-type}" = "xservice"; then
+ CFLAGS="$CFLAGS -DMULTIPLE_VM -DSERVICE_GC -DMULTIPLE_GC -DSERVICE_VM"
+ CXXFLAGS="$CXXFLAGS -DMULTIPLE_VM -DSERVICE_GC -DMULTIPLE_GC -DSERVICE_VM"
+ fi
+fi
+
+dnl **************************************************************************
dnl GNU CLASSPATH version
dnl **************************************************************************
AC_ARG_WITH(gnu-classpath-version,
Modified: vmkit/trunk/include/mvm/Object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Object.h?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Object.h (original)
+++ vmkit/trunk/include/mvm/Object.h Mon Apr 21 16:29:09 2008
@@ -86,7 +86,7 @@
return popRoots(1);
}
- static void markAndTraceRoots(void);
+ static void markAndTraceRoots(void*);
static void initialise();
};
Modified: vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h Mon Apr 21 16:29:09 2008
@@ -17,6 +17,10 @@
//#include "gc/gc_local_alloc.h"
#include "gc/gc.h"
+#define TRACER tracer()
+#define PARENT_TRACER tracer()
+#define MARK_AND_TRACE markAndTrace()
+
extern "C" void * GC_dlopen(const char *path, int mode) throw ();
#include "mvm/GC/GC.h"
@@ -71,7 +75,7 @@
class Collector {
public:
- typedef void (*markerFn)(void);
+ typedef void (*markerFn)(void*);
static void initialise(markerFn mark, void *base_sp) {
GC_INIT();
Modified: vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h Mon Apr 21 16:29:09 2008
@@ -64,7 +64,7 @@
class Collector {
public:
- typedef void (*markerFn)(void);
+ typedef void (*markerFn)(void*);
static void initialise(markerFn mark, void *base_sp);
STATIC void destroy();
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Mon Apr 21 16:29:09 2008
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#include <setjmp.h>
#include <stdlib.h>
#include "mvm/GC/GC.h"
@@ -179,7 +180,18 @@
#endif
}
+#undef COLLECTOR
void GCThread::waitCollection() {
+#if defined(MULTIPLE_GC)
+#if defined(SERVICE_GC)
+ GCCollector* GC = GCCollector::collectingGC;
+#else
+ GCCollector* GC = ((GCCollector*)mvm::Thread::get()->GC);
+#endif
+#define COLLECTOR GC->
+#else
+#define COLLECTOR GCCollector::
+#endif
unsigned int cm = COLLECTOR current_mark;
if(Thread::self() != collector_tid) {
@@ -204,17 +216,16 @@
#else
#define COLLECTOR GCCollector::
#endif
- GCThreadCollector *loc = COLLECTOR threads->myloc();
- register unsigned int cm = COLLECTOR current_mark;
- // jmp_buf buf;
-
- // setjmp(buf);
+ GCThreadCollector *loc = COLLECTOR threads->myloc();
+
+ jmp_buf buf;
+ setjmp(buf);
COLLECTOR threads->stackLock();
if(!loc) /* a key is being destroyed */
COLLECTOR threads->another_mark();
- else if(loc->current_mark() != cm) {
+ else {
register unsigned int **cur = (unsigned int **)&cur;
register unsigned int **max = loc->base_sp();
@@ -228,7 +239,6 @@
}
}
- loc->current_mark(cm);
COLLECTOR threads->another_mark();
COLLECTOR threads->waitCollection();
}
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Mon Apr 21 16:29:09 2008
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
#include "gccollector.h"
-#include <setjmp.h>
using namespace mvm;
@@ -40,92 +39,94 @@
#ifdef SERVICE_GC
GCCollector* GCCollector::collectingGC;
+unsigned int GCCollector::current_mark;
#endif
void GCCollector::do_collect() {
- //printf("----- do collect -----\n");
- jmp_buf buf;
- setjmp(buf);
- GCChunkNode *cur;
- _since_last_collection = _collect_freq_auto;
+ //printf("----- do collect -----\n");
+ GCChunkNode *cur;
+ _since_last_collection = _collect_freq_auto;
- current_mark++;
+ current_mark++;
- unused_nodes->attrape(used_nodes);
+ unused_nodes->attrape(used_nodes);
#ifdef SERVICE_GC
collectingGC = this;
#endif
#ifdef HAVE_PTHREAD
- threads->synchronize();
+ threads->synchronize();
#endif
- for(cur=used_nodes->next(); cur!=used_nodes; cur=cur->next())
- trace(cur);
-
- if(_marker)
- _marker();
+ for(cur=used_nodes->next(); cur!=used_nodes; cur=cur->next())
+ trace(cur);
- status = stat_finalize;
+ if(_marker)
+#ifdef MULTIPLE_GC
+ _marker(this);
+#else
+ _marker(0);
+#endif
+ status = stat_finalize;
- /* finalize */
- GCChunkNode finalizable;
- finalizable.attrape(unused_nodes);
+ /* finalize */
+ GCChunkNode finalizable;
+ finalizable.attrape(unused_nodes);
- status = stat_alloc;
+ status = stat_alloc;
#ifdef HAVE_PTHREAD
- threads->collectionFinished();
+ threads->collectionFinished();
#endif
-
- /* kill everyone */
- GCChunkNode *next;
-
- for(cur=finalizable.next(); cur!=&finalizable; cur=next) {
- register gc_header *c = cur->chunk();
- next = cur->next();
-
- c->_2gc()->destroyer(real_nbb(cur));
-
- //printf(" !!!! reject %p [%p]\n", cur->chunk()->_2gc(), cur);
- allocator->reject_chunk(cur);
- }
+
+ /* kill everyone */
+ GCChunkNode *next;
+
+ for(cur=finalizable.next(); cur!=&finalizable; cur=next) {
+ register gc_header *c = cur->chunk();
+ next = cur->next();
+
+ c->_2gc()->destroyer(real_nbb(cur));
+
+ //printf(" !!!! reject %p [%p]\n", cur->chunk()->_2gc(), cur);
+ allocator->reject_chunk(cur);
+ }
used_nodes->alone();
}
void GCCollector::collect_unprotect() {
- if(_enable_collection && (status == stat_alloc)) {
- status = stat_collect;
- do_collect();
- }
+ if(_enable_collection && (status == stat_alloc)) {
+ status = stat_collect;
+ do_collect();
+ }
}
#ifdef HAVE_PTHREAD
void GCCollector::die_if_sigsegv_occured_during_collection(void *addr) {
- if(!isStable(0, 0, 0, 0, 0, 0, 0, 0, 0)) {
- printf("; ****************************************************** ;\n");
- printf("; SIGSEGV occured during a collection ;\n");
- printf("; I'm trying to let the allocator in a coherent stat ;\n");
- printf("; but the collector is DEAD and will never collect again ;\n");
- printf("; ****************************************************** ;\n");
-
- status = stat_broken; /* Collection is finished and no other collection will happend */
- threads->cancel(); /* Emulates a full collection to unlock mutators */
- used_nodes->eat(unused_nodes); /* All nodes are uses. Finalized are lost */
- unlock_dont_recovery(); /* Unlocks the GC lock */
- //gcfatal("SIGSEGV occured during collection at %p", addr);
- }
+ if(!isStable(0, 0, 0, 0, 0, 0, 0, 0, 0)) {
+ printf("; ****************************************************** ;\n");
+ printf("; SIGSEGV occured during a collection ;\n");
+ printf("; I'm trying to let the allocator in a coherent stat ;\n");
+ printf("; but the collector is DEAD and will never collect again ;\n");
+ printf("; ****************************************************** ;\n");
+
+ status = stat_broken; /* Collection is finished and no other collection will happend */
+ threads->cancel(); /* Emulates a full collection to unlock mutators */
+ used_nodes->eat(unused_nodes); /* All nodes are uses. Finalized are lost */
+ unlock_dont_recovery(); /* Unlocks the GC lock */
+ //gcfatal("SIGSEGV occured during collection at %p", addr);
+ }
}
#endif /* HAVE_PTHREAD */
void GCCollector::gcStats(size_t *_no, size_t *_nbb) {
- register unsigned int n, tot;
- register GCChunkNode *cur;
- lock();
- for(n=0, tot=0, cur=used_nodes->next(); cur!=used_nodes; cur=cur->next(), n++)
- tot += cur->nbb();
- unlock();
- *_no = n;
- *_nbb = tot;
+ register unsigned int n, tot;
+ register GCChunkNode *cur;
+ lock();
+ for(n=0, tot=0, cur=used_nodes->next(); cur!=used_nodes; cur=cur->next(), n++)
+ tot += cur->nbb();
+ unlock();
+ *_no = n;
+ *_nbb = tot;
}
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h Mon Apr 21 16:29:09 2008
@@ -34,8 +34,11 @@
STATIC GCChunkNode *used_nodes; /* Used memory nodes */
STATIC GCChunkNode *unused_nodes; /* Unused memory nodes */
-
+#ifdef SERVICE_GC
+ static unsigned int current_mark;
+#else
STATIC unsigned int current_mark;
+#endif
STATIC int _collect_freq_auto; /* Collection frequency in gcmalloc/gcrealloc */
STATIC int _collect_freq_maybe; /* Collection frequency in maybeCollect */
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp Mon Apr 21 16:29:09 2008
@@ -12,21 +12,21 @@
using namespace mvm;
-static const size_t def_collect_freq_auto = 4*1024*1024;
+static const size_t def_collect_freq_auto = 4*1024*1024;
static const size_t def_collect_freq_maybe = 512*1024;
#if defined(__MACH__)
-# define SIGGC SIGXCPU
+# define SIGGC SIGXCPU
#else
-# define SIGGC SIGPWR
+# define SIGGC SIGPWR
#endif
int GCCollector::siggc() {
- return SIGGC;
+ return SIGGC;
}
void GCCollector::initialise(Collector::markerFn marker) {
-
+
used_nodes = new GCChunkNode();
unused_nodes = new GCChunkNode();
#ifdef HAVE_PTHREAD
@@ -41,81 +41,83 @@
#endif
struct sigaction sa;
- sigset_t mask;
+ sigset_t mask;
#ifdef HAVE_PTHREAD
- //on_fatal = unlock_dont_recovery;
+ //on_fatal = unlock_dont_recovery;
#endif
- sigaction(SIGGC, 0, &sa);
- sigfillset(&mask);
- sa.sa_mask = mask;
- sa.sa_handler = siggc_handler;
- sa.sa_flags |= SA_RESTART;
- sigaction(SIGGC, &sa, 0);
-
- allocator = new GCAllocator();
-// GCCollector::GCCollector(void (*marker)(void *)) {
-
- _marker = marker;
+ sigaction(SIGGC, 0, &sa);
+ sigfillset(&mask);
+ sa.sa_mask = mask;
+ sa.sa_handler = siggc_handler;
+ sa.sa_flags |= SA_RESTART;
+ sigaction(SIGGC, &sa, 0);
+
+ allocator = new GCAllocator();
+
+ _marker = marker;
- used_nodes->alone();
+ used_nodes->alone();
- current_mark = 0;
+#ifdef SERVICE_GC
+ if (this == bootstrapGC)
+#endif
+ current_mark = 0;
- _collect_freq_auto = def_collect_freq_auto;
- _collect_freq_maybe = def_collect_freq_maybe;
-
- _since_last_collection = _collect_freq_auto;
+ _collect_freq_auto = def_collect_freq_auto;
+ _collect_freq_maybe = def_collect_freq_maybe;
+
+ _since_last_collection = _collect_freq_auto;
- _enable_auto = 1;
- _enable_collection = 1;
- _enable_maybe = 1;
+ _enable_auto = 1;
+ _enable_collection = 1;
+ _enable_maybe = 1;
- status = stat_alloc;
+ status = stat_alloc;
}
void GCCollector::destroy() {
- delete allocator;
- allocator = 0;
+ delete allocator;
+ allocator = 0;
}
static void *get_curr_fp(void)
{
- register void *fp;
- asm(
+ register void *fp;
+ asm(
# if defined(__ppc__) || defined(__PPC__)
# if defined(__MACH__)
- " mr %0, r1 "
+ "mr %0, r1"
# else
- " mr %0, 1 "
+ "mr %0, 1"
# endif
# elif defined(__i386__)
- " movl %%ebp, %0 "
+ "movl %%ebp, %0"
# elif defined(__amd64__)
- " movq %%rbp, %0 "
+ "movq %%rbp, %0"
# else
# error:
# error: I do not know how to read the frame pointer on this machine
# error:
# endif
- :"=r"(fp):);
- return fp;
+ :"=r"(fp):);
+ return fp;
}
static void *get_base_sp(void)
{
- void *fp= 0;
- for (fp= get_curr_fp(); (*(void **)fp); fp= *(void **)fp);
- return fp;
+ void *fp= 0;
+ for (fp= get_curr_fp(); (*(void **)fp); fp= *(void **)fp);
+ return fp;
}
#ifdef HAVE_PTHREAD
void GCCollector::inject_my_thread(void *base_sp) {
- if(!base_sp)
- base_sp = get_base_sp();
- threads->inject(base_sp, current_mark);
+ if(!base_sp)
+ base_sp = get_base_sp();
+ threads->inject(base_sp, current_mark);
}
#endif
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h Mon Apr 21 16:29:09 2008
@@ -22,14 +22,12 @@
class GCThreadCollector : public CircularBase {
void *_base_sp;
- int _cur_mark;
int _tid;
public:
inline GCThreadCollector() {}
inline GCThreadCollector(GCThreadCollector *pred, int t, void *p, int m) : CircularBase(pred) {
_base_sp = p;
- _cur_mark = m;
_tid = t;
}
@@ -40,8 +38,6 @@
inline ~GCThreadCollector() {}
inline int tid() { return _tid; }
- inline unsigned int current_mark() { return _cur_mark; }
- inline void current_mark(unsigned int m) { _cur_mark = m; }
inline unsigned int **base_sp() { return (unsigned int **)_base_sp; }
};
Modified: vmkit/trunk/lib/Mvm/GCMmap2/main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/main.cpp?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/main.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/main.cpp Mon Apr 21 16:29:09 2008
@@ -21,7 +21,7 @@
// printf("Trace %p\n", me);
}
-void marker(void) {
+void marker(void*) {
// printf("Marker...\n");
}
Modified: vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp (original)
+++ vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp Mon Apr 21 16:29:09 2008
@@ -40,9 +40,16 @@
unsigned Alignment) {
size_t nbb = ((StubSize - 1) & -4) + 4 + sizeof(Method *);
#ifdef MULTIPLE_GC
- Collector* GC = GCMap[F->getParent()];
- Code *res = (Code *)gc::operator new(nbb, Code::VT, GC);
- Method* meth = collector_new(Method, GC)(res, StubSize);
+ Code *res = 0;
+ Method* meth = 0;
+ if (GV) {
+ Collector* GC = GCMap[GV->getParent()];
+ res = (Code *)gc::operator new(nbb, Code::VT, GC);
+ meth = collector_new(Method, GC)(res, StubSize);
+ } else {
+ res = (Code *)gc::operator new(nbb, Code::VT);
+ meth = gc_new(Method)(res, StubSize);
+ }
#else
Code *res = (Code *)gc::operator new(nbb, Code::VT);
Method* meth = gc_new(Method)(res, StubSize);
Modified: vmkit/trunk/lib/Mvm/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Object.cpp?rev=50061&r1=50060&r2=50061&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Object.cpp (original)
+++ vmkit/trunk/lib/Mvm/Object.cpp Mon Apr 21 16:29:09 2008
@@ -45,13 +45,14 @@
}
-void Object::markAndTraceRoots(void) {
- for (int i= 0; i < rootTableSize; ++i)
+void Object::markAndTraceRoots(void* GC) {
+ for (int i= 0; i < rootTableSize; ++i) {
#ifdef MULTIPLE_GC
- rootTable[i]->markAndTrace(mvm::Thread::get()->GC);
+ rootTable[i]->markAndTrace((Collector*)GC);
#else
rootTable[i]->markAndTrace();;
#endif
+ }
}
void Object::initialise() {
More information about the llvm-commits
mailing list