OSDN Git Service

Resolve a few errors with the new collector and the dalvik tests.
authorCarl Shapiro <cshapiro@google.com>
Thu, 13 May 2010 06:11:37 +0000 (23:11 -0700)
committerCarl Shapiro <cshapiro@google.com>
Thu, 13 May 2010 06:33:55 +0000 (23:33 -0700)
* First, Scavenge class object instance fields.  This fixes a crash in
  the 067-preemptive-unpark test.

* Assert that allocations to back the transport of gray objects
  succeeds.  Fragmentation caused by pinning can cause a blow-up in
  the size of to-space.  Until we can perform emergency promotions
  this leads to more diagnosable test failures.

* Zero dvmHeapSweepUnmarkObjects's out parameters.  This silences some
  valgrind errors.

Change-Id: Iafbd915f2020418d584477b58c512b9ff4637213

vm/alloc/Copying.c

index 8c6ebe9..9c6a79b 100644 (file)
@@ -669,6 +669,7 @@ void *allocateGray(size_t size)
     /* TODO: add a check that we are in a GC. */
     heapSource = gDvm.gcHeap->heapSource;
     addr = dvmHeapSourceAlloc(size);
+    assert(addr != NULL);
     block = addressToBlock(heapSource, (const u1 *)addr);
     if (heapSource->queueHead == QUEUE_TAIL) {
         /*
@@ -956,8 +957,8 @@ static void scavengeClassObject(ClassObject *obj)
     assert(obj->descriptor != NULL);
     LOG_SCAV("scavengeClassObject: descriptor='%s',vtableCount=%zu",
              obj->descriptor, obj->vtableCount);
-    /* Scavenge our class object. */
-    scavengeReference((Object **) obj);
+    /* Delegate class object and instance field scavenging. */
+    scavengeDataObject((Object *)obj);
     /* Scavenge the array element class object. */
     if (IS_CLASS_FLAG_SET(obj, CLASS_ISARRAY)) {
         scavengeReference((Object **)(void *)&obj->elementClass);
@@ -2621,6 +2622,8 @@ void dvmHeapScheduleFinalizations(void)
 
 void dvmHeapSweepUnmarkedObjects(GcMode mode, int *numFreed, size_t *sizeFreed)
 {
+    *numFreed = 0;
+    *sizeFreed = 0;
     /* do nothing */
 }