OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 ElementsAccessorSubclass::ValidateContents(holder, length); | 521 ElementsAccessorSubclass::ValidateContents(holder, length); |
522 } | 522 } |
523 | 523 |
524 virtual void Validate(JSObject* holder) { | 524 virtual void Validate(JSObject* holder) { |
525 ElementsAccessorSubclass::ValidateImpl(holder); | 525 ElementsAccessorSubclass::ValidateImpl(holder); |
526 } | 526 } |
527 | 527 |
528 static bool HasElementImpl(Object* receiver, | 528 static bool HasElementImpl(Object* receiver, |
529 JSObject* holder, | 529 JSObject* holder, |
530 uint32_t key, | 530 uint32_t key, |
531 BackingStore* backing_store) { | 531 FixedArrayBase* backing_store) { |
532 return ElementsAccessorSubclass::GetAttributesImpl( | 532 return ElementsAccessorSubclass::GetAttributesImpl( |
533 receiver, holder, key, backing_store) != ABSENT; | 533 receiver, holder, key, backing_store) != ABSENT; |
534 } | 534 } |
535 | 535 |
536 virtual bool HasElement(Object* receiver, | 536 virtual bool HasElement(Object* receiver, |
537 JSObject* holder, | 537 JSObject* holder, |
538 uint32_t key, | 538 uint32_t key, |
539 FixedArrayBase* backing_store) { | 539 FixedArrayBase* backing_store) { |
540 if (backing_store == NULL) { | 540 if (backing_store == NULL) { |
541 backing_store = holder->elements(); | 541 backing_store = holder->elements(); |
(...skipping 24 matching lines...) Expand all Loading... |
566 | 566 |
567 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( | 567 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( |
568 Object* receiver, | 568 Object* receiver, |
569 JSObject* holder, | 569 JSObject* holder, |
570 uint32_t key, | 570 uint32_t key, |
571 FixedArrayBase* backing_store) { | 571 FixedArrayBase* backing_store) { |
572 if (backing_store == NULL) { | 572 if (backing_store == NULL) { |
573 backing_store = holder->elements(); | 573 backing_store = holder->elements(); |
574 } | 574 } |
575 return ElementsAccessorSubclass::GetAttributesImpl( | 575 return ElementsAccessorSubclass::GetAttributesImpl( |
576 receiver, holder, key, BackingStore::cast(backing_store)); | 576 receiver, holder, key, backing_store); |
577 } | 577 } |
578 | 578 |
579 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | 579 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( |
580 Object* receiver, | 580 Object* receiver, |
581 JSObject* obj, | 581 JSObject* obj, |
582 uint32_t key, | 582 uint32_t key, |
583 BackingStore* backing_store) { | 583 FixedArrayBase* backing_store) { |
584 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { | 584 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { |
585 return ABSENT; | 585 return ABSENT; |
586 } | 586 } |
587 return backing_store->is_the_hole(key) ? ABSENT : NONE; | 587 return BackingStore::cast(backing_store)->is_the_hole(key) ? ABSENT : NONE; |
588 } | 588 } |
589 | 589 |
590 MUST_USE_RESULT virtual PropertyType GetType( | 590 MUST_USE_RESULT virtual PropertyType GetType( |
591 Object* receiver, | 591 Object* receiver, |
592 JSObject* holder, | 592 JSObject* holder, |
593 uint32_t key, | 593 uint32_t key, |
594 FixedArrayBase* backing_store) { | 594 FixedArrayBase* backing_store) { |
595 if (backing_store == NULL) { | 595 if (backing_store == NULL) { |
596 backing_store = holder->elements(); | 596 backing_store = holder->elements(); |
597 } | 597 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 result->set(len0 + index, value); | 777 result->set(len0 + index, value); |
778 index++; | 778 index++; |
779 } | 779 } |
780 } | 780 } |
781 } | 781 } |
782 ASSERT(extra == index); | 782 ASSERT(extra == index); |
783 return result; | 783 return result; |
784 } | 784 } |
785 | 785 |
786 protected: | 786 protected: |
787 static uint32_t GetCapacityImpl(BackingStore* backing_store) { | 787 static uint32_t GetCapacityImpl(FixedArrayBase* backing_store) { |
788 return backing_store->length(); | 788 return backing_store->length(); |
789 } | 789 } |
790 | 790 |
791 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) { | 791 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) { |
792 return ElementsAccessorSubclass::GetCapacityImpl( | 792 return ElementsAccessorSubclass::GetCapacityImpl(backing_store); |
793 BackingStore::cast(backing_store)); | |
794 } | 793 } |
795 | 794 |
796 static uint32_t GetKeyForIndexImpl(BackingStore* backing_store, | 795 static uint32_t GetKeyForIndexImpl(BackingStore* backing_store, |
797 uint32_t index) { | 796 uint32_t index) { |
798 return index; | 797 return index; |
799 } | 798 } |
800 | 799 |
801 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, | 800 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
802 uint32_t index) { | 801 uint32_t index) { |
803 return ElementsAccessorSubclass::GetKeyForIndexImpl( | 802 return ElementsAccessorSubclass::GetKeyForIndexImpl( |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 return | 1202 return |
1204 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) | 1203 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) |
1205 ? backing_store->get(key) | 1204 ? backing_store->get(key) |
1206 : backing_store->GetHeap()->undefined_value(); | 1205 : backing_store->GetHeap()->undefined_value(); |
1207 } | 1206 } |
1208 | 1207 |
1209 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | 1208 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( |
1210 Object* receiver, | 1209 Object* receiver, |
1211 JSObject* obj, | 1210 JSObject* obj, |
1212 uint32_t key, | 1211 uint32_t key, |
1213 BackingStore* backing_store) { | 1212 FixedArrayBase* backing_store) { |
1214 return | 1213 return |
1215 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) | 1214 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) |
1216 ? NONE : ABSENT; | 1215 ? NONE : ABSENT; |
1217 } | 1216 } |
1218 | 1217 |
1219 MUST_USE_RESULT static PropertyType GetTypeImpl( | 1218 MUST_USE_RESULT static PropertyType GetTypeImpl( |
1220 Object* receiver, | 1219 Object* receiver, |
1221 JSObject* obj, | 1220 JSObject* obj, |
1222 uint32_t key, | 1221 uint32_t key, |
1223 BackingStore* backing_store) { | 1222 BackingStore* backing_store) { |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 return element; | 1511 return element; |
1513 } | 1512 } |
1514 } | 1513 } |
1515 return obj->GetHeap()->the_hole_value(); | 1514 return obj->GetHeap()->the_hole_value(); |
1516 } | 1515 } |
1517 | 1516 |
1518 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | 1517 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( |
1519 Object* receiver, | 1518 Object* receiver, |
1520 JSObject* obj, | 1519 JSObject* obj, |
1521 uint32_t key, | 1520 uint32_t key, |
1522 SeededNumberDictionary* backing_store) { | 1521 FixedArrayBase* backing_store) { |
1523 int entry = backing_store->FindEntry(key); | 1522 SeededNumberDictionary* dictionary = |
| 1523 SeededNumberDictionary::cast(backing_store); |
| 1524 int entry = dictionary->FindEntry(key); |
1524 if (entry != SeededNumberDictionary::kNotFound) { | 1525 if (entry != SeededNumberDictionary::kNotFound) { |
1525 return backing_store->DetailsAt(entry).attributes(); | 1526 return dictionary->DetailsAt(entry).attributes(); |
1526 } | 1527 } |
1527 return ABSENT; | 1528 return ABSENT; |
1528 } | 1529 } |
1529 | 1530 |
1530 MUST_USE_RESULT static PropertyType GetTypeImpl( | 1531 MUST_USE_RESULT static PropertyType GetTypeImpl( |
1531 Object* receiver, | 1532 Object* receiver, |
1532 JSObject* obj, | 1533 JSObject* obj, |
1533 uint32_t key, | 1534 uint32_t key, |
1534 SeededNumberDictionary* backing_store) { | 1535 SeededNumberDictionary* backing_store) { |
1535 int entry = backing_store->FindEntry(key); | 1536 int entry = backing_store->FindEntry(key); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 } else { | 1610 } else { |
1610 return result; | 1611 return result; |
1611 } | 1612 } |
1612 } | 1613 } |
1613 } | 1614 } |
1614 | 1615 |
1615 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | 1616 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( |
1616 Object* receiver, | 1617 Object* receiver, |
1617 JSObject* obj, | 1618 JSObject* obj, |
1618 uint32_t key, | 1619 uint32_t key, |
1619 FixedArray* parameter_map) { | 1620 FixedArrayBase* backing_store) { |
| 1621 FixedArray* parameter_map = FixedArray::cast(backing_store); |
1620 Object* probe = GetParameterMapArg(obj, parameter_map, key); | 1622 Object* probe = GetParameterMapArg(obj, parameter_map, key); |
1621 if (!probe->IsTheHole()) { | 1623 if (!probe->IsTheHole()) { |
1622 return NONE; | 1624 return NONE; |
1623 } else { | 1625 } else { |
1624 // If not aliased, check the arguments. | 1626 // If not aliased, check the arguments. |
1625 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 1627 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
1626 return ElementsAccessor::ForArray(arguments)->GetAttributes( | 1628 return ElementsAccessor::ForArray(arguments)->GetAttributes( |
1627 receiver, obj, key, arguments); | 1629 receiver, obj, key, arguments); |
1628 } | 1630 } |
1629 } | 1631 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 uint32_t to_start, | 1703 uint32_t to_start, |
1702 int packed_size, | 1704 int packed_size, |
1703 int copy_size) { | 1705 int copy_size) { |
1704 FixedArray* parameter_map = FixedArray::cast(from); | 1706 FixedArray* parameter_map = FixedArray::cast(from); |
1705 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 1707 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
1706 ElementsAccessor* accessor = ElementsAccessor::ForArray(arguments); | 1708 ElementsAccessor* accessor = ElementsAccessor::ForArray(arguments); |
1707 return accessor->CopyElements(NULL, from_start, to, to_kind, | 1709 return accessor->CopyElements(NULL, from_start, to, to_kind, |
1708 to_start, copy_size, arguments); | 1710 to_start, copy_size, arguments); |
1709 } | 1711 } |
1710 | 1712 |
1711 static uint32_t GetCapacityImpl(FixedArray* parameter_map) { | 1713 static uint32_t GetCapacityImpl(FixedArrayBase* backing_store) { |
| 1714 FixedArray* parameter_map = FixedArray::cast(backing_store); |
1712 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); | 1715 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); |
1713 return Max(static_cast<uint32_t>(parameter_map->length() - 2), | 1716 return Max(static_cast<uint32_t>(parameter_map->length() - 2), |
1714 ForArray(arguments)->GetCapacity(arguments)); | 1717 ForArray(arguments)->GetCapacity(arguments)); |
1715 } | 1718 } |
1716 | 1719 |
1717 static uint32_t GetKeyForIndexImpl(FixedArray* dict, | 1720 static uint32_t GetKeyForIndexImpl(FixedArray* dict, |
1718 uint32_t index) { | 1721 uint32_t index) { |
1719 return index; | 1722 return index; |
1720 } | 1723 } |
1721 | 1724 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; | 1860 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; |
1858 new_backing_store->set(0, length); | 1861 new_backing_store->set(0, length); |
1859 { MaybeObject* result = array->SetContent(new_backing_store); | 1862 { MaybeObject* result = array->SetContent(new_backing_store); |
1860 if (result->IsFailure()) return result; | 1863 if (result->IsFailure()) return result; |
1861 } | 1864 } |
1862 return array; | 1865 return array; |
1863 } | 1866 } |
1864 | 1867 |
1865 | 1868 |
1866 } } // namespace v8::internal | 1869 } } // namespace v8::internal |
OLD | NEW |