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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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, | 586 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key, |
587 Handle<FixedArrayBase> backing_store) { | 587 Handle<FixedArrayBase> backing_store) { |
588 return ElementsAccessorSubclass::GetAttributesImpl( | 588 return ElementsAccessorSubclass::GetIndexForKeyImpl(*holder, *backing_store, |
Igor Sheludko
2015/06/11 14:59:45
Do we need HasElementImpl() given that now GetInde
Toon Verwaest
2015/06/11 15:16:06
Done.
| |
589 *holder, key, *backing_store) != ABSENT; | 589 key) != kMaxUInt32; |
590 } | 590 } |
591 | 591 |
592 virtual bool HasElement(Handle<JSObject> holder, uint32_t key, | 592 virtual bool HasElement(Handle<JSObject> holder, uint32_t key, |
593 Handle<FixedArrayBase> backing_store) final { | 593 Handle<FixedArrayBase> backing_store) final { |
594 return ElementsAccessorSubclass::HasElementImpl(holder, key, backing_store); | 594 return ElementsAccessorSubclass::HasElementImpl(holder, key, backing_store); |
595 } | 595 } |
596 | 596 |
597 virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key, | 597 virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key, |
598 Handle<FixedArrayBase> backing_store) final { | 598 Handle<FixedArrayBase> backing_store) final { |
599 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && | 599 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && |
(...skipping 26 matching lines...) Expand all Loading... | |
626 | 626 |
627 static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key, | 627 static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key, |
628 Handle<FixedArrayBase> backing_store, | 628 Handle<FixedArrayBase> backing_store, |
629 Handle<Object> value) { | 629 Handle<Object> value) { |
630 CHECK(key < | 630 CHECK(key < |
631 ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)); | 631 ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)); |
632 return BackingStore::SetValue( | 632 return BackingStore::SetValue( |
633 obj, Handle<BackingStore>::cast(backing_store), key, value); | 633 obj, Handle<BackingStore>::cast(backing_store), key, value); |
634 } | 634 } |
635 | 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 | |
650 virtual MaybeHandle<AccessorPair> GetAccessorPair( | 636 virtual MaybeHandle<AccessorPair> GetAccessorPair( |
651 Handle<JSObject> holder, uint32_t key, | 637 Handle<JSObject> holder, uint32_t key, |
652 Handle<FixedArrayBase> backing_store) final { | 638 Handle<FixedArrayBase> backing_store) final { |
653 return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key, | 639 return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key, |
654 backing_store); | 640 backing_store); |
655 } | 641 } |
656 | 642 |
657 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 643 static MaybeHandle<AccessorPair> GetAccessorPairImpl( |
658 Handle<JSObject> obj, uint32_t key, | 644 Handle<JSObject> obj, uint32_t key, |
659 Handle<FixedArrayBase> backing_store) { | 645 Handle<FixedArrayBase> backing_store) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 static uint32_t GetKeyForIndexImpl(FixedArrayBase* backing_store, | 821 static uint32_t GetKeyForIndexImpl(FixedArrayBase* backing_store, |
836 uint32_t index) { | 822 uint32_t index) { |
837 return index; | 823 return index; |
838 } | 824 } |
839 | 825 |
840 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, | 826 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
841 uint32_t index) final { | 827 uint32_t index) final { |
842 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index); | 828 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index); |
843 } | 829 } |
844 | 830 |
845 static uint32_t GetIndexForKeyImpl(FixedArrayBase* backing_store, | 831 static uint32_t GetIndexForKeyImpl(JSObject* holder, |
832 FixedArrayBase* backing_store, | |
846 uint32_t key) { | 833 uint32_t key) { |
847 return key; | 834 return key < ElementsAccessorSubclass::GetCapacityImpl(holder, |
835 backing_store) && | |
836 !BackingStore::cast(backing_store)->is_the_hole(key) | |
837 ? key | |
838 : kMaxUInt32; | |
848 } | 839 } |
849 | 840 |
850 virtual uint32_t GetIndexForKey(FixedArrayBase* backing_store, | 841 virtual uint32_t GetIndexForKey(JSObject* holder, |
842 FixedArrayBase* backing_store, | |
851 uint32_t key) final { | 843 uint32_t key) final { |
852 return ElementsAccessorSubclass::GetIndexForKeyImpl(backing_store, key); | 844 return ElementsAccessorSubclass::GetIndexForKeyImpl(holder, backing_store, |
845 key); | |
853 } | 846 } |
854 | 847 |
855 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, | 848 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, |
856 uint32_t index) { | 849 uint32_t index) { |
857 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); | 850 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); |
858 } | 851 } |
859 | 852 |
860 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, | 853 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, |
861 uint32_t index) final { | 854 uint32_t index) final { |
862 return ElementsAccessorSubclass::GetDetailsImpl(backing_store, index); | 855 return ElementsAccessorSubclass::GetDetailsImpl(backing_store, index); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 } | 980 } |
988 } | 981 } |
989 } | 982 } |
990 } | 983 } |
991 | 984 |
992 virtual void Delete(Handle<JSObject> obj, uint32_t key, | 985 virtual void Delete(Handle<JSObject> obj, uint32_t key, |
993 LanguageMode language_mode) final { | 986 LanguageMode language_mode) final { |
994 DeleteCommon(obj, key, language_mode); | 987 DeleteCommon(obj, key, language_mode); |
995 } | 988 } |
996 | 989 |
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 | |
1007 static bool HasIndexImpl(FixedArrayBase* backing_store, uint32_t index) { | 990 static bool HasIndexImpl(FixedArrayBase* backing_store, uint32_t index) { |
1008 return !BackingStore::cast(backing_store)->is_the_hole(index); | 991 return !BackingStore::cast(backing_store)->is_the_hole(index); |
1009 } | 992 } |
1010 | 993 |
1011 static void ValidateContents(Handle<JSObject> holder, int length) { | 994 static void ValidateContents(Handle<JSObject> holder, int length) { |
1012 #if DEBUG | 995 #if DEBUG |
1013 Isolate* isolate = holder->GetIsolate(); | 996 Isolate* isolate = holder->GetIsolate(); |
1014 HandleScope scope(isolate); | 997 HandleScope scope(isolate); |
1015 Handle<FixedArrayBase> elements(holder->elements(), isolate); | 998 Handle<FixedArrayBase> elements(holder->elements(), isolate); |
1016 Map* map = elements->map(); | 999 Map* map = elements->map(); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1286 | 1269 |
1287 static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t key, | 1270 static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t key, |
1288 Handle<FixedArrayBase> backing_store) { | 1271 Handle<FixedArrayBase> backing_store) { |
1289 if (key < AccessorClass::GetCapacityImpl(*obj, *backing_store)) { | 1272 if (key < AccessorClass::GetCapacityImpl(*obj, *backing_store)) { |
1290 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); | 1273 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); |
1291 } else { | 1274 } else { |
1292 return backing_store->GetIsolate()->factory()->undefined_value(); | 1275 return backing_store->GetIsolate()->factory()->undefined_value(); |
1293 } | 1276 } |
1294 } | 1277 } |
1295 | 1278 |
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 | |
1303 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, | 1279 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, |
1304 uint32_t index) { | 1280 uint32_t index) { |
1305 return PropertyDetails(DONT_DELETE, DATA, 0, PropertyCellType::kNoCell); | 1281 return PropertyDetails(DONT_DELETE, DATA, 0, PropertyCellType::kNoCell); |
1306 } | 1282 } |
1307 | 1283 |
1308 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( | 1284 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( |
1309 Handle<JSObject> obj, | 1285 Handle<JSObject> obj, |
1310 Handle<Object> length, | 1286 Handle<Object> length, |
1311 Handle<FixedArrayBase> backing_store) { | 1287 Handle<FixedArrayBase> backing_store) { |
1312 // External arrays do not support changing their length. | 1288 // External arrays do not support changing their length. |
1313 UNREACHABLE(); | 1289 UNREACHABLE(); |
1314 return obj; | 1290 return obj; |
1315 } | 1291 } |
1316 | 1292 |
1317 virtual void Delete(Handle<JSObject> obj, uint32_t key, | 1293 virtual void Delete(Handle<JSObject> obj, uint32_t key, |
1318 LanguageMode language_mode) final { | 1294 LanguageMode language_mode) final { |
1319 // External arrays always ignore deletes. | 1295 // External arrays always ignore deletes. |
1320 } | 1296 } |
1321 | 1297 |
1322 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key, | 1298 static uint32_t GetIndexForKeyImpl(JSObject* holder, |
1323 Handle<FixedArrayBase> backing_store) { | 1299 FixedArrayBase* backing_store, |
1324 uint32_t capacity = AccessorClass::GetCapacityImpl(*holder, *backing_store); | 1300 uint32_t key) { |
1325 return key < capacity; | 1301 return key < AccessorClass::GetCapacityImpl(holder, backing_store) |
1302 ? key | |
1303 : kMaxUInt32; | |
1326 } | 1304 } |
1327 | 1305 |
1328 static uint32_t GetCapacityImpl(JSObject* holder, | 1306 static uint32_t GetCapacityImpl(JSObject* holder, |
1329 FixedArrayBase* backing_store) { | 1307 FixedArrayBase* backing_store) { |
1330 JSArrayBufferView* view = JSArrayBufferView::cast(holder); | 1308 JSArrayBufferView* view = JSArrayBufferView::cast(holder); |
1331 if (view->WasNeutered()) return 0; | 1309 if (view->WasNeutered()) return 0; |
1332 return backing_store->length(); | 1310 return backing_store->length(); |
1333 } | 1311 } |
1334 }; | 1312 }; |
1335 | 1313 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1478 Handle<FixedArrayBase> store, | 1456 Handle<FixedArrayBase> store, |
1479 Handle<Object> value) { | 1457 Handle<Object> value) { |
1480 Handle<SeededNumberDictionary> backing_store = | 1458 Handle<SeededNumberDictionary> backing_store = |
1481 Handle<SeededNumberDictionary>::cast(store); | 1459 Handle<SeededNumberDictionary>::cast(store); |
1482 int entry = backing_store->FindEntry(key); | 1460 int entry = backing_store->FindEntry(key); |
1483 DCHECK_NE(SeededNumberDictionary::kNotFound, entry); | 1461 DCHECK_NE(SeededNumberDictionary::kNotFound, entry); |
1484 backing_store->ValueAtPut(entry, *value); | 1462 backing_store->ValueAtPut(entry, *value); |
1485 return value; | 1463 return value; |
1486 } | 1464 } |
1487 | 1465 |
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 | |
1499 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 1466 static MaybeHandle<AccessorPair> GetAccessorPairImpl( |
1500 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> store) { | 1467 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> store) { |
1501 Handle<SeededNumberDictionary> backing_store = | 1468 Handle<SeededNumberDictionary> backing_store = |
1502 Handle<SeededNumberDictionary>::cast(store); | 1469 Handle<SeededNumberDictionary>::cast(store); |
1503 int entry = backing_store->FindEntry(key); | 1470 int entry = backing_store->FindEntry(key); |
1504 if (entry != SeededNumberDictionary::kNotFound && | 1471 if (entry != SeededNumberDictionary::kNotFound && |
1505 backing_store->DetailsAt(entry).type() == ACCESSOR_CONSTANT && | 1472 backing_store->DetailsAt(entry).type() == ACCESSOR_CONSTANT && |
1506 backing_store->ValueAt(entry)->IsAccessorPair()) { | 1473 backing_store->ValueAt(entry)->IsAccessorPair()) { |
1507 return handle(AccessorPair::cast(backing_store->ValueAt(entry))); | 1474 return handle(AccessorPair::cast(backing_store->ValueAt(entry))); |
1508 } | 1475 } |
1509 return MaybeHandle<AccessorPair>(); | 1476 return MaybeHandle<AccessorPair>(); |
1510 } | 1477 } |
1511 | 1478 |
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 | |
1519 static bool HasIndexImpl(FixedArrayBase* store, uint32_t index) { | 1479 static bool HasIndexImpl(FixedArrayBase* store, uint32_t index) { |
1520 DisallowHeapAllocation no_gc; | 1480 DisallowHeapAllocation no_gc; |
1521 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); | 1481 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
1522 Object* key = dict->KeyAt(index); | 1482 Object* key = dict->KeyAt(index); |
1523 return !key->IsTheHole(); | 1483 return !key->IsTheHole(); |
1524 } | 1484 } |
1525 | 1485 |
1526 static uint32_t GetKeyForIndexImpl(FixedArrayBase* store, uint32_t index) { | 1486 static uint32_t GetKeyForIndexImpl(FixedArrayBase* store, uint32_t index) { |
1527 DisallowHeapAllocation no_gc; | 1487 DisallowHeapAllocation no_gc; |
1528 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); | 1488 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
1529 Object* key = dict->KeyAt(index); | 1489 Object* key = dict->KeyAt(index); |
1530 return Smi::cast(key)->value(); | 1490 return Smi::cast(key)->value(); |
1531 } | 1491 } |
1532 | 1492 |
1533 static uint32_t GetIndexForKeyImpl(FixedArrayBase* store, uint32_t key) { | 1493 static uint32_t GetIndexForKeyImpl(JSObject* holder, FixedArrayBase* store, |
1494 uint32_t key) { | |
1534 DisallowHeapAllocation no_gc; | 1495 DisallowHeapAllocation no_gc; |
1535 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); | 1496 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
1536 int entry = dict->FindEntry(key); | 1497 int entry = dict->FindEntry(key); |
1537 if (entry == SeededNumberDictionary::kNotFound) { | 1498 return entry == SeededNumberDictionary::kNotFound |
1538 return kMaxUInt32; | 1499 ? kMaxUInt32 |
1539 } | 1500 : static_cast<uint32_t>(entry); |
1540 return static_cast<uint32_t>(entry); | |
1541 } | 1501 } |
1542 | 1502 |
1543 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, | 1503 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, |
1544 uint32_t index) { | 1504 uint32_t index) { |
1545 return SeededNumberDictionary::cast(backing_store)->DetailsAt(index); | 1505 return SeededNumberDictionary::cast(backing_store)->DetailsAt(index); |
1546 } | 1506 } |
1547 }; | 1507 }; |
1548 | 1508 |
1549 | 1509 |
1550 class SloppyArgumentsElementsAccessor : public ElementsAccessorBase< | 1510 class SloppyArgumentsElementsAccessor : public ElementsAccessorBase< |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1601 int context_index = Smi::cast(probe)->value(); | 1561 int context_index = Smi::cast(probe)->value(); |
1602 DCHECK(!context->get(context_index)->IsTheHole()); | 1562 DCHECK(!context->get(context_index)->IsTheHole()); |
1603 context->set(context_index, *value); | 1563 context->set(context_index, *value); |
1604 return value; | 1564 return value; |
1605 } | 1565 } |
1606 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); | 1566 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); |
1607 return ElementsAccessor::ForArray(arguments) | 1567 return ElementsAccessor::ForArray(arguments) |
1608 ->Set(obj, key, arguments, value); | 1568 ->Set(obj, key, arguments, value); |
1609 } | 1569 } |
1610 | 1570 |
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 | |
1625 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 1571 static MaybeHandle<AccessorPair> GetAccessorPairImpl( |
1626 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> parameters) { | 1572 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> parameters) { |
1627 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); | 1573 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); |
1628 Handle<Object> probe(GetParameterMapArg(*parameter_map, key), | 1574 Handle<Object> probe(GetParameterMapArg(*parameter_map, key), |
1629 obj->GetIsolate()); | 1575 obj->GetIsolate()); |
1630 if (!probe->IsTheHole()) { | 1576 if (!probe->IsTheHole()) { |
1631 return MaybeHandle<AccessorPair>(); | 1577 return MaybeHandle<AccessorPair>(); |
1632 } else { | 1578 } else { |
1633 // If not aliased, check the arguments. | 1579 // If not aliased, check the arguments. |
1634 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); | 1580 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1699 static uint32_t GetKeyForIndexImpl(FixedArrayBase* parameters, | 1645 static uint32_t GetKeyForIndexImpl(FixedArrayBase* parameters, |
1700 uint32_t index) { | 1646 uint32_t index) { |
1701 FixedArray* parameter_map = FixedArray::cast(parameters); | 1647 FixedArray* parameter_map = FixedArray::cast(parameters); |
1702 uint32_t length = parameter_map->length() - 2; | 1648 uint32_t length = parameter_map->length() - 2; |
1703 if (index < length) return index; | 1649 if (index < length) return index; |
1704 | 1650 |
1705 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 1651 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
1706 return ForArray(arguments)->GetKeyForIndex(arguments, index - length); | 1652 return ForArray(arguments)->GetKeyForIndex(arguments, index - length); |
1707 } | 1653 } |
1708 | 1654 |
1709 static uint32_t GetIndexForKeyImpl(FixedArrayBase* parameters, uint32_t key) { | 1655 static uint32_t GetIndexForKeyImpl(JSObject* holder, |
1656 FixedArrayBase* parameters, uint32_t key) { | |
1710 FixedArray* parameter_map = FixedArray::cast(parameters); | 1657 FixedArray* parameter_map = FixedArray::cast(parameters); |
1711 Object* probe = GetParameterMapArg(parameter_map, key); | 1658 Object* probe = GetParameterMapArg(parameter_map, key); |
1712 if (!probe->IsTheHole()) return key; | 1659 if (!probe->IsTheHole()) return key; |
1713 | 1660 |
1714 uint32_t length = parameter_map->length() - 2; | |
1715 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 1661 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
1716 return length + | 1662 uint32_t index = ElementsAccessor::ForArray(arguments) |
1717 ElementsAccessor::ForArray(arguments) | 1663 ->GetIndexForKey(holder, arguments, key); |
1718 ->GetIndexForKey(arguments, key); | 1664 if (index == kMaxUInt32) return index; |
1665 return (parameter_map->length() - 2) + index; | |
1719 } | 1666 } |
1720 | 1667 |
1721 static PropertyDetails GetDetailsImpl(FixedArrayBase* parameters, | 1668 static PropertyDetails GetDetailsImpl(FixedArrayBase* parameters, |
1722 uint32_t index) { | 1669 uint32_t index) { |
1723 FixedArray* parameter_map = FixedArray::cast(parameters); | 1670 FixedArray* parameter_map = FixedArray::cast(parameters); |
1724 uint32_t length = parameter_map->length() - 2; | 1671 uint32_t length = parameter_map->length() - 2; |
1725 if (index < length) { | 1672 if (index < length) { |
1726 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); | 1673 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); |
1727 } | 1674 } |
1728 index -= length; | 1675 index -= length; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1929 break; | 1876 break; |
1930 } | 1877 } |
1931 | 1878 |
1932 array->set_elements(*elms); | 1879 array->set_elements(*elms); |
1933 array->set_length(Smi::FromInt(number_of_elements)); | 1880 array->set_length(Smi::FromInt(number_of_elements)); |
1934 return array; | 1881 return array; |
1935 } | 1882 } |
1936 | 1883 |
1937 } // namespace internal | 1884 } // namespace internal |
1938 } // namespace v8 | 1885 } // namespace v8 |
OLD | NEW |