Commit 658e5ebd authored by fpizlo@apple.com's avatar fpizlo@apple.com

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):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129179 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 404e130b
2012-09-20 Filip Pizlo <fpizlo@apple.com>
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 <mark.lam@apple.com>
Fixed a missing semicolon in the C++ llint backend.
......
......@@ -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:
......
......@@ -730,7 +730,6 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec)
return JSValue::encode(jsUndefined());
resObj->initializeIndex(globalData, k, v);
}
resObj->completeInitialization(deleteCount);
unsigned additionalArgs = std::max<int>(exec->argumentCount() - 2, 0);
if (additionalArgs < deleteCount) {
......
......@@ -64,10 +64,6 @@ public:
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 @@ public:
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];
......
......@@ -193,7 +193,6 @@ EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState* exec)
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.
......
......@@ -60,10 +60,6 @@ Butterfly* createArrayButterflyInDictionaryIndexingMode(JSGlobalData& globalData
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::unshiftCountSlowCase(JSGlobalData& globalData, unsigned count)
bool JSArray::setLength(ExecState* exec, unsigned newLength, bool throwException)
{
checkIndexingConsistency();
ArrayStorage* storage = ensureArrayStorage(exec->globalData());
unsigned length = storage->length();
......@@ -392,14 +386,11 @@ bool JSArray::setLength(ExecState* exec, unsigned newLength, bool throwException
storage->setLength(newLength);
checkIndexingConsistency();
return true;
}
JSValue JSArray::pop(ExecState* exec)
{
checkIndexingConsistency();
switch (structure()->indexingType()) {
case ArrayClass:
return jsUndefined();
......@@ -424,7 +415,6 @@ JSValue JSArray::pop(ExecState* exec)
ASSERT(isLengthWritable());
storage->setLength(index);
checkIndexingConsistency();
return element;
}
}
......@@ -441,7 +431,6 @@ JSValue JSArray::pop(ExecState* exec)
// 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 @@ JSValue JSArray::pop(ExecState* exec)
// - 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 @@ void JSArray::push(ExecState* exec, JSValue value)
storage->m_vector[length].set(exec->globalData(), this, value);
storage->setLength(length + 1);
++storage->m_numValuesInVector;
checkIndexingConsistency();
return;
}
......@@ -498,7 +484,6 @@ void JSArray::push(ExecState* exec, JSValue value)
// Handled the same as putIndex.
putByIndexBeyondVectorLengthWithArrayStorage(exec, storage->length(), value, true, storage);
checkIndexingConsistency();
break;
}
......@@ -622,7 +607,6 @@ void JSArray::sortNumeric(ExecState* exec, JSValue compareFunction, CallType cal
// 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 @@ void JSArray::sort(ExecState* exec)
Heap::heap(this)->popTempSortVector(&values);
checkIndexingConsistency(SortConsistencyCheck);
return;
}
......@@ -807,7 +790,6 @@ void JSArray::sort(ExecState* exec, JSValue compareFunction, CallType callType,
case ArrayWithArrayStorage: {
ArrayStorage* storage = m_butterfly->arrayStorage();
checkIndexingConsistency();
// FIXME: This ignores exceptions raised in the compare function or in toNumber.
......@@ -912,7 +894,6 @@ void JSArray::sort(ExecState* exec, JSValue compareFunction, CallType callType,
storage->m_numValuesInVector = newUsedVectorLength;
checkIndexingConsistency(SortConsistencyCheck);
return;
}
......@@ -983,8 +964,6 @@ unsigned JSArray::compactForSorting(JSGlobalData& globalData)
{
ASSERT(!inSparseIndexingMode());
checkIndexingConsistency();
switch (structure()->indexingType()) {
case ArrayClass:
return 0;
......@@ -1040,8 +1019,6 @@ unsigned JSArray::compactForSorting(JSGlobalData& globalData)
storage->m_numValuesInVector = newUsedVectorLength;
checkIndexingConsistency(SortConsistencyCheck);
return numDefined;
}
......
......@@ -51,7 +51,6 @@ namespace JSC {
// 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 @@ namespace JSC {
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 @@ namespace JSC {
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 @@ namespace JSC {
for (unsigned i = 0; i < length; ++i)
array->initializeIndex(globalData, i, values.at(i));
array->completeInitialization(length);
return array;
}
......@@ -204,7 +194,6 @@ namespace JSC {
for (unsigned i = 0; i < length; ++i)
array->initializeIndex(globalData, i, values[i]);
array->completeInitialization(length);
return array;
}
......
......@@ -341,7 +341,6 @@ void JSObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSV
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 @@ void JSObject::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName,
++storage->m_numValuesInVector;
valueSlot.set(exec->globalData(), thisObject, value);
thisObject->checkIndexingConsistency();
return;
}
......@@ -400,7 +398,6 @@ void JSObject::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName,
}
valueSlot.set(exec->globalData(), thisObject, value);
thisObject->checkIndexingConsistency();
return;
}
......@@ -409,7 +406,6 @@ void JSObject::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName,
}
thisObject->putByIndexBeyondVectorLength(exec, propertyName, value, shouldThrow);
thisObject->checkIndexingConsistency();
}
ArrayStorage* JSObject::enterDictionaryIndexingModeWhenArrayStorageAlreadyExists(JSGlobalData& globalData, ArrayStorage* storage)
......@@ -485,10 +481,6 @@ ArrayStorage* JSObject::createArrayStorage(JSGlobalData& globalData, unsigned le
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 @@ bool JSObject::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned i)
}
}
thisObject->checkIndexingConsistency();
return true;
}
......@@ -1570,49 +1561,6 @@ bool JSObject::increaseVectorLength(JSGlobalData& globalData, unsigned newLength
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);
......
......@@ -259,15 +259,6 @@ namespace JSC {
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 @@ namespace JSC {
}
}
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 @@ namespace JSC {
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment