Title: [129179] trunk/Source/_javascript_Core
Revision
129179
Author
[email protected]
Date
2012-09-20 16:38:48 -0700 (Thu, 20 Sep 2012)

Log Message

CHECK_ARRAY_CONSISTENCY isn't being used or tested, so we should remove it
https://bugs.webkit.org/show_bug.cgi?id=97260

Rubber stamped by Geoffrey Garen.
        
Supporting it will become difficult as we add more indexing types. It makes more
sense to kill, especially since we don't appear to use it or test it, ever.

* runtime/ArrayConventions.h:
(JSC):
* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoFuncSplice):
* runtime/ArrayStorage.h:
(JSC::ArrayStorage::copyHeaderFromDuringGC):
(ArrayStorage):
* runtime/FunctionPrototype.cpp:
(JSC::functionProtoFuncBind):
* runtime/JSArray.cpp:
(JSC::createArrayButterflyInDictionaryIndexingMode):
(JSC::JSArray::setLength):
(JSC::JSArray::pop):
(JSC::JSArray::push):
(JSC::JSArray::sortNumeric):
(JSC::JSArray::sort):
(JSC::JSArray::compactForSorting):
* runtime/JSArray.h:
(JSArray):
(JSC::createArrayButterfly):
(JSC::JSArray::tryCreateUninitialized):
(JSC::constructArray):
* runtime/JSObject.cpp:
(JSC::JSObject::putByIndex):
(JSC::JSObject::createArrayStorage):
(JSC::JSObject::deletePropertyByIndex):
(JSC):
* runtime/JSObject.h:
(JSC::JSObject::initializeIndex):
(JSObject):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (129178 => 129179)


--- trunk/Source/_javascript_Core/ChangeLog	2012-09-20 23:38:21 UTC (rev 129178)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-09-20 23:38:48 UTC (rev 129179)
@@ -1,3 +1,44 @@
+2012-09-20  Filip Pizlo  <[email protected]>
+
+        CHECK_ARRAY_CONSISTENCY isn't being used or tested, so we should remove it
+        https://bugs.webkit.org/show_bug.cgi?id=97260
+
+        Rubber stamped by Geoffrey Garen.
+        
+        Supporting it will become difficult as we add more indexing types. It makes more
+        sense to kill, especially since we don't appear to use it or test it, ever.
+
+        * runtime/ArrayConventions.h:
+        (JSC):
+        * runtime/ArrayPrototype.cpp:
+        (JSC::arrayProtoFuncSplice):
+        * runtime/ArrayStorage.h:
+        (JSC::ArrayStorage::copyHeaderFromDuringGC):
+        (ArrayStorage):
+        * runtime/FunctionPrototype.cpp:
+        (JSC::functionProtoFuncBind):
+        * runtime/JSArray.cpp:
+        (JSC::createArrayButterflyInDictionaryIndexingMode):
+        (JSC::JSArray::setLength):
+        (JSC::JSArray::pop):
+        (JSC::JSArray::push):
+        (JSC::JSArray::sortNumeric):
+        (JSC::JSArray::sort):
+        (JSC::JSArray::compactForSorting):
+        * runtime/JSArray.h:
+        (JSArray):
+        (JSC::createArrayButterfly):
+        (JSC::JSArray::tryCreateUninitialized):
+        (JSC::constructArray):
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::putByIndex):
+        (JSC::JSObject::createArrayStorage):
+        (JSC::JSObject::deletePropertyByIndex):
+        (JSC):
+        * runtime/JSObject.h:
+        (JSC::JSObject::initializeIndex):
+        (JSObject):
+
 2012-09-20  Mark Lam  <[email protected]>
 
         Fixed a missing semicolon in the C++ llint backend.

Modified: trunk/Source/_javascript_Core/runtime/ArrayConventions.h (129178 => 129179)


