[vmkit-commits] [vmkit] r72302 - in /vmkit/trunk: include/mvm/VirtualMachine.h lib/Mvm/Runtime/Object.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Fri May 22 16:40:40 PDT 2009
Author: geoffray
Date: Fri May 22 18:40:40 2009
New Revision: 72302
URL: http://llvm.org/viewvc/llvm-project?rev=72302&view=rev
Log:
Don't grow both queues when one is too small.
Modified:
vmkit/trunk/include/mvm/VirtualMachine.h
vmkit/trunk/lib/Mvm/Runtime/Object.cpp
Modified: vmkit/trunk/include/mvm/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/VirtualMachine.h?rev=72302&r1=72301&r2=72302&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/VirtualMachine.h (original)
+++ vmkit/trunk/include/mvm/VirtualMachine.h Fri May 22 18:40:40 2009
@@ -99,9 +99,9 @@
///
uint32 QueueLength;
- /// growQueue - Grow the queue of finalizable objects.
+ /// growFinalizationQueue - Grow the queue of finalizable objects.
///
- void growQueue();
+ void growFinalizationQueue();
/// ToBeFinalized - List of objects that are scheduled to be finalized.
///
@@ -117,10 +117,9 @@
///
uint32 CurrentFinalizedIndex;
- /// LastFinalizedIndex - The last index in the ToBeFinalized queue whose
- /// finalize method has been called.
+ /// growToBeFinalizedQueue - Grow the queue of the to-be finalized objects.
///
- uint32 LastFinalizedIndex;
+ void growToBeFinalizedQueue();
/// finalizationCond - Condition variable to wake up finalization threads.
///
Modified: vmkit/trunk/lib/Mvm/Runtime/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/Object.cpp?rev=72302&r1=72301&r2=72302&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/Object.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/Object.cpp Fri May 22 18:40:40 2009
@@ -152,17 +152,29 @@
}
}
-void VirtualMachine::growQueue() {
+void VirtualMachine::growFinalizationQueue() {
if (CurrentIndex >= QueueLength) {
uint32 newLength = QueueLength * GROW_FACTOR;
gc** newQueue = new gc*[newLength];
+ if (!newQueue) {
+ fprintf(stderr, "I don't know how to handle finalizer overflows yet!\n");
+ abort();
+ }
for (uint32 i = 0; i < QueueLength; ++i) newQueue[i] = FinalizationQueue[i];
delete[] FinalizationQueue;
FinalizationQueue = newQueue;
QueueLength = newLength;
-
- newLength = ToBeFinalizedLength * GROW_FACTOR;
- newQueue = new gc*[newLength];
+ }
+}
+
+void VirtualMachine::growToBeFinalizedQueue() {
+ if (CurrentFinalizedIndex >= ToBeFinalizedLength) {
+ uint32 newLength = ToBeFinalizedLength * GROW_FACTOR;
+ gc** newQueue = new gc*[newLength];
+ if (!newQueue) {
+ fprintf(stderr, "I don't know how to handle finalizer overflows yet!\n");
+ abort();
+ }
for (uint32 i = 0; i < ToBeFinalizedLength; ++i) newQueue[i] = ToBeFinalized[i];
delete[] ToBeFinalized;
ToBeFinalized = newQueue;
@@ -175,7 +187,7 @@
FinalizationQueueLock.acquire();
if (CurrentIndex >= QueueLength) {
- growQueue();
+ growFinalizationQueue();
}
FinalizationQueue[CurrentIndex++] = obj;
@@ -191,7 +203,8 @@
if (!Collector::isLive(obj)) {
obj->markAndTrace();
- if (CurrentFinalizedIndex >= ToBeFinalizedLength) growQueue();
+ if (CurrentFinalizedIndex >= ToBeFinalizedLength)
+ growToBeFinalizedQueue();
/* Add to object table */
ToBeFinalized[CurrentFinalizedIndex++] = obj;
More information about the vmkit-commits
mailing list