[vmkit-commits] [vmkit] r85111 - in /vmkit/trunk: Makefile include/mvm/Threads/CollectionRV.h include/mvm/Threads/Thread.h include/mvm/VirtualMachine.h lib/Mvm/CommonThread/CollectionRV.cpp lib/Mvm/CommonThread/ctthread.cpp lib/Mvm/GCMmap2/MvmGC.h lib/Mvm/GCMmap2/gc.cpp lib/Mvm/GCMmap2/gccollector.cpp lib/Mvm/GCMmap2/gcinit.cpp lib/Mvm/GCMmap2/gcthread.cpp lib/Mvm/GCMmap2/gcthread.h mmtk/mmtk-j3/Scanning.cpp tools/jnjvm/Makefile tools/n3-mono/Makefile tools/n3-pnetlib/Makefile tools/vmjc/Makefile tools/vmkit/Makefile
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Oct 26 05:10:06 PDT 2009
Author: geoffray
Date: Mon Oct 26 07:10:05 2009
New Revision: 85111
URL: http://llvm.org/viewvc/llvm-project?rev=85111&view=rev
Log:
Put the rendezvous for garbage collection out of GCMmap2,
so that other collectors can use it.
Added:
vmkit/trunk/include/mvm/Threads/CollectionRV.h
vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp
Modified:
vmkit/trunk/Makefile
vmkit/trunk/include/mvm/Threads/Thread.h
vmkit/trunk/include/mvm/VirtualMachine.h
vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
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/gcinit.cpp
vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp
vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h
vmkit/trunk/mmtk/mmtk-j3/Scanning.cpp
vmkit/trunk/tools/jnjvm/Makefile
vmkit/trunk/tools/n3-mono/Makefile
vmkit/trunk/tools/n3-pnetlib/Makefile
vmkit/trunk/tools/vmjc/Makefile
vmkit/trunk/tools/vmkit/Makefile
Modified: vmkit/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/Makefile?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/Makefile (original)
+++ vmkit/trunk/Makefile Mon Oct 26 07:10:05 2009
@@ -15,7 +15,7 @@
#
DIRS := lib tools
-ifeq ($(WITH_LLVM_GCC), 1)
+ifeq ($(GC_MMTK), 1)
DIRS += mmtk
endif
Added: vmkit/trunk/include/mvm/Threads/CollectionRV.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/CollectionRV.h?rev=85111&view=auto
==============================================================================
--- vmkit/trunk/include/mvm/Threads/CollectionRV.h (added)
+++ vmkit/trunk/include/mvm/Threads/CollectionRV.h Mon Oct 26 07:10:05 2009
@@ -0,0 +1,103 @@
+//===---------- CollectionRV.h - Rendez-vous for garbage collection -------===//
+//
+// The VMKit project
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _MVM_COLLECTIONRV_H_
+#define _MVM_COLLECTIONRV_H_
+
+#include "mvm/Threads/Cond.h"
+#include "mvm/Threads/Locks.h"
+#include "mvm/Threads/Thread.h"
+
+namespace mvm {
+
+class CollectionRV {
+
+ /// stackLock - Stack lock for synchronization.
+ LockNormal _stackLock;
+
+ /// stackCond - Condition for unlocking other tasks (write protect).
+ Cond stackCond;
+
+ /// collectionCond - Condition for unblocking the collector.
+ Cond collectionCond;
+
+ /// nbCollected - Number of threads collected.
+ unsigned nbCollected;
+
+ /// currentCollector - The initiating thread for collection. Don't
+ /// synchonize this one.
+ mvm::Thread* currentCollector;
+
+ /// cooperative - Is the rendez-vous cooperative?
+ bool cooperative;
+
+
+ /// rendezvousNb - The identifier of the rendez-vous.
+ ///
+ unsigned rendezvousNb;
+
+public:
+
+ mvm::Thread* getCurrentCollector() {
+ return currentCollector;
+ }
+
+ CollectionRV() {
+ rendezvousNb = 0;
+ nbCollected = 0;
+ currentCollector = 0;
+#ifdef WITH_LLVM_GCC
+ cooperative = true;
+#else
+ cooperative = false;
+#endif
+ }
+
+ bool isCooperative() { return cooperative; }
+
+ void stackLock() { _stackLock.lock(); }
+ void stackUnlock() { _stackLock.unlock(); }
+
+ void waitStacks();
+ void waitCollection();
+
+ void collectionFinished() {
+ if (cooperative) {
+ // We lock here to make sure no threads previously blocked in native
+ // will join the collection and never go back to running code.
+ stackLock();
+ mvm::Thread* cur = currentCollector;
+ do {
+ cur->doYield = false;
+ cur = (mvm::Thread*)cur->next();
+ } while (cur != currentCollector);
+ rendezvousNb++;
+ collectionCond.broadcast();
+ stackUnlock();
+ } else {
+ rendezvousNb++;
+ collectionCond.broadcast();
+ }
+ currentCollector->inGC = false;
+ }
+
+ void collectorGo() { stackCond.broadcast(); }
+
+ void another_mark() { nbCollected++; }
+
+ void synchronize();
+
+ void traceForeignThreadStack(mvm::Thread* th);
+ void traceThreadStack();
+
+};
+
+}
+
+#endif
Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Mon Oct 26 07:10:05 2009
@@ -114,6 +114,10 @@
/// kill - Kill the given thread by sending it a signal.
///
int kill(int signo);
+
+ /// killForRendezvous - Kill the given thread for a rendezvous.
+ ///
+ void killForRendezvous();
/// exit - Exit the current thread.
///
Modified: vmkit/trunk/include/mvm/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/VirtualMachine.h?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/VirtualMachine.h (original)
+++ vmkit/trunk/include/mvm/VirtualMachine.h Mon Oct 26 07:10:05 2009
@@ -16,6 +16,7 @@
#define MVM_VIRTUALMACHINE_H
#include "mvm/Allocator.h"
+#include "mvm/Threads/CollectionRV.h"
#include "mvm/Threads/Cond.h"
#include "mvm/Threads/Locks.h"
#include "mvm/GC/GC.h"
@@ -480,6 +481,10 @@
return res;
}
+ /// rendezvous - The rendezvous implementation for garbage collection.
+ ///
+ CollectionRV rendezvous;
+
#ifdef ISOLATE
size_t IsolateID;
#endif
Added: vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp?rev=85111&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp (added)
+++ vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp Mon Oct 26 07:10:05 2009
@@ -0,0 +1,144 @@
+//===-------- CollectionRV.cpp - Rendez-vous for garbage collection -------===//
+//
+// The VMKit project
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cassert>
+#include "MvmGC.h"
+
+using namespace mvm;
+
+void CollectionRV::waitCollection() {
+ mvm::Thread* th = mvm::Thread::get();
+ unsigned cm = rendezvousNb;
+
+ if (th != currentCollector) {
+ collectorGo();
+ while (rendezvousNb == cm) {
+ collectionCond.wait(&_stackLock);
+ }
+ }
+}
+
+
+void CollectionRV::waitStacks() {
+ mvm::Thread* self = mvm::Thread::get();
+ stackLock();
+
+ while (nbCollected < self->MyVM->NumberOfThreads)
+ stackCond.wait(&_stackLock);
+
+ stackUnlock();
+}
+
+void CollectionRV::synchronize() {
+
+ mvm::Thread* self = mvm::Thread::get();
+ assert(self && "No thread local data for this thread");
+
+ // Lock thread lock, so that we can traverse the thread list safely.
+ self->MyVM->ThreadLock.lock();
+
+ if (cooperative) {
+ currentCollector = self;
+ nbCollected = 0;
+
+ // Lock stacks. Changes on the doYield flag of threads must be
+ // protected, as threads may wake up after being blocked in native code
+ // and join the collection.
+ stackLock();
+
+ mvm::Thread* cur = self;
+ do {
+ cur->stackScanned = false;
+ cur->doYield = true;
+ cur = (mvm::Thread*)cur->next();
+ } while (cur != self);
+
+ // Unlock now. Each running thread will scan its stack.
+ stackUnlock();
+
+ // Scan the stacks of currently blocked threads.
+ for (mvm::Thread* cur = (mvm::Thread*)self->next(); cur != self;
+ cur = (mvm::Thread*)cur->next()) {
+ void* val = cur->getLastSP();
+ // If val is null, this means that the thread woke up, and is
+ // joining the collection. We are sure the thread will scan its stack.
+ if (val) traceForeignThreadStack(cur);
+ }
+
+ // Finally, scan my stack too!
+ traceThreadStack();
+
+ // And wait for other threads to finish.
+ waitStacks();
+ } else {
+ mvm::Thread* self = mvm::Thread::get();
+ self->stackScanned = false;
+ assert(self && "No thread local data for this thread");
+ currentCollector = self;
+ nbCollected = 0;
+
+ for (mvm::Thread* cur = (mvm::Thread*)self->next(); cur != self;
+ cur = (mvm::Thread*)cur->next()) {
+ cur->stackScanned = false;
+ cur->killForRendezvous();
+ }
+
+ traceThreadStack();
+
+ waitStacks();
+ }
+
+ self->MyVM->ThreadLock.unlock();
+}
+
+void CollectionRV::traceThreadStack() {
+ mvm::Thread* th = mvm::Thread::get();
+ th->inGC = true;
+
+ stackLock();
+
+ if (isCooperative() && !th->doYield) {
+ // I was previously blocked, and I'm running late: someone else collected
+ // my stack, and the GC has finished already. Just unlock and return.
+ stackUnlock();
+ th->inGC = false;
+ return;
+ }
+
+ // I woke up while a GC was happening, and no-one has collected my stack yet.
+ // Do it now.
+ if (!th->stackScanned) {
+ th->MyVM->getScanner()->scanStack(th);
+ another_mark();
+ th->stackScanned = true;
+ }
+
+ // Wait for the collection to finish.
+ waitCollection();
+ stackUnlock();
+
+ // If the current thread is not the collector thread, this means that the
+ // collection is finished. Set inGC to false.
+ if(th != getCurrentCollector())
+ th->inGC = false;
+}
+
+void CollectionRV::traceForeignThreadStack(mvm::Thread* th) {
+ stackLock();
+
+ // The thread may have waken up during this GC. In this case, it may also
+ // have collected its stack. Don't scan it then.
+ if (!th->stackScanned) {
+ th->MyVM->getScanner()->scanStack(th);
+ th->MyVM->rendezvous.another_mark();
+ th->stackScanned = true;
+ }
+
+ stackUnlock();
+}
Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Mon Oct 26 07:10:05 2009
@@ -45,7 +45,7 @@
}
void Thread::joinCollection() {
- Collector::traceStackThread();
+ MyVM->rendezvous.traceThreadStack();
}
void Thread::startNative(int level) {
@@ -150,6 +150,18 @@
extern void sigsegvHandler(int, siginfo_t*, void*);
+
+#if defined(__MACH__)
+# define SIGGC SIGXCPU
+#else
+# define SIGGC SIGPWR
+#endif
+
+static void siggcHandler(int) {
+ mvm::Thread* th = mvm::Thread::get();
+ th->MyVM->rendezvous.traceThreadStack();
+}
+
/// internalThreadStart - The initial function called by a thread. Sets some
/// thread specific data, registers the thread to the GC and calls the
/// given routine of th.
@@ -173,6 +185,14 @@
sa.sa_sigaction = sigsegvHandler;
sigaction(SIGSEGV, &sa, NULL);
+ // Set the SIGGC handler for uncooperative rendezvous.
+ sigaction(SIGGC, 0, &sa);
+ sigfillset(&mask);
+ sa.sa_mask = mask;
+ sa.sa_handler = siggcHandler;
+ sa.sa_flags |= SA_RESTART;
+ sigaction(SIGGC, &sa, NULL);
+
assert(th->MyVM && "VM not set in a thread");
#ifdef ISOLATE
th->IsolateID = th->MyVM->IsolateID;
@@ -223,3 +243,8 @@
index = (index & ~TheStackManager.baseAddr) >> 20;
TheStackManager.used[index] = 0;
}
+
+void Thread::killForRendezvous() {
+ int res = kill(SIGGC);
+ assert(!res && "Error on kill");
+}
Modified: vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h Mon Oct 26 07:10:05 2009
@@ -32,6 +32,7 @@
class Collector {
friend class GCThread;
+ friend class CollectionRV;
static GCAllocator *allocator; /* The allocator */
@@ -50,7 +51,6 @@
enum { stat_collect, stat_alloc, stat_broken };
- static void siggc_handler(int);
static inline void lock() { threads->lock(); }
static inline void unlock() { threads->unlock(); }
@@ -68,12 +68,11 @@
return n->nbb() - sizeof(gcRoot);
}
- static void traceForeignThreadStack(mvm::Thread* th);
public:
- static GCThread *threads; /* le gestionnaire de thread et de synchro */
+ static GCThread *threads;
static void (*internMemoryError)(unsigned int);
-
+
static bool isLive(void* ptr) {
GCChunkNode *node = o2node(ptr);
@@ -86,12 +85,6 @@
static void initialise();
static void destroy();
- static int siggc();
-
- static void traceStackThread() {
- siggc_handler(0);
- }
-
static inline void *allocate_unprotected(size_t sz) {
return allocator->alloc(sz);
}
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Mon Oct 26 07:10:05 2009
@@ -29,25 +29,12 @@
return res;
}
-
extern "C" void conditionalSafePoint() {
mvm::Thread::get()->startNative(1);
- Collector::traceStackThread();
+ mvm::Thread::get()->MyVM->rendezvous.traceThreadStack();
mvm::Thread::get()->endNative();
}
-void GCThread::waitCollection() {
- mvm::Thread* th = mvm::Thread::get();
- unsigned int cm = Collector::current_mark;
-
- if(th != current_collector) {
- collectorGo();
- while((Collector::current_mark == cm) &&
- (Collector::status == Collector::stat_collect))
- _collectionCond.wait(&_stackLock);
- }
-}
-
void Collector::scanObject(void* obj) {
if (obj) {
GCChunkNode *node = o2node(obj);
@@ -63,50 +50,3 @@
}
}
}
-
-void Collector::siggc_handler(int) {
- mvm::Thread* th = mvm::Thread::get();
- th->inGC = true;
-
-
- Collector::threads->stackLock();
-
- if (Collector::threads->cooperative && !th->doYield) {
- // I was previously blocked, and I'm running late: someone else collected
- // my stack, and the GC has finished already. Just unlock and return.
- Collector::threads->stackUnlock();
- th->inGC = false;
- return;
- }
-
- // I woke up while a GC was happening, and no-one has collected my stack yet.
- // Do it now.
- if (!th->stackScanned) {
- th->MyVM->getScanner()->scanStack(th);
- Collector::threads->another_mark();
- th->stackScanned = true;
- }
-
- // Wait for the collection to finish.
- Collector::threads->waitCollection();
- Collector::threads->stackUnlock();
-
- // If the current thread is not the collector thread, this means that the
- // collection is finished. Set inGC to false.
- if(th != threads->getCurrentCollector())
- th->inGC = false;
-}
-
-void Collector::traceForeignThreadStack(mvm::Thread* th) {
- Collector::threads->stackLock();
-
- // The thread may have waken up during this GC. In this case, it may also
- // have collected its stack. Don't scan it then.
- if (!th->stackScanned) {
- th->MyVM->getScanner()->scanStack(th);
- Collector::threads->another_mark();
- th->stackScanned = true;
- }
-
- Collector::threads->stackUnlock();
-}
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Mon Oct 26 07:10:05 2009
@@ -46,7 +46,7 @@
th->MyVM->startCollection();
th->inGC = true;
- threads->synchronize();
+ th->MyVM->rendezvous.synchronize();
mvm::Thread* tcur = th;
@@ -92,7 +92,7 @@
// Wake up all threads.
th->MyVM->endCollection();
- threads->collectionFinished();
+ th->MyVM->rendezvous.collectionFinished();
th->MyVM->wakeUpFinalizers();
th->MyVM->wakeUpEnqueue();
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp Mon Oct 26 07:10:05 2009
@@ -7,40 +7,19 @@
//
//===----------------------------------------------------------------------===//
-#include <signal.h>
#include "MvmGC.h"
using namespace mvm;
-static const size_t def_collect_freq_auto = 64*1024*1024;
+static const size_t def_collect_freq_auto = 64*1024*1024;
static const size_t def_collect_freq_maybe = 64*1024*1024;
-#if defined(__MACH__)
-# define SIGGC SIGXCPU
-#else
-# define SIGGC SIGPWR
-#endif
-
-int Collector::siggc() {
- return SIGGC;
-}
void Collector::initialise() {
used_nodes = new GCChunkNode();
unused_nodes = new GCChunkNode();
- threads = new GCThread();
-
- struct sigaction sa;
- sigset_t mask;
-
- sigaction(SIGGC, 0, &sa);
- sigfillset(&mask);
- sa.sa_mask = mask;
- sa.sa_handler = siggc_handler;
- sa.sa_flags |= SA_RESTART;
- sigaction(SIGGC, &sa, 0);
-
+ threads = new GCThread();
allocator = new GCAllocator();
used_nodes->alone();
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp Mon Oct 26 07:10:05 2009
@@ -11,74 +11,3 @@
#include "MvmGC.h"
using namespace mvm;
-
-void GCThread::waitStacks() {
- mvm::Thread* self = mvm::Thread::get();
- _stackLock.lock();
- while(_nb_collected < self->MyVM->NumberOfThreads)
- _stackCond.wait(&_stackLock);
- _stackLock.unlock();
-}
-
-void GCThread::synchronize() {
-
- mvm::Thread* self = mvm::Thread::get();
- assert(self && "No thread local data for this thread");
-
- // Lock thread lock, so that we can traverse the thread list safely.
- self->MyVM->ThreadLock.lock();
-
- if (cooperative) {
- current_collector = self;
- _nb_collected = 0;
-
- // Lock stacks. Changes on the doYield flag of threads must be
- // protected, as threads may wake up after being blocked in native code
- // and join the collection.
- stackLock();
-
- mvm::Thread* cur = self;
- do {
- cur->stackScanned = false;
- cur->doYield = true;
- cur = (mvm::Thread*)cur->next();
- } while (cur != self);
-
- // Unlock now. Each running thread will scan its stack.
- stackUnlock();
-
- // Scan the stacks of currently blocked threads.
- for (mvm::Thread* cur = (mvm::Thread*)self->next(); cur != self;
- cur = (mvm::Thread*)cur->next()) {
- void* val = cur->getLastSP();
- // If val is null, this means that the thread woke up, and is
- // joining the collection. We are sure the thread will scan its stack.
- if (val) Collector::traceForeignThreadStack(cur);
- }
-
- // Finally, scan my stack too!
- Collector::siggc_handler(0);
-
- // And wait for other threads to finish.
- waitStacks();
- } else {
- int signo = Collector::siggc();
- mvm::Thread* self = mvm::Thread::get();
- self->stackScanned = false;
- assert(self && "No thread local data for this thread");
- current_collector = self;
- _nb_collected = 0;
-
- for (mvm::Thread* cur = (mvm::Thread*)self->next(); cur != self;
- cur = (mvm::Thread*)cur->next()) {
- cur->stackScanned = false;
- cur->kill(signo);
- }
-
- Collector::siggc_handler(signo);
-
- waitStacks();
- }
-
- self->MyVM->ThreadLock.unlock();
-}
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h Mon Oct 26 07:10:05 2009
@@ -20,72 +20,13 @@
/// _globalLock - Global lock for gcmalloc.
SpinLock _globalLock;
- /// _stackLock - Stack lock for synchronization.
- LockNormal _stackLock;
-
- /// _stackCond - Condition for unlocking other tasks (write protect).
- Cond _stackCond;
-
- /// _collectionCond - Condition for unblocking the collector.
- Cond _collectionCond;
-
- /// _nb_collected - Number of threads collected.
- unsigned int _nb_collected;
-
- /// current_collector - The initiating thread for collection. Don't
- /// synchonize this one.
- mvm::Thread* current_collector;
-
public:
- bool cooperative;
-
- mvm::Thread* getCurrentCollector() {
- return current_collector;
- }
- GCThread() {
- _nb_collected = 0;
- current_collector = 0;
-#ifdef WITH_LLVM_GCC
- cooperative = true;
-#else
- cooperative = false;
-#endif
- }
+ GCThread() {}
- inline void lock() { _globalLock.lock(); }
- inline void unlock() { _globalLock.unlock(); }
-
- inline void stackLock() { _stackLock.lock(); }
- inline void stackUnlock() { _stackLock.unlock(); }
-
- void waitStacks();
- void waitCollection();
-
- inline void collectionFinished() {
- if (cooperative) {
- // We lock here to make sure no threads previously blocked in native
- // will join the collection and never go back to running code.
- stackLock();
- mvm::Thread* cur = current_collector;
- do {
- cur->doYield = false;
- cur = (mvm::Thread*)cur->next();
- } while (cur != current_collector);
- _collectionCond.broadcast();
- stackUnlock();
- } else {
- _collectionCond.broadcast();
- }
- current_collector->inGC = false;
- }
-
- inline void collectorGo() { _stackCond.broadcast(); }
-
- inline void another_mark() { _nb_collected++; }
-
- void synchronize();
+ void lock() { _globalLock.lock(); }
+ void unlock() { _globalLock.unlock(); }
};
Modified: vmkit/trunk/mmtk/mmtk-j3/Scanning.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-j3/Scanning.cpp?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-j3/Scanning.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-j3/Scanning.cpp Mon Oct 26 07:10:05 2009
@@ -12,7 +12,7 @@
using namespace jnjvm;
-extern "C" void Java_org_j3_mmtk_Scanning_computeThreadRoots__Lorg_mmtk_plan_TraceLocal_2 () {
+extern "C" void Java_org_j3_mmtk_Scanning_computeThreadRoots__Lorg_mmtk_plan_TraceLocal_2 (JavaObject* Scanning, JavaObject* TraceLocal) {
JavaThread::get()->printBacktrace(); abort();
}
Modified: vmkit/trunk/tools/jnjvm/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/jnjvm/Makefile?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/tools/jnjvm/Makefile (original)
+++ vmkit/trunk/tools/jnjvm/Makefile Mon Oct 26 07:10:05 2009
@@ -27,8 +27,8 @@
else
-USEDLIBS = JnJVM.a Classpath.a JnJVM.a JnjvmCompiler.a Allocator.a CommonThread.a \
- Mvm.a MvmCompiler.a $(GCLIB).a
+USEDLIBS = JnJVM.a Classpath.a JnJVM.a JnjvmCompiler.a Allocator.a \
+ Mvm.a MvmCompiler.a $(GCLIB).a CommonThread.a
ifeq ($(ISOLATE_SHARING_BUILD), 1)
USEDLIBS += Isolate
Modified: vmkit/trunk/tools/n3-mono/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/n3-mono/Makefile?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/tools/n3-mono/Makefile (original)
+++ vmkit/trunk/tools/n3-mono/Makefile Mon Oct 26 07:10:05 2009
@@ -22,8 +22,8 @@
SOURCES = vmkit.s $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp))
else
- USEDLIBS = N3.a Mono.a Allocator.a CommonThread.a Mvm.a MvmCompiler.a \
- $(GCLIB).a
+ USEDLIBS = N3.a Mono.a Allocator.a Mvm.a MvmCompiler.a \
+ $(GCLIB).a CommonThread.a
endif
include $(LEVEL)/Makefile.common
Modified: vmkit/trunk/tools/n3-pnetlib/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/n3-pnetlib/Makefile?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/tools/n3-pnetlib/Makefile (original)
+++ vmkit/trunk/tools/n3-pnetlib/Makefile Mon Oct 26 07:10:05 2009
@@ -20,8 +20,8 @@
BUILT_SOURCES = vmkit.s
SOURCES = vmkit.s $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp))
else
- USEDLIBS = N3.a PNetLib.a Allocator.a CommonThread.a Mvm.a MvmCompiler.a \
- $(GCLIB).a
+ USEDLIBS = N3.a PNetLib.a Allocator.a Mvm.a MvmCompiler.a \
+ $(GCLIB).a CommonThread.a
endif
include $(LEVEL)/Makefile.common
Modified: vmkit/trunk/tools/vmjc/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/Makefile?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/tools/vmjc/Makefile (original)
+++ vmkit/trunk/tools/vmjc/Makefile Mon Oct 26 07:10:05 2009
@@ -25,8 +25,8 @@
else
- USEDLIBS = JnJVM.a Classpath.a JnJVM.a JnjvmCompiler.a Allocator.a CommonThread.a \
- Mvm.a MvmCompiler.a $(GCLIB).a
+ USEDLIBS = JnJVM.a Classpath.a JnJVM.a JnjvmCompiler.a Allocator.a \
+ Mvm.a MvmCompiler.a $(GCLIB).a CommonThread.a
endif
LINK_COMPONENTS = jit nativecodegen scalaropts instrumentation ipa ipo bitwriter bitreader asmparser linker
Modified: vmkit/trunk/tools/vmkit/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Makefile?rev=85111&r1=85110&r2=85111&view=diff
==============================================================================
--- vmkit/trunk/tools/vmkit/Makefile (original)
+++ vmkit/trunk/tools/vmkit/Makefile Mon Oct 26 07:10:05 2009
@@ -49,7 +49,7 @@
USEDLIBS += N3.a PNetLib.a
endif
- USEDLIBS += Allocator.a CommonThread.a Mvm.a MvmCompiler.a $(GCLIB).a
+ USEDLIBS += Allocator.a Mvm.a MvmCompiler.a $(GCLIB).a CommonThread.a
endif
More information about the vmkit-commits
mailing list