--- trunk/Source/_javascript_Core/runtime/ArrayConventions.h	2012-09-20 23:38:21 UTC (rev 129178)
+++ trunk/Source/_javascript_Core/runtime/ArrayConventions.h	2012-09-20 23:38:48 UTC (rev 129179)
@@ -26,8 +26,6 @@
 
 namespace JSC {
 
-#define CHECK_ARRAY_CONSISTENCY 0
-
 // Overview of JSArray
 //
 // Properties of JSArray objects may be stored in one of three locations:

Modified: trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp (129178 => 129179)


--- trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp	2012-09-20 23:38:21 UTC (rev 129178)
+++ trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp	2012-09-20 23:38:48 UTC (rev 129179)
@@ -730,7 +730,6 @@
             return JSValue::encode(jsUndefined());
         resObj->initializeIndex(globalData, k, v);
     }
-    resObj->completeInitialization(deleteCount);
 
     unsigned additionalArgs = std::max<int>(exec->argumentCount() - 2, 0);
     if (additionalArgs < deleteCount) {

Modified: trunk/Source/_javascript_Core/runtime/ArrayStorage.h (129178 => 129179)


--- trunk/Source/_javascript_Core/runtime/ArrayStorage.h	2012-09-20 23:38:21 UTC (rev 129178)
+++ trunk/Source/_javascript_Core/runtime/ArrayStorage.h	2012-09-20 23:38:48 UTC (rev 129179)
@@ -64,10 +64,6 @@
         m_sparseMap.copyFrom(other.m_sparseMap);
         m_indexBias = other.m_indexBias;
         m_numValuesInVector = other.m_numValuesInVector;
-#if CHECK_ARRAY_CONSISTENCY
-        m_initializationIndex = other.m_initializationIndex;
-        m_inCompactInitialization = other.m_inCompactInitialization;
-#endif
     }
     
     bool inSparseMode()
@@ -78,11 +74,7 @@
     WriteBarrier<SparseArrayValueMap> m_sparseMap;
     unsigned m_indexBias;
     unsigned m_numValuesInVector;
-#if CHECK_ARRAY_CONSISTENCY
-    // Needs to be a uintptr_t for alignment purposes.
-    uintptr_t m_initializationIndex;
-    uintptr_t m_inCompactInitialization;
-#elif USE(JSVALUE32_64)
+#if USE(JSVALUE32_64)
     uintptr_t m_padding;
 #endif
     WriteBarrier<Unknown> m_vector[1];

Modified: trunk/Source/_javascript_Core/runtime/FunctionPrototype.cpp (129178 => 129179)


--- trunk/Source/_javascript_Core/runtime/FunctionPrototype.cpp	2012-09-20 23:38:21 UTC (rev 129178)
+++ trunk/Source/_javascript_Core/runtime/FunctionPrototype.cpp	2012-09-20 23:38:48 UTC (rev 129179)
@@ -193,7 +193,6 @@
 
     for (size_t i = 0; i < numBoundArgs; ++i)
         boundArgs->initializeIndex(exec->globalData(), i, exec->argument(i + 1));
-    boundArgs->completeInitialization(numBoundArgs);
 
     // If the [[Class]] internal property of Target is "Function", then ...
     // Else set the length own property of F to 0.

Modified: trunk/Source/_javascript_Core/runtime/JSArray.cpp (129178 => 129179)


--- trunk/Source/_javascript_Core/runtime/JSArray.cpp	2012-09-20 23:38:21 UTC (rev 129178)
+++ trunk/Source/_javascript_Core/runtime/JSArray.cpp	2012-09-20 23:38:48 UTC (rev 129179)
@@ -60,10 +60,6 @@
     storage->m_indexBias = 0;
     storage->m_sparseMap.clear();
     storage->m_numValuesInVector = 0;
-#if CHECK_ARRAY_CONSISTENCY
-    storage->m_initializationIndex = 0;
-    storage->m_inCompactInitialization = 0;
-#endif
     return butterfly;
 }
 
