blob: 4877eb86aa1d18916d84502c03aa3c5027a84964 [file] [log] [blame]
darinc758b282002-11-20 21:12:14 +00001/*
darinc758b282002-11-20 21:12:14 +00002 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
fpizlo@apple.com47d0cf72018-01-25 19:32:00 +00003 * Copyright (C) 2003-2018 Apple Inc. All rights reserved.
darinc758b282002-11-20 21:12:14 +00004 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
mjscdff33b2006-01-23 21:41:36 +000017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
darinc758b282002-11-20 21:12:14 +000018 *
19 */
20
ryanhaddad@apple.com22104f52016-09-28 17:08:17 +000021#pragma once
darinc758b282002-11-20 21:12:14 +000022
annulen@yandex.ru6712c2d2017-06-25 17:40:30 +000023#include "ArgList.h"
fpizlo@apple.comd8dd0532012-09-13 04:18:52 +000024#include "ArrayConventions.h"
mark.lam@apple.coma4fe7ab2012-11-09 03:03:44 +000025#include "ButterflyInlines.h"
keith_miller@apple.com5bed6f62016-06-16 06:01:47 +000026#include "JSCellInlines.h"
ggaren@apple.come5531972012-08-30 23:33:05 +000027#include "JSObject.h"
darinc758b282002-11-20 21:12:14 +000028
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +000029namespace JSC {
darinc758b282002-11-20 21:12:14 +000030
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000031class JSArray;
32class LLIntOffsetsExtractor;
barraclough@apple.com617f4642011-12-23 01:41:04 +000033
utatane.tea@gmail.com84077632018-06-23 08:39:34 +000034extern const ASCIILiteral LengthExceededTheMaximumArrayLengthError;
utatane.tea@gmail.com90782872017-09-30 01:16:52 +000035
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000036class JSArray : public JSNonFinalObject {
37 friend class LLIntOffsetsExtractor;
38 friend class Walker;
39 friend class JIT;
mrowe@apple.comf88a4632008-09-07 05:44:58 +000040
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000041public:
42 typedef JSNonFinalObject Base;
akling@apple.com4b9e0002015-04-13 19:12:48 +000043 static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames;
commit-queue@webkit.org6c25c522011-08-09 20:46:17 +000044
oliver@apple.com26d90af2017-04-13 23:13:41 +000045 static size_t allocationSize(Checked<size_t> inlineCapacity)
fpizlo@apple.com372fa822013-08-21 19:43:47 +000046 {
47 ASSERT_UNUSED(inlineCapacity, !inlineCapacity);
48 return sizeof(JSArray);
49 }
50
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000051protected:
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +000052 explicit JSArray(VM& vm, Structure* structure, Butterfly* butterfly)
53 : JSNonFinalObject(vm, structure, butterfly)
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +000054 {
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +000055 }
56
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000057public:
msaboff@apple.com741818a2017-01-23 18:45:17 +000058 static JSArray* tryCreate(VM&, Structure*, unsigned initialLength = 0);
utatane.tea@gmail.comb9355b52017-09-22 12:19:54 +000059 static JSArray* tryCreate(VM&, Structure*, unsigned initialLength, unsigned vectorLengthHint);
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +000060 static JSArray* create(VM&, Structure*, unsigned initialLength = 0);
fpizlo@apple.com9a175952016-09-28 21:55:53 +000061 static JSArray* createWithButterfly(VM&, GCDeferralContext*, Structure*, Butterfly*);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000062
mark.lam@apple.com21476402017-04-27 19:24:07 +000063 // tryCreateUninitializedRestricted is used for fast construction of arrays whose size and
64 // contents are known at time of creation. This is a restricted API for careful use only in
65 // performance critical code paths. If you don't have a good reason to use it, you probably
66 // shouldn't use it. Instead, you should go with
67 // - JSArray::tryCreate() or JSArray::create() instead of tryCreateUninitializedRestricted(), and
68 // - putDirectIndex() instead of initializeIndex().
69 //
msaboff@apple.com741818a2017-01-23 18:45:17 +000070 // Clients of this interface must:
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000071 // - null-check the result (indicating out of memory, or otherwise unable to allocate vector).
72 // - call 'initializeIndex' for all properties in sequence, for 0 <= i < initialLength.
msaboff@apple.com741818a2017-01-23 18:45:17 +000073 // - Provide a valid GCDefferalContext* if they might garbage collect when initializing properties,
74 // otherwise the caller can provide a null GCDefferalContext*.
mark.lam@apple.com21476402017-04-27 19:24:07 +000075 // - Provide a local stack instance of ObjectInitializationScope at the call site.
msaboff@apple.com741818a2017-01-23 18:45:17 +000076 //
mark.lam@apple.com21476402017-04-27 19:24:07 +000077 JS_EXPORT_PRIVATE static JSArray* tryCreateUninitializedRestricted(ObjectInitializationScope&, GCDeferralContext*, Structure*, unsigned initialLength);
78 static JSArray* tryCreateUninitializedRestricted(ObjectInitializationScope& scope, Structure* structure, unsigned initialLength)
fpizlo@apple.com9a175952016-09-28 21:55:53 +000079 {
mark.lam@apple.com21476402017-04-27 19:24:07 +000080 return tryCreateUninitializedRestricted(scope, nullptr, structure, initialLength);
fpizlo@apple.com9a175952016-09-28 21:55:53 +000081 }
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000082
mark.lam@apple.com5d338932018-07-11 06:21:22 +000083 static void eagerlyInitializeButterfly(ObjectInitializationScope&, JSArray*, unsigned initialLength);
84
barraclough@apple.com61ff98c2013-08-21 22:32:10 +000085 JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool throwException);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000086
fpizlo@apple.comff27eed2014-07-23 04:33:37 +000087 JS_EXPORT_PRIVATE static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000088
fpizlo@apple.com10ae2d02013-08-14 02:41:47 +000089 DECLARE_EXPORT_INFO;
darin@apple.com7efa84c2015-06-24 08:14:14 +000090
91 // OK if we know this is a JSArray, but not if it could be an object of a derived class; for RuntimeArray this always returns 0.
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000092 unsigned length() const { return getArrayLength(); }
darin@apple.com7efa84c2015-06-24 08:14:14 +000093
94 // OK to use on new arrays, but not if it might be a RegExpMatchArray or RuntimeArray.
fpizlo@apple.comff27eed2014-07-23 04:33:37 +000095 JS_EXPORT_PRIVATE bool setLength(ExecState*, unsigned, bool throwException = false);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +000096
utatane.tea@gmail.com90782872017-09-30 01:16:52 +000097 void pushInline(ExecState*, JSValue);
fpizlo@apple.comff27eed2014-07-23 04:33:37 +000098 JS_EXPORT_PRIVATE void push(ExecState*, JSValue);
99 JS_EXPORT_PRIVATE JSValue pop(ExecState*);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000100
akling@apple.com59585302015-05-22 10:18:47 +0000101 JSArray* fastSlice(ExecState&, unsigned startIndex, unsigned count);
rniwa@webkit.org2fa49732015-05-12 21:04:10 +0000102
keith_miller@apple.com5bed6f62016-06-16 06:01:47 +0000103 bool canFastCopy(VM&, JSArray* otherArray);
yusukesuzuki@slowstart.orgfbf1df92018-09-20 05:54:27 +0000104 bool canDoFastIndexedAccess(VM&);
keith_miller@apple.com5bed6f62016-06-16 06:01:47 +0000105 // This function returns NonArray if the indexing types are not compatable for copying.
106 IndexingType mergeIndexingTypeForCopying(IndexingType other);
107 bool appendMemcpy(ExecState*, VM&, unsigned startIndex, JSArray* otherArray);
rniwa@webkit.orgd5e9b422015-07-06 17:45:29 +0000108
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000109 enum ShiftCountMode {
110 // This form of shift hints that we're doing queueing. With this assumption in hand,
111 // we convert to ArrayStorage, which has queue optimizations.
112 ShiftCountForShift,
113
114 // This form of shift hints that we're just doing care and feeding on an array that
115 // is probably typically used for ordinary accesses. With this assumption in hand,
116 // we try to preserve whatever indexing type it has already.
117 ShiftCountForSplice
118 };
119
120 bool shiftCountForShift(ExecState* exec, unsigned startIndex, unsigned count)
fpizlo@apple.comd8dd0532012-09-13 04:18:52 +0000121 {
mark.lam@apple.com23e96242017-09-09 16:21:45 +0000122 VM& vm = exec->vm();
123 return shiftCountWithArrayStorage(vm, startIndex, count, ensureArrayStorage(vm));
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000124 }
mhahnenberg@apple.coma3572b42014-05-20 18:07:48 +0000125 bool shiftCountForSplice(ExecState* exec, unsigned& startIndex, unsigned count)
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000126 {
127 return shiftCountWithAnyIndexingType(exec, startIndex, count);
128 }
129 template<ShiftCountMode shiftCountMode>
mhahnenberg@apple.coma3572b42014-05-20 18:07:48 +0000130 bool shiftCount(ExecState* exec, unsigned& startIndex, unsigned count)
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000131 {
132 switch (shiftCountMode) {
133 case ShiftCountForShift:
134 return shiftCountForShift(exec, startIndex, count);
135 case ShiftCountForSplice:
136 return shiftCountForSplice(exec, startIndex, count);
137 default:
138 CRASH();
139 return false;
140 }
141 }
142
143 bool unshiftCountForShift(ExecState* exec, unsigned startIndex, unsigned count)
144 {
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000145 return unshiftCountWithArrayStorage(exec, startIndex, count, ensureArrayStorage(exec->vm()));
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000146 }
147 bool unshiftCountForSplice(ExecState* exec, unsigned startIndex, unsigned count)
148 {
149 return unshiftCountWithAnyIndexingType(exec, startIndex, count);
150 }
151 template<ShiftCountMode shiftCountMode>
152 bool unshiftCount(ExecState* exec, unsigned startIndex, unsigned count)
153 {
154 switch (shiftCountMode) {
155 case ShiftCountForShift:
156 return unshiftCountForShift(exec, startIndex, count);
157 case ShiftCountForSplice:
158 return unshiftCountForSplice(exec, startIndex, count);
159 default:
160 CRASH();
161 return false;
162 }
163 }
164
fpizlo@apple.comff27eed2014-07-23 04:33:37 +0000165 JS_EXPORT_PRIVATE void fillArgList(ExecState*, MarkedArgumentBuffer&);
fpizlo@apple.combcfd39e2015-02-10 23:16:36 +0000166 JS_EXPORT_PRIVATE void copyToArguments(ExecState*, VirtualRegister firstElementDest, unsigned offset, unsigned length);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000167
sbarati@apple.com732d0672017-04-26 00:52:35 +0000168 JS_EXPORT_PRIVATE bool isIteratorProtocolFastAndNonObservable();
sbarati@apple.com5b8aea12017-01-24 00:15:21 +0000169
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000170 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype, IndexingType indexingType)
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000171 {
keith_miller@apple.com5bed6f62016-06-16 06:01:47 +0000172 return Structure::create(vm, globalObject, prototype, TypeInfo(ArrayType, StructureFlags), info(), indexingType);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000173 }
174
175protected:
utatane.tea@gmail.com4a748b12016-09-17 06:32:50 +0000176 void finishCreation(VM& vm)
177 {
178 Base::finishCreation(vm);
keith_miller@apple.com3f891422018-02-15 02:08:41 +0000179 ASSERT(jsDynamicCast<JSArray*>(vm, this));
utatane.tea@gmail.com4a748b12016-09-17 06:32:50 +0000180 ASSERT_WITH_MESSAGE(type() == ArrayType || type() == DerivedArrayType, "Instance inheriting JSArray should have either ArrayType or DerivedArrayType");
181 }
182
utatane.tea@gmail.com78b50c62016-03-11 17:28:46 +0000183 static bool put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000184
185 static bool deleteProperty(JSCell*, ExecState*, PropertyName);
186 JS_EXPORT_PRIVATE static void getOwnNonIndexPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
187
188private:
189 bool isLengthWritable()
190 {
191 ArrayStorage* storage = arrayStorageOrNull();
192 if (!storage)
193 return true;
194 SparseArrayValueMap* map = storage->m_sparseMap.get();
195 return !map || !map->lengthIsReadOnly();
196 }
197
mhahnenberg@apple.coma3572b42014-05-20 18:07:48 +0000198 bool shiftCountWithAnyIndexingType(ExecState*, unsigned& startIndex, unsigned count);
fpizlo@apple.comff27eed2014-07-23 04:33:37 +0000199 JS_EXPORT_PRIVATE bool shiftCountWithArrayStorage(VM&, unsigned startIndex, unsigned count, ArrayStorage*);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000200
201 bool unshiftCountWithAnyIndexingType(ExecState*, unsigned startIndex, unsigned count);
202 bool unshiftCountWithArrayStorage(ExecState*, unsigned startIndex, unsigned count, ArrayStorage*);
fpizlo@apple.coma88b5ac2017-01-10 18:44:45 +0000203 bool unshiftCountSlowCase(const AbstractLocker&, VM&, DeferGC&, bool, unsigned);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000204
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000205 bool setLengthWithArrayStorage(ExecState*, unsigned newLength, bool throwException, ArrayStorage*);
206 void setLengthWritable(ExecState*, bool writable);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000207};
208
keith_miller@apple.com66c57652018-06-18 23:53:27 +0000209inline Butterfly* tryCreateArrayButterfly(VM& vm, JSObject* intendedOwner, unsigned initialLength)
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000210{
msaboff@apple.com741818a2017-01-23 18:45:17 +0000211 Butterfly* butterfly = Butterfly::tryCreate(
fpizlo@apple.combc16ddb2016-09-06 01:02:22 +0000212 vm, intendedOwner, 0, 0, true, baseIndexingHeaderForArrayStorage(initialLength),
213 ArrayStorage::sizeFor(BASE_ARRAY_STORAGE_VECTOR_LEN));
msaboff@apple.com741818a2017-01-23 18:45:17 +0000214 if (!butterfly)
215 return nullptr;
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000216 ArrayStorage* storage = butterfly->arrayStorage();
fpizlo@apple.com595eebd2016-08-24 19:00:37 +0000217 storage->m_sparseMap.clear();
fpizlo@apple.combc16ddb2016-09-06 01:02:22 +0000218 storage->m_indexBias = 0;
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000219 storage->m_numValuesInVector = 0;
220 return butterfly;
221}
222
utatane.tea@gmail.comb9355b52017-09-22 12:19:54 +0000223inline JSArray* JSArray::tryCreate(VM& vm, Structure* structure, unsigned initialLength, unsigned vectorLengthHint)
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000224{
utatane.tea@gmail.comb9355b52017-09-22 12:19:54 +0000225 ASSERT(vectorLengthHint >= initialLength);
msaboff@apple.com741818a2017-01-23 18:45:17 +0000226 unsigned outOfLineStorage = structure->outOfLineCapacity();
227
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000228 Butterfly* butterfly;
msaboff@apple.com741818a2017-01-23 18:45:17 +0000229 IndexingType indexingType = structure->indexingType();
230 if (LIKELY(!hasAnyArrayStorage(indexingType))) {
fpizlo@apple.com75c91a72012-11-08 22:28:25 +0000231 ASSERT(
msaboff@apple.com741818a2017-01-23 18:45:17 +0000232 hasUndecided(indexingType)
233 || hasInt32(indexingType)
234 || hasDouble(indexingType)
235 || hasContiguous(indexingType));
236
utatane.tea@gmail.comb9355b52017-09-22 12:19:54 +0000237 if (UNLIKELY(vectorLengthHint > MAX_STORAGE_VECTOR_LENGTH))
mark.lam@apple.com21476402017-04-27 19:24:07 +0000238 return nullptr;
msaboff@apple.com741818a2017-01-23 18:45:17 +0000239
utatane.tea@gmail.comb9355b52017-09-22 12:19:54 +0000240 unsigned vectorLength = Butterfly::optimalContiguousVectorLength(structure, vectorLengthHint);
fpizlo@apple.com5efcc492017-11-30 04:39:50 +0000241 void* temp = vm.jsValueGigacageAuxiliarySpace.allocateNonVirtual(
fpizlo@apple.com47d0cf72018-01-25 19:32:00 +0000242 vm,
fpizlo@apple.com5efcc492017-11-30 04:39:50 +0000243 Butterfly::totalSize(0, outOfLineStorage, true, vectorLength * sizeof(EncodedJSValue)),
244 nullptr, AllocationFailureMode::ReturnNull);
msaboff@apple.com741818a2017-01-23 18:45:17 +0000245 if (!temp)
246 return nullptr;
247 butterfly = Butterfly::fromBase(temp, 0, outOfLineStorage);
248 butterfly->setVectorLength(vectorLength);
249 butterfly->setPublicLength(initialLength);
250 if (hasDouble(indexingType))
fpizlo@apple.combc16ddb2016-09-06 01:02:22 +0000251 clearArray(butterfly->contiguousDouble().data(), vectorLength);
rmorisset@apple.com3155c4b2018-01-23 20:49:26 +0000252 else
fpizlo@apple.combc16ddb2016-09-06 01:02:22 +0000253 clearArray(butterfly->contiguous().data(), vectorLength);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000254 } else {
255 ASSERT(
msaboff@apple.com741818a2017-01-23 18:45:17 +0000256 indexingType == ArrayWithSlowPutArrayStorage
257 || indexingType == ArrayWithArrayStorage);
mark.lam@apple.com21476402017-04-27 19:24:07 +0000258 butterfly = tryCreateArrayButterfly(vm, nullptr, initialLength);
msaboff@apple.com741818a2017-01-23 18:45:17 +0000259 if (!butterfly)
260 return nullptr;
fpizlo@apple.combc16ddb2016-09-06 01:02:22 +0000261 for (unsigned i = 0; i < BASE_ARRAY_STORAGE_VECTOR_LEN; ++i)
262 butterfly->arrayStorage()->m_vector[i].clear();
fpizlo@apple.comd8dd0532012-09-13 04:18:52 +0000263 }
akling@apple.com406c2f82015-06-16 18:38:04 +0000264
fpizlo@apple.com9a175952016-09-28 21:55:53 +0000265 return createWithButterfly(vm, nullptr, structure, butterfly);
akling@apple.com406c2f82015-06-16 18:38:04 +0000266}
267
utatane.tea@gmail.comb9355b52017-09-22 12:19:54 +0000268inline JSArray* JSArray::tryCreate(VM& vm, Structure* structure, unsigned initialLength)
269{
270 return tryCreate(vm, structure, initialLength, initialLength);
271}
272
msaboff@apple.com741818a2017-01-23 18:45:17 +0000273inline JSArray* JSArray::create(VM& vm, Structure* structure, unsigned initialLength)
274{
275 JSArray* result = JSArray::tryCreate(vm, structure, initialLength);
276 RELEASE_ASSERT(result);
277
278 return result;
279}
280
fpizlo@apple.com9a175952016-09-28 21:55:53 +0000281inline JSArray* JSArray::createWithButterfly(VM& vm, GCDeferralContext* deferralContext, Structure* structure, Butterfly* butterfly)
akling@apple.com406c2f82015-06-16 18:38:04 +0000282{
fpizlo@apple.com9a175952016-09-28 21:55:53 +0000283 JSArray* array = new (NotNull, allocateCell<JSArray>(vm.heap, deferralContext)) JSArray(vm, structure, butterfly);
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000284 array->finishCreation(vm);
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000285 return array;
286}
mhahnenberg@apple.comc2748322012-02-10 22:44:09 +0000287
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000288JSArray* asArray(JSValue);
darin@apple.com5a494422008-10-18 23:08:12 +0000289
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000290inline JSArray* asArray(JSCell* cell)
291{
utatane.tea@gmail.comdd7199d2018-03-08 16:06:48 +0000292 ASSERT(cell->inherits<JSArray>(*cell->vm()));
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000293 return jsCast<JSArray*>(cell);
294}
darin@apple.com5a494422008-10-18 23:08:12 +0000295
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000296inline JSArray* asArray(JSValue value)
297{
298 return asArray(value.asCell());
299}
darin@apple.com8a1a5b52009-09-04 19:03:33 +0000300
keith_miller@apple.com8736ef12016-04-13 20:49:57 +0000301inline bool isJSArray(JSCell* cell)
302{
keith_miller@apple.com45da7602017-01-27 01:47:52 +0000303 ASSERT((cell->classInfo(*cell->vm()) == JSArray::info()) == (cell->type() == ArrayType));
keith_miller@apple.com5bed6f62016-06-16 06:01:47 +0000304 return cell->type() == ArrayType;
keith_miller@apple.com8736ef12016-04-13 20:49:57 +0000305}
306
fpizlo@apple.coma34ff7d2012-11-06 19:10:37 +0000307inline bool isJSArray(JSValue v) { return v.isCell() && isJSArray(v.asCell()); }
ggaren@apple.comc3343bd2009-02-24 03:58:09 +0000308
keith_miller@apple.com296d5a72018-06-19 20:09:15 +0000309JS_EXPORT_PRIVATE JSArray* constructArray(ExecState*, Structure*, const ArgList& values);
310JS_EXPORT_PRIVATE JSArray* constructArray(ExecState*, Structure*, const JSValue* values, unsigned length);
311JS_EXPORT_PRIVATE JSArray* constructArrayNegativeIndexed(ExecState*, Structure*, const JSValue* values, unsigned length);
msaboff@apple.comb70e41b2013-09-13 18:03:55 +0000312
fpizlo@apple.com6c89cd32012-06-26 19:42:05 +0000313} // namespace JSC