| 1 | /* |
| 2 | * Copyright (C) 1999-2000 Harri Porten ([email protected]) |
| 3 | * Copyright (C) 2003, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 4 | * Copyright (C) 2003 Peter Kelly ([email protected]) |
| 5 | * Copyright (C) 2006 Alexey Proskuryakov ([email protected]) |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include "config.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/config.h`/ |
| 24 | #include "JSArray.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.h`/ |
| 25 | |
| 26 | #include "ArrayPrototype.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayPrototype.h`/ |
| 27 | #include "CachedCall.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/CachedCall.h`/ |
| 28 | #include "Error.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Error.h`/ |
| 29 | #include "Executable.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Executable.h`/ |
| 30 | #include "PropertyNameArray.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PropertyNameArray.h`/ |
| 31 | #include <wtf/AVLTree.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/AVLTree.h`/ |
| 32 | #include <wtf/Assertions.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h`/ |
| 33 | #include <wtf/OwnPtr.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/OwnPtr.h`/ |
| 34 | #include <Operations.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Operations.h`/ |
| 35 | |
| 36 | #define CHECK_ARRAY_CONSISTENCYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:36:9`! 0 |
| 37 | |
| 38 | using namespace std; |
| 39 | using namespace WTFcxx . . $ `<built-in>:467:9`!; |
| 40 | |
| 41 | namespace JSCcxx . . $ `<built-in>:463:9`! { |
| 42 | |
| 43 | ASSERT_CLASS_FITS_IN_CELLcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h:42:9`!(JSArray); |
| 44 | |
| 45 | // Overview of JSArray |
| 46 | // |
| 47 | // Properties of JSArray objects may be stored in one of three locations: |
| 48 | // * The regular JSObject property map. |
| 49 | // * A storage vector. |
| 50 | // * A sparse map of array entries. |
| 51 | // |
| 52 | // Properties with non-numeric identifiers, with identifiers that are not representable |
| 53 | // as an unsigned integer, or where the value is greater than MAX_ARRAY_INDEX |
| 54 | // (specifically, this is only one property - the value 0xFFFFFFFFU as an unsigned 32-bit |
| 55 | // integer) are not considered array indices and will be stored in the JSObject property map. |
| 56 | // |
| 57 | // All properties with a numeric identifer, representable as an unsigned integer i, |
| 58 | // where (i <= MAX_ARRAY_INDEX), are an array index and will be stored in either the |
| 59 | // storage vector or the sparse map. An array index i will be handled in the following |
| 60 | // fashion: |
| 61 | // |
| 62 | // * Where (i < MIN_SPARSE_ARRAY_INDEX) the value will be stored in the storage vector. |
| 63 | // * Where (MIN_SPARSE_ARRAY_INDEX <= i <= MAX_STORAGE_VECTOR_INDEX) the value will either |
| 64 | // be stored in the storage vector or in the sparse array, depending on the density of |
| 65 | // data that would be stored in the vector (a vector being used where at least |
| 66 | // (1 / minDensityMultiplier) of the entries would be populated). |
| 67 | // * Where (MAX_STORAGE_VECTOR_INDEX < i <= MAX_ARRAY_INDEX) the value will always be stored |
| 68 | // in the sparse array. |
| 69 | |
| 70 | // The definition of MAX_STORAGE_VECTOR_LENGTH is dependant on the definition storageSize |
| 71 | // function below - the MAX_STORAGE_VECTOR_LENGTH limit is defined such that the storage |
| 72 | // size calculation cannot overflow. (sizeof(ArrayStorage) - sizeof(JSValue)) + |
| 73 | // (vectorLength * sizeof(JSValue)) must be <= 0xFFFFFFFFU (which is maximum value of size_t). |
| 74 | #define MAX_STORAGE_VECTOR_LENGTHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:74:9`! static_cast<unsigned>((0xFFFFFFFFU - (sizeof(ArrayStorage) - sizeof(JSValue))) / sizeof(JSValue)) |
| 75 | |
| 76 | // These values have to be macros to be used in max() and min() without introducing |
| 77 | // a PIC branch in Mach-O binaries, see <rdar://problem/5971391>. |
| 78 | #define MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`! 10000U |
| 79 | #define MAX_STORAGE_VECTOR_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:79:9`! (MAX_STORAGE_VECTOR_LENGTHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:74:9`! - 1) |
| 80 | // 0xFFFFFFFF is a bit weird -- is not an array index even though it's an integer. |
| 81 | #define MAX_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:81:9`! 0xFFFFFFFEU |
| 82 | |
| 83 | // Our policy for when to use a vector and when to use a sparse map. |
| 84 | // For all array indices under MIN_SPARSE_ARRAY_INDEX, we always use a vector. |
| 85 | // When indices greater than MIN_SPARSE_ARRAY_INDEX are involved, we use a vector |
| 86 | // as long as it is 1/8 full. If more sparse than that, we use a map. |
| 87 | static const unsigned minDensityMultipliercxx . . $ QTJSC/minDensityMultiplier. = 8; |
| 88 | |
| 89 | const ClassInfocxx . . $ QTJSC/ClassInfo# JSArraycxx . . $ QTJSC/JSArray#::infocxx . . $ QTJSC/JSArray#info. = {"Array", 0, 0, 0}; |
| 90 | |
| 91 | static inline size_tcxx . . $ size_t# storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(unsigned vectorLength) |
| 92 | { |
| 93 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(vectorLength <= MAX_STORAGE_VECTOR_LENGTH); |
| 94 | |
| 95 | // MAX_STORAGE_VECTOR_LENGTH is defined such that provided (vectorLength <= MAX_STORAGE_VECTOR_LENGTH) |
| 96 | // - as asserted above - the following calculation cannot overflow. |
| 97 | size_tcxx . . $ size_t# size = (sizeof(ArrayStoragecxx . . $ QTJSC/ArrayStorage#) - sizeof(JSValuecxx . . $ QTJSC/JSValue#)) + (vectorLength * sizeof(JSValuecxx . . $ QTJSC/JSValue#)); |
| 98 | // Assertion to detect integer overflow in previous calculation (should not be possible, provided that |
| 99 | // MAX_STORAGE_VECTOR_LENGTH is correctly defined). |
| 100 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(((size - (sizeof(ArrayStorage) - sizeof(JSValue))) / sizeof(JSValue) == vectorLength) && (size >= (sizeof(ArrayStorage) - sizeof(JSValue)))); |
| 101 | |
| 102 | return size; |
| 103 | } |
| 104 | |
| 105 | static inline unsigned increasedVectorLengthcxx . . $ QTJSC/increasedVectorLength(2141b656ce2cc063).(unsigned newLength) |
| 106 | { |
| 107 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(newLength <= MAX_STORAGE_VECTOR_LENGTH); |
| 108 | |
| 109 | // Mathematically equivalent to: |
| 110 | // increasedLength = (newLength * 3 + 1) / 2; |
| 111 | // or: |
| 112 | // increasedLength = (unsigned)ceil(newLength * 1.5)); |
| 113 | // This form is not prone to internal overflow. |
| 114 | unsigned increasedLength = newLength + (newLength >> 1) + (newLength & 1); |
| 115 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(increasedLength >= newLength); |
| 116 | |
| 117 | return mincxx . . $ std/min(2a338fce5842aa6a).(increasedLength, MAX_STORAGE_VECTOR_LENGTHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:74:9`!); |
| 118 | } |
| 119 | |
| 120 | static inline bool isDenseEnoughForVectorcxx . . $ QTJSC/isDenseEnoughForVector(8e1b545ea3aecce3).(unsigned length, unsigned numValues) |
| 121 | { |
| 122 | return length / minDensityMultipliercxx . . $ QTJSC/minDensityMultiplier. <= numValues; |
| 123 | } |
| 124 | |
| 125 | #if !CHECK_ARRAY_CONSISTENCYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:36:9`! |
| 126 | |
| 127 | inline void JSArraycxx . . $ QTJSC/JSArray#::checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(ConsistencyCheckTypecxx . . $ QTJSC/JSArray#ConsistencyCheckType#) |
| 128 | { |
| 129 | } |
| 130 | |
| 131 | #endif |
| 132 | |
| 133 | JSArraycxx . . $ QTJSC/JSArray#::JSArraycxx . . $ QTJSC/JSArray#JSArray(9678d77265d996b).(NonNullPassRefPtrcxx . . $ NonNullPassRefPtr#<Structurecxx . . $ QTJSC/Structure#> structure) |
| 134 | : JSObjectcxx . . $ QTJSC/JSObject#(structure) |
| 135 | { |
| 136 | unsigned initialCapacity = 0; |
| 137 | |
| 138 | m_storagecxx . . $ QTJSC/JSArray#m_storage. = static_cast<ArrayStoragecxx . . $ QTJSC/ArrayStorage#*>(fastZeroedMalloccxx . . $ fastZeroedMalloc(bfcfa4d6b7f7ef64).(storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(initialCapacity))); |
| 139 | m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength. = initialCapacity; |
| 140 | |
| 141 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 142 | } |
| 143 | |
| 144 | JSArraycxx . . $ QTJSC/JSArray#::JSArraycxx . . $ QTJSC/JSArray#JSArray(ead898eaba3ad86d).(NonNullPassRefPtrcxx . . $ NonNullPassRefPtr#<Structurecxx . . $ QTJSC/Structure#> structure, unsigned initialLength) |
| 145 | : JSObjectcxx . . $ QTJSC/JSObject#(structure) |
| 146 | { |
| 147 | unsigned initialCapacity = mincxx . . $ std/min(2a338fce5842aa6a).(initialLength, MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!); |
| 148 | |
| 149 | m_storagecxx . . $ QTJSC/JSArray#m_storage. = static_cast<ArrayStoragecxx . . $ QTJSC/ArrayStorage#*>(fastMalloccxx . . $ fastMalloc(bfcfa4d6b7f7ef64).(storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(initialCapacity))); |
| 150 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length. = initialLength; |
| 151 | m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength. = initialCapacity; |
| 152 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector. = 0; |
| 153 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap. = 0; |
| 154 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->lazyCreationDatacxx . . $ QTJSC/ArrayStorage#lazyCreationData. = 0; |
| 155 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->reportedMapCapacitycxx . . $ QTJSC/ArrayStorage#reportedMapCapacity. = 0; |
| 156 | |
| 157 | JSValuecxx . . $ QTJSC/JSValue#* vector = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.; |
| 158 | for (size_tcxx . . $ size_t# i = 0; i < initialCapacity; ++i) |
| 159 | vector[i] =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). JSValuecxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).(); |
| 160 | |
| 161 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 162 | |
| 163 | Heapcxx . . $ QTJSC/Heap#::heapcxx . . $ QTJSC/Heap#heap(4163b73911f9bcad).(this)->reportExtraMemoryCostcxx . . $ QTJSC/Heap#reportExtraMemoryCost(2c44cd906ae4e829).(initialCapacity * sizeof(JSValuecxx . . $ QTJSC/JSValue#)); |
| 164 | } |
| 165 | |
| 166 | JSArraycxx . . $ QTJSC/JSArray#::JSArraycxx . . $ QTJSC/JSArray#JSArray(38f0b54a35ef9cab).(NonNullPassRefPtrcxx . . $ NonNullPassRefPtr#<Structurecxx . . $ QTJSC/Structure#> structure, const ArgListcxx . . $ QTJSC/ArgList#& list) |
| 167 | : JSObjectcxx . . $ QTJSC/JSObject#(structure) |
| 168 | { |
| 169 | unsigned initialCapacity = list.sizecxx . . $ QTJSC/ArgList#size(fe4d2d262d4164a8).(); |
| 170 | |
| 171 | m_storagecxx . . $ QTJSC/JSArray#m_storage. = static_cast<ArrayStoragecxx . . $ QTJSC/ArrayStorage#*>(fastMalloccxx . . $ fastMalloc(bfcfa4d6b7f7ef64).(storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(initialCapacity))); |
| 172 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length. = initialCapacity; |
| 173 | m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength. = initialCapacity; |
| 174 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector. = initialCapacity; |
| 175 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap. = 0; |
| 176 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->lazyCreationDatacxx . . $ QTJSC/ArrayStorage#lazyCreationData. = 0; |
| 177 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->reportedMapCapacitycxx . . $ QTJSC/ArrayStorage#reportedMapCapacity. = 0; |
| 178 | |
| 179 | size_tcxx . . $ size_t# i = 0; |
| 180 | ArgListcxx . . $ QTJSC/ArgList#::const_iteratorcxx . . $ QTJSC/ArgList#const_iterator# end = list.endcxx . . $ QTJSC/ArgList#end(6314d561bd93d1d).(); |
| 181 | for (ArgListcxx . . $ QTJSC/ArgList#::const_iteratorcxx . . $ QTJSC/ArgList#const_iterator# it = list.begincxx . . $ QTJSC/ArgList#begin(6314d561bd93d1d).(); it != end; ++it, ++i) |
| 182 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i] =cxx . . $ QTJSC/JSValue#`operator=`(af0e8a528f82a1b5). *it; |
| 183 | |
| 184 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 185 | |
| 186 | Heapcxx . . $ QTJSC/Heap#::heapcxx . . $ QTJSC/Heap#heap(4163b73911f9bcad).(this)->reportExtraMemoryCostcxx . . $ QTJSC/Heap#reportExtraMemoryCost(2c44cd906ae4e829).(storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(initialCapacity)); |
| 187 | } |
| 188 | |
| 189 | JSArraycxx . . $ QTJSC/JSArray#::~cxx . . $ QTJSC/JSArray#`~JSArray`(49f6e7a06ebc5aa8).JSArraycxx . . $ QTJSC/JSArray#() |
| 190 | { |
| 191 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(vptr() == JSGlobalData::jsArrayVPtr); |
| 192 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(DestructorConsistencyCheckcxx . . $ QTJSC/JSArray#DestructorConsistencyCheck.); |
| 193 | |
| 194 | delete m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.; |
| 195 | fastFreecxx . . $ fastFree(5d22bdacc48458e8).(m_storagecxx . . $ QTJSC/JSArray#m_storage.); |
| 196 | } |
| 197 | |
| 198 | bool JSArraycxx . . $ QTJSC/JSArray#::getOwnPropertySlotcxx . . $ QTJSC/JSArray#getOwnPropertySlot(d57d1c8d4b24d235).(ExecStatecxx . . $ QTJSC/ExecState#* exec, unsigned i, PropertySlotcxx . . $ QTJSC/PropertySlot#& slot) |
| 199 | { |
| 200 | ArrayStoragecxx . . $ QTJSC/ArrayStorage#* storage = m_storagecxx . . $ QTJSC/JSArray#m_storage.; |
| 201 | |
| 202 | if (i >= storage->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.) { |
| 203 | if (i > MAX_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:81:9`!) |
| 204 | return getOwnPropertySlotcxx . . $ QTJSC/JSArray#getOwnPropertySlot(6f4ef3dbfe7d5ab9).(exec, Identifiercxx . . $ QTJSC/Identifier#::fromcxx . . $ QTJSC/Identifier#from(d1afedae20629715).(exec, i), slot); |
| 205 | return false; |
| 206 | } |
| 207 | |
| 208 | if (i < m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.) { |
| 209 | JSValuecxx . . $ QTJSC/JSValue#& valueSlot = storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i]; |
| 210 | if (valueSlot) { |
| 211 | slot.setValueSlotcxx . . $ QTJSC/PropertySlot#setValueSlot(1b789a609c0b4a9).(&valueSlot); |
| 212 | return true; |
| 213 | } |
| 214 | } else if (SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#* map = storage->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.) { |
| 215 | if (i >= MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!) { |
| 216 | SparseArrayValueMap::iterator it = map->find(i); |
| 217 | if (it !=cxx . . $ QTJSC/`operator!=`(8208a731c2dadbc2). map->end()) { |
| 218 | slot.setValueSlotcxx . . $ QTJSC/PropertySlot#setValueSlot(1b789a609c0b4a9).(&cxx . . $ std/`operator&`(3fbb01592cd53f2a).it->second); |
| 219 | return true; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | return JSObjectcxx . . $ QTJSC/JSObject#::getOwnPropertySlotcxx . . $ QTJSC/JSArray#getOwnPropertySlot(6f4ef3dbfe7d5ab9).(exec, Identifiercxx . . $ QTJSC/Identifier#::fromcxx . . $ QTJSC/Identifier#from(d1afedae20629715).(exec, i), slot); |
| 225 | } |
| 226 | |
| 227 | bool JSArraycxx . . $ QTJSC/JSArray#::getOwnPropertySlotcxx . . $ QTJSC/JSArray#getOwnPropertySlot(6f4ef3dbfe7d5ab9).(ExecStatecxx . . $ QTJSC/ExecState#* exec, const Identifiercxx . . $ QTJSC/Identifier#& propertyName, PropertySlotcxx . . $ QTJSC/PropertySlot#& slot) |
| 228 | { |
| 229 | if (propertyName ==cxx . . $ QTJSC/`operator==`(8208a731c2dadbc2). exec->propertyNamescxx . . $ QTJSC/ExecState#propertyNames(16296db726e31f87).().length) { |
| 230 | slot.setValuecxx . . $ QTJSC/PropertySlot#setValue(5c2ac18db087b3e6).(jsNumbercxx . . $ QTJSC/jsNumber(bf7e02f8c8245e31).(exec, lengthcxx . . $ QTJSC/JSArray#length(ddd8539a2fcdd4ce).())); |
| 231 | return true; |
| 232 | } |
| 233 | |
| 234 | bool isArrayIndex; |
| 235 | unsigned i = propertyName.toArrayIndexcxx . . $ QTJSC/Identifier#toArrayIndex(870b63f89c7fb98).(&isArrayIndex); |
| 236 | if (isArrayIndex) |
| 237 | return JSArraycxx . . $ QTJSC/JSArray#::getOwnPropertySlotcxx . . $ QTJSC/JSArray#getOwnPropertySlot(d57d1c8d4b24d235).(exec, i, slot); |
| 238 | |
| 239 | return JSObjectcxx . . $ QTJSC/JSObject#::getOwnPropertySlotcxx . . $ QTJSC/JSArray#getOwnPropertySlot(6f4ef3dbfe7d5ab9).(exec, propertyName, slot); |
| 240 | } |
| 241 | |
| 242 | bool JSArraycxx . . $ QTJSC/JSArray#::getOwnPropertyDescriptorcxx . . $ QTJSC/JSArray#getOwnPropertyDescriptor(dce4ef7012294c32).(ExecStatecxx . . $ QTJSC/ExecState#* exec, const Identifiercxx . . $ QTJSC/Identifier#& propertyName, PropertyDescriptorcxx . . $ QTJSC/PropertyDescriptor#& descriptor) |
| 243 | { |
| 244 | if (propertyName ==cxx . . $ QTJSC/`operator==`(8208a731c2dadbc2). exec->propertyNamescxx . . $ QTJSC/ExecState#propertyNames(16296db726e31f87).().length) { |
| 245 | descriptor.setDescriptorcxx . . $ QTJSC/PropertyDescriptor#setDescriptor(48358939f851dacc).(jsNumbercxx . . $ QTJSC/jsNumber(bf7e02f8c8245e31).(exec, lengthcxx . . $ QTJSC/JSArray#length(ddd8539a2fcdd4ce).()), DontDeletecxx . . $ QTJSC/DontDelete. | DontEnumcxx . . $ QTJSC/DontEnum.); |
| 246 | return true; |
| 247 | } |
| 248 | |
| 249 | bool isArrayIndex; |
| 250 | unsigned i = propertyName.toArrayIndexcxx . . $ QTJSC/Identifier#toArrayIndex(870b63f89c7fb98).(&isArrayIndex); |
| 251 | if (isArrayIndex) { |
| 252 | if (i >= m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.) |
| 253 | return false; |
| 254 | if (i < m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.) { |
| 255 | JSValuecxx . . $ QTJSC/JSValue#& value = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i]; |
| 256 | if (value) { |
| 257 | descriptor.setDescriptorcxx . . $ QTJSC/PropertyDescriptor#setDescriptor(48358939f851dacc).(value, 0); |
| 258 | return true; |
| 259 | } |
| 260 | } else if (SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#* map = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.) { |
| 261 | if (i >= MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!) { |
| 262 | SparseArrayValueMap::iterator it = map->find(i); |
| 263 | if (it !=cxx . . $ QTJSC/`operator!=`(8208a731c2dadbc2). map->end()) { |
| 264 | descriptor.setDescriptorcxx . . $ QTJSC/PropertyDescriptor#setDescriptor(48358939f851dacc).(it->second, 0); |
| 265 | return true; |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | return JSObjectcxx . . $ QTJSC/JSObject#::getOwnPropertyDescriptorcxx . . $ QTJSC/JSObject#getOwnPropertyDescriptor(dce4ef7012294c32).(exec, propertyName, descriptor); |
| 271 | } |
| 272 | |
| 273 | // ECMA 15.4.5.1 |
| 274 | void JSArraycxx . . $ QTJSC/JSArray#::putcxx . . $ QTJSC/JSArray#put(dfb3133dafbe9ff4).(ExecStatecxx . . $ QTJSC/ExecState#* exec, const Identifiercxx . . $ QTJSC/Identifier#& propertyName, JSValuecxx . . $ QTJSC/JSValue# value, PutPropertySlotcxx . . $ QTJSC/PutPropertySlot#& slot) |
| 275 | { |
| 276 | bool isArrayIndex; |
| 277 | unsigned i = propertyName.toArrayIndexcxx . . $ QTJSC/Identifier#toArrayIndex(870b63f89c7fb98).(&isArrayIndex); |
| 278 | if (isArrayIndex) { |
| 279 | putcxx . . $ QTJSC/JSArray#put(b1b60585cf3bb95).(exec, i, value); |
| 280 | return; |
| 281 | } |
| 282 | |
| 283 | if (propertyName ==cxx . . $ QTJSC/`operator==`(8208a731c2dadbc2). exec->propertyNamescxx . . $ QTJSC/ExecState#propertyNames(16296db726e31f87).().length) { |
| 284 | unsigned newLength = value.toUInt32cxx . . $ QTJSC/JSValue#toUInt32(fedcfd78cee4cc89).(exec); |
| 285 | if (value.toNumbercxx . . $ QTJSC/JSValue#toNumber(1fd034e372fd1279).(exec) != static_cast<double>(newLength)) { |
| 286 | throwErrorcxx . . $ QTJSC/throwError(c8108d54e75f502b).(exec, RangeErrorcxx . . $ QTJSC/RangeError., "Invalid array length."); |
| 287 | return; |
| 288 | } |
| 289 | setLengthcxx . . $ QTJSC/JSArray#setLength(cb2f890c2fdad230).(newLength); |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | JSObjectcxx . . $ QTJSC/JSObject#::putcxx . . $ QTJSC/JSArray#put(dfb3133dafbe9ff4).(exec, propertyName, value, slot); |
| 294 | } |
| 295 | |
| 296 | void JSArraycxx . . $ QTJSC/JSArray#::putcxx . . $ QTJSC/JSArray#put(b1b60585cf3bb95).(ExecStatecxx . . $ QTJSC/ExecState#* exec, unsigned i, JSValuecxx . . $ QTJSC/JSValue# value) |
| 297 | { |
| 298 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 299 | |
| 300 | unsigned length = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.; |
| 301 | if (i >= length && i <= MAX_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:81:9`!) { |
| 302 | length = i + 1; |
| 303 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length. = length; |
| 304 | } |
| 305 | |
| 306 | if (i < m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.) { |
| 307 | JSValuecxx . . $ QTJSC/JSValue#& valueSlot = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i]; |
| 308 | if (valueSlot) { |
| 309 | valueSlot =cxx . . $ QTJSC/JSValue#`operator=`(af0e8a528f82a1b5). value; |
| 310 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 311 | return; |
| 312 | } |
| 313 | valueSlot =cxx . . $ QTJSC/JSValue#`operator=`(af0e8a528f82a1b5). value; |
| 314 | ++m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector.; |
| 315 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 316 | return; |
| 317 | } |
| 318 | |
| 319 | putSlowCasecxx . . $ QTJSC/JSArray#putSlowCase(b1b60585cf3bb95).(exec, i, value); |
| 320 | } |
| 321 | |
| 322 | NEVER_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:35:9`! void JSArraycxx . . $ QTJSC/JSArray#::putSlowCasecxx . . $ QTJSC/JSArray#putSlowCase(b1b60585cf3bb95).(ExecStatecxx . . $ QTJSC/ExecState#* exec, unsigned i, JSValuecxx . . $ QTJSC/JSValue# value) |
| 323 | { |
| 324 | ArrayStoragecxx . . $ QTJSC/ArrayStorage#* storage = m_storagecxx . . $ QTJSC/JSArray#m_storage.; |
| 325 | SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#* map = storage->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.; |
| 326 | |
| 327 | if (i >= MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!) { |
| 328 | if (i > MAX_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:81:9`!) { |
| 329 | PutPropertySlotcxx . . $ QTJSC/PutPropertySlot# slotcxx . . $ QTJSC/PutPropertySlot#PutPropertySlot(49f6e7a06ebc5aa8).; |
| 330 | putcxx . . $ QTJSC/JSArray#put(dfb3133dafbe9ff4).(exec, Identifiercxx . . $ QTJSC/Identifier#::fromcxx . . $ QTJSC/Identifier#from(d1afedae20629715).(exec, i), value, slot); |
| 331 | return; |
| 332 | } |
| 333 | |
| 334 | // We miss some cases where we could compact the storage, such as a large array that is being filled from the end |
| 335 | // (which will only be compacted as we reach indices that are less than MIN_SPARSE_ARRAY_INDEX) - but this makes the check much faster. |
| 336 | if ((i > MAX_STORAGE_VECTOR_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:79:9`!) || !isDenseEnoughForVectorcxx . . $ QTJSC/isDenseEnoughForVector(8e1b545ea3aecce3).(i + 1, storage->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector. + 1)) { |
| 337 | if (!map) { |
| 338 | map = new SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#; |
| 339 | storage->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap. = map; |
| 340 | } |
| 341 | |
| 342 | pair<SparseArrayValueMap::iterator, bool> result = map->add(i, value); |
| 343 | if (!result.second) { // pre-existing entry |
| 344 | result.first->second = value; |
| 345 | return; |
| 346 | } |
| 347 | |
| 348 | size_tcxx . . $ size_t# capacity = map->capacity(); |
| 349 | if (capacity != storage->reportedMapCapacitycxx . . $ QTJSC/ArrayStorage#reportedMapCapacity.) { |
| 350 | Heapcxx . . $ QTJSC/Heap#::heapcxx . . $ QTJSC/Heap#heap(4163b73911f9bcad).(this)->reportExtraMemoryCostcxx . . $ QTJSC/Heap#reportExtraMemoryCost(2c44cd906ae4e829).((capacity - storage->reportedMapCapacitycxx . . $ QTJSC/ArrayStorage#reportedMapCapacity.) * (sizeof(unsigned) + sizeof(JSValuecxx . . $ QTJSC/JSValue#))); |
| 351 | storage->reportedMapCapacitycxx . . $ QTJSC/ArrayStorage#reportedMapCapacity. = capacity; |
| 352 | } |
| 353 | return; |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | // We have decided that we'll put the new item into the vector. |
| 358 | // Fast case is when there is no sparse map, so we can increase the vector size without moving values from it. |
| 359 | if (!map || map->isEmpty()) { |
| 360 | if (increaseVectorLengthcxx . . $ QTJSC/JSArray#increaseVectorLength(dfa6e707f7696010).(i + 1)) { |
| 361 | storage = m_storagecxx . . $ QTJSC/JSArray#m_storage.; |
| 362 | storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i] =cxx . . $ QTJSC/JSValue#`operator=`(af0e8a528f82a1b5). value; |
| 363 | ++storage->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector.; |
| 364 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 365 | } else |
| 366 | throwOutOfMemoryErrorcxx . . $ QTJSC/throwOutOfMemoryError(3fbe51058e39576a).(exec); |
| 367 | return; |
| 368 | } |
| 369 | |
| 370 | // Decide how many values it would be best to move from the map. |
| 371 | unsigned newNumValuesInVector = storage->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector. + 1; |
| 372 | unsigned newVectorLength = increasedVectorLengthcxx . . $ QTJSC/increasedVectorLength(2141b656ce2cc063).(i + 1); |
| 373 | for (unsigned j = maxcxx . . $ std/max(2a338fce5842aa6a).(m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength., MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!); j < newVectorLength; ++j) |
| 374 | newNumValuesInVector +=cxx . . $ `operator+=`(79c69f12ebd2f310). map->contains(j); |
| 375 | if (i >= MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!) |
| 376 | newNumValuesInVector -= map->contains(i); |
| 377 | if (isDenseEnoughForVectorcxx . . $ QTJSC/isDenseEnoughForVector(8e1b545ea3aecce3).(newVectorLength, newNumValuesInVector)) { |
| 378 | unsigned proposedNewNumValuesInVector = newNumValuesInVector; |
| 379 | // If newVectorLength is already the maximum - MAX_STORAGE_VECTOR_LENGTH - then do not attempt to grow any further. |
| 380 | while (newVectorLength < MAX_STORAGE_VECTOR_LENGTHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:74:9`!) { |
| 381 | unsigned proposedNewVectorLength = increasedVectorLengthcxx . . $ QTJSC/increasedVectorLength(2141b656ce2cc063).(newVectorLength + 1); |
| 382 | for (unsigned j = maxcxx . . $ std/max(2a338fce5842aa6a).(newVectorLength, MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!); j < proposedNewVectorLength; ++j) |
| 383 | proposedNewNumValuesInVector +=cxx . . $ `operator+=`(79c69f12ebd2f310). map->contains(j); |
| 384 | if (!isDenseEnoughForVectorcxx . . $ QTJSC/isDenseEnoughForVector(8e1b545ea3aecce3).(proposedNewVectorLength, proposedNewNumValuesInVector)) |
| 385 | break; |
| 386 | newVectorLength = proposedNewVectorLength; |
| 387 | newNumValuesInVector = proposedNewNumValuesInVector; |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | if (!tryFastRealloccxx . . $ tryFastRealloc(6696b16547a81308).(storage, storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(newVectorLength)).getValuecxx . . $ QTWTF/TryMallocReturnValue#getValue(e5bfd7b2d24a2428).(storage)) { |
| 392 | throwOutOfMemoryErrorcxx . . $ QTJSC/throwOutOfMemoryError(3fbe51058e39576a).(exec); |
| 393 | return; |
| 394 | } |
| 395 | |
| 396 | unsigned vectorLength = m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.; |
| 397 | |
| 398 | if (newNumValuesInVector == storage->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector. + 1) { |
| 399 | for (unsigned j = vectorLength; j < newVectorLength; ++j) |
| 400 | storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[j] =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). JSValuecxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).(); |
| 401 | if (i > MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!) |
| 402 | map->remove(i); |
| 403 | } else { |
| 404 | for (unsigned j = vectorLength; j <cxx . . $ QTJSC/`operator<`(11610d830df66bbf). maxcxx . . $ std/max(2a338fce5842aa6a).(vectorLength, MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!); ++j) |
| 405 | storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[j] =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). JSValuecxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).(); |
| 406 | for (unsigned j = maxcxx . . $ std/max(2a338fce5842aa6a).(vectorLength, MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!); j < newVectorLength; ++j) |
| 407 | storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[j] = map->take(j); |
| 408 | } |
| 409 | |
| 410 | storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i] =cxx . . $ QTJSC/JSValue#`operator=`(af0e8a528f82a1b5). value; |
| 411 | |
| 412 | m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength. = newVectorLength; |
| 413 | storage->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector. = newNumValuesInVector; |
| 414 | |
| 415 | m_storagecxx . . $ QTJSC/JSArray#m_storage. = storage; |
| 416 | |
| 417 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 418 | |
| 419 | Heapcxx . . $ QTJSC/Heap#::heapcxx . . $ QTJSC/Heap#heap(4163b73911f9bcad).(this)->reportExtraMemoryCostcxx . . $ QTJSC/Heap#reportExtraMemoryCost(2c44cd906ae4e829).(storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(newVectorLength) - storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(vectorLength)); |
| 420 | } |
| 421 | |
| 422 | bool JSArraycxx . . $ QTJSC/JSArray#::deletePropertycxx . . $ QTJSC/JSArray#deleteProperty(13154ef9bddc9416).(ExecStatecxx . . $ QTJSC/ExecState#* exec, const Identifiercxx . . $ QTJSC/Identifier#& propertyName) |
| 423 | { |
| 424 | bool isArrayIndex; |
| 425 | unsigned i = propertyName.toArrayIndexcxx . . $ QTJSC/Identifier#toArrayIndex(870b63f89c7fb98).(&isArrayIndex); |
| 426 | if (isArrayIndex) |
| 427 | return deletePropertycxx . . $ QTJSC/JSArray#deleteProperty(2f8cbeb04562a47b).(exec, i); |
| 428 | |
| 429 | if (propertyName ==cxx . . $ QTJSC/`operator==`(8208a731c2dadbc2). exec->propertyNamescxx . . $ QTJSC/ExecState#propertyNames(16296db726e31f87).().length) |
| 430 | return false; |
| 431 | |
| 432 | return JSObjectcxx . . $ QTJSC/JSObject#::deletePropertycxx . . $ QTJSC/JSArray#deleteProperty(2f8cbeb04562a47b).(exec, propertyName); |
| 433 | } |
| 434 | |
| 435 | bool JSArraycxx . . $ QTJSC/JSArray#::deletePropertycxx . . $ QTJSC/JSArray#deleteProperty(2f8cbeb04562a47b).(ExecStatecxx . . $ QTJSC/ExecState#* exec, unsigned i) |
| 436 | { |
| 437 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 438 | |
| 439 | ArrayStoragecxx . . $ QTJSC/ArrayStorage#* storage = m_storagecxx . . $ QTJSC/JSArray#m_storage.; |
| 440 | |
| 441 | if (i < m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.) { |
| 442 | JSValuecxx . . $ QTJSC/JSValue#& valueSlot = storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i]; |
| 443 | if (!valueSlot) { |
| 444 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 445 | return false; |
| 446 | } |
| 447 | valueSlot =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). JSValuecxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).(); |
| 448 | --storage->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector.; |
| 449 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 450 | return true; |
| 451 | } |
| 452 | |
| 453 | if (SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#* map = storage->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.) { |
| 454 | if (i >= MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!) { |
| 455 | SparseArrayValueMap::iterator it = map->find(i); |
| 456 | if (it !=cxx . . $ QTJSC/`operator!=`(8208a731c2dadbc2). map->end()) { |
| 457 | map->remove(it); |
| 458 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 459 | return true; |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 465 | |
| 466 | if (i > MAX_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:81:9`!) |
| 467 | return deletePropertycxx . . $ QTJSC/JSArray#deleteProperty(13154ef9bddc9416).(exec, Identifiercxx . . $ QTJSC/Identifier#::fromcxx . . $ QTJSC/Identifier#from(d1afedae20629715).(exec, i)); |
| 468 | |
| 469 | return false; |
| 470 | } |
| 471 | |
| 472 | void JSArraycxx . . $ QTJSC/JSArray#::getOwnPropertyNamescxx . . $ QTJSC/JSArray#getOwnPropertyNames(2f9e3f18de200b4e).(ExecStatecxx . . $ QTJSC/ExecState#* exec, PropertyNameArraycxx . . $ QTJSC/PropertyNameArray#& propertyNames, EnumerationModecxx . . $ QTJSC/EnumerationMode# mode) |
| 473 | { |
| 474 | // FIXME: Filling PropertyNameArray with an identifier for every integer |
| 475 | // is incredibly inefficient for large arrays. We need a different approach, |
| 476 | // which almost certainly means a different structure for PropertyNameArray. |
| 477 | |
| 478 | ArrayStoragecxx . . $ QTJSC/ArrayStorage#* storage = m_storagecxx . . $ QTJSC/JSArray#m_storage.; |
| 479 | |
| 480 | unsigned usedVectorLength = mincxx . . $ std/min(2a338fce5842aa6a).(storage->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length., m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.); |
| 481 | for (unsigned i = 0; i < usedVectorLength; ++i) { |
| 482 | if (storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i]) |
| 483 | propertyNames.addcxx . . $ QTJSC/PropertyNameArray#add(d7ed36c5537ed570).(Identifiercxx . . $ QTJSC/Identifier#::fromcxx . . $ QTJSC/Identifier#from(d1afedae20629715).(exec, i)); |
| 484 | } |
| 485 | |
| 486 | if (SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#* map = storage->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.) { |
| 487 | SparseArrayValueMap::iterator end = map->end(); |
| 488 | for (SparseArrayValueMap::iterator it = map->begin(); it !=cxx . . $ QTJSC/`operator!=`(8208a731c2dadbc2). endcxx . . $ std/end(309ad712043406cf).; ++it) |
| 489 | propertyNames.addcxx . . $ QTJSC/PropertyNameArray#add(d7ed36c5537ed570).(Identifiercxx . . $ QTJSC/Identifier#::fromcxx . . $ QTJSC/Identifier#from(d1afedae20629715).(exec, it->first)); |
| 490 | } |
| 491 | |
| 492 | if (mode == IncludeDontEnumPropertiescxx . . $ QTJSC/IncludeDontEnumProperties.) |
| 493 | propertyNames.addcxx . . $ QTJSC/PropertyNameArray#add(d7ed36c5537ed570).(exec->propertyNamescxx . . $ QTJSC/ExecState#propertyNames(16296db726e31f87).().length); |
| 494 | |
| 495 | JSObjectcxx . . $ QTJSC/JSObject#::getOwnPropertyNamescxx . . $ QTJSC/JSObject#getOwnPropertyNames(2f9e3f18de200b4e).(exec, propertyNames, mode); |
| 496 | } |
| 497 | |
| 498 | bool JSArraycxx . . $ QTJSC/JSArray#::increaseVectorLengthcxx . . $ QTJSC/JSArray#increaseVectorLength(dfa6e707f7696010).(unsigned newLength) |
| 499 | { |
| 500 | // This function leaves the array in an internally inconsistent state, because it does not move any values from sparse value map |
| 501 | // to the vector. Callers have to account for that, because they can do it more efficiently. |
| 502 | |
| 503 | ArrayStoragecxx . . $ QTJSC/ArrayStorage#* storage = m_storagecxx . . $ QTJSC/JSArray#m_storage.; |
| 504 | |
| 505 | unsigned vectorLength = m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.; |
| 506 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(newLength > vectorLength); |
| 507 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(newLength <= MAX_STORAGE_VECTOR_INDEX); |
| 508 | unsigned newVectorLength = increasedVectorLengthcxx . . $ QTJSC/increasedVectorLength(2141b656ce2cc063).(newLength); |
| 509 | |
| 510 | if (!tryFastRealloccxx . . $ tryFastRealloc(6696b16547a81308).(storage, storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(newVectorLength)).getValuecxx . . $ QTWTF/TryMallocReturnValue#getValue(e5bfd7b2d24a2428).(storage)) |
| 511 | return false; |
| 512 | |
| 513 | m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength. = newVectorLength; |
| 514 | |
| 515 | for (unsigned i = vectorLength; i < newVectorLength; ++i) |
| 516 | storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i] =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). JSValuecxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).(); |
| 517 | |
| 518 | m_storagecxx . . $ QTJSC/JSArray#m_storage. = storage; |
| 519 | |
| 520 | Heapcxx . . $ QTJSC/Heap#::heapcxx . . $ QTJSC/Heap#heap(4163b73911f9bcad).(this)->reportExtraMemoryCostcxx . . $ QTJSC/Heap#reportExtraMemoryCost(2c44cd906ae4e829).(storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(newVectorLength) - storageSizecxx . . $ QTJSC/storageSize(1892545c1754497d).(vectorLength)); |
| 521 | |
| 522 | return true; |
| 523 | } |
| 524 | |
| 525 | void JSArraycxx . . $ QTJSC/JSArray#::setLengthcxx . . $ QTJSC/JSArray#setLength(cb2f890c2fdad230).(unsigned newLength) |
| 526 | { |
| 527 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 528 | |
| 529 | ArrayStoragecxx . . $ QTJSC/ArrayStorage#* storage = m_storagecxx . . $ QTJSC/JSArray#m_storage.; |
| 530 | |
| 531 | unsigned length = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.; |
| 532 | |
| 533 | if (newLength < length) { |
| 534 | unsigned usedVectorLength = mincxx . . $ std/min(2a338fce5842aa6a).(length, m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.); |
| 535 | for (unsigned i = newLength; i < usedVectorLength; ++i) { |
| 536 | JSValuecxx . . $ QTJSC/JSValue#& valueSlot = storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i]; |
| 537 | bool hadValue = valueSlot; |
| 538 | valueSlot =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). JSValuecxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).(); |
| 539 | storage->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector. -= hadValue; |
| 540 | } |
| 541 | |
| 542 | if (SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#* map = storage->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.) { |
| 543 | SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap# copy = *map; |
| 544 | SparseArrayValueMap::iterator end = copy.end(); |
| 545 | for (SparseArrayValueMap::iterator it = copy.begin(); it !=cxx . . $ QTJSC/`operator!=`(8208a731c2dadbc2). endcxx . . $ std/end(309ad712043406cf).; ++it) { |
| 546 | if (it->first >=cxx . . $ `operator>=`(8f8a8e6a6f1fc74b). newLength) |
| 547 | map->remove(it->first); |
| 548 | } |
| 549 | if (map->isEmpty()) { |
| 550 | delete map; |
| 551 | storage->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap. = 0; |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length. = newLength; |
| 557 | |
| 558 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 559 | } |
| 560 | |
| 561 | JSValuecxx . . $ QTJSC/JSValue# JSArraycxx . . $ QTJSC/JSArray#::popcxx . . $ QTJSC/JSArray#pop(ad9afe69d7bf6378).() |
| 562 | { |
| 563 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 564 | |
| 565 | unsigned length = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.; |
| 566 | if (!length) |
| 567 | return jsUndefinedcxx . . $ QTJSC/jsUndefined(ad9afe69d7bf6378).(); |
| 568 | |
| 569 | --length; |
| 570 | |
| 571 | JSValuecxx . . $ QTJSC/JSValue# resultcxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).; |
| 572 | |
| 573 | if (length < m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.) { |
| 574 | JSValuecxx . . $ QTJSC/JSValue#& valueSlot = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[length]; |
| 575 | if (valueSlot) { |
| 576 | --m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector.; |
| 577 | result =cxx . . $ QTJSC/JSValue#`operator=`(af0e8a528f82a1b5). valueSlot; |
| 578 | valueSlot =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). JSValuecxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).(); |
| 579 | } else |
| 580 | result =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). jsUndefinedcxx . . $ QTJSC/jsUndefined(ad9afe69d7bf6378).(); |
| 581 | } else { |
| 582 | result =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). jsUndefinedcxx . . $ QTJSC/jsUndefined(ad9afe69d7bf6378).(); |
| 583 | if (SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#* map = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.) { |
| 584 | SparseArrayValueMap::iterator it = map->find(length); |
| 585 | if (it !=cxx . . $ QTJSC/`operator!=`(8208a731c2dadbc2). map->end()) { |
| 586 | result = it->second; |
| 587 | map->remove(it); |
| 588 | if (map->isEmpty()) { |
| 589 | delete map; |
| 590 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap. = 0; |
| 591 | } |
| 592 | } |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length. = length; |
| 597 | |
| 598 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 599 | |
| 600 | return result; |
| 601 | } |
| 602 | |
| 603 | void JSArraycxx . . $ QTJSC/JSArray#::pushcxx . . $ QTJSC/JSArray#push(1aadac95d0a8d6ce).(ExecStatecxx . . $ QTJSC/ExecState#* exec, JSValuecxx . . $ QTJSC/JSValue# value) |
| 604 | { |
| 605 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 606 | |
| 607 | if (m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length. < m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.) { |
| 608 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.] =cxx . . $ QTJSC/JSValue#`operator=`(af0e8a528f82a1b5). value; |
| 609 | ++m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector.; |
| 610 | ++m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.; |
| 611 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 612 | return; |
| 613 | } |
| 614 | |
| 615 | if (m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length. < MIN_SPARSE_ARRAY_INDEXcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:78:9`!) { |
| 616 | SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#* map = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.; |
| 617 | if (!map || map->isEmpty()) { |
| 618 | if (increaseVectorLengthcxx . . $ QTJSC/JSArray#increaseVectorLength(dfa6e707f7696010).(m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length. + 1)) { |
| 619 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.] =cxx . . $ QTJSC/JSValue#`operator=`(af0e8a528f82a1b5). value; |
| 620 | ++m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector.; |
| 621 | ++m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.; |
| 622 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 623 | return; |
| 624 | } |
| 625 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 626 | throwOutOfMemoryErrorcxx . . $ QTJSC/throwOutOfMemoryError(3fbe51058e39576a).(exec); |
| 627 | return; |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | putSlowCasecxx . . $ QTJSC/JSArray#putSlowCase(b1b60585cf3bb95).(exec, m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.++, value); |
| 632 | } |
| 633 | |
| 634 | void JSArraycxx . . $ QTJSC/JSArray#::markChildrencxx . . $ QTJSC/JSArray#markChildren(bd9cae851d80a865).(MarkStackcxx . . $ QTJSC/MarkStack#& markStack) |
| 635 | { |
| 636 | markChildrenDirectcxx . . $ QTJSC/JSArray#markChildrenDirect(bd9cae851d80a865).(markStack); |
| 637 | } |
| 638 | |
| 639 | static int compareNumbersForQSortcxx . . $ QTJSC/compareNumbersForQSort(9148c8c3ff42c9d8).(const void* a, const void* b) |
| 640 | { |
| 641 | double da = static_cast<const JSValuecxx . . $ QTJSC/JSValue#*>(a)->uncheckedGetNumbercxx . . $ QTJSC/JSValue#uncheckedGetNumber(21b6c25e127938e2).(); |
| 642 | double db = static_cast<const JSValuecxx . . $ QTJSC/JSValue#*>(b)->uncheckedGetNumbercxx . . $ QTJSC/JSValue#uncheckedGetNumber(21b6c25e127938e2).(); |
| 643 | return (da > db) - (da < db); |
| 644 | } |
| 645 | |
| 646 | typedef stdcxx . . $ std/::paircxx . . $ std/pair#<JSValuecxx . . $ QTJSC/JSValue#, UStringcxx . . $ QTJSC/UString#> ValueStringPaircxx . . $ QTJSC/ValueStringPair#; |
| 647 | |
| 648 | static int compareByStringPairForQSortcxx . . $ QTJSC/compareByStringPairForQSort(9148c8c3ff42c9d8).(const void* a, const void* b) |
| 649 | { |
| 650 | const ValueStringPaircxx . . $ QTJSC/ValueStringPair#* va = static_cast<const ValueStringPaircxx . . $ QTJSC/ValueStringPair#*>(a); |
| 651 | const ValueStringPaircxx . . $ QTJSC/ValueStringPair#* vb = static_cast<const ValueStringPaircxx . . $ QTJSC/ValueStringPair#*>(b); |
| 652 | return comparecxx . . $ QTJSC/compare(3b03898a94650926).(va->second, vb->second); |
| 653 | } |
| 654 | |
| 655 | void JSArraycxx . . $ QTJSC/JSArray#::sortNumericcxx . . $ QTJSC/JSArray#sortNumeric(8d295068ccf0002f).(ExecStatecxx . . $ QTJSC/ExecState#* exec, JSValuecxx . . $ QTJSC/JSValue# compareFunction, CallTypecxx . . $ QTJSC/CallType# callType, const CallDatacxx . . $ QTJSC/CallData#& callData) |
| 656 | { |
| 657 | unsigned lengthNotIncludingUndefined = compactForSortingcxx . . $ QTJSC/JSArray#compactForSorting(db52760e79bf9054).(); |
| 658 | if (m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.) { |
| 659 | throwOutOfMemoryErrorcxx . . $ QTJSC/throwOutOfMemoryError(3fbe51058e39576a).(exec); |
| 660 | return; |
| 661 | } |
| 662 | |
| 663 | if (!lengthNotIncludingUndefined) |
| 664 | return; |
| 665 | |
| 666 | bool allValuesAreNumbers = true; |
| 667 | size_tcxx . . $ size_t# size = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector.; |
| 668 | for (size_tcxx . . $ size_t# i = 0; i < size; ++i) { |
| 669 | if (!m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i].isNumbercxx . . $ QTJSC/JSValue#isNumber(50ce9a9e25b4a850).()) { |
| 670 | allValuesAreNumbers = false; |
| 671 | break; |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | if (!allValuesAreNumbers) |
| 676 | return sortcxx . . $ QTJSC/JSArray#sort(8d295068ccf0002f).(exec, compareFunction, callType, callData); |
| 677 | |
| 678 | // For numeric comparison, which is fast, qsort is faster than mergesort. We |
| 679 | // also don't require mergesort's stability, since there's no user visible |
| 680 | // side-effect from swapping the order of equal primitive values. |
| 681 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector., size, sizeof(JSValuecxx . . $ QTJSC/JSValue#), compareNumbersForQSortcxx . . $ QTJSC/compareNumbersForQSort(9148c8c3ff42c9d8).); |
| 682 | |
| 683 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(SortConsistencyCheckcxx . . $ QTJSC/JSArray#SortConsistencyCheck.); |
| 684 | } |
| 685 | |
| 686 | void JSArraycxx . . $ QTJSC/JSArray#::sortcxx . . $ QTJSC/JSArray#sort(d2cb180e190a9680).(ExecStatecxx . . $ QTJSC/ExecState#* exec) |
| 687 | { |
| 688 | unsigned lengthNotIncludingUndefined = compactForSortingcxx . . $ QTJSC/JSArray#compactForSorting(db52760e79bf9054).(); |
| 689 | if (m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.) { |
| 690 | throwOutOfMemoryErrorcxx . . $ QTJSC/throwOutOfMemoryError(3fbe51058e39576a).(exec); |
| 691 | return; |
| 692 | } |
| 693 | |
| 694 | if (!lengthNotIncludingUndefined) |
| 695 | return; |
| 696 | |
| 697 | // Converting JavaScript values to strings can be expensive, so we do it once up front and sort based on that. |
| 698 | // This is a considerable improvement over doing it twice per comparison, though it requires a large temporary |
| 699 | // buffer. Besides, this protects us from crashing if some objects have custom toString methods that return |
| 700 | // random or otherwise changing results, effectively making compare function inconsistent. |
| 701 | |
| 702 | Vector<ValueStringPair> values(lengthNotIncludingUndefined); |
| 703 | if (!values.begin()) { |
| 704 | throwOutOfMemoryErrorcxx . . $ QTJSC/throwOutOfMemoryError(3fbe51058e39576a).(exec); |
| 705 | return; |
| 706 | } |
| 707 | |
| 708 | for (size_tcxx . . $ size_t# i = 0; i < lengthNotIncludingUndefined; i++) { |
| 709 | JSValuecxx . . $ QTJSC/JSValue# value = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i]; |
| 710 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!value.isUndefined()); |
| 711 | values[i].first = value; |
| 712 | } |
| 713 | |
| 714 | // FIXME: While calling these toString functions, the array could be mutated. |
| 715 | // In that case, objects pointed to by values in this vector might get garbage-collected! |
| 716 | |
| 717 | // FIXME: The following loop continues to call toString on subsequent values even after |
| 718 | // a toString call raises an exception. |
| 719 | |
| 720 | for (size_tcxx . . $ size_t# i = 0; i < lengthNotIncludingUndefined; i++) |
| 721 | values[i].second = values[i].first.toString(exec); |
| 722 | |
| 723 | if (exec->hadExceptioncxx . . $ QTJSC/ExecState#hadException(50ce9a9e25b4a850).()) |
| 724 | return; |
| 725 | |
| 726 | // FIXME: Since we sort by string value, a fast algorithm might be to use a radix sort. That would be O(N) rather |
| 727 | // than O(N log N). |
| 728 | |
| 729 | #if HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(MERGESORT) |
| 730 | mergesort(values.begin(), values.size(), sizeof(ValueStringPair), compareByStringPairForQSort); |
| 731 | #else |
| 732 | // FIXME: The qsort library function is likely to not be a stable sort. |
| 733 | // ECMAScript-262 does not specify a stable sort, but in practice, browsers perform a stable sort. |
| 734 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(values.begin(), values.size(), sizeof(ValueStringPair), compareByStringPairForQSortcxx . . $ QTJSC/compareByStringPairForQSort(9148c8c3ff42c9d8).); |
| 735 | #endif |
| 736 | |
| 737 | // FIXME: If the toString function changed the length of the array, this might be |
| 738 | // modifying the vector incorrectly. |
| 739 | |
| 740 | for (size_tcxx . . $ size_t# i = 0; i < lengthNotIncludingUndefined; i++) |
| 741 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i] = values[i].first; |
| 742 | |
| 743 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(SortConsistencyCheckcxx . . $ QTJSC/JSArray#SortConsistencyCheck.); |
| 744 | } |
| 745 | |
| 746 | struct AVLTreeNodeForArrayComparecxx . . $ QTJSC/AVLTreeNodeForArrayCompare# { |
| 747 | JSValuecxx . . $ QTJSC/JSValue# valuecxx . . $ QTJSC/AVLTreeNodeForArrayCompare#value.; |
| 748 | |
| 749 | // Child pointers. The high bit of gt is robbed and used as the |
| 750 | // balance factor sign. The high bit of lt is robbed and used as |
| 751 | // the magnitude of the balance factor. |
| 752 | int32_tcxx . . $ int32_t# gtcxx . . $ QTJSC/AVLTreeNodeForArrayCompare#gt.; |
| 753 | int32_tcxx . . $ int32_t# ltcxx . . $ QTJSC/AVLTreeNodeForArrayCompare#lt.; |
| 754 | }; |
| 755 | |
| 756 | struct AVLTreeAbstractorForArrayComparecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare# { |
| 757 | typedef int32_tcxx . . $ int32_t# handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle#; // Handle is an index into m_nodes vector. |
| 758 | typedef JSValuecxx . . $ QTJSC/JSValue# keycxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#key#; |
| 759 | typedef int32_tcxx . . $ int32_t# sizecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#size#; |
| 760 | |
| 761 | Vector<AVLTreeNodeForArrayCompare> m_nodescxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_nodes.; |
| 762 | ExecStatecxx . . $ QTJSC/ExecState#* m_execcxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_exec.; |
| 763 | JSValuecxx . . $ QTJSC/JSValue# m_compareFunctioncxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_compareFunction.; |
| 764 | CallTypecxx . . $ QTJSC/CallType# m_compareCallTypecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_compareCallType.; |
| 765 | const CallDatacxx . . $ QTJSC/CallData#* m_compareCallDatacxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_compareCallData.; |
| 766 | JSValuecxx . . $ QTJSC/JSValue# m_globalThisValuecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_globalThisValue.; |
| 767 | OwnPtrcxx . . $ OwnPtr#<CachedCallcxx . . $ QTJSC/CachedCall#> m_cachedCallcxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_cachedCall.; |
| 768 | |
| 769 | handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# get_lesscxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#get_less(7864480464b09eea).(handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# h) { return m_nodes[h].lt & 0x7FFFFFFF; } |
| 770 | void set_lesscxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#set_less(3e454b8ccf442868).(handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# h, handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# lh) { m_nodes[h].lt &= 0x80000000; m_nodes[h].lt |= lh; } |
| 771 | handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# get_greatercxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#get_greater(7864480464b09eea).(handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# h) { return m_nodes[h].gt & 0x7FFFFFFF; } |
| 772 | void set_greatercxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#set_greater(3e454b8ccf442868).(handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# h, handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# gh) { m_nodes[h].gt &= 0x80000000; m_nodes[h].gt |= gh; } |
| 773 | |
| 774 | int get_balance_factorcxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#get_balance_factor(7864480464b09eea).(handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# h) |
| 775 | { |
| 776 | if (m_nodes[h].gt & 0x80000000) |
| 777 | return -1; |
| 778 | return static_cast<unsigned>(m_nodes[h].lt) >> 31; |
| 779 | } |
| 780 | |
| 781 | void set_balance_factorcxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#set_balance_factor(3e454b8ccf442868).(handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# h, int bf) |
| 782 | { |
| 783 | if (bf == 0) { |
| 784 | m_nodes[h].lt &= 0x7FFFFFFF; |
| 785 | m_nodes[h].gt &= 0x7FFFFFFF; |
| 786 | } else { |
| 787 | m_nodes[h].lt |= 0x80000000; |
| 788 | if (bf < 0) |
| 789 | m_nodes[h].gt |= 0x80000000; |
| 790 | else |
| 791 | m_nodes[h].gt &= 0x7FFFFFFF; |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | int compare_key_keycxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#compare_key_key(51cd1fa50e05a831).(keycxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#key# va, keycxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#key# vb) |
| 796 | { |
| 797 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!va.isUndefined()); |
| 798 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!vb.isUndefined()); |
| 799 | |
| 800 | if (m_execcxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_exec.->hadExceptioncxx . . $ QTJSC/ExecState#hadException(50ce9a9e25b4a850).()) |
| 801 | return 1; |
| 802 | |
| 803 | double compareResult; |
| 804 | if (m_cachedCall) { |
| 805 | m_cachedCall->setThis(m_globalThisValue); |
| 806 | m_cachedCall->setArgument(0, va); |
| 807 | m_cachedCall->setArgument(1, vb); |
| 808 | compareResult = m_cachedCall->call().toNumber(m_cachedCall->newCallFrame(m_exec)); |
| 809 | } else { |
| 810 | MarkedArgumentBuffercxx . . $ QTJSC/MarkedArgumentBuffer# argumentscxx . . $ QTJSC/MarkedArgumentBuffer#MarkedArgumentBuffer(49f6e7a06ebc5aa8).; |
| 811 | arguments.appendcxx . . $ QTJSC/MarkedArgumentBuffer#append(5c2ac18db087b3e6).(va); |
| 812 | arguments.appendcxx . . $ QTJSC/MarkedArgumentBuffer#append(5c2ac18db087b3e6).(vb); |
| 813 | compareResult = callcxx . . $ QTJSC/call(342816bfcb24d530).(m_execcxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_exec., m_compareFunctioncxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_compareFunction., m_compareCallTypecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_compareCallType., *m_compareCallDatacxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_compareCallData., m_globalThisValuecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_globalThisValue., arguments).toNumber(m_execcxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#m_exec.); |
| 814 | } |
| 815 | return (compareResult < 0) ? -1 : 1; // Not passing equality through, because we need to store all values, even if equivalent. |
| 816 | } |
| 817 | |
| 818 | int compare_key_nodecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#compare_key_node(54ad3d2b8c564b78).(keycxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#key# k, handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# h) { return compare_key_keycxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#compare_key_key(51cd1fa50e05a831).(k, m_nodes[h].value); } |
| 819 | int compare_node_nodecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#compare_node_node(9b79fb6aee4c0440).(handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# h1, handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# h2) { return compare_key_keycxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#compare_key_key(51cd1fa50e05a831).(m_nodes[h1].value, m_nodes[h2].value); } |
| 820 | |
| 821 | static handlecxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#handle# nullcxx . . $ QTJSC/AVLTreeAbstractorForArrayCompare#null(b126dc7c1de90089).() { return 0x7FFFFFFF; } |
| 822 | }; |
| 823 | |
| 824 | void JSArraycxx . . $ QTJSC/JSArray#::sortcxx . . $ QTJSC/JSArray#sort(8d295068ccf0002f).(ExecStatecxx . . $ QTJSC/ExecState#* exec, JSValuecxx . . $ QTJSC/JSValue# compareFunction, CallTypecxx . . $ QTJSC/CallType# callType, const CallDatacxx . . $ QTJSC/CallData#& callData) |
| 825 | { |
| 826 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 827 | |
| 828 | // FIXME: This ignores exceptions raised in the compare function or in toNumber. |
| 829 | |
| 830 | // The maximum tree depth is compiled in - but the caller is clearly up to no good |
| 831 | // if a larger array is passed. |
| 832 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(m_storage->m_length <= static_cast<unsigned>(std::numeric_limits<int>::max())); |
| 833 | if (m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length. > static_cast<unsigned>(stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<int>::maxcxx . . $ std/numeric_limits#max(b126dc7c1de90089).())) |
| 834 | return; |
| 835 | |
| 836 | if (!m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.) |
| 837 | return; |
| 838 | |
| 839 | unsigned usedVectorLength = mincxx . . $ std/min(2a338fce5842aa6a).(m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length., m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.); |
| 840 | |
| 841 | AVLTree<AVLTreeAbstractorForArrayCompare, 44> tree; // Depth 44 is enough for 2^31 items |
| 842 | tree.abstractor().m_exec = exec; |
| 843 | tree.abstractor().m_compareFunction = compareFunction; |
| 844 | tree.abstractor().m_compareCallType = callType; |
| 845 | tree.abstractor().m_compareCallData = &callData; |
| 846 | tree.abstractor().m_globalThisValue = exec->globalThisValuecxx . . $ QTJSC/ExecState#globalThisValue(8ac23ea934d7a115).(); |
| 847 | tree.abstractor().m_nodes.resize(usedVectorLength +cxx . . $ operator+(f3789794639247d3). (m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap. ? m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.->size() : 0)); |
| 848 | |
| 849 | if (callType == CallTypeJScxx . . $ QTJSC/CallTypeJS.) |
| 850 | tree.abstractor().m_cachedCall.set(new CachedCallcxx . . $ QTJSC/CachedCall#CachedCall(f8d1ab3b8a580a38).(exec, asFunctioncxx . . $ QTJSC/asFunction(deffc94ad83de35f).(compareFunction), 2, exec->exceptionSlotcxx . . $ QTJSC/ExecState#exceptionSlot(6880e523701d9eaa).())); |
| 851 | |
| 852 | if (!tree.abstractor().m_nodes.begin()) { |
| 853 | throwOutOfMemoryErrorcxx . . $ QTJSC/throwOutOfMemoryError(3fbe51058e39576a).(exec); |
| 854 | return; |
| 855 | } |
| 856 | |
| 857 | // FIXME: If the compare function modifies the array, the vector, map, etc. could be modified |
| 858 | // right out from under us while we're building the tree here. |
| 859 | |
| 860 | unsigned numDefined = 0; |
| 861 | unsigned numUndefined = 0; |
| 862 | |
| 863 | // Iterate over the array, ignoring missing values, counting undefined ones, and inserting all other ones into the tree. |
| 864 | for (; numDefined < usedVectorLength; ++numDefined) { |
| 865 | JSValuecxx . . $ QTJSC/JSValue# v = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[numDefined]; |
| 866 | if (!v || v.isUndefinedcxx . . $ QTJSC/JSValue#isUndefined(50ce9a9e25b4a850).()) |
| 867 | break; |
| 868 | tree.abstractor().m_nodes[numDefined].value = v; |
| 869 | tree.insert(numDefined); |
| 870 | } |
| 871 | for (unsigned i = numDefined; i < usedVectorLength; ++i) { |
| 872 | JSValuecxx . . $ QTJSC/JSValue# v = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i]; |
| 873 | if (v) { |
| 874 | if (v.isUndefinedcxx . . $ QTJSC/JSValue#isUndefined(50ce9a9e25b4a850).()) |
| 875 | ++numUndefined; |
| 876 | else { |
| 877 | tree.abstractor().m_nodes[numDefined].value = v; |
| 878 | tree.insert(numDefined); |
| 879 | ++numDefined; |
| 880 | } |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | unsigned newUsedVectorLength = numDefined + numUndefined; |
| 885 | |
| 886 | if (SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#* map = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.) { |
| 887 | newUsedVectorLength +=cxx . . $ `operator+=`(79c69f12ebd2f310). map->size(); |
| 888 | if (newUsedVectorLength > m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.) { |
| 889 | // Check that it is possible to allocate an array large enough to hold all the entries. |
| 890 | if ((newUsedVectorLength > MAX_STORAGE_VECTOR_LENGTHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:74:9`!) || !increaseVectorLengthcxx . . $ QTJSC/JSArray#increaseVectorLength(dfa6e707f7696010).(newUsedVectorLength)) { |
| 891 | throwOutOfMemoryErrorcxx . . $ QTJSC/throwOutOfMemoryError(3fbe51058e39576a).(exec); |
| 892 | return; |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | SparseArrayValueMap::iterator end = map->end(); |
| 897 | for (SparseArrayValueMap::iterator it = map->begin(); it !=cxx . . $ QTJSC/`operator!=`(8208a731c2dadbc2). endcxx . . $ std/end(309ad712043406cf).; ++it) { |
| 898 | tree.abstractor().m_nodes[numDefined].value = it->second; |
| 899 | tree.insert(numDefined); |
| 900 | ++numDefined; |
| 901 | } |
| 902 | |
| 903 | delete map; |
| 904 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap. = 0; |
| 905 | } |
| 906 | |
| 907 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(tree.abstractor().m_nodes.size() >= numDefined); |
| 908 | |
| 909 | // FIXME: If the compare function changed the length of the array, the following might be |
| 910 | // modifying the vector incorrectly. |
| 911 | |
| 912 | // Copy the values back into m_storage. |
| 913 | AVLTree<AVLTreeAbstractorForArrayCompare, 44>::Iterator iter; |
| 914 | iter.start_iter_least(tree); |
| 915 | for (unsigned i = 0; i < numDefined; ++i) { |
| 916 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i] = tree.abstractor().m_nodes[*iter].value; |
| 917 | ++iter; |
| 918 | } |
| 919 | |
| 920 | // Put undefined values back in. |
| 921 | for (unsigned i = numDefined; i < newUsedVectorLength; ++i) |
| 922 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i] =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). jsUndefinedcxx . . $ QTJSC/jsUndefined(ad9afe69d7bf6378).(); |
| 923 | |
| 924 | // Ensure that unused values in the vector are zeroed out. |
| 925 | for (unsigned i = newUsedVectorLength; i < usedVectorLength; ++i) |
| 926 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i] =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). JSValuecxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).(); |
| 927 | |
| 928 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector. = newUsedVectorLength; |
| 929 | |
| 930 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(SortConsistencyCheckcxx . . $ QTJSC/JSArray#SortConsistencyCheck.); |
| 931 | } |
| 932 | |
| 933 | void JSArraycxx . . $ QTJSC/JSArray#::fillArgListcxx . . $ QTJSC/JSArray#fillArgList(eebde0cafc55d4c7).(ExecStatecxx . . $ QTJSC/ExecState#* exec, MarkedArgumentBuffercxx . . $ QTJSC/MarkedArgumentBuffer#& args) |
| 934 | { |
| 935 | JSValuecxx . . $ QTJSC/JSValue#* vector = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.; |
| 936 | unsigned vectorEnd = mincxx . . $ std/min(2a338fce5842aa6a).(m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length., m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.); |
| 937 | unsigned i = 0; |
| 938 | for (; i < vectorEnd; ++i) { |
| 939 | JSValuecxx . . $ QTJSC/JSValue#& v = vector[i]; |
| 940 | if (!v) |
| 941 | break; |
| 942 | args.appendcxx . . $ QTJSC/MarkedArgumentBuffer#append(5c2ac18db087b3e6).(v); |
| 943 | } |
| 944 | |
| 945 | for (; i < m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.; ++i) |
| 946 | args.appendcxx . . $ QTJSC/MarkedArgumentBuffer#append(5c2ac18db087b3e6).(getcxx . . $ QTJSC/JSObject#get(ccadc8db5e9d2977).(exec, i)); |
| 947 | } |
| 948 | |
| 949 | void JSArraycxx . . $ QTJSC/JSArray#::copyToRegisterscxx . . $ QTJSC/JSArray#copyToRegisters(d632f462723cc6fe).(ExecStatecxx . . $ QTJSC/ExecState#* exec, Registercxx . . $ QTJSC/Register#* buffer, uint32_tcxx . . $ uint32_t# maxSize) |
| 950 | { |
| 951 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(m_storage->m_length == maxSize); |
| 952 | UNUSED_PARAMcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/UnusedParam.h:27:9`!(maxSize); |
| 953 | JSValuecxx . . $ QTJSC/JSValue#* vector = m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.; |
| 954 | unsigned vectorEnd = mincxx . . $ std/min(2a338fce5842aa6a).(m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length., m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.); |
| 955 | unsigned i = 0; |
| 956 | for (; i < vectorEnd; ++i) { |
| 957 | JSValuecxx . . $ QTJSC/JSValue#& v = vector[i]; |
| 958 | if (!v) |
| 959 | break; |
| 960 | buffer[i] =cxx . . $ QTJSC/Register#`operator=`(812d218e081e87f4). v; |
| 961 | } |
| 962 | |
| 963 | for (; i < m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length.; ++i) |
| 964 | buffer[i] =cxx . . $ QTJSC/Register#`operator=`(812d218e081e87f4). getcxx . . $ QTJSC/JSObject#get(ccadc8db5e9d2977).(exec, i); |
| 965 | } |
| 966 | |
| 967 | unsigned JSArraycxx . . $ QTJSC/JSArray#::compactForSortingcxx . . $ QTJSC/JSArray#compactForSorting(db52760e79bf9054).() |
| 968 | { |
| 969 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(); |
| 970 | |
| 971 | ArrayStoragecxx . . $ QTJSC/ArrayStorage#* storage = m_storagecxx . . $ QTJSC/JSArray#m_storage.; |
| 972 | |
| 973 | unsigned usedVectorLength = mincxx . . $ std/min(2a338fce5842aa6a).(m_storagecxx . . $ QTJSC/JSArray#m_storage.->m_lengthcxx . . $ QTJSC/ArrayStorage#m_length., m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.); |
| 974 | |
| 975 | unsigned numDefined = 0; |
| 976 | unsigned numUndefined = 0; |
| 977 | |
| 978 | for (; numDefined < usedVectorLength; ++numDefined) { |
| 979 | JSValuecxx . . $ QTJSC/JSValue# v = storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[numDefined]; |
| 980 | if (!v || v.isUndefinedcxx . . $ QTJSC/JSValue#isUndefined(50ce9a9e25b4a850).()) |
| 981 | break; |
| 982 | } |
| 983 | for (unsigned i = numDefined; i < usedVectorLength; ++i) { |
| 984 | JSValuecxx . . $ QTJSC/JSValue# v = storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i]; |
| 985 | if (v) { |
| 986 | if (v.isUndefinedcxx . . $ QTJSC/JSValue#isUndefined(50ce9a9e25b4a850).()) |
| 987 | ++numUndefined; |
| 988 | else |
| 989 | storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[numDefined++] =cxx . . $ QTJSC/JSValue#`operator=`(af0e8a528f82a1b5). v; |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | unsigned newUsedVectorLength = numDefined + numUndefined; |
| 994 | |
| 995 | if (SparseArrayValueMapcxx . . $ QTJSC/SparseArrayValueMap#* map = storage->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap.) { |
| 996 | newUsedVectorLength +=cxx . . $ `operator+=`(79c69f12ebd2f310). map->size(); |
| 997 | if (newUsedVectorLength > m_vectorLengthcxx . . $ QTJSC/JSArray#m_vectorLength.) { |
| 998 | // Check that it is possible to allocate an array large enough to hold all the entries - if not, |
| 999 | // exception is thrown by caller. |
| 1000 | if ((newUsedVectorLength > MAX_STORAGE_VECTOR_LENGTHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:74:9`!) || !increaseVectorLengthcxx . . $ QTJSC/JSArray#increaseVectorLength(dfa6e707f7696010).(newUsedVectorLength)) |
| 1001 | return 0; |
| 1002 | storage = m_storagecxx . . $ QTJSC/JSArray#m_storage.; |
| 1003 | } |
| 1004 | |
| 1005 | SparseArrayValueMap::iterator end = map->end(); |
| 1006 | for (SparseArrayValueMap::iterator it = map->begin(); it !=cxx . . $ QTJSC/`operator!=`(8208a731c2dadbc2). endcxx . . $ std/end(309ad712043406cf).; ++it) |
| 1007 | storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[numDefined++] = it->second; |
| 1008 | |
| 1009 | delete map; |
| 1010 | storage->m_sparseValueMapcxx . . $ QTJSC/ArrayStorage#m_sparseValueMap. = 0; |
| 1011 | } |
| 1012 | |
| 1013 | for (unsigned i = numDefined; i < newUsedVectorLength; ++i) |
| 1014 | storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i] =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). jsUndefinedcxx . . $ QTJSC/jsUndefined(ad9afe69d7bf6378).(); |
| 1015 | for (unsigned i = newUsedVectorLength; i < usedVectorLength; ++i) |
| 1016 | storage->m_vectorcxx . . $ QTJSC/ArrayStorage#m_vector.[i] =cxx . . $ QTJSC/JSValue#`operator=`(5dfb8b6405afb35f). JSValuecxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).(); |
| 1017 | |
| 1018 | storage->m_numValuesInVectorcxx . . $ QTJSC/ArrayStorage#m_numValuesInVector. = newUsedVectorLength; |
| 1019 | |
| 1020 | checkConsistencycxx . . $ QTJSC/JSArray#checkConsistency(25e60553dff36af9).(SortConsistencyCheckcxx . . $ QTJSC/JSArray#SortConsistencyCheck.); |
| 1021 | |
| 1022 | return numDefined; |
| 1023 | } |
| 1024 | |
| 1025 | void* JSArraycxx . . $ QTJSC/JSArray#::lazyCreationDatacxx . . $ QTJSC/JSArray#lazyCreationData(50c7df7de5344ebb).() |
| 1026 | { |
| 1027 | return m_storagecxx . . $ QTJSC/JSArray#m_storage.->lazyCreationDatacxx . . $ QTJSC/ArrayStorage#lazyCreationData.; |
| 1028 | } |
| 1029 | |
| 1030 | void JSArraycxx . . $ QTJSC/JSArray#::setLazyCreationDatacxx . . $ QTJSC/JSArray#setLazyCreationData(5d22bdacc48458e8).(void* d) |
| 1031 | { |
| 1032 | m_storagecxx . . $ QTJSC/JSArray#m_storage.->lazyCreationDatacxx . . $ QTJSC/ArrayStorage#lazyCreationData. = d; |
| 1033 | } |
| 1034 | |
| 1035 | #if CHECK_ARRAY_CONSISTENCYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp:36:9`! |
| 1036 | |
| 1037 | void JSArray::checkConsistency(ConsistencyCheckType type) |
| 1038 | { |
| 1039 | ASSERT(m_storage); |
| 1040 | if (type == SortConsistencyCheck) |
| 1041 | ASSERT(!m_storage->m_sparseValueMap); |
| 1042 | |
| 1043 | unsigned numValuesInVector = 0; |
| 1044 | for (unsigned i = 0; i < m_vectorLength; ++i) { |
| 1045 | if (JSValue value = m_storage->m_vector[i]) { |
| 1046 | ASSERT(i < m_storage->m_length); |
| 1047 | if (type != DestructorConsistencyCheck) |
| 1048 | value->type(); // Likely to crash if the object was deallocated. |
| 1049 | ++numValuesInVector; |
| 1050 | } else { |
| 1051 | if (type == SortConsistencyCheck) |
| 1052 | ASSERT(i >= m_storage->m_numValuesInVector); |
| 1053 | } |
| 1054 | } |
| 1055 | ASSERT(numValuesInVector == m_storage->m_numValuesInVector); |
| 1056 | ASSERT(numValuesInVector <= m_storage->m_length); |
| 1057 | |
| 1058 | if (m_storage->m_sparseValueMap) { |
| 1059 | SparseArrayValueMap::iterator end = m_storage->m_sparseValueMap->end(); |
| 1060 | for (SparseArrayValueMap::iterator it = m_storage->m_sparseValueMap->begin(); it != end; ++it) { |
| 1061 | unsigned index = it->first; |
| 1062 | ASSERT(index < m_storage->m_length); |
| 1063 | ASSERT(index >= m_vectorLength); |
| 1064 | ASSERT(index <= MAX_ARRAY_INDEX); |
| 1065 | ASSERT(it->second); |
| 1066 | if (type != DestructorConsistencyCheck) |
| 1067 | it->second->type(); // Likely to crash if the object was deallocated. |
| 1068 | } |
| 1069 | } |
| 1070 | } |
| 1071 | |
| 1072 | #endif |
| 1073 | |
| 1074 | } // namespace JSC |