[vmkit-commits] [vmkit] r120999 - in /vmkit/branches/multi-vm: include/mvm/VMKit.h lib/J3/VMCore/Jnjvm.cpp lib/Mvm/CommonThread/ctthread.cpp lib/Mvm/GCMmap2/gccollector.cpp lib/Mvm/Runtime/VMKit.cpp mmtk/mmtk-j3/Collection.cpp

Gael Thomas gael.thomas at lip6.fr
Mon Dec 6 04:03:01 PST 2010


Author: gthomas
Date: Mon Dec  6 06:03:01 2010
New Revision: 120999

URL: http://llvm.org/viewvc/llvm-project?rev=120999&view=rev
Log:
startCollection/endCollection are now centralized in vmkit.

Modified:
    vmkit/branches/multi-vm/include/mvm/VMKit.h
    vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
    vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp
    vmkit/branches/multi-vm/lib/Mvm/GCMmap2/gccollector.cpp
    vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp
    vmkit/branches/multi-vm/mmtk/mmtk-j3/Collection.cpp

Modified: vmkit/branches/multi-vm/include/mvm/VMKit.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/VMKit.h?rev=120999&r1=120998&r2=120999&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/VMKit.h (original)
+++ vmkit/branches/multi-vm/include/mvm/VMKit.h Mon Dec  6 06:03:01 2010
@@ -55,7 +55,7 @@
 	// vms - the list of vms. Could be directly an array and we could also directly use the vmID as index in this array.
 	// synchronize with vmkitLock
 	VirtualMachine**             vms;
-	size_t                       numberOfVms;
+	size_t                       vmsArraySize;
 
 	size_t addVM(VirtualMachine* vm);
 	void   removeVM(size_t id);
@@ -89,6 +89,13 @@
 	void unregisterRunningThread(mvm::Thread* th);
 
 	/// ------------------------------------------------- ///
