-}
-
-#endif
-
-JSArray::JSArray(VPtrStealingHackType)
- : JSNonFinalObject(VPtrStealingHack)
-{
-}
-
-JSArray::JSArray(JSGlobalData& globalData, Structure* structure)
- : JSNonFinalObject(globalData, structure)
-{
- ASSERT(inherits(&s_info));
-
- unsigned initialCapacity = 0;
-
- m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
- m_storage->m_allocBase = m_storage;
- m_indexBias = 0;
- m_vectorLength = initialCapacity;
-
- checkConsistency();
-
- Heap::heap(this)->reportExtraMemoryCost(storageSize(0));
-}
-
-JSArray::JSArray(JSGlobalData& globalData, Structure* structure, unsigned initialLength, ArrayCreationMode creationMode)
- : JSNonFinalObject(globalData, structure)
-{
- ASSERT(inherits(&s_info));
-
- unsigned initialCapacity;
- if (creationMode == CreateCompact)
- initialCapacity = initialLength;
- else
- initialCapacity = min(BASE_VECTOR_LEN, MIN_SPARSE_ARRAY_INDEX);
-
- m_storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialCapacity)));
- m_storage->m_allocBase = m_storage;
- m_storage->m_length = initialLength;
- m_indexBias = 0;
- m_vectorLength = initialCapacity;
- m_storage->m_sparseValueMap = 0;
- m_storage->subclassData = 0;
- m_storage->reportedMapCapacity = 0;
-
- if (creationMode == CreateCompact) {
-#if CHECK_ARRAY_CONSISTENCY
- m_storage->m_inCompactInitialization = !!initialCapacity;
-#endif
- m_storage->m_length = 0;
- m_storage->m_numValuesInVector = initialCapacity;
- } else {
-#if CHECK_ARRAY_CONSISTENCY
- storage->m_inCompactInitialization = false;
-#endif
- m_storage->m_length = initialLength;
- m_storage->m_numValuesInVector = 0;
- WriteBarrier<Unknown>* vector = m_storage->m_vector;
- for (size_t i = 0; i < initialCapacity; ++i)
- vector[i].clear();
- }
-
- checkConsistency();
-
- Heap::heap(this)->reportExtraMemoryCost(storageSize(initialCapacity));
-}
-
-JSArray::JSArray(JSGlobalData& globalData, Structure* structure, const ArgList& list)
- : JSNonFinalObject(globalData, structure)
-{
- ASSERT(inherits(&s_info));
-
- unsigned initialCapacity = list.size();
- unsigned initialStorage;
-
- // If the ArgList is empty, allocate space for 3 entries. This value empirically
- // works well for benchmarks.
- if (!initialCapacity)
- initialStorage = 3;
- else
- initialStorage = initialCapacity;
-
- m_storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialStorage)));
- m_storage->m_allocBase = m_storage;
- m_indexBias = 0;
- m_storage->m_length = initialCapacity;
- m_vectorLength = initialStorage;
- m_storage->m_numValuesInVector = initialCapacity;
- m_storage->m_sparseValueMap = 0;
- m_storage->subclassData = 0;
- m_storage->reportedMapCapacity = 0;
-#if CHECK_ARRAY_CONSISTENCY
- m_storage->m_inCompactInitialization = false;
-#endif
-
- size_t i = 0;
- WriteBarrier<Unknown>* vector = m_storage->m_vector;
- ArgList::const_iterator end = list.end();
- for (ArgList::const_iterator it = list.begin(); it != end; ++it, ++i)
- vector[i].set(globalData, this, *it);
- for (; i < initialStorage; i++)
- vector[i].clear();
-
- checkConsistency();
-
- Heap::heap(this)->reportExtraMemoryCost(storageSize(initialStorage));
-}