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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/elements.h" | 9 #include "src/elements.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 length = fixed_array_base->length(); | 576 length = fixed_array_base->length(); |
577 } | 577 } |
578 ElementsAccessorSubclass::ValidateContents(holder, length); | 578 ElementsAccessorSubclass::ValidateContents(holder, length); |
579 } | 579 } |
580 | 580 |
581 void Validate(Handle<JSObject> holder) final { | 581 void Validate(Handle<JSObject> holder) final { |
582 DisallowHeapAllocation no_gc; | 582 DisallowHeapAllocation no_gc; |
583 ElementsAccessorSubclass::ValidateImpl(holder); | 583 ElementsAccessorSubclass::ValidateImpl(holder); |
584 } | 584 } |
585 | 585 |
| 586 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key, |
| 587 Handle<FixedArrayBase> backing_store) { |
| 588 return ElementsAccessorSubclass::GetAttributesImpl( |
| 589 *holder, key, *backing_store) != ABSENT; |
| 590 } |
| 591 |
586 virtual bool HasElement(Handle<JSObject> holder, uint32_t key, | 592 virtual bool HasElement(Handle<JSObject> holder, uint32_t key, |
587 Handle<FixedArrayBase> backing_store) final { | 593 Handle<FixedArrayBase> backing_store) final { |
588 return ElementsAccessorSubclass::GetIndexForKeyImpl(*holder, *backing_store, | 594 return ElementsAccessorSubclass::HasElementImpl(holder, key, backing_store); |
589 key) != kMaxUInt32; | |
590 } | 595 } |
591 | 596 |
592 virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key, | 597 virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key, |
593 Handle<FixedArrayBase> backing_store) final { | 598 Handle<FixedArrayBase> backing_store) final { |
594 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && | 599 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && |
595 FLAG_trace_js_array_abuse) { | 600 FLAG_trace_js_array_abuse) { |
596 CheckArrayAbuse(holder, "elements read", key); | 601 CheckArrayAbuse(holder, "elements read", key); |
597 } | 602 } |
598 | 603 |
599 if (IsExternalArrayElementsKind(ElementsTraits::Kind) && | 604 if (IsExternalArrayElementsKind(ElementsTraits::Kind) && |
(...skipping 21 matching lines...) Expand all Loading... |
621 | 626 |
622 static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key, | 627 static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key, |
623 Handle<FixedArrayBase> backing_store, | 628 Handle<FixedArrayBase> backing_store, |
624 Handle<Object> value) { | 629 Handle<Object> value) { |
625 CHECK(key < | 630 CHECK(key < |
626 ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)); | 631 ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)); |
627 return BackingStore::SetValue( | 632 return BackingStore::SetValue( |
628 obj, Handle<BackingStore>::cast(backing_store), key, value); | 633 obj, Handle<BackingStore>::cast(backing_store), key, value); |
629 } | 634 } |
630 | 635 |
| 636 virtual PropertyAttributes GetAttributes( |
| 637 JSObject* holder, uint32_t key, FixedArrayBase* backing_store) final { |
| 638 return ElementsAccessorSubclass::GetAttributesImpl(holder, key, |
| 639 backing_store); |
| 640 } |
| 641 |
| 642 static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key, |
| 643 FixedArrayBase* backing_store) { |
| 644 if (key >= ElementsAccessorSubclass::GetCapacityImpl(obj, backing_store)) { |
| 645 return ABSENT; |
| 646 } |
| 647 return BackingStore::cast(backing_store)->is_the_hole(key) ? ABSENT : NONE; |
| 648 } |
| 649 |
631 virtual MaybeHandle<AccessorPair> GetAccessorPair( | 650 virtual MaybeHandle<AccessorPair> GetAccessorPair( |
632 Handle<JSObject> holder, uint32_t key, | 651 Handle<JSObject> holder, uint32_t key, |
633 Handle<FixedArrayBase> backing_store) final { | 652 Handle<FixedArrayBase> backing_store) final { |
634 return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key, | 653 return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key, |
635 backing_store); | 654 backing_store); |
636 } | 655 } |
637 | 656 |
638 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 657 static MaybeHandle<AccessorPair> GetAccessorPairImpl( |
639 Handle<JSObject> obj, uint32_t key, | 658 Handle<JSObject> obj, uint32_t key, |
640 Handle<FixedArrayBase> backing_store) { | 659 Handle<FixedArrayBase> backing_store) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 static uint32_t GetKeyForIndexImpl(FixedArrayBase* backing_store, | 835 static uint32_t GetKeyForIndexImpl(FixedArrayBase* backing_store, |
817 uint32_t index) { | 836 uint32_t index) { |
818 return index; | 837 return index; |
819 } | 838 } |
820 | 839 |
821 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, | 840 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
822 uint32_t index) final { | 841 uint32_t index) final { |
823 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index); | 842 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index); |
824 } | 843 } |
825 | 844 |
826 static uint32_t GetIndexForKeyImpl(JSObject* holder, | 845 static uint32_t GetIndexForKeyImpl(FixedArrayBase* backing_store, |
827 FixedArrayBase* backing_store, | |
828 uint32_t key) { | 846 uint32_t key) { |
829 return key < ElementsAccessorSubclass::GetCapacityImpl(holder, | 847 return key; |
830 backing_store) && | |
831 !BackingStore::cast(backing_store)->is_the_hole(key) | |
832 ? key | |
833 : kMaxUInt32; | |
834 } | 848 } |
835 | 849 |
836 virtual uint32_t GetIndexForKey(JSObject* holder, | 850 virtual uint32_t GetIndexForKey(FixedArrayBase* backing_store, |
837 FixedArrayBase* backing_store, | |
838 uint32_t key) final { | 851 uint32_t key) final { |
839 return ElementsAccessorSubclass::GetIndexForKeyImpl(holder, backing_store, | 852 return ElementsAccessorSubclass::GetIndexForKeyImpl(backing_store, key); |
840 key); | |
841 } | 853 } |
842 | 854 |
843 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, | 855 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, |
844 uint32_t index) { | 856 uint32_t index) { |
845 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); | 857 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); |
846 } | 858 } |
847 | 859 |
848 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, | 860 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, |
849 uint32_t index) final { | 861 uint32_t index) final { |
850 return ElementsAccessorSubclass::GetDetailsImpl(backing_store, index); | 862 return ElementsAccessorSubclass::GetDetailsImpl(backing_store, index); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 } | 987 } |
976 } | 988 } |
977 } | 989 } |
978 } | 990 } |
979 | 991 |
980 virtual void Delete(Handle<JSObject> obj, uint32_t key, | 992 virtual void Delete(Handle<JSObject> obj, uint32_t key, |
981 LanguageMode language_mode) final { | 993 LanguageMode language_mode) final { |
982 DeleteCommon(obj, key, language_mode); | 994 DeleteCommon(obj, key, language_mode); |
983 } | 995 } |
984 | 996 |
| 997 static bool HasElementImpl( |
| 998 Handle<JSObject> holder, |
| 999 uint32_t key, |
| 1000 Handle<FixedArrayBase> backing_store) { |
| 1001 if (key >= static_cast<uint32_t>(backing_store->length())) { |
| 1002 return false; |
| 1003 } |
| 1004 return !Handle<BackingStore>::cast(backing_store)->is_the_hole(key); |
| 1005 } |
| 1006 |
985 static bool HasIndexImpl(FixedArrayBase* backing_store, uint32_t index) { | 1007 static bool HasIndexImpl(FixedArrayBase* backing_store, uint32_t index) { |
986 return !BackingStore::cast(backing_store)->is_the_hole(index); | 1008 return !BackingStore::cast(backing_store)->is_the_hole(index); |
987 } | 1009 } |
988 | 1010 |
989 static void ValidateContents(Handle<JSObject> holder, int length) { | 1011 static void ValidateContents(Handle<JSObject> holder, int length) { |
990 #if DEBUG | 1012 #if DEBUG |
991 Isolate* isolate = holder->GetIsolate(); | 1013 Isolate* isolate = holder->GetIsolate(); |
992 HandleScope scope(isolate); | 1014 HandleScope scope(isolate); |
993 Handle<FixedArrayBase> elements(holder->elements(), isolate); | 1015 Handle<FixedArrayBase> elements(holder->elements(), isolate); |
994 Map* map = elements->map(); | 1016 Map* map = elements->map(); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 | 1286 |
1265 static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t key, | 1287 static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t key, |
1266 Handle<FixedArrayBase> backing_store) { | 1288 Handle<FixedArrayBase> backing_store) { |
1267 if (key < AccessorClass::GetCapacityImpl(*obj, *backing_store)) { | 1289 if (key < AccessorClass::GetCapacityImpl(*obj, *backing_store)) { |
1268 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); | 1290 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); |
1269 } else { | 1291 } else { |
1270 return backing_store->GetIsolate()->factory()->undefined_value(); | 1292 return backing_store->GetIsolate()->factory()->undefined_value(); |
1271 } | 1293 } |
1272 } | 1294 } |
1273 | 1295 |
| 1296 static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key, |
| 1297 FixedArrayBase* backing_store) { |
| 1298 return key < AccessorClass::GetCapacityImpl(obj, backing_store) |
| 1299 ? DONT_DELETE |
| 1300 : ABSENT; |
| 1301 } |
| 1302 |
1274 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, | 1303 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, |
1275 uint32_t index) { | 1304 uint32_t index) { |
1276 return PropertyDetails(DONT_DELETE, DATA, 0, PropertyCellType::kNoCell); | 1305 return PropertyDetails(DONT_DELETE, DATA, 0, PropertyCellType::kNoCell); |
1277 } | 1306 } |
1278 | 1307 |
1279 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( | 1308 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( |
1280 Handle<JSObject> obj, | 1309 Handle<JSObject> obj, |
1281 Handle<Object> length, | 1310 Handle<Object> length, |
1282 Handle<FixedArrayBase> backing_store) { | 1311 Handle<FixedArrayBase> backing_store) { |
1283 // External arrays do not support changing their length. | 1312 // External arrays do not support changing their length. |
1284 UNREACHABLE(); | 1313 UNREACHABLE(); |
1285 return obj; | 1314 return obj; |
1286 } | 1315 } |
1287 | 1316 |
1288 virtual void Delete(Handle<JSObject> obj, uint32_t key, | 1317 virtual void Delete(Handle<JSObject> obj, uint32_t key, |
1289 LanguageMode language_mode) final { | 1318 LanguageMode language_mode) final { |
1290 // External arrays always ignore deletes. | 1319 // External arrays always ignore deletes. |
1291 } | 1320 } |
1292 | 1321 |
1293 static uint32_t GetIndexForKeyImpl(JSObject* holder, | 1322 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key, |
1294 FixedArrayBase* backing_store, | 1323 Handle<FixedArrayBase> backing_store) { |
1295 uint32_t key) { | 1324 uint32_t capacity = AccessorClass::GetCapacityImpl(*holder, *backing_store); |
1296 return key < AccessorClass::GetCapacityImpl(holder, backing_store) | 1325 return key < capacity; |
1297 ? key | |
1298 : kMaxUInt32; | |
1299 } | 1326 } |
1300 | 1327 |
1301 static uint32_t GetCapacityImpl(JSObject* holder, | 1328 static uint32_t GetCapacityImpl(JSObject* holder, |
1302 FixedArrayBase* backing_store) { | 1329 FixedArrayBase* backing_store) { |
1303 JSArrayBufferView* view = JSArrayBufferView::cast(holder); | 1330 JSArrayBufferView* view = JSArrayBufferView::cast(holder); |
1304 if (view->WasNeutered()) return 0; | 1331 if (view->WasNeutered()) return 0; |
1305 return backing_store->length(); | 1332 return backing_store->length(); |
1306 } | 1333 } |
1307 }; | 1334 }; |
1308 | 1335 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 Handle<FixedArrayBase> store, | 1478 Handle<FixedArrayBase> store, |
1452 Handle<Object> value) { | 1479 Handle<Object> value) { |
1453 Handle<SeededNumberDictionary> backing_store = | 1480 Handle<SeededNumberDictionary> backing_store = |
1454 Handle<SeededNumberDictionary>::cast(store); | 1481 Handle<SeededNumberDictionary>::cast(store); |
1455 int entry = backing_store->FindEntry(key); | 1482 int entry = backing_store->FindEntry(key); |
1456 DCHECK_NE(SeededNumberDictionary::kNotFound, entry); | 1483 DCHECK_NE(SeededNumberDictionary::kNotFound, entry); |
1457 backing_store->ValueAtPut(entry, *value); | 1484 backing_store->ValueAtPut(entry, *value); |
1458 return value; | 1485 return value; |
1459 } | 1486 } |
1460 | 1487 |
| 1488 static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key, |
| 1489 FixedArrayBase* backing_store) { |
| 1490 SeededNumberDictionary* dictionary = |
| 1491 SeededNumberDictionary::cast(backing_store); |
| 1492 int entry = dictionary->FindEntry(key); |
| 1493 if (entry != SeededNumberDictionary::kNotFound) { |
| 1494 return dictionary->DetailsAt(entry).attributes(); |
| 1495 } |
| 1496 return ABSENT; |
| 1497 } |
| 1498 |
1461 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 1499 static MaybeHandle<AccessorPair> GetAccessorPairImpl( |
1462 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> store) { | 1500 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> store) { |
1463 Handle<SeededNumberDictionary> backing_store = | 1501 Handle<SeededNumberDictionary> backing_store = |
1464 Handle<SeededNumberDictionary>::cast(store); | 1502 Handle<SeededNumberDictionary>::cast(store); |
1465 int entry = backing_store->FindEntry(key); | 1503 int entry = backing_store->FindEntry(key); |
1466 if (entry != SeededNumberDictionary::kNotFound && | 1504 if (entry != SeededNumberDictionary::kNotFound && |
1467 backing_store->DetailsAt(entry).type() == ACCESSOR_CONSTANT && | 1505 backing_store->DetailsAt(entry).type() == ACCESSOR_CONSTANT && |
1468 backing_store->ValueAt(entry)->IsAccessorPair()) { | 1506 backing_store->ValueAt(entry)->IsAccessorPair()) { |
1469 return handle(AccessorPair::cast(backing_store->ValueAt(entry))); | 1507 return handle(AccessorPair::cast(backing_store->ValueAt(entry))); |
1470 } | 1508 } |
1471 return MaybeHandle<AccessorPair>(); | 1509 return MaybeHandle<AccessorPair>(); |
1472 } | 1510 } |
1473 | 1511 |
| 1512 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key, |
| 1513 Handle<FixedArrayBase> store) { |
| 1514 Handle<SeededNumberDictionary> backing_store = |
| 1515 Handle<SeededNumberDictionary>::cast(store); |
| 1516 return backing_store->FindEntry(key) != SeededNumberDictionary::kNotFound; |
| 1517 } |
| 1518 |
1474 static bool HasIndexImpl(FixedArrayBase* store, uint32_t index) { | 1519 static bool HasIndexImpl(FixedArrayBase* store, uint32_t index) { |
1475 DisallowHeapAllocation no_gc; | 1520 DisallowHeapAllocation no_gc; |
1476 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); | 1521 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
1477 Object* key = dict->KeyAt(index); | 1522 Object* key = dict->KeyAt(index); |
1478 return !key->IsTheHole(); | 1523 return !key->IsTheHole(); |
1479 } | 1524 } |
1480 | 1525 |
1481 static uint32_t GetKeyForIndexImpl(FixedArrayBase* store, uint32_t index) { | 1526 static uint32_t GetKeyForIndexImpl(FixedArrayBase* store, uint32_t index) { |
1482 DisallowHeapAllocation no_gc; | 1527 DisallowHeapAllocation no_gc; |
1483 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); | 1528 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
1484 Object* key = dict->KeyAt(index); | 1529 Object* key = dict->KeyAt(index); |
1485 return Smi::cast(key)->value(); | 1530 return Smi::cast(key)->value(); |
1486 } | 1531 } |
1487 | 1532 |
1488 static uint32_t GetIndexForKeyImpl(JSObject* holder, FixedArrayBase* store, | 1533 static uint32_t GetIndexForKeyImpl(FixedArrayBase* store, uint32_t key) { |
1489 uint32_t key) { | |
1490 DisallowHeapAllocation no_gc; | 1534 DisallowHeapAllocation no_gc; |
1491 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); | 1535 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
1492 int entry = dict->FindEntry(key); | 1536 int entry = dict->FindEntry(key); |
1493 return entry == SeededNumberDictionary::kNotFound | 1537 if (entry == SeededNumberDictionary::kNotFound) { |
1494 ? kMaxUInt32 | 1538 return kMaxUInt32; |
1495 : static_cast<uint32_t>(entry); | 1539 } |
| 1540 return static_cast<uint32_t>(entry); |
1496 } | 1541 } |
1497 | 1542 |
1498 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, | 1543 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, |
1499 uint32_t index) { | 1544 uint32_t index) { |
1500 return SeededNumberDictionary::cast(backing_store)->DetailsAt(index); | 1545 return SeededNumberDictionary::cast(backing_store)->DetailsAt(index); |
1501 } | 1546 } |
1502 }; | 1547 }; |
1503 | 1548 |
1504 | 1549 |
1505 class SloppyArgumentsElementsAccessor : public ElementsAccessorBase< | 1550 class SloppyArgumentsElementsAccessor : public ElementsAccessorBase< |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 int context_index = Smi::cast(probe)->value(); | 1601 int context_index = Smi::cast(probe)->value(); |
1557 DCHECK(!context->get(context_index)->IsTheHole()); | 1602 DCHECK(!context->get(context_index)->IsTheHole()); |
1558 context->set(context_index, *value); | 1603 context->set(context_index, *value); |
1559 return value; | 1604 return value; |
1560 } | 1605 } |
1561 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); | 1606 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); |
1562 return ElementsAccessor::ForArray(arguments) | 1607 return ElementsAccessor::ForArray(arguments) |
1563 ->Set(obj, key, arguments, value); | 1608 ->Set(obj, key, arguments, value); |
1564 } | 1609 } |
1565 | 1610 |
| 1611 static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key, |
| 1612 FixedArrayBase* backing_store) { |
| 1613 FixedArray* parameter_map = FixedArray::cast(backing_store); |
| 1614 Object* probe = GetParameterMapArg(parameter_map, key); |
| 1615 if (!probe->IsTheHole()) { |
| 1616 return NONE; |
| 1617 } else { |
| 1618 // If not aliased, check the arguments. |
| 1619 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 1620 return ElementsAccessor::ForArray(arguments) |
| 1621 ->GetAttributes(obj, key, arguments); |
| 1622 } |
| 1623 } |
| 1624 |
1566 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 1625 static MaybeHandle<AccessorPair> GetAccessorPairImpl( |
1567 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> parameters) { | 1626 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> parameters) { |
1568 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); | 1627 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); |
1569 Handle<Object> probe(GetParameterMapArg(*parameter_map, key), | 1628 Handle<Object> probe(GetParameterMapArg(*parameter_map, key), |
1570 obj->GetIsolate()); | 1629 obj->GetIsolate()); |
1571 if (!probe->IsTheHole()) { | 1630 if (!probe->IsTheHole()) { |
1572 return MaybeHandle<AccessorPair>(); | 1631 return MaybeHandle<AccessorPair>(); |
1573 } else { | 1632 } else { |
1574 // If not aliased, check the arguments. | 1633 // If not aliased, check the arguments. |
1575 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); | 1634 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 static uint32_t GetKeyForIndexImpl(FixedArrayBase* parameters, | 1699 static uint32_t GetKeyForIndexImpl(FixedArrayBase* parameters, |
1641 uint32_t index) { | 1700 uint32_t index) { |
1642 FixedArray* parameter_map = FixedArray::cast(parameters); | 1701 FixedArray* parameter_map = FixedArray::cast(parameters); |
1643 uint32_t length = parameter_map->length() - 2; | 1702 uint32_t length = parameter_map->length() - 2; |
1644 if (index < length) return index; | 1703 if (index < length) return index; |
1645 | 1704 |
1646 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 1705 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
1647 return ForArray(arguments)->GetKeyForIndex(arguments, index - length); | 1706 return ForArray(arguments)->GetKeyForIndex(arguments, index - length); |
1648 } | 1707 } |
1649 | 1708 |
1650 static uint32_t GetIndexForKeyImpl(JSObject* holder, | 1709 static uint32_t GetIndexForKeyImpl(FixedArrayBase* parameters, uint32_t key) { |
1651 FixedArrayBase* parameters, uint32_t key) { | |
1652 FixedArray* parameter_map = FixedArray::cast(parameters); | 1710 FixedArray* parameter_map = FixedArray::cast(parameters); |
1653 Object* probe = GetParameterMapArg(parameter_map, key); | 1711 Object* probe = GetParameterMapArg(parameter_map, key); |
1654 if (!probe->IsTheHole()) return key; | 1712 if (!probe->IsTheHole()) return key; |
1655 | 1713 |
| 1714 uint32_t length = parameter_map->length() - 2; |
1656 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 1715 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
1657 uint32_t index = ElementsAccessor::ForArray(arguments) | 1716 return length + |
1658 ->GetIndexForKey(holder, arguments, key); | 1717 ElementsAccessor::ForArray(arguments) |
1659 if (index == kMaxUInt32) return index; | 1718 ->GetIndexForKey(arguments, key); |
1660 return (parameter_map->length() - 2) + index; | |
1661 } | 1719 } |
1662 | 1720 |
1663 static PropertyDetails GetDetailsImpl(FixedArrayBase* parameters, | 1721 static PropertyDetails GetDetailsImpl(FixedArrayBase* parameters, |
1664 uint32_t index) { | 1722 uint32_t index) { |
1665 FixedArray* parameter_map = FixedArray::cast(parameters); | 1723 FixedArray* parameter_map = FixedArray::cast(parameters); |
1666 uint32_t length = parameter_map->length() - 2; | 1724 uint32_t length = parameter_map->length() - 2; |
1667 if (index < length) { | 1725 if (index < length) { |
1668 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); | 1726 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); |
1669 } | 1727 } |
1670 index -= length; | 1728 index -= length; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 break; | 1929 break; |
1872 } | 1930 } |
1873 | 1931 |
1874 array->set_elements(*elms); | 1932 array->set_elements(*elms); |
1875 array->set_length(Smi::FromInt(number_of_elements)); | 1933 array->set_length(Smi::FromInt(number_of_elements)); |
1876 return array; | 1934 return array; |
1877 } | 1935 } |
1878 | 1936 |
1879 } // namespace internal | 1937 } // namespace internal |
1880 } // namespace v8 | 1938 } // namespace v8 |
OLD | NEW |