@@ -330,8 +326,6 @@
 
 bool JSArray::setLength(ExecState* exec, unsigned newLength, bool throwException)
 {
-    checkIndexingConsistency();
-
     ArrayStorage* storage = ensureArrayStorage(exec->globalData());
     unsigned length = storage->length();
 
@@ -392,14 +386,11 @@
 
     storage->setLength(newLength);
 
-    checkIndexingConsistency();
     return true;
 }
 
 JSValue JSArray::pop(ExecState* exec)
 {
-    checkIndexingConsistency();
-    
     switch (structure()->indexingType()) {
     case ArrayClass:
         return jsUndefined();
@@ -424,7 +415,6 @@
             
                 ASSERT(isLengthWritable());
                 storage->setLength(index);
-                checkIndexingConsistency();
                 return element;
             }
         }
@@ -441,7 +431,6 @@
         // Call the [[Put]] internal method of O with arguments "length", indx, and true.
         setLength(exec, index, true);
         // Return element.
-        checkIndexingConsistency();
         return element;
     }
         
@@ -456,8 +445,6 @@
 //  - pushing to an array of length 2^32-1 stores the property, but throws a range error.
 void JSArray::push(ExecState* exec, JSValue value)
 {
-    checkIndexingConsistency();
-    
     switch (structure()->indexingType()) {
     case ArrayClass: {
         putByIndexBeyondVectorLengthWithArrayStorage(exec, 0, value, true, createInitialArrayStorage(exec->globalData()));
@@ -483,7 +470,6 @@
             storage->m_vector[length].set(exec->globalData(), this, value);
             storage->setLength(length + 1);
             ++storage->m_numValuesInVector;
-            checkIndexingConsistency();
             return;
         }
 
@@ -498,7 +484,6 @@
 
         // Handled the same as putIndex.
         putByIndexBeyondVectorLengthWithArrayStorage(exec, storage->length(), value, true, storage);
-        checkIndexingConsistency();
         break;
     }
         
@@ -622,7 +607,6 @@
         // side-effect from swapping the order of equal primitive values.
         qsort(storage->m_vector, size, sizeof(WriteBarrier<Unknown>), compareNumbersForQSort);
         
-        checkIndexingConsistency(SortConsistencyCheck);
         return;
     }
         
@@ -711,7 +695,6 @@
         
         Heap::heap(this)->popTempSortVector(&values);
         
-        checkIndexingConsistency(SortConsistencyCheck);
         return;
     }
         
@@ -807,7 +790,6 @@
         
     case ArrayWithArrayStorage: {
         ArrayStorage* storage = m_butterfly->arrayStorage();
-        checkIndexingConsistency();
         
         // FIXME: This ignores exceptions raised in the compare function or in toNumber.
         
@@ -912,7 +894,6 @@
         
         storage->m_numValuesInVector = newUsedVectorLength;
         
-        checkIndexingConsistency(SortConsistencyCheck);
         return;
     }
         
@@ -983,8 +964,6 @@
 {
     ASSERT(!inSparseIndexingMode());
 
-    checkIndexingConsistency();
-    
     switch (structure()->indexingType()) {
     case ArrayClass:
         return 0;
@@ -1040,8 +1019,6 @@
         
         storage->m_numValuesInVector = newUsedVectorLength;
         
-        checkIndexingConsistency(SortConsistencyCheck);
-        
         return numDefined;
     }
         

Modified: trunk/Source/_javascript_Core/runtime/JSArray.h (129178 => 129179)


--- trunk/Source/_javascript_Core/runtime/JSArray.h	2012-09-20 23:38:21 UTC (rev 129178)
+++ trunk/Source/_javascript_Core/runtime/JSArray.h	2012-09-20 23:38:48 UTC (rev 129179)
@@ -51,7 +51,6 @@
         // contents are known at time of creation. Clients of this interface must:
         //   - null-check the result (indicating out of memory, or otherwise unable to allocate vector).
         //   - call 'initializeIndex' for all properties in sequence, for 0 <= i < initialLength.
-        //   - called 'completeInitialization' after all properties have been initialized.
         static JSArray* tryCreateUninitialized(JSGlobalData&, Structure*, unsigned initialLength);
 
         JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, PropertyDescriptor&, bool throwException);
@@ -115,10 +114,6 @@
         storage->m_indexBias = 0;
         storage->m_sparseMap.clear();
         storage->m_numValuesInVector = 0;
