[vmkit-commits] [vmkit] r117231 - in /vmkit/branches/precise: include/mvm/GC/GC.h include/mvm/Threads/Thread.h include/mvm/VirtualMachine.h lib/J3/VMCore/LockedMap.h lib/Mvm/CommonThread/ctthread.cpp lib/Mvm/GCMmap2/gccollector.cpp lib/Mvm/Runtime/Object.cpp mmtk/mmtk-j3/Scanning.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Oct 24 09:18:26 PDT 2010
Author: geoffray
Date: Sun Oct 24 11:18:25 2010
New Revision: 117231
URL: http://llvm.org/viewvc/llvm-project?rev=117231&view=rev
Log:
Some more code cleanup, related to stack walking.
Modified:
vmkit/branches/precise/include/mvm/GC/GC.h
vmkit/branches/precise/include/mvm/Threads/Thread.h
vmkit/branches/precise/include/mvm/VirtualMachine.h
vmkit/branches/precise/lib/J3/VMCore/LockedMap.h
vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp
vmkit/branches/precise/lib/Mvm/GCMmap2/gccollector.cpp
vmkit/branches/precise/lib/Mvm/Runtime/Object.cpp
vmkit/branches/precise/mmtk/mmtk-j3/Scanning.cpp
Modified: vmkit/branches/precise/include/mvm/GC/GC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/GC/GC.h?rev=117231&r1=117230&r2=117231&view=diff
==============================================================================
--- vmkit/branches/precise/include/mvm/GC/GC.h (original)
+++ vmkit/branches/precise/include/mvm/GC/GC.h Sun Oct 24 11:18:25 2010
@@ -34,26 +34,4 @@
}
};
-namespace mvm {
-
-class Thread;
-
-class StackScanner {
-public:
- virtual void scanStack(mvm::Thread* th, uintptr_t closure) = 0;
- virtual ~StackScanner() {}
-};
-
-class UnpreciseStackScanner : public StackScanner {
-public:
- virtual void scanStack(mvm::Thread* th, uintptr_t closure);
-};
-
-class PreciseStackScanner : public StackScanner {
-public:
- virtual void scanStack(mvm::Thread* th, uintptr_t closure);
-};
-
-}
-
#endif
Modified: vmkit/branches/precise/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/Threads/Thread.h?rev=117231&r1=117230&r2=117231&view=diff
==============================================================================
--- vmkit/branches/precise/include/mvm/Threads/Thread.h (original)
+++ vmkit/branches/precise/include/mvm/Threads/Thread.h Sun Oct 24 11:18:25 2010
@@ -237,6 +237,7 @@
/// a tracer.
///
virtual void tracer(uintptr_t closure) {}
+ void scanStack(uintptr_t closure);
void* getLastSP() { return lastSP; }
void setLastSP(void* V) { lastSP = V; }
Modified: vmkit/branches/precise/include/mvm/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/VirtualMachine.h?rev=117231&r1=117230&r2=117231&view=diff
==============================================================================
--- vmkit/branches/precise/include/mvm/VirtualMachine.h (original)
+++ vmkit/branches/precise/include/mvm/VirtualMachine.h Sun Oct 24 11:18:25 2010
@@ -11,22 +11,17 @@
#define MVM_VIRTUALMACHINE_H
#include "mvm/Allocator.h"
-#include "mvm/MethodInfo.h"
#include "mvm/Threads/CollectionRV.h"
-#include "mvm/Threads/Cond.h"
#include "mvm/Threads/Locks.h"
#include "mvm/GC/GC.h"
#include <cassert>
#include <map>
-namespace j3 {
- class JavaCompiler;
- class JnjvmClassLoader;
-}
-
namespace mvm {
+class MethodInfo;
+
class FunctionMap {
public:
/// Functions - Map of applicative methods to function pointers. This map is
@@ -162,14 +157,10 @@
/// rendezvous - The rendezvous implementation for garbage collection.
///
- /// scanner - Scanner of threads' stacks.
- ///
#ifdef WITH_LLVM_GCC
CooperativeCollectionRV rendezvous;
- PreciseStackScanner scanner;
#else
UncooperativeCollectionRV rendezvous;
- UnpreciseStackScanner scanner;
#endif
//===----------------------------------------------------------------------===//
Modified: vmkit/branches/precise/lib/J3/VMCore/LockedMap.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/LockedMap.h?rev=117231&r1=117230&r2=117231&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/LockedMap.h (original)
+++ vmkit/branches/precise/lib/J3/VMCore/LockedMap.h Sun Oct 24 11:18:25 2010
@@ -31,6 +31,7 @@
namespace j3 {
class JavaString;
+class JnjvmClassLoader;
class Signdef;
class Typedef;
class UserCommonClass;
Modified: vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp?rev=117231&r1=117230&r2=117231&view=diff
==============================================================================
--- vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp Sun Oct 24 11:18:25 2010
@@ -10,13 +10,14 @@
#include "debug.h"
#include "MvmGC.h"
+#include "mvm/MethodInfo.h"
#include "mvm/VirtualMachine.h"
#include "mvm/Threads/Cond.h"
#include "mvm/Threads/Locks.h"
#include "mvm/Threads/Thread.h"
#include <cassert>
-#include <signal.h>
+#include <csetjmp>
#include <cstdio>
#include <ctime>
#include <dlfcn.h>
@@ -24,6 +25,7 @@
#include <pthread.h>
#include <sys/mman.h>
#include <sched.h>
+#include <signal.h>
#include <unistd.h>
using namespace mvm;
@@ -361,3 +363,30 @@
int res = kill(SIGGC);
assert(!res && "Error on kill");
}
+
+
+#ifdef WITH_LLVM_GCC
+void Thread::scanStack(uintptr_t closure) {
+ StackWalker Walker(this);
+
+ while (MethodInfo* MI = Walker.get()) {
+ MI->scan(closure, Walker.ip, Walker.addr);
+ ++Walker;
+ }
+}
+
+#else
+
+void Thread::scanStack(uintptr_t closure) {
+ register unsigned int **max = (unsigned int**)(void*)this->baseSP;
+ if (mvm::Thread::get() != this) {
+ register unsigned int **cur = (unsigned int**)this->waitOnSP();
+ for(; cur<max; cur++) Collector::scanObject((void**)cur, closure);
+ } else {
+ jmp_buf buf;
+ setjmp(buf);
+ register unsigned int **cur = (unsigned int**)&buf;
+ for(; cur<max; cur++) Collector::scanObject((void**)cur, closure);
+ }
+}
+#endif
Modified: vmkit/branches/precise/lib/Mvm/GCMmap2/gccollector.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/GCMmap2/gccollector.cpp?rev=117231&r1=117230&r2=117231&view=diff
==============================================================================
--- vmkit/branches/precise/lib/Mvm/GCMmap2/gccollector.cpp (original)
+++ vmkit/branches/precise/lib/Mvm/GCMmap2/gccollector.cpp Sun Oct 24 11:18:25 2010
@@ -40,7 +40,6 @@
unused_nodes->attrape(used_nodes);
mvm::Thread* th = mvm::Thread::get();
- mvm::StackScanner& sc = th->MyVM->scanner;
th->MyVM->rendezvous.startRV();
th->MyVM->startCollection();
@@ -53,7 +52,7 @@
// (2) Trace the threads.
do {
- sc.scanStack(tcur, 0);
+ tcur->scanStack(0);
tcur->tracer(0);
tcur = (mvm::Thread*)tcur->next();
} while (tcur != th);
Modified: vmkit/branches/precise/lib/Mvm/Runtime/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Runtime/Object.cpp?rev=117231&r1=117230&r2=117231&view=diff
==============================================================================
--- vmkit/branches/precise/lib/Mvm/Runtime/Object.cpp (original)
+++ vmkit/branches/precise/lib/Mvm/Runtime/Object.cpp Sun Oct 24 11:18:25 2010
@@ -9,14 +9,10 @@
#include <cstdio>
#include <cstdlib>
-#include <csetjmp>
#include "MvmGC.h"
-#include "mvm/Allocator.h"
#include "mvm/Object.h"
#include "mvm/PrintBuffer.h"
-#include "mvm/VirtualMachine.h"
-#include "mvm/Threads/Thread.h"
using namespace mvm;
@@ -58,26 +54,3 @@
buf->writePtr((void*)o);
buf->write(">");
}
-
-void PreciseStackScanner::scanStack(mvm::Thread* th, uintptr_t closure) {
- StackWalker Walker(th);
-
- while (MethodInfo* MI = Walker.get()) {
- MI->scan(closure, Walker.ip, Walker.addr);
- ++Walker;
- }
-}
-
-
-void UnpreciseStackScanner::scanStack(mvm::Thread* th, uintptr_t closure) {
- register unsigned int **max = (unsigned int**)(void*)th->baseSP;
- if (mvm::Thread::get() != th) {
- register unsigned int **cur = (unsigned int**)th->waitOnSP();
- for(; cur<max; cur++) Collector::scanObject((void**)cur, closure);
- } else {
- jmp_buf buf;
- setjmp(buf);
- register unsigned int **cur = (unsigned int**)&buf;
- for(; cur<max; cur++) Collector::scanObject((void**)cur, closure);
- }
-}
Modified: vmkit/branches/precise/mmtk/mmtk-j3/Scanning.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/mmtk/mmtk-j3/Scanning.cpp?rev=117231&r1=117230&r2=117231&view=diff
==============================================================================
--- vmkit/branches/precise/mmtk/mmtk-j3/Scanning.cpp (original)
+++ vmkit/branches/precise/mmtk/mmtk-j3/Scanning.cpp Sun Oct 24 11:18:25 2010
@@ -20,11 +20,10 @@
// When entering this function, all threads are waiting on the rendezvous to
// finish.
mvm::Thread* th = mvm::Thread::get();
- mvm::StackScanner& sc = th->MyVM->scanner;
mvm::Thread* tcur = th;
do {
- sc.scanStack(tcur, reinterpret_cast<uintptr_t>(TL));
+ tcur->scanStack(reinterpret_cast<uintptr_t>(TL));
tcur = (mvm::Thread*)tcur->next();
} while (tcur != th);
}
@@ -39,7 +38,6 @@
tcur->tracer(reinterpret_cast<uintptr_t>(TL));
tcur = (mvm::Thread*)tcur->next();
} while (tcur != th);
-
}
extern "C" void Java_org_j3_mmtk_Scanning_computeStaticRoots__Lorg_mmtk_plan_TraceLocal_2 (JavaObject* Scanning, JavaObject* TL) {
More information about the vmkit-commits
mailing list