[vmkit-commits] [vmkit] r85753 - in /vmkit/trunk/lib/Mvm: Compiler/JIT.cpp MMTk/MutatorThread.cpp MMTk/MutatorThread.h MMTk/MvmGC.cpp MMTk/MvmGC.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Nov 1 14:15:20 PST 2009


Author: geoffray
Date: Sun Nov  1 16:15:19 2009
New Revision: 85753

URL: http://llvm.org/viewvc/llvm-project?rev=85753&view=rev
Log:
Call Mutator.init on creation and Mutator.deinit on destruction
of a thread.


Modified:
    vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
    vmkit/trunk/lib/Mvm/MMTk/MutatorThread.cpp
    vmkit/trunk/lib/Mvm/MMTk/MutatorThread.h
    vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
    vmkit/trunk/lib/Mvm/MMTk/MvmGC.h

Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=85753&r1=85752&r2=85753&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sun Nov  1 16:15:19 2009
@@ -145,6 +145,17 @@
     MutatorThread::MutatorInit = (MutatorThread::MMTkInitType)
       (uintptr_t)executionEngine->getPointerToFunction(F);
     
+    F = globalModule->getFunction("JnJVM_org_mmtk_plan_MutatorContext_initMutator__I");
+    assert(F && "Could not find init from Mutator");
+    MutatorThread::MutatorCallInit = (MutatorThread::MMTkInitIntType)
+      (uintptr_t)executionEngine->getPointerToFunction(F);
+    
+    F = globalModule->getFunction("JnJVM_org_mmtk_plan_MutatorContext_deinitMutator__");
+    assert(F && "Could not find deinit from Mutator");
+    MutatorThread::MutatorCallDeinit = (MutatorThread::MMTkInitType)
+      (uintptr_t)executionEngine->getPointerToFunction(F);
+    
+    
     GV = globalModule->getGlobalVariable("org_j3_config_Selected_4Mutator_VT", false);
     assert(GV && "Could not find VT from Mutator");
     MutatorThread::MutatorVT = (VirtualTable*)executionEngine->getPointerToGlobal(GV);
@@ -504,7 +515,7 @@
   VirtualMachine* vm = th->MyVM;
 
   void** addr = mvm::Thread::get() == th ? 
-    (void**)FRAME_PTR() : (void**)th->getLastSP();
+    (void**)FRAME_PTR() : (void**)th->waitOnSP();
   assert(addr && "No address to start with");
   void** oldAddr = addr;
   DEBUG(fprintf(stderr, "%p trace %p\n", (void*)mvm::Thread::get(), (void*)th));

Modified: vmkit/trunk/lib/Mvm/MMTk/MutatorThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MutatorThread.cpp?rev=85753&r1=85752&r2=85753&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MutatorThread.cpp (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MutatorThread.cpp Sun Nov  1 16:15:19 2009
@@ -16,8 +16,10 @@
 uint32_t MutatorThread::MMTkMutatorSize = 0;
 uint32_t MutatorThread::MMTkCollectorSize = 0;
 
-MutatorThread::MMTkInitType MutatorThread::MutatorInit = 0;
-MutatorThread::MMTkInitType MutatorThread::CollectorInit = 0;
+MutatorThread::MMTkInitType    MutatorThread::MutatorInit = 0;
+MutatorThread::MMTkInitIntType MutatorThread::MutatorCallInit = 0;
+MutatorThread::MMTkInitType    MutatorThread::MutatorCallDeinit = 0;
+MutatorThread::MMTkInitType    MutatorThread::CollectorInit = 0;
 
 VirtualTable* MutatorThread::MutatorVT = 0;
 VirtualTable* MutatorThread::CollectorVT = 0;

Modified: vmkit/trunk/lib/Mvm/MMTk/MutatorThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MutatorThread.h?rev=85753&r1=85752&r2=85753&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MutatorThread.h (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MutatorThread.h Sun Nov  1 16:15:19 2009
@@ -31,8 +31,11 @@
   static uint32_t MMTkCollectorSize;
 
   typedef void (*MMTkInitType)(uintptr_t);
-  static MMTkInitType MutatorInit;
-  static MMTkInitType CollectorInit;
+  typedef void (*MMTkInitIntType)(uintptr_t, int32_t);
+  static MMTkInitType    MutatorInit;
+  static MMTkInitIntType MutatorCallInit;
+  static MMTkInitType    MutatorCallDeinit;
+  static MMTkInitType    CollectorInit;
 
   static VirtualTable* MutatorVT;
   static VirtualTable* CollectorVT;
@@ -43,11 +46,13 @@
       (uintptr_t)th->Allocator.Allocate(MMTkMutatorSize, "Mutator");
     ((VirtualTable**)th->MutatorContext)[0] = MutatorVT;
     MutatorInit(th->MutatorContext);
+    MutatorCallInit(th->MutatorContext, (int32_t)_th->getThreadID());
     th->CollectorContext = 
       (uintptr_t)th->Allocator.Allocate(MMTkCollectorSize, "Collector");
     ((VirtualTable**)th->CollectorContext)[0] = CollectorVT;
     CollectorInit(th->CollectorContext);
     th->realRoutine(_th);
+    MutatorCallDeinit(th->MutatorContext);
   }
 
   static MutatorThread* get() {

Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp?rev=85753&r1=85752&r2=85753&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp Sun Nov  1 16:15:19 2009
@@ -77,6 +77,9 @@
 extern "C" void fakeInit(uintptr_t) {
 }
 
+extern "C" void fakeInitInt(uintptr_t, int32_t) {
+}
+
 void Collector::initialise() {
   if (!gc::MMTkGCAllocator) {
     gc::MMTkGCAllocator = internalMalloc;
@@ -86,6 +89,8 @@
     MutatorThread::MMTkCollectorSize = 0;
     MutatorThread::MutatorInit = fakeInit;
     MutatorThread::CollectorInit = fakeInit;
+    MutatorThread::MutatorCallDeinit = fakeInit;
+    MutatorThread::MutatorCallInit = fakeInitInt;
   }
 }
 

Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.h?rev=85753&r1=85752&r2=85753&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.h Sun Nov  1 16:15:19 2009
@@ -87,10 +87,13 @@
 
 
   void* operator new(size_t sz, VirtualTable *VT) {
+    assert(VT->tracer && "VT without a tracer");
     sz = llvm::RoundUpToAlignment(sz, sizeof(void*));
     uintptr_t Mutator = mvm::MutatorThread::get()->MutatorContext;
     int allocator = MMTkCheckAllocator(Mutator, sz, 0, 0);
     gc* res = (gc*)MMTkGCAllocator(Mutator, sz, 0, 0, allocator, 0);
+    assert(res && "Allocation failed");
+    assert(res->getVirtualTable() == 0 && "Allocation not zeroed");
     res->setVirtualTable(VT);
     MMTkGCPostAllocator(Mutator, (uintptr_t)res, (uintptr_t)VT, sz, allocator);
     





More information about the vmkit-commits mailing list