-#if CHECK_ARRAY_CONSISTENCY
-        storage->m_initializationIndex = 0;
-        storage->m_inCompactInitialization = 0;
-#endif
         return butterfly;
     }
 
@@ -147,10 +142,6 @@
         storage->m_indexBias = 0;
         storage->m_sparseMap.clear();
         storage->m_numValuesInVector = initialLength;
-#if CHECK_ARRAY_CONSISTENCY
-        storage->m_initializationIndex = 0;
-        storage->m_inCompactInitialization = true;
-#endif
         
         JSArray* array = new (NotNull, allocateCell<JSArray>(globalData.heap)) JSArray(globalData, structure, butterfly);
         array->finishCreation(globalData);
@@ -187,7 +178,6 @@
 
         for (unsigned i = 0; i < length; ++i)
             array->initializeIndex(globalData, i, values.at(i));
-        array->completeInitialization(length);
         return array;
     }
     
@@ -204,7 +194,6 @@
 
         for (unsigned i = 0; i < length; ++i)
             array->initializeIndex(globalData, i, values[i]);
-        array->completeInitialization(length);
         return array;
     }
 

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (129178 => 129179)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2012-09-20 23:38:21 UTC (rev 129178)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2012-09-20 23:38:48 UTC (rev 129179)
@@ -341,7 +341,6 @@
 void JSObject::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool shouldThrow)
 {
     JSObject* thisObject = jsCast<JSObject*>(cell);
-    thisObject->checkIndexingConsistency();
     
     if (propertyName > MAX_ARRAY_INDEX) {
         PutPropertySlot slot(shouldThrow);
@@ -372,7 +371,6 @@
             ++storage->m_numValuesInVector;
         
         valueSlot.set(exec->globalData(), thisObject, value);
-        thisObject->checkIndexingConsistency();
         return;
     }
         
@@ -400,7 +398,6 @@
         }
         
         valueSlot.set(exec->globalData(), thisObject, value);
-        thisObject->checkIndexingConsistency();
         return;
     }
         
@@ -409,7 +406,6 @@
     }
     
     thisObject->putByIndexBeyondVectorLength(exec, propertyName, value, shouldThrow);
-    thisObject->checkIndexingConsistency();
 }
 
 ArrayStorage* JSObject::enterDictionaryIndexingModeWhenArrayStorageAlreadyExists(JSGlobalData& globalData, ArrayStorage* storage)
@@ -485,10 +481,6 @@
     result->m_sparseMap.clear();
     result->m_numValuesInVector = 0;
     result->m_indexBias = 0;
-#if CHECK_ARRAY_CONSISTENCY
-    result->m_initializationIndex = 0;
-    result->m_inCompactInitialization = 0;
-#endif
     Structure* newStructure = Structure::nonPropertyTransition(globalData, structure(), structure()->suggestedIndexingTransition());
     setButterfly(globalData, newButterfly, newStructure);
     return result;
@@ -717,7 +709,6 @@
             }
         }
         
-        thisObject->checkIndexingConsistency();
         return true;
     }
         
@@ -1570,49 +1561,6 @@
     return true;
 }
 
