| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/builtins.h" | 5 #include "src/builtins.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 | 202 |
| 203 | 203 |
| 204 inline bool PrototypeHasNoElements(PrototypeIterator* iter) { | 204 inline bool PrototypeHasNoElements(PrototypeIterator* iter) { |
| 205 DisallowHeapAllocation no_gc; | 205 DisallowHeapAllocation no_gc; |
| 206 for (; !iter->IsAtEnd(); iter->Advance()) { | 206 for (; !iter->IsAtEnd(); iter->Advance()) { |
| 207 if (iter->GetCurrent()->IsJSProxy()) return false; | 207 if (iter->GetCurrent()->IsJSProxy()) return false; |
| 208 JSObject* current = iter->GetCurrent<JSObject>(); | 208 JSObject* current = iter->GetCurrent<JSObject>(); |
| 209 if (current->IsAccessCheckNeeded()) return false; | 209 if (current->IsAccessCheckNeeded()) return false; |
| 210 if (current->HasIndexedInterceptor()) return false; | 210 if (current->HasIndexedInterceptor()) return false; |
| 211 if (current->IsJSValue()) return false; |
| 211 if (current->elements()->length() != 0) return false; | 212 if (current->elements()->length() != 0) return false; |
| 212 } | 213 } |
| 213 return true; | 214 return true; |
| 214 } | 215 } |
| 215 | 216 |
| 216 | |
| 217 inline bool IsJSArrayFastElementMovingAllowed(Isolate* isolate, | 217 inline bool IsJSArrayFastElementMovingAllowed(Isolate* isolate, |
| 218 JSArray* receiver) { | 218 JSArray* receiver) { |
| 219 DisallowHeapAllocation no_gc; | 219 DisallowHeapAllocation no_gc; |
| 220 // If the array prototype chain is intact (and free of elements), and if the | 220 // If the array prototype chain is intact (and free of elements), and if the |
| 221 // receiver's prototype is the array prototype, then we are done. | 221 // receiver's prototype is the array prototype, then we are done. |
| 222 Object* prototype = receiver->map()->prototype(); | 222 Object* prototype = receiver->map()->prototype(); |
| 223 if (prototype->IsJSArray() && | 223 if (prototype->IsJSArray() && |
| 224 isolate->is_initial_array_prototype(JSArray::cast(prototype)) && | 224 isolate->is_initial_array_prototype(JSArray::cast(prototype)) && |
| 225 isolate->IsFastArrayConstructorPrototypeChainIntact()) { | 225 isolate->IsFastArrayConstructorPrototypeChainIntact()) { |
| 226 return true; | 226 return true; |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Slow case. | 229 // Slow case. |
| 230 PrototypeIterator iter(isolate, receiver); | 230 PrototypeIterator iter(isolate, receiver); |
| 231 return PrototypeHasNoElements(&iter); | 231 return PrototypeHasNoElements(&iter); |
| 232 } | 232 } |
| 233 | 233 |
| 234 inline bool HasSimpleElements(JSObject* current) { |
| 235 if (current->IsAccessCheckNeeded()) return false; |
| 236 if (current->HasIndexedInterceptor()) return false; |
| 237 if (current->IsJSValue()) return false; |
| 238 if (current->GetElementsAccessor()->HasAccessors(current)) return false; |
| 239 return true; |
| 240 } |
| 241 |
| 242 inline bool HasOnlySimpleReceiverElements(Isolate* isolate, |
| 243 JSReceiver* receiver) { |
| 244 // Check that we have no accessors on the receiver's elements. |
| 245 JSObject* object = JSObject::cast(receiver); |
| 246 if (!HasSimpleElements(object)) return false; |
| 247 // Check that ther are not elements on the prototype. |
| 248 DisallowHeapAllocation no_gc; |
| 249 PrototypeIterator iter(isolate, receiver); |
| 250 return PrototypeHasNoElements(&iter); |
| 251 } |
| 252 |
| 253 inline bool HasOnlySimpleElements(Isolate* isolate, JSReceiver* receiver) { |
| 254 // Check that ther are not elements on the prototype. |
| 255 DisallowHeapAllocation no_gc; |
| 256 PrototypeIterator iter(isolate, receiver, |
| 257 PrototypeIterator::START_AT_RECEIVER); |
| 258 for (; !iter.IsAtEnd(); iter.Advance()) { |
| 259 if (iter.GetCurrent()->IsJSProxy()) return false; |
| 260 JSObject* current = iter.GetCurrent<JSObject>(); |
| 261 if (!HasSimpleElements(current)) return false; |
| 262 } |
| 263 return true; |
| 264 } |
| 234 | 265 |
| 235 // Returns empty handle if not applicable. | 266 // Returns empty handle if not applicable. |
| 236 MUST_USE_RESULT | 267 MUST_USE_RESULT |
| 237 inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements( | 268 inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements( |
| 238 Isolate* isolate, Handle<Object> receiver, Arguments* args, | 269 Isolate* isolate, Handle<Object> receiver, Arguments* args, |
| 239 int first_added_arg) { | 270 int first_added_arg) { |
| 240 if (!receiver->IsJSArray()) return MaybeHandle<FixedArrayBase>(); | 271 if (!receiver->IsJSArray()) return MaybeHandle<FixedArrayBase>(); |
| 241 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 272 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 242 // If there may be elements accessors in the prototype chain, the fast path | 273 // If there may be elements accessors in the prototype chain, the fast path |
| 243 // cannot be used if there arguments to add to the array. | 274 // cannot be used if there arguments to add to the array. |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 Handle<Object> key = isolate->factory()->length_string(); | 1037 Handle<Object> key = isolate->factory()->length_string(); |
| 1007 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 1038 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 1008 isolate, val, Runtime::GetObjectProperty(isolate, receiver, key), | 1039 isolate, val, Runtime::GetObjectProperty(isolate, receiver, key), |
| 1009 false); | 1040 false); |
| 1010 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, val, | 1041 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, val, |
| 1011 Object::ToLength(isolate, val), false); | 1042 Object::ToLength(isolate, val), false); |
| 1012 // TODO(caitp): Support larger element indexes (up to 2^53-1). | 1043 // TODO(caitp): Support larger element indexes (up to 2^53-1). |
| 1013 if (!val->ToUint32(&length)) { | 1044 if (!val->ToUint32(&length)) { |
| 1014 length = 0; | 1045 length = 0; |
| 1015 } | 1046 } |
| 1047 return IterateElementsSlow(isolate, receiver, length, visitor); |
| 1016 } | 1048 } |
| 1017 | 1049 |
| 1018 if (!(receiver->IsJSArray() || receiver->IsJSTypedArray())) { | 1050 if (!HasOnlySimpleElements(isolate, *receiver)) { |
| 1019 // For classes which are not known to be safe to access via elements alone, | 1051 // For classes which are not known to be safe to access via elements alone, |
| 1020 // use the slow case. | 1052 // use the slow case. |
| 1021 return IterateElementsSlow(isolate, receiver, length, visitor); | 1053 return IterateElementsSlow(isolate, receiver, length, visitor); |
| 1022 } | 1054 } |
| 1023 Handle<JSObject> array = Handle<JSObject>::cast(receiver); | 1055 Handle<JSObject> array = Handle<JSObject>::cast(receiver); |
| 1024 | 1056 |
| 1025 switch (array->GetElementsKind()) { | 1057 switch (array->GetElementsKind()) { |
| 1026 case FAST_SMI_ELEMENTS: | 1058 case FAST_SMI_ELEMENTS: |
| 1027 case FAST_ELEMENTS: | 1059 case FAST_ELEMENTS: |
| 1028 case FAST_HOLEY_SMI_ELEMENTS: | 1060 case FAST_HOLEY_SMI_ELEMENTS: |
| 1029 case FAST_HOLEY_ELEMENTS: { | 1061 case FAST_HOLEY_ELEMENTS: { |
| 1030 // Run through the elements FixedArray and use HasElement and GetElement | 1062 // Run through the elements FixedArray and use HasElement and GetElement |
| 1031 // to check the prototype for missing elements. | 1063 // to check the prototype for missing elements. |
| 1032 Handle<FixedArray> elements(FixedArray::cast(array->elements())); | 1064 Handle<FixedArray> elements(FixedArray::cast(array->elements())); |
| 1033 int fast_length = static_cast<int>(length); | 1065 int fast_length = static_cast<int>(length); |
| 1034 DCHECK(fast_length <= elements->length()); | 1066 DCHECK_LE(fast_length, elements->length()); |
| 1035 for (int j = 0; j < fast_length; j++) { | 1067 for (int j = 0; j < fast_length; j++) { |
| 1036 HandleScope loop_scope(isolate); | 1068 HandleScope loop_scope(isolate); |
| 1037 Handle<Object> element_value(elements->get(j), isolate); | 1069 Handle<Object> element_value(elements->get(j), isolate); |
| 1038 if (!element_value->IsTheHole()) { | 1070 if (!element_value->IsTheHole()) { |
| 1039 visitor->visit(j, element_value); | 1071 visitor->visit(j, element_value); |
| 1040 } else { | 1072 } else { |
| 1041 Maybe<bool> maybe = JSReceiver::HasElement(array, j); | 1073 Maybe<bool> maybe = JSReceiver::HasElement(array, j); |
| 1042 if (!maybe.IsJust()) return false; | 1074 if (!maybe.IsJust()) return false; |
| 1043 if (maybe.FromJust()) { | 1075 if (maybe.FromJust()) { |
| 1044 // Call GetElement on array, not its prototype, or getters won't | 1076 // Call GetElement on array, not its prototype, or getters won't |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 1115 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 1084 isolate, element_value, Object::GetElement(isolate, array, j), | 1116 isolate, element_value, Object::GetElement(isolate, array, j), |
| 1085 false); | 1117 false); |
| 1086 visitor->visit(j, element_value); | 1118 visitor->visit(j, element_value); |
| 1087 } | 1119 } |
| 1088 } | 1120 } |
| 1089 } | 1121 } |
| 1090 break; | 1122 break; |
| 1091 } | 1123 } |
| 1092 case DICTIONARY_ELEMENTS: { | 1124 case DICTIONARY_ELEMENTS: { |
| 1093 // CollectElementIndices() can't be called when there's a JSProxy | |
| 1094 // on the prototype chain. | |
| 1095 for (PrototypeIterator iter(isolate, array); !iter.IsAtEnd(); | |
| 1096 iter.Advance()) { | |
| 1097 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { | |
| 1098 return IterateElementsSlow(isolate, array, length, visitor); | |
| 1099 } | |
| 1100 } | |
| 1101 Handle<SeededNumberDictionary> dict(array->element_dictionary()); | 1125 Handle<SeededNumberDictionary> dict(array->element_dictionary()); |
| 1102 List<uint32_t> indices(dict->Capacity() / 2); | 1126 List<uint32_t> indices(dict->Capacity() / 2); |
| 1103 // Collect all indices in the object and the prototypes less | 1127 // Collect all indices in the object and the prototypes less |
| 1104 // than length. This might introduce duplicates in the indices list. | 1128 // than length. This might introduce duplicates in the indices list. |
| 1105 CollectElementIndices(array, length, &indices); | 1129 CollectElementIndices(array, length, &indices); |
| 1106 indices.Sort(&compareUInt32); | 1130 indices.Sort(&compareUInt32); |
| 1107 int j = 0; | 1131 int j = 0; |
| 1108 int n = indices.length(); | 1132 int n = indices.length(); |
| 1109 while (j < n) { | 1133 while (j < n) { |
| 1110 HandleScope loop_scope(isolate); | 1134 HandleScope loop_scope(isolate); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 } | 1204 } |
| 1181 break; | 1205 break; |
| 1182 } | 1206 } |
| 1183 } | 1207 } |
| 1184 visitor->increase_index_offset(length); | 1208 visitor->increase_index_offset(length); |
| 1185 return true; | 1209 return true; |
| 1186 } | 1210 } |
| 1187 | 1211 |
| 1188 | 1212 |
| 1189 bool HasConcatSpreadableModifier(Isolate* isolate, Handle<JSArray> obj) { | 1213 bool HasConcatSpreadableModifier(Isolate* isolate, Handle<JSArray> obj) { |
| 1190 DCHECK(isolate->IsFastArrayConstructorPrototypeChainIntact()); | |
| 1191 if (!FLAG_harmony_concat_spreadable) return false; | 1214 if (!FLAG_harmony_concat_spreadable) return false; |
| 1192 Handle<Symbol> key(isolate->factory()->is_concat_spreadable_symbol()); | 1215 Handle<Symbol> key(isolate->factory()->is_concat_spreadable_symbol()); |
| 1193 Maybe<bool> maybe = JSReceiver::HasProperty(obj, key); | 1216 Maybe<bool> maybe = JSReceiver::HasProperty(obj, key); |
| 1194 return maybe.FromMaybe(false); | 1217 return maybe.FromMaybe(false); |
| 1195 } | 1218 } |
| 1196 | 1219 |
| 1197 | 1220 |
| 1198 static Maybe<bool> IsConcatSpreadable(Isolate* isolate, Handle<Object> obj) { | 1221 static Maybe<bool> IsConcatSpreadable(Isolate* isolate, Handle<Object> obj) { |
| 1199 HandleScope handle_scope(isolate); | 1222 HandleScope handle_scope(isolate); |
| 1200 if (!obj->IsJSReceiver()) return Just(false); | 1223 if (!obj->IsJSReceiver()) return Just(false); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1225 for (int i = 0; i < argument_count; i++) { | 1248 for (int i = 0; i < argument_count; i++) { |
| 1226 HandleScope loop_scope(isolate); | 1249 HandleScope loop_scope(isolate); |
| 1227 Handle<Object> obj((*args)[i], isolate); | 1250 Handle<Object> obj((*args)[i], isolate); |
| 1228 uint32_t length_estimate; | 1251 uint32_t length_estimate; |
| 1229 uint32_t element_estimate; | 1252 uint32_t element_estimate; |
| 1230 if (obj->IsJSArray()) { | 1253 if (obj->IsJSArray()) { |
| 1231 Handle<JSArray> array(Handle<JSArray>::cast(obj)); | 1254 Handle<JSArray> array(Handle<JSArray>::cast(obj)); |
| 1232 length_estimate = static_cast<uint32_t>(array->length()->Number()); | 1255 length_estimate = static_cast<uint32_t>(array->length()->Number()); |
| 1233 if (length_estimate != 0) { | 1256 if (length_estimate != 0) { |
| 1234 ElementsKind array_kind = | 1257 ElementsKind array_kind = |
| 1235 GetPackedElementsKind(array->map()->elements_kind()); | 1258 GetPackedElementsKind(array->GetElementsKind()); |
| 1236 kind = GetMoreGeneralElementsKind(kind, array_kind); | 1259 kind = GetMoreGeneralElementsKind(kind, array_kind); |
| 1237 } | 1260 } |
| 1238 element_estimate = EstimateElementCount(array); | 1261 element_estimate = EstimateElementCount(array); |
| 1239 } else { | 1262 } else { |
| 1240 if (obj->IsHeapObject()) { | 1263 if (obj->IsHeapObject()) { |
| 1241 if (obj->IsNumber()) { | 1264 kind = GetMoreGeneralElementsKind( |
| 1242 kind = GetMoreGeneralElementsKind(kind, FAST_DOUBLE_ELEMENTS); | 1265 kind, obj->IsNumber() ? FAST_DOUBLE_ELEMENTS : FAST_ELEMENTS); |
| 1243 } else { | |
| 1244 kind = GetMoreGeneralElementsKind(kind, FAST_ELEMENTS); | |
| 1245 } | |
| 1246 } | 1266 } |
| 1247 length_estimate = 1; | 1267 length_estimate = 1; |
| 1248 element_estimate = 1; | 1268 element_estimate = 1; |
| 1249 } | 1269 } |
| 1250 // Avoid overflows by capping at kMaxElementCount. | 1270 // Avoid overflows by capping at kMaxElementCount. |
| 1251 if (JSObject::kMaxElementCount - estimate_result_length < length_estimate) { | 1271 if (JSObject::kMaxElementCount - estimate_result_length < length_estimate) { |
| 1252 estimate_result_length = JSObject::kMaxElementCount; | 1272 estimate_result_length = JSObject::kMaxElementCount; |
| 1253 } else { | 1273 } else { |
| 1254 estimate_result_length += length_estimate; | 1274 estimate_result_length += length_estimate; |
| 1255 } | 1275 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1277 Handle<Object> obj((*args)[i], isolate); | 1297 Handle<Object> obj((*args)[i], isolate); |
| 1278 if (obj->IsSmi()) { | 1298 if (obj->IsSmi()) { |
| 1279 double_storage->set(j, Smi::cast(*obj)->value()); | 1299 double_storage->set(j, Smi::cast(*obj)->value()); |
| 1280 j++; | 1300 j++; |
| 1281 } else if (obj->IsNumber()) { | 1301 } else if (obj->IsNumber()) { |
| 1282 double_storage->set(j, obj->Number()); | 1302 double_storage->set(j, obj->Number()); |
| 1283 j++; | 1303 j++; |
| 1284 } else { | 1304 } else { |
| 1285 JSArray* array = JSArray::cast(*obj); | 1305 JSArray* array = JSArray::cast(*obj); |
| 1286 uint32_t length = static_cast<uint32_t>(array->length()->Number()); | 1306 uint32_t length = static_cast<uint32_t>(array->length()->Number()); |
| 1287 switch (array->map()->elements_kind()) { | 1307 switch (array->GetElementsKind()) { |
| 1288 case FAST_HOLEY_DOUBLE_ELEMENTS: | 1308 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 1289 case FAST_DOUBLE_ELEMENTS: { | 1309 case FAST_DOUBLE_ELEMENTS: { |
| 1290 // Empty array is FixedArray but not FixedDoubleArray. | 1310 // Empty array is FixedArray but not FixedDoubleArray. |
| 1291 if (length == 0) break; | 1311 if (length == 0) break; |
| 1292 FixedDoubleArray* elements = | 1312 FixedDoubleArray* elements = |
| 1293 FixedDoubleArray::cast(array->elements()); | 1313 FixedDoubleArray::cast(array->elements()); |
| 1294 for (uint32_t i = 0; i < length; i++) { | 1314 for (uint32_t i = 0; i < length; i++) { |
| 1295 if (elements->is_the_hole(i)) { | 1315 if (elements->is_the_hole(i)) { |
| 1296 // TODO(jkummerow/verwaest): We could be a bit more clever | 1316 // TODO(jkummerow/verwaest): We could be a bit more clever |
| 1297 // here: Check if there are no elements/getters on the | 1317 // here: Check if there are no elements/getters on the |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1328 DCHECK_EQ(0u, length); | 1348 DCHECK_EQ(0u, length); |
| 1329 break; | 1349 break; |
| 1330 default: | 1350 default: |
| 1331 UNREACHABLE(); | 1351 UNREACHABLE(); |
| 1332 } | 1352 } |
| 1333 } | 1353 } |
| 1334 if (failure) break; | 1354 if (failure) break; |
| 1335 } | 1355 } |
| 1336 } | 1356 } |
| 1337 if (!failure) { | 1357 if (!failure) { |
| 1338 Handle<JSArray> array = isolate->factory()->NewJSArray(0); | 1358 return *isolate->factory()->NewJSArrayWithElements(storage, kind, j); |
| 1339 Smi* length = Smi::FromInt(j); | |
| 1340 Handle<Map> map; | |
| 1341 map = JSObject::GetElementsTransitionMap(array, kind); | |
| 1342 array->set_map(*map); | |
| 1343 array->set_length(length); | |
| 1344 array->set_elements(*storage); | |
| 1345 return *array; | |
| 1346 } | 1359 } |
| 1347 // In case of failure, fall through. | 1360 // In case of failure, fall through. |
| 1348 } | 1361 } |
| 1349 | 1362 |
| 1350 Handle<FixedArray> storage; | 1363 Handle<FixedArray> storage; |
| 1351 if (fast_case) { | 1364 if (fast_case) { |
| 1352 // The backing storage array must have non-existing elements to preserve | 1365 // The backing storage array must have non-existing elements to preserve |
| 1353 // holes across concat operations. | 1366 // holes across concat operations. |
| 1354 storage = | 1367 storage = |
| 1355 isolate->factory()->NewFixedArrayWithHoles(estimate_result_length); | 1368 isolate->factory()->NewFixedArrayWithHoles(estimate_result_length); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1380 | 1393 |
| 1381 if (visitor.exceeds_array_limit()) { | 1394 if (visitor.exceeds_array_limit()) { |
| 1382 THROW_NEW_ERROR_RETURN_FAILURE( | 1395 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1383 isolate, NewRangeError(MessageTemplate::kInvalidArrayLength)); | 1396 isolate, NewRangeError(MessageTemplate::kInvalidArrayLength)); |
| 1384 } | 1397 } |
| 1385 return *visitor.ToArray(); | 1398 return *visitor.ToArray(); |
| 1386 } | 1399 } |
| 1387 | 1400 |
| 1388 | 1401 |
| 1389 MaybeHandle<JSArray> Fast_ArrayConcat(Isolate* isolate, Arguments* args) { | 1402 MaybeHandle<JSArray> Fast_ArrayConcat(Isolate* isolate, Arguments* args) { |
| 1390 if (!isolate->IsFastArrayConstructorPrototypeChainIntact()) { | |
| 1391 return MaybeHandle<JSArray>(); | |
| 1392 } | |
| 1393 int n_arguments = args->length(); | 1403 int n_arguments = args->length(); |
| 1394 int result_len = 0; | 1404 int result_len = 0; |
| 1395 { | 1405 { |
| 1396 DisallowHeapAllocation no_gc; | 1406 DisallowHeapAllocation no_gc; |
| 1397 Object* array_proto = isolate->array_function()->prototype(); | |
| 1398 // Iterate through all the arguments performing checks | 1407 // Iterate through all the arguments performing checks |
| 1399 // and calculating total length. | 1408 // and calculating total length. |
| 1400 for (int i = 0; i < n_arguments; i++) { | 1409 for (int i = 0; i < n_arguments; i++) { |
| 1401 Object* arg = (*args)[i]; | 1410 Object* arg = (*args)[i]; |
| 1402 if (!arg->IsJSArray()) return MaybeHandle<JSArray>(); | 1411 if (!arg->IsJSArray()) return MaybeHandle<JSArray>(); |
| 1412 if (!HasOnlySimpleReceiverElements(isolate, JSObject::cast(arg))) { |
| 1413 return MaybeHandle<JSArray>(); |
| 1414 } |
| 1415 // TODO(cbruni): support fast concatenation of DICTIONARY_ELEMENTS. |
| 1416 if (!JSObject::cast(arg)->HasFastElements()) { |
| 1417 return MaybeHandle<JSArray>(); |
| 1418 } |
| 1403 Handle<JSArray> array(JSArray::cast(arg), isolate); | 1419 Handle<JSArray> array(JSArray::cast(arg), isolate); |
| 1404 if (!array->HasFastElements()) return MaybeHandle<JSArray>(); | |
| 1405 PrototypeIterator iter(isolate, arg); | |
| 1406 if (iter.GetCurrent() != array_proto) return MaybeHandle<JSArray>(); | |
| 1407 if (HasConcatSpreadableModifier(isolate, array)) { | 1420 if (HasConcatSpreadableModifier(isolate, array)) { |
| 1408 return MaybeHandle<JSArray>(); | 1421 return MaybeHandle<JSArray>(); |
| 1409 } | 1422 } |
| 1410 int len = Smi::cast(array->length())->value(); | 1423 int len = Smi::cast(array->length())->value(); |
| 1411 | 1424 |
| 1412 // We shouldn't overflow when adding another len. | 1425 // We shouldn't overflow when adding another len. |
| 1413 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2); | 1426 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2); |
| 1414 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt); | 1427 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt); |
| 1415 USE(kHalfOfMaxInt); | 1428 USE(kHalfOfMaxInt); |
| 1416 result_len += len; | 1429 result_len += len; |
| (...skipping 2570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3987 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4000 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 3988 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4001 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 3989 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4002 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 3990 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4003 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 3991 #undef DEFINE_BUILTIN_ACCESSOR_C | 4004 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 3992 #undef DEFINE_BUILTIN_ACCESSOR_A | 4005 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 3993 | 4006 |
| 3994 | 4007 |
| 3995 } // namespace internal | 4008 } // namespace internal |
| 3996 } // namespace v8 | 4009 } // namespace v8 |
| OLD | NEW |