Changeset 35807 in webkit for trunk/JavaScriptCore/kjs/JSArray.cpp
- Timestamp:
- Aug 17, 2008, 1:23:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSArray.cpp
r35806 r35807 35 35 36 36 namespace KJS { 37 38 ASSERT_CLASS_FITS_IN_CELL(JSArray); 37 39 38 40 // Overview of JSArray … … 129 131 unsigned initialCapacity = min(initialLength, MIN_SPARSE_ARRAY_INDEX); 130 132 131 m_ length = initialLength;133 m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity))); 132 134 m_fastAccessCutoff = 0; 133 m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));134 135 m_storage->m_vectorLength = initialCapacity; 136 m_storage->m_length = initialLength; 135 137 136 138 Heap::heap(this)->reportExtraMemoryCost(initialCapacity * sizeof(JSValue*)); … … 144 146 unsigned length = list.size(); 145 147 146 m_length = length;147 148 m_fastAccessCutoff = length; 148 149 … … 152 153 storage->m_numValuesInVector = length; 153 154 storage->m_sparseValueMap = 0; 155 storage->m_length = length; 154 156 155 157 size_t i = 0; … … 178 180 ArrayStorage* storage = m_storage; 179 181 180 if (i >= m_length) {182 if (i >= storage->m_length) { 181 183 if (i > MAX_ARRAY_INDEX) 182 184 return getOwnPropertySlot(exec, Identifier::from(exec, i), slot); … … 206 208 { 207 209 if (propertyName == exec->propertyNames().length) { 208 slot.setValue(jsNumber(exec, getLength()));210 slot.setValue(jsNumber(exec, length())); 209 211 return true; 210 212 } … … 245 247 checkConsistency(); 246 248 247 unsigned length = m_ length;249 unsigned length = m_storage->m_length; 248 250 if (i >= length && i <= MAX_ARRAY_INDEX) { 249 251 length = i + 1; 250 m_ length = length;252 m_storage->m_length = length; 251 253 } 252 254 … … 259 261 } 260 262 valueSlot = value; 261 if (++m_storage->m_numValuesInVector == m_ length)262 m_fastAccessCutoff = m_ length;263 if (++m_storage->m_numValuesInVector == m_storage->m_length) 264 m_fastAccessCutoff = m_storage->m_length; 263 265 checkConsistency(); 264 266 return; … … 414 416 ArrayStorage* storage = m_storage; 415 417 416 unsigned usedVectorLength = min( m_length, storage->m_vectorLength);418 unsigned usedVectorLength = min(storage->m_length, storage->m_vectorLength); 417 419 for (unsigned i = 0; i < usedVectorLength; ++i) { 418 420 if (storage->m_vector[i]) … … 460 462 ArrayStorage* storage = m_storage; 461 463 462 unsigned length = m_ length;464 unsigned length = m_storage->m_length; 463 465 464 466 if (newLength < length) { … … 488 490 } 489 491 490 m_ length = newLength;492 m_storage->m_length = newLength; 491 493 492 494 checkConsistency(); … … 499 501 ArrayStorage* storage = m_storage; 500 502 501 unsigned usedVectorLength = min( m_length, storage->m_vectorLength);503 unsigned usedVectorLength = min(storage->m_length, storage->m_vectorLength); 502 504 for (unsigned i = 0; i < usedVectorLength; ++i) { 503 505 JSValue* value = storage->m_vector[i]; … … 662 664 // The maximum tree depth is compiled in - but the caller is clearly up to no good 663 665 // if a larger array is passed. 664 ASSERT(m_ length <= static_cast<unsigned>(std::numeric_limits<int>::max()));665 if (m_ length > static_cast<unsigned>(std::numeric_limits<int>::max()))666 return; 667 668 if (!m_ length)669 return; 670 671 unsigned usedVectorLength = min(m_ length, m_storage->m_vectorLength);666 ASSERT(m_storage->m_length <= static_cast<unsigned>(std::numeric_limits<int>::max())); 667 if (m_storage->m_length > static_cast<unsigned>(std::numeric_limits<int>::max())) 668 return; 669 670 if (!m_storage->m_length) 671 return; 672 673 unsigned usedVectorLength = min(m_storage->m_length, m_storage->m_vectorLength); 672 674 673 675 AVLTree<AVLTreeAbstractorForArrayCompare, 44> tree; // Depth 44 is enough for 2^31 items … … 766 768 ArrayStorage* storage = m_storage; 767 769 768 unsigned usedVectorLength = min(m_ length, storage->m_vectorLength);770 unsigned usedVectorLength = min(m_storage->m_length, storage->m_vectorLength); 769 771 770 772 unsigned numDefined = 0; … … 836 838 ASSERT(!m_storage->m_sparseValueMap); 837 839 838 ASSERT(m_fastAccessCutoff <= m_ length);840 ASSERT(m_fastAccessCutoff <= m_storage->m_length); 839 841 ASSERT(m_fastAccessCutoff <= m_storage->m_numValuesInVector); 840 842 … … 842 844 for (unsigned i = 0; i < m_storage->m_vectorLength; ++i) { 843 845 if (JSValue* value = m_storage->m_vector[i]) { 844 ASSERT(i < m_ length);846 ASSERT(i < m_storage->m_length); 845 847 if (type != DestructorConsistencyCheck) 846 848 value->type(); // Likely to crash if the object was deallocated. … … 858 860 for (SparseArrayValueMap::iterator it = m_storage->m_sparseValueMap->begin(); it != end; ++it) { 859 861 unsigned index = it->first; 860 ASSERT(index < m_ length);862 ASSERT(index < m_storage->m_length); 861 863 ASSERT(index >= m_storage->m_vectorLength); 862 864 ASSERT(index <= MAX_ARRAY_INDEX);
Note:
See TracChangeset
for help on using the changeset viewer.