[vmkit-commits] [vmkit] r85391 - in /vmkit/trunk: include/mvm/Threads/CollectionRV.h lib/Mvm/CommonThread/CollectionRV.cpp lib/Mvm/CommonThread/ctthread.cpp lib/Mvm/GCMmap2/gc.cpp lib/Mvm/GCMmap2/gccollector.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed Oct 28 08:09:04 PDT 2009
Author: geoffray
Date: Wed Oct 28 10:09:03 2009
New Revision: 85391
URL: http://llvm.org/viewvc/llvm-project?rev=85391&view=rev
Log:
CollectionRV is now "just" a rendezvous, it doesn't scan stacks.
Modified:
vmkit/trunk/include/mvm/Threads/CollectionRV.h
vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp
vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
Modified: vmkit/trunk/include/mvm/Threads/CollectionRV.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/CollectionRV.h?rev=85391&r1=85390&r2=85391&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/CollectionRV.h (original)
+++ vmkit/trunk/include/mvm/Threads/CollectionRV.h Wed Oct 28 10:09:03 2009
@@ -93,9 +93,9 @@
void synchronize();
- void traceForeignThreadStack(mvm::Thread* th);
- void traceThreadStack();
+ void addForeignThread(mvm::Thread* th);
+ void join();
};
}
Modified: vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp?rev=85391&r1=85390&r2=85391&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp Wed Oct 28 10:09:03 2009
@@ -16,11 +16,10 @@
mvm::Thread* th = mvm::Thread::get();
unsigned cm = rendezvousNb;
- if (th != currentCollector) {
- collectorGo();
- while (rendezvousNb == cm) {
- collectionCond.wait(&_stackLock);
- }
+ if (nbCollected == th->MyVM->NumberOfThreads) collectorGo();
+
+ while (rendezvousNb == cm) {
+ collectionCond.wait(&_stackLock);
}
}
@@ -67,14 +66,15 @@
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);
+ if (val) addForeignThread(cur);
}
- // Finally, scan my stack too!
- traceThreadStack();
+ // Add myself.
+ another_mark();
// And wait for other threads to finish.
waitStacks();
+
} else {
mvm::Thread* self = mvm::Thread::get();
self->stackScanned = false;
@@ -87,18 +87,21 @@
cur->stackScanned = false;
cur->killForRendezvous();
}
+
+ // Add myself.
+ another_mark();
- traceThreadStack();
-
+ // And wait for other threads to finish.
waitStacks();
}
self->MyVM->ThreadLock.unlock();
}
-void CollectionRV::traceThreadStack() {
+void CollectionRV::join() {
mvm::Thread* th = mvm::Thread::get();
th->inGC = true;
+ bool changed = false;
stackLock();
@@ -110,32 +113,32 @@
return;
}
- // I woke up while a GC was happening, and no-one has collected my stack yet.
- // Do it now.
+ // I woke up while a GC was happening, and no-one has listed me yet.
if (!th->stackScanned) {
- th->MyVM->getScanner()->scanStack(th);
another_mark();
th->stackScanned = true;
+ if (!th->getLastSP()) {
+ changed = true;
+ th->setLastSP(FRAME_PTR());
+ }
}
// 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;
+ // The collection is finished. Set inGC to false.
+ th->inGC = false;
+ if (changed) th->setLastSP(0);
}
-void CollectionRV::traceForeignThreadStack(mvm::Thread* th) {
+void CollectionRV::addForeignThread(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.
+
+ // The thread may have waken up during this GC. In this case, it may have
+ // put itself into the waiting list.
if (!th->stackScanned) {
- th->MyVM->getScanner()->scanStack(th);
- th->MyVM->rendezvous.another_mark();
+ another_mark();
th->stackScanned = true;
}
Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=85391&r1=85390&r2=85391&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Wed Oct 28 10:09:03 2009
@@ -45,7 +45,7 @@
}
void Thread::joinCollection() {
- MyVM->rendezvous.traceThreadStack();
+ MyVM->rendezvous.join();
}
void Thread::startNative(int level) {
@@ -159,7 +159,7 @@
static void siggcHandler(int) {
mvm::Thread* th = mvm::Thread::get();
- th->MyVM->rendezvous.traceThreadStack();
+ th->MyVM->rendezvous.join();
}
/// internalThreadStart - The initial function called by a thread. Sets some
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp?rev=85391&r1=85390&r2=85391&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Wed Oct 28 10:09:03 2009
@@ -27,7 +27,7 @@
extern "C" void conditionalSafePoint() {
mvm::Thread::get()->startNative(1);
- mvm::Thread::get()->MyVM->rendezvous.traceThreadStack();
+ mvm::Thread::get()->MyVM->rendezvous.join();
mvm::Thread::get()->endNative();
}
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp?rev=85391&r1=85390&r2=85391&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Wed Oct 28 10:09:03 2009
@@ -42,6 +42,7 @@
unused_nodes->attrape(used_nodes);
mvm::Thread* th = mvm::Thread::get();
+ mvm::StackScanner* sc = th->MyVM->getScanner();
th->MyVM->startCollection();
th->inGC = true;
@@ -54,6 +55,7 @@
// (2) Trace the threads.
do {
+ sc->scanStack(tcur);
tcur->tracer();
tcur = (mvm::Thread*)tcur->next();
} while (tcur != th);
More information about the vmkit-commits
mailing list