+	/// ---             collection managment          --- ///
+	/// ------------------------------------------------- ///
+
+	void startCollection();
+	void endCollection();
+
+	/// ------------------------------------------------- ///
 	/// ---    backtrace related methods              --- ///
 	/// ------------------------------------------------- ///
   /// FunctionsCache - cache of compiled functions

Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp?rev=120999&r1=120998&r2=120999&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Mon Dec  6 06:03:01 2010
@@ -1411,11 +1411,14 @@
 }
 
 void Jnjvm::startCollection() {
+	printf("start collection of %p\n", this);
+	printf("%p - %p\n", finalizerThread, referenceThread);
   finalizerThread->FinalizationQueueLock.acquire();
   referenceThread->ToEnqueueLock.acquire();
   referenceThread->SoftReferencesQueue.acquire();
   referenceThread->WeakReferencesQueue.acquire();
   referenceThread->PhantomReferencesQueue.acquire();
+	printf("yop\n");
 }
   
 void Jnjvm::endCollection() {

Modified: vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp?rev=120999&r1=120998&r2=120999&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp Mon Dec  6 06:03:01 2010
@@ -72,7 +72,7 @@
 	mvm::Collector::markAndTraceRoot(&pendingException, closure);
 
 	// should we take the vmkit lock? I suppose that all the threads are suspended during the collection...
-	for(size_t i=0; i<vmkit->numberOfVms; i++)
+	for(size_t i=0; i<vmkit->vmsArraySize; i++)
 		if(allVmsData[i]) {
 			allVmsData[i]->tracer(closure);
 		}

Modified: vmkit/branches/multi-vm/lib/Mvm/GCMmap2/gccollector.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/GCMmap2/gccollector.cpp?rev=120999&r1=120998&r2=120999&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/GCMmap2/gccollector.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/GCMmap2/gccollector.cpp Mon Dec  6 06:03:01 2010
@@ -42,7 +42,7 @@
 
   mvm::Thread* th = mvm::Thread::get();
   th->vmkit->rendezvous.startRV();
-  th->MyVM->startCollection();
+  th->vmkit->startCollection();
 
   th->vmkit->rendezvous.synchronize();
 
@@ -91,7 +91,7 @@
   
   // Wake up all threads.
   th->vmkit->rendezvous.finishRV();
-  th->MyVM->endCollection();
+  th->vmkit->endCollection();
   
   // Kill unreachable objects.
   GCChunkNode *next = 0;

Modified: vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp?rev=120999&r1=120998&r2=120999&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp Mon Dec  6 06:03:01 2010
@@ -4,36 +4,56 @@
 using namespace mvm;
 
 VMKit::VMKit(mvm::BumpPtrAllocator &Alloc) : allocator(Alloc) {
-	vms         = 0;
-	numberOfVms = 0;
+	vms          = 0;
+	vmsArraySize = 0;
+}
+
+void VMKit::startCollection() {
+	vmkitLock();
+	for(size_t i=0; i<vmsArraySize; i++)
+		if(vms[i])
+			vms[i]->startCollection();
+	vmkitUnlock();
+}
+
+void VMKit::endCollection() {
+	vmkitLock();
+	for(size_t i=0; i<vmsArraySize; i++)
+		if(vms[i])
+			vms[i]->endCollection();
+	vmkitUnlock();
 }
 
 size_t VMKit::addVM(VirtualMachine* vm) {
 	vmkitLock();
 
-	for(size_t i=0; i<numberOfVms; i++)
+	for(size_t i=0; i<vmsArraySize; i++)
 		if(!vms[i]) {
 			vms[i] = vm;
 			vmkitUnlock();
 			return i;
 		}
 
-	int res = numberOfVms;
-	numberOfVms = numberOfVms ? (numberOfVms<<1) : 1;
+	int res = vmsArraySize;
+	vmsArraySize = vmsArraySize ? (vmsArraySize<<1) : 1;
 	// reallocate the vms
-	VirtualMachine **newVms = new VirtualMachine*[numberOfVms];
+	VirtualMachine **newVms = new VirtualMachine*[vmsArraySize];
+
 	memcpy(newVms, vms, res*sizeof(VirtualMachine*));
+	memset(newVms + res*sizeof(VirtualMachine*), 0, (vmsArraySize-res)*sizeof(VirtualMachine*));
+	newVms[res] = vm;
+
 	VirtualMachine **oldVms = vms;
 	vms = newVms; // vms must always contain valid data
 	delete[] oldVms;
 	
  	// reallocate the allVMDatas
  	for(Thread* cur=preparedThreads.next(); cur!=&preparedThreads; cur=cur->next()) {
-		cur->reallocAllVmsData(res, numberOfVms);
+		cur->reallocAllVmsData(res, vmsArraySize);
 	}
 
  	for(Thread* cur=runningThreads.next(); cur!=&runningThreads; cur=cur->next()) {
-		cur->reallocAllVmsData(res, numberOfVms);
+		cur->reallocAllVmsData(res, vmsArraySize);
 	}
 
 	vmkitUnlock();
@@ -49,14 +69,14 @@
 void VMKit::registerPreparedThread(mvm::Thread* th) {
 	vmkitLock();
 	th->appendTo(&preparedThreads);
-	th->reallocAllVmsData(0, numberOfVms);
+	th->reallocAllVmsData(0, vmsArraySize);
 	vmkitUnlock();
 }
   
 void VMKit::unregisterPreparedThread(mvm::Thread* th) {
 	vmkitLock();
 	th->remove();
-	for(size_t i=0; i<numberOfVms; i++)
+	for(size_t i=0; i<vmsArraySize; i++)
 		if(th->allVmsData[i])
 			delete th->allVmsData[i];
 	delete th->allVmsData;

Modified: vmkit/branches/multi-vm/mmtk/mmtk-j3/Collection.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/mmtk/mmtk-j3/Collection.cpp?rev=120999&r1=120998&r2=120999&view=diff
==============================================================================
--- vmkit/branches/multi-vm/mmtk/mmtk-j3/Collection.cpp (original)
+++ vmkit/branches/multi-vm/mmtk/mmtk-j3/Collection.cpp Mon Dec  6 06:03:01 2010
@@ -42,7 +42,7 @@
     th->vmkit->rendezvous.join();
     return;
   } else {
-    th->MyVM->startCollection();
+    th->vmkit->startCollection();
     th->vmkit->rendezvous.synchronize();
   
     JnJVM_org_mmtk_plan_Plan_setCollectionTriggered__();
@@ -74,7 +74,7 @@
     }
 
     th->vmkit->rendezvous.finishRV();
-    th->MyVM->endCollection();
+    th->vmkit->endCollection();
   }
 
 }





More information about the vmkit-commits mailing list