Changeset 63268 in webkit for trunk/JavaScriptCore/runtime/JSArray.cpp
- Timestamp:
- Jul 13, 2010, 5:29:32 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSArray.cpp
r62677 r63268 33 33 #include <wtf/OwnPtr.h> 34 34 #include <Operations.h> 35 36 #define CHECK_ARRAY_CONSISTENCY 037 35 38 36 using namespace std; … … 142 140 } 143 141 144 JSArray::JSArray(NonNullPassRefPtr<Structure> structure, unsigned initialLength )142 JSArray::JSArray(NonNullPassRefPtr<Structure> structure, unsigned initialLength, ArrayCreationMode creationMode) 145 143 : JSObject(structure) 146 144 { 147 unsigned initialCapacity = min(initialLength, MIN_SPARSE_ARRAY_INDEX); 145 unsigned initialCapacity; 146 if (creationMode == CreateCompact) 147 initialCapacity = initialLength; 148 else 149 initialCapacity = min(initialLength, MIN_SPARSE_ARRAY_INDEX); 148 150 149 151 m_storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialCapacity))); 150 m_storage->m_length = initialLength;151 152 m_vectorLength = initialCapacity; 152 m_storage->m_numValuesInVector = 0;153 153 m_storage->m_sparseValueMap = 0; 154 154 m_storage->subclassData = 0; 155 155 m_storage->reportedMapCapacity = 0; 156 156 157 JSValue* vector = m_storage->m_vector; 158 for (size_t i = 0; i < initialCapacity; ++i) 159 vector[i] = JSValue(); 157 if (creationMode == CreateCompact) { 158 #if CHECK_ARRAY_CONSISTENCY 159 m_storage->m_inCompactInitialization = !!initialCapacity; 160 #endif 161 m_storage->m_length = 0; 162 m_storage->m_numValuesInVector = initialCapacity; 163 } else { 164 #if CHECK_ARRAY_CONSISTENCY 165 m_storage->m_inCompactInitialization = false; 166 #endif 167 m_storage->m_length = initialLength; 168 m_storage->m_numValuesInVector = 0; 169 JSValue* vector = m_storage->m_vector; 170 for (size_t i = 0; i < initialCapacity; ++i) 171 vector[i] = JSValue(); 172 } 160 173 161 174 checkConsistency(); … … 176 189 m_storage->subclassData = 0; 177 190 m_storage->reportedMapCapacity = 0; 191 #if CHECK_ARRAY_CONSISTENCY 192 m_storage->m_inCompactInitialization = false; 193 #endif 178 194 179 195 size_t i = 0; … … 525 541 void JSArray::setLength(unsigned newLength) 526 542 { 527 checkConsistency(); 543 #if CHECK_ARRAY_CONSISTENCY 544 if (!m_storage->m_inCompactInitialization) 545 checkConsistency(); 546 else 547 m_storage->m_inCompactInitialization = false; 548 #endif 528 549 529 550 ArrayStorage* storage = m_storage; … … 1046 1067 ASSERT(i < m_storage->m_length); 1047 1068 if (type != DestructorConsistencyCheck) 1048 value ->type(); // Likely to crash if the object was deallocated.1069 value.isUndefined(); // Likely to crash if the object was deallocated. 1049 1070 ++numValuesInVector; 1050 1071 } else { … … 1065 1086 ASSERT(it->second); 1066 1087 if (type != DestructorConsistencyCheck) 1067 it->second ->type(); // Likely to crash if the object was deallocated.1088 it->second.isUndefined(); // Likely to crash if the object was deallocated. 1068 1089 } 1069 1090 }
Note:
See TracChangeset
for help on using the changeset viewer.