Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1589)

Side by Side Diff: src/elements.cc

Issue 1144883002: Start adding support for elements to the LookupIterator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/elements.h ('k') | src/lookup.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 609
610 return ElementsAccessorSubclass::GetImpl( 610 return ElementsAccessorSubclass::GetImpl(
611 receiver, holder, key, backing_store); 611 receiver, holder, key, backing_store);
612 } 612 }
613 613
614 MUST_USE_RESULT static MaybeHandle<Object> GetImpl( 614 MUST_USE_RESULT static MaybeHandle<Object> GetImpl(
615 Handle<Object> receiver, 615 Handle<Object> receiver,
616 Handle<JSObject> obj, 616 Handle<JSObject> obj,
617 uint32_t key, 617 uint32_t key,
618 Handle<FixedArrayBase> backing_store) { 618 Handle<FixedArrayBase> backing_store) {
619 if (key < ElementsAccessorSubclass::GetCapacityImpl(obj, backing_store)) { 619 if (key < ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)) {
620 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); 620 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key);
621 } else { 621 } else {
622 return backing_store->GetIsolate()->factory()->the_hole_value(); 622 return backing_store->GetIsolate()->factory()->the_hole_value();
623 } 623 }
624 } 624 }
625 625
626 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( 626 MUST_USE_RESULT virtual PropertyAttributes GetAttributes(
627 Handle<JSObject> holder, uint32_t key, 627 Handle<JSObject> holder, uint32_t key,
628 Handle<FixedArrayBase> backing_store) final { 628 Handle<FixedArrayBase> backing_store) final {
629 return ElementsAccessorSubclass::GetAttributesImpl(holder, key, 629 return ElementsAccessorSubclass::GetAttributesImpl(holder, key,
630 backing_store); 630 backing_store);
631 } 631 }
632 632
633 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( 633 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
634 Handle<JSObject> obj, 634 Handle<JSObject> obj,
635 uint32_t key, 635 uint32_t key,
636 Handle<FixedArrayBase> backing_store) { 636 Handle<FixedArrayBase> backing_store) {
637 if (key >= ElementsAccessorSubclass::GetCapacityImpl(obj, backing_store)) { 637 if (key >=
638 ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)) {
638 return ABSENT; 639 return ABSENT;
639 } 640 }
640 return 641 return
641 Handle<BackingStore>::cast(backing_store)->is_the_hole(key) 642 Handle<BackingStore>::cast(backing_store)->is_the_hole(key)
642 ? ABSENT : NONE; 643 ? ABSENT : NONE;
643 } 644 }
644 645
645 MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair( 646 MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair(
646 Handle<JSObject> holder, uint32_t key, 647 Handle<JSObject> holder, uint32_t key,
647 Handle<FixedArrayBase> backing_store) final { 648 Handle<FixedArrayBase> backing_store) final {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 #ifdef ENABLE_SLOW_DCHECKS 743 #ifdef ENABLE_SLOW_DCHECKS
743 if (FLAG_enable_slow_asserts) { 744 if (FLAG_enable_slow_asserts) {
744 for (int i = 0; i < len0; i++) { 745 for (int i = 0; i < len0; i++) {
745 DCHECK(!to->get(i)->IsTheHole()); 746 DCHECK(!to->get(i)->IsTheHole());
746 } 747 }
747 } 748 }
748 #endif 749 #endif
749 750
750 // Optimize if 'other' is empty. 751 // Optimize if 'other' is empty.
751 // We cannot optimize if 'this' is empty, as other may have holes. 752 // We cannot optimize if 'this' is empty, as other may have holes.
752 uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(receiver, from); 753 uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(*receiver, *from);
753 if (len1 == 0) return to; 754 if (len1 == 0) return to;
754 755
755 Isolate* isolate = from->GetIsolate(); 756 Isolate* isolate = from->GetIsolate();
756 757
757 // Compute how many elements are not in other. 758 // Compute how many elements are not in other.
758 uint32_t extra = 0; 759 uint32_t extra = 0;
759 for (uint32_t y = 0; y < len1; y++) { 760 for (uint32_t y = 0; y < len1; y++) {
760 uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(from, y); 761 uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(*from, y);
761 if (ElementsAccessorSubclass::HasElementImpl(receiver, key, from)) { 762 if (ElementsAccessorSubclass::HasElementImpl(receiver, key, from)) {
762 Handle<Object> value; 763 Handle<Object> value;
763 ASSIGN_RETURN_ON_EXCEPTION( 764 ASSIGN_RETURN_ON_EXCEPTION(
764 isolate, value, 765 isolate, value,
765 ElementsAccessorSubclass::GetImpl(receiver, receiver, key, from), 766 ElementsAccessorSubclass::GetImpl(receiver, receiver, key, from),
766 FixedArray); 767 FixedArray);
767 768
768 DCHECK(!value->IsTheHole()); 769 DCHECK(!value->IsTheHole());
769 if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) { 770 if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) {
770 continue; 771 continue;
(...skipping 15 matching lines...) Expand all
786 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); 787 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
787 for (int i = 0; i < len0; i++) { 788 for (int i = 0; i < len0; i++) {
788 Object* e = to->get(i); 789 Object* e = to->get(i);
789 DCHECK(e->IsString() || e->IsNumber()); 790 DCHECK(e->IsString() || e->IsNumber());
790 result->set(i, e, mode); 791 result->set(i, e, mode);
791 } 792 }
792 } 793 }
793 // Fill in the extra values. 794 // Fill in the extra values.
794 uint32_t index = 0; 795 uint32_t index = 0;
795 for (uint32_t y = 0; y < len1; y++) { 796 for (uint32_t y = 0; y < len1; y++) {
796 uint32_t key = 797 uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(*from, y);
797 ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
798 if (ElementsAccessorSubclass::HasElementImpl(receiver, key, from)) { 798 if (ElementsAccessorSubclass::HasElementImpl(receiver, key, from)) {
799 Handle<Object> value; 799 Handle<Object> value;
800 ASSIGN_RETURN_ON_EXCEPTION( 800 ASSIGN_RETURN_ON_EXCEPTION(
801 isolate, value, 801 isolate, value,
802 ElementsAccessorSubclass::GetImpl(receiver, receiver, key, from), 802 ElementsAccessorSubclass::GetImpl(receiver, receiver, key, from),
803 FixedArray); 803 FixedArray);
804 if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) { 804 if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) {
805 continue; 805 continue;
806 } 806 }
807 if (!value->IsTheHole() && !HasKey(to, value)) { 807 if (!value->IsTheHole() && !HasKey(to, value)) {
808 result->set(len0 + index, *value); 808 result->set(len0 + index, *value);
809 index++; 809 index++;
810 } 810 }
811 } 811 }
812 } 812 }
813 DCHECK(extra == index); 813 DCHECK(extra == index);
814 return result; 814 return result;
815 } 815 }
816 816
817 protected: 817 protected:
818 static uint32_t GetCapacityImpl(Handle<JSObject> holder, 818 static uint32_t GetCapacityImpl(JSObject* holder,
819 Handle<FixedArrayBase> backing_store) { 819 FixedArrayBase* backing_store) {
820 return backing_store->length(); 820 return backing_store->length();
821 } 821 }
822 822
823 uint32_t GetCapacity(Handle<JSObject> holder, 823 uint32_t GetCapacity(JSObject* holder, FixedArrayBase* backing_store) final {
824 Handle<FixedArrayBase> backing_store) final {
825 return ElementsAccessorSubclass::GetCapacityImpl(holder, backing_store); 824 return ElementsAccessorSubclass::GetCapacityImpl(holder, backing_store);
826 } 825 }
827 826
828 static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> backing_store, 827 static uint32_t GetKeyForIndexImpl(FixedArrayBase* backing_store,
829 uint32_t index) { 828 uint32_t index) {
830 return index; 829 return index;
831 } 830 }
832 831
833 virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store, 832 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store,
834 uint32_t index) final { 833 uint32_t index) final {
835 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index); 834 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index);
836 } 835 }
837 836
837 static uint32_t GetIndexForKeyImpl(FixedArrayBase* backing_store,
838 uint32_t key) {
839 return key;
840 }
841
842 virtual uint32_t GetIndexForKey(FixedArrayBase* backing_store,
843 uint32_t key) final {
844 return ElementsAccessorSubclass::GetIndexForKeyImpl(backing_store, key);
845 }
846
847 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store,
848 uint32_t index) {
849 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell);
850 }
851
852 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store,
853 uint32_t index) final {
854 return ElementsAccessorSubclass::GetDetailsImpl(backing_store, index);
855 }
856
838 private: 857 private:
839 DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase); 858 DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase);
840 }; 859 };
841 860
842 861
843 // Super class for all fast element arrays. 862 // Super class for all fast element arrays.
844 template<typename FastElementsAccessorSubclass, 863 template<typename FastElementsAccessorSubclass,
845 typename KindTraits> 864 typename KindTraits>
846 class FastElementsAccessor 865 class FastElementsAccessor
847 : public ElementsAccessorBase<FastElementsAccessorSubclass, KindTraits> { 866 : public ElementsAccessorBase<FastElementsAccessorSubclass, KindTraits> {
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 typedef TypedElementsAccessor<Kind> AccessorClass; 1272 typedef TypedElementsAccessor<Kind> AccessorClass;
1254 1273
1255 friend class ElementsAccessorBase<AccessorClass, 1274 friend class ElementsAccessorBase<AccessorClass,
1256 ElementsKindTraits<Kind> >; 1275 ElementsKindTraits<Kind> >;
1257 1276
1258 MUST_USE_RESULT static MaybeHandle<Object> GetImpl( 1277 MUST_USE_RESULT static MaybeHandle<Object> GetImpl(
1259 Handle<Object> receiver, 1278 Handle<Object> receiver,
1260 Handle<JSObject> obj, 1279 Handle<JSObject> obj,
1261 uint32_t key, 1280 uint32_t key,
1262 Handle<FixedArrayBase> backing_store) { 1281 Handle<FixedArrayBase> backing_store) {
1263 if (key < AccessorClass::GetCapacityImpl(obj, backing_store)) { 1282 if (key < AccessorClass::GetCapacityImpl(*obj, *backing_store)) {
1264 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); 1283 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key);
1265 } else { 1284 } else {
1266 return backing_store->GetIsolate()->factory()->undefined_value(); 1285 return backing_store->GetIsolate()->factory()->undefined_value();
1267 } 1286 }
1268 } 1287 }
1269 1288
1270 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( 1289 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
1271 Handle<JSObject> obj, 1290 Handle<JSObject> obj,
1272 uint32_t key, 1291 uint32_t key,
1273 Handle<FixedArrayBase> backing_store) { 1292 Handle<FixedArrayBase> backing_store) {
1274 return key < AccessorClass::GetCapacityImpl(obj, backing_store) ? NONE 1293 return key < AccessorClass::GetCapacityImpl(*obj, *backing_store) ? NONE
1275 : ABSENT; 1294 : ABSENT;
1276 } 1295 }
1277 1296
1278 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( 1297 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl(
1279 Handle<JSObject> obj, 1298 Handle<JSObject> obj,
1280 Handle<Object> length, 1299 Handle<Object> length,
1281 Handle<FixedArrayBase> backing_store) { 1300 Handle<FixedArrayBase> backing_store) {
1282 // External arrays do not support changing their length. 1301 // External arrays do not support changing their length.
1283 UNREACHABLE(); 1302 UNREACHABLE();
1284 return obj; 1303 return obj;
1285 } 1304 }
1286 1305
1287 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( 1306 MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
1288 Handle<JSObject> obj, uint32_t key, LanguageMode language_mode) final { 1307 Handle<JSObject> obj, uint32_t key, LanguageMode language_mode) final {
1289 // External arrays always ignore deletes. 1308 // External arrays always ignore deletes.
1290 return obj->GetIsolate()->factory()->true_value(); 1309 return obj->GetIsolate()->factory()->true_value();
1291 } 1310 }
1292 1311
1293 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key, 1312 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
1294 Handle<FixedArrayBase> backing_store) { 1313 Handle<FixedArrayBase> backing_store) {
1295 uint32_t capacity = AccessorClass::GetCapacityImpl(holder, backing_store); 1314 uint32_t capacity = AccessorClass::GetCapacityImpl(*holder, *backing_store);
1296 return key < capacity; 1315 return key < capacity;
1297 } 1316 }
1298 1317
1299 static uint32_t GetCapacityImpl(Handle<JSObject> holder, 1318 static uint32_t GetCapacityImpl(JSObject* holder,
1300 Handle<FixedArrayBase> backing_store) { 1319 FixedArrayBase* backing_store) {
1301 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); 1320 JSArrayBufferView* view = JSArrayBufferView::cast(holder);
1302 if (view->WasNeutered()) return 0; 1321 if (view->WasNeutered()) return 0;
1303 return backing_store->length(); 1322 return backing_store->length();
1304 } 1323 }
1305 }; 1324 };
1306 1325
1307 1326
1308 1327
1309 #define EXTERNAL_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ 1328 #define EXTERNAL_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \
1310 typedef TypedElementsAccessor<EXTERNAL_##TYPE##_ELEMENTS> \ 1329 typedef TypedElementsAccessor<EXTERNAL_##TYPE##_ELEMENTS> \
1311 External##Type##ElementsAccessor; 1330 External##Type##ElementsAccessor;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 return MaybeHandle<AccessorPair>(); 1512 return MaybeHandle<AccessorPair>();
1494 } 1513 }
1495 1514
1496 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key, 1515 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
1497 Handle<FixedArrayBase> store) { 1516 Handle<FixedArrayBase> store) {
1498 Handle<SeededNumberDictionary> backing_store = 1517 Handle<SeededNumberDictionary> backing_store =
1499 Handle<SeededNumberDictionary>::cast(store); 1518 Handle<SeededNumberDictionary>::cast(store);
1500 return backing_store->FindEntry(key) != SeededNumberDictionary::kNotFound; 1519 return backing_store->FindEntry(key) != SeededNumberDictionary::kNotFound;
1501 } 1520 }
1502 1521
1503 static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> store, 1522 static uint32_t GetKeyForIndexImpl(FixedArrayBase* store, uint32_t index) {
1504 uint32_t index) {
1505 DisallowHeapAllocation no_gc; 1523 DisallowHeapAllocation no_gc;
1506 Handle<SeededNumberDictionary> dict = 1524 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store);
1507 Handle<SeededNumberDictionary>::cast(store);
1508 Object* key = dict->KeyAt(index); 1525 Object* key = dict->KeyAt(index);
1509 return Smi::cast(key)->value(); 1526 return Smi::cast(key)->value();
1510 } 1527 }
1528
1529 static uint32_t GetIndexForKeyImpl(FixedArrayBase* store, uint32_t key) {
1530 DisallowHeapAllocation no_gc;
1531 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store);
1532 int entry = dict->FindEntry(key);
1533 if (entry == SeededNumberDictionary::kNotFound) {
1534 return kMaxUInt32;
1535 }
1536 return static_cast<uint32_t>(entry);
1537 }
1538
1539 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store,
1540 uint32_t index) {
1541 return SeededNumberDictionary::cast(backing_store)->DetailsAt(index);
1542 }
1511 }; 1543 };
1512 1544
1513 1545
1514 class SloppyArgumentsElementsAccessor : public ElementsAccessorBase< 1546 class SloppyArgumentsElementsAccessor : public ElementsAccessorBase<
1515 SloppyArgumentsElementsAccessor, 1547 SloppyArgumentsElementsAccessor,
1516 ElementsKindTraits<SLOPPY_ARGUMENTS_ELEMENTS> > { 1548 ElementsKindTraits<SLOPPY_ARGUMENTS_ELEMENTS> > {
1517 public: 1549 public:
1518 explicit SloppyArgumentsElementsAccessor(const char* name) 1550 explicit SloppyArgumentsElementsAccessor(const char* name)
1519 : ElementsAccessorBase< 1551 : ElementsAccessorBase<
1520 SloppyArgumentsElementsAccessor, 1552 SloppyArgumentsElementsAccessor,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 return isolate->factory()->true_value(); 1662 return isolate->factory()->true_value();
1631 } 1663 }
1632 1664
1633 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start, 1665 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,
1634 FixedArrayBase* to, ElementsKind from_kind, 1666 FixedArrayBase* to, ElementsKind from_kind,
1635 uint32_t to_start, int packed_size, 1667 uint32_t to_start, int packed_size,
1636 int copy_size) { 1668 int copy_size) {
1637 UNREACHABLE(); 1669 UNREACHABLE();
1638 } 1670 }
1639 1671
1640 static uint32_t GetCapacityImpl(Handle<JSObject> holder, 1672 static uint32_t GetCapacityImpl(JSObject* holder,
1641 Handle<FixedArrayBase> backing_store) { 1673 FixedArrayBase* backing_store) {
1642 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(backing_store); 1674 FixedArray* parameter_map = FixedArray::cast(backing_store);
1643 Handle<FixedArrayBase> arguments( 1675 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1));
1644 FixedArrayBase::cast(parameter_map->get(1)));
1645 return Max(static_cast<uint32_t>(parameter_map->length() - 2), 1676 return Max(static_cast<uint32_t>(parameter_map->length() - 2),
1646 ForArray(arguments)->GetCapacity(holder, arguments)); 1677 ForArray(arguments)->GetCapacity(holder, arguments));
1647 } 1678 }
1648 1679
1649 static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> dict, 1680 static uint32_t GetKeyForIndexImpl(FixedArrayBase* dict, uint32_t index) {
1650 uint32_t index) {
1651 return index; 1681 return index;
1652 } 1682 }
1653 1683
1684 static uint32_t GetIndexForKeyImpl(FixedArrayBase* dict, uint32_t key) {
1685 return key;
1686 }
1687
1688 static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store,
1689 uint32_t index) {
1690 return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell);
1691 }
1692
1693
1654 private: 1694 private:
1655 static Handle<Object> GetParameterMapArg(Handle<JSObject> holder, 1695 static Handle<Object> GetParameterMapArg(Handle<JSObject> holder,
1656 Handle<FixedArray> parameter_map, 1696 Handle<FixedArray> parameter_map,
1657 uint32_t key) { 1697 uint32_t key) {
1658 Isolate* isolate = holder->GetIsolate(); 1698 Isolate* isolate = holder->GetIsolate();
1659 uint32_t length = holder->IsJSArray() 1699 uint32_t length = holder->IsJSArray()
1660 ? Smi::cast(Handle<JSArray>::cast(holder)->length())->value() 1700 ? Smi::cast(Handle<JSArray>::cast(holder)->length())->value()
1661 : parameter_map->length(); 1701 : parameter_map->length();
1662 return key < (length - 2) 1702 return key < (length - 2)
1663 ? handle(parameter_map->get(key + 2), isolate) 1703 ? handle(parameter_map->get(key + 2), isolate)
1664 : Handle<Object>::cast(isolate->factory()->the_hole_value()); 1704 : Handle<Object>::cast(isolate->factory()->the_hole_value());
1665 } 1705 }
1666 }; 1706 };
1667 1707
1668 1708
1669 ElementsAccessor* ElementsAccessor::ForArray(Handle<FixedArrayBase> array) { 1709 ElementsAccessor* ElementsAccessor::ForArray(FixedArrayBase* array) {
1670 return elements_accessors_[ElementsKindForArray(*array)]; 1710 return elements_accessors_[ElementsKindForArray(array)];
1671 } 1711 }
1672 1712
1673 1713
1714 ElementsAccessor* ElementsAccessor::ForArray(Handle<FixedArrayBase> array) {
1715 return ForArray(*array);
1716 }
1717
1718
1674 void ElementsAccessor::InitializeOncePerProcess() { 1719 void ElementsAccessor::InitializeOncePerProcess() {
1675 static ElementsAccessor* accessor_array[] = { 1720 static ElementsAccessor* accessor_array[] = {
1676 #define ACCESSOR_ARRAY(Class, Kind, Store) new Class(#Kind), 1721 #define ACCESSOR_ARRAY(Class, Kind, Store) new Class(#Kind),
1677 ELEMENTS_LIST(ACCESSOR_ARRAY) 1722 ELEMENTS_LIST(ACCESSOR_ARRAY)
1678 #undef ACCESSOR_ARRAY 1723 #undef ACCESSOR_ARRAY
1679 }; 1724 };
1680 1725
1681 STATIC_ASSERT((sizeof(accessor_array) / sizeof(*accessor_array)) == 1726 STATIC_ASSERT((sizeof(accessor_array) / sizeof(*accessor_array)) ==
1682 kElementsKindCount); 1727 kElementsKindCount);
1683 1728
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 UNREACHABLE(); 1894 UNREACHABLE();
1850 break; 1895 break;
1851 } 1896 }
1852 1897
1853 array->set_elements(*elms); 1898 array->set_elements(*elms);
1854 array->set_length(Smi::FromInt(number_of_elements)); 1899 array->set_length(Smi::FromInt(number_of_elements));
1855 return array; 1900 return array;
1856 } 1901 }
1857 1902
1858 } } // namespace v8::internal 1903 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/lookup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698