[INFER] Don't scan values above obj->getDenseArrayInitializedLength.
authorBrian Hackett <bhackett1024@gmail.com>
Thu, 21 Apr 2011 07:12:08 -0700
changeset 74970 dc74f51aad04ff8762b6c70f664a08e9c654ba18
parent 74969 17cbc8fed5784d1d4d7c0e5ef79ad5299f2f0f5b
child 74971 90a7b141e0cf06506829bf47307c683541f206ec
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone6.0a1
[INFER] Don't scan values above obj->getDenseArrayInitializedLength.
js/src/jsgcmark.cpp
--- a/js/src/jsgcmark.cpp
+++ b/js/src/jsgcmark.cpp
@@ -547,17 +547,17 @@ ScanObject(GCMarker *gcmarker, JSObject 
 
     if (JSObject *parent = obj->getParent())
         PushMarkStack(gcmarker, parent);
     if (!obj->isDenseArray() && obj->newType && !obj->newType->marked)
         obj->newType->trace(gcmarker);
 
     Class *clasp = obj->getClass();
     if (clasp->trace) {
-        if (obj->isDenseArray() && obj->getDenseArrayCapacity() > LARGE_OBJECT_CHUNK_SIZE)
+        if (obj->isDenseArray() && obj->getDenseArrayInitializedLength() > LARGE_OBJECT_CHUNK_SIZE)
             gcmarker->largeStack.push(LargeMarkItem(obj));
         else
             clasp->trace(gcmarker, obj);
     }
 
     if (obj->isNative()) {
 #ifdef JS_DUMP_SCOPE_METERS
         js::MeterEntryCount(obj->propertyCount);
@@ -588,29 +588,32 @@ ScanObject(GCMarker *gcmarker, JSObject 
     }
 }
 
 static bool
 ScanLargeObject(GCMarker *gcmarker, LargeMarkItem &item)
 {
     JSObject *obj = item.obj;
 
+    uintN start = item.markpos;
+    uintN stop;
     uint32 capacity;
     if (obj->isDenseArray()) {
-        capacity = obj->getDenseArrayCapacity();
+        capacity = obj->getDenseArrayInitializedLength();
+        stop = JS_MIN(start + LARGE_OBJECT_CHUNK_SIZE, capacity);
+        for (uintN i=stop; i>start; i--)
+            ScanValue(gcmarker, obj->getDenseArrayElement(i-1));
     } else {
         JS_ASSERT(obj->isNative());
         capacity = obj->slotSpan();
+        stop = JS_MIN(start + LARGE_OBJECT_CHUNK_SIZE, capacity);
+        for (uintN i=stop; i>start; i--)
+            ScanValue(gcmarker, obj->getSlot(i-1));
     }
 
-    uintN start = item.markpos;
-    uintN stop = JS_MIN(start + LARGE_OBJECT_CHUNK_SIZE, capacity);
-    for (uintN i=stop; i>start; i--)
-        ScanValue(gcmarker, obj->getSlot(i-1));
-
     if (stop == capacity)
         return true;
 
     item.markpos += LARGE_OBJECT_CHUNK_SIZE;
     return false;
 }
 
 void