-#if CHECK_ARRAY_CONSISTENCY
-void JSObject::checkIndexingConsistency(ConsistencyCheckType type)
-{
-    ArrayStorage* storage = arrayStorageOrNull();
-    if (!storage)
-        return;
-
-    ASSERT(!storage->m_inCompactInitialization);
-
-    ASSERT(storage);
-    if (type == SortConsistencyCheck)
-        ASSERT(!storage->m_sparseMap);
-
-    unsigned numValuesInVector = 0;
-    for (unsigned i = 0; i < storage->vectorLength(); ++i) {
-        if (JSValue value = storage->m_vector[i].get()) {
-            ASSERT(i < storage->length());
-            if (type != DestructorConsistencyCheck)
-                value.isUndefined(); // Likely to crash if the object was deallocated.
-            ++numValuesInVector;
-        } else {
-            if (type == SortConsistencyCheck)
-                ASSERT(i >= storage->m_numValuesInVector);
-        }
-    }
-    ASSERT(numValuesInVector == storage->m_numValuesInVector);
-    ASSERT(numValuesInVector <= storage->length());
-
-    if (m_sparseValueMap) {
-        SparseArrayValueMap::const_iterator end = m_sparseValueMap->end();
-        for (SparseArrayValueMap::const_iterator it = m_sparseValueMap->begin(); it != end; ++it) {
-            unsigned index = it->first;
-            ASSERT(index < storage->length());
-            ASSERT(index >= storage->vectorLength());
-            ASSERT(index <= MAX_ARRAY_INDEX);
-            ASSERT(it->second);
-            if (type != DestructorConsistencyCheck)
-                it->second.getNonSparseMode().isUndefined(); // Likely to crash if the object was deallocated.
-        }
-    }
-}
-#endif // CHECK_ARRAY_CONSISTENCY
-
 Butterfly* JSObject::growOutOfLineStorage(JSGlobalData& globalData, size_t oldSize, size_t newSize)
 {
     ASSERT(newSize > oldSize);

Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (129178 => 129179)


--- trunk/Source/_javascript_Core/runtime/JSObject.h	2012-09-20 23:38:21 UTC (rev 129178)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h	2012-09-20 23:38:48 UTC (rev 129179)
@@ -259,15 +259,6 @@
             switch (structure()->indexingType()) {
             case ALL_ARRAY_STORAGE_INDEXING_TYPES: {
                 ArrayStorage* storage = m_butterfly->arrayStorage();
-#if CHECK_ARRAY_CONSISTENCY
-                ASSERT(storage->m_inCompactInitialization);
-                // Check that we are initializing the next index in sequence.
-                ASSERT(i == storage->m_initializationIndex);
-                // tryCreateUninitialized set m_numValuesInVector to the initialLength,
-                // check we do not try to initialize more than this number of properties.
-                ASSERT(storage->m_initializationIndex < storage->m_numValuesInVector);
-                storage->m_initializationIndex++;
-#endif
                 ASSERT(i < storage->length());
                 ASSERT(i < storage->m_numValuesInVector);
                 storage->m_vector[i].set(globalData, this, v);
@@ -278,27 +269,6 @@
             }
         }
         
-        void completeInitialization(unsigned newLength)
-        {
-            switch (structure()->indexingType()) {
-            case ALL_ARRAY_STORAGE_INDEXING_TYPES: {
-                ArrayStorage* storage = m_butterfly->arrayStorage();
-                // Check that we have initialized as meny properties as we think we have.
-                UNUSED_PARAM(storage);
-                ASSERT_UNUSED(newLength, newLength == storage->length());
-#if CHECK_ARRAY_CONSISTENCY
-                // Check that the number of propreties initialized matches the initialLength.
-                ASSERT(storage->m_initializationIndex == m_storage->m_numValuesInVector);
-                ASSERT(storage->m_inCompactInitialization);
-                storage->m_inCompactInitialization = false;
-#endif
-                break;
-            }
-            default:
-                ASSERT_NOT_REACHED();
-            }
-        }
-        
         bool inSparseIndexingMode()
         {
             switch (structure()->indexingType()) {
@@ -591,13 +561,6 @@
         
         bool defineOwnNonIndexProperty(ExecState*, PropertyName, PropertyDescriptor&, bool throwException);
 
-        enum ConsistencyCheckType { NormalConsistencyCheck, DestructorConsistencyCheck, SortConsistencyCheck };
-#if !CHECK_ARRAY_CONSISTENCY
-        void checkIndexingConsistency(ConsistencyCheckType = NormalConsistencyCheck) { }
-#else
-        void checkIndexingConsistency(ConsistencyCheckType = NormalConsistencyCheck);
-#endif
-        
         void putByIndexBeyondVectorLengthWithArrayStorage(ExecState*, unsigned propertyName, JSValue, bool shouldThrow, ArrayStorage*);
 
         bool increaseVectorLength(JSGlobalData&, unsigned newLength);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to