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

Side by Side Diff: src/elements.cc

Issue 939933002: Remove receiver as parameter to Get/Has Element in the accessors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/objects.cc » ('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/objects.h" 10 #include "src/objects.h"
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 length = fixed_array_base->length(); 580 length = fixed_array_base->length();
581 } 581 }
582 ElementsAccessorSubclass::ValidateContents(holder, length); 582 ElementsAccessorSubclass::ValidateContents(holder, length);
583 } 583 }
584 584
585 void Validate(Handle<JSObject> holder) FINAL { 585 void Validate(Handle<JSObject> holder) FINAL {
586 DisallowHeapAllocation no_gc; 586 DisallowHeapAllocation no_gc;
587 ElementsAccessorSubclass::ValidateImpl(holder); 587 ElementsAccessorSubclass::ValidateImpl(holder);
588 } 588 }
589 589
590 static bool HasElementImpl(Handle<Object> receiver, 590 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
591 Handle<JSObject> holder,
592 uint32_t key,
593 Handle<FixedArrayBase> backing_store) { 591 Handle<FixedArrayBase> backing_store) {
594 return ElementsAccessorSubclass::GetAttributesImpl( 592 return ElementsAccessorSubclass::GetAttributesImpl(holder, key,
595 receiver, holder, key, backing_store) != ABSENT; 593 backing_store) != ABSENT;
596 } 594 }
597 595
598 virtual bool HasElement(Handle<Object> receiver, Handle<JSObject> holder, 596 virtual bool HasElement(Handle<JSObject> holder, uint32_t key,
599 uint32_t key,
600 Handle<FixedArrayBase> backing_store) FINAL { 597 Handle<FixedArrayBase> backing_store) FINAL {
601 return ElementsAccessorSubclass::HasElementImpl( 598 return ElementsAccessorSubclass::HasElementImpl(holder, key, backing_store);
602 receiver, holder, key, backing_store);
603 } 599 }
604 600
605 MUST_USE_RESULT virtual MaybeHandle<Object> Get( 601 MUST_USE_RESULT virtual MaybeHandle<Object> Get(
606 Handle<Object> receiver, Handle<JSObject> holder, uint32_t key, 602 Handle<Object> receiver, Handle<JSObject> holder, uint32_t key,
607 Handle<FixedArrayBase> backing_store) FINAL { 603 Handle<FixedArrayBase> backing_store) FINAL {
608 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && 604 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) &&
609 FLAG_trace_js_array_abuse) { 605 FLAG_trace_js_array_abuse) {
610 CheckArrayAbuse(holder, "elements read", key); 606 CheckArrayAbuse(holder, "elements read", key);
611 } 607 }
612 608
(...skipping 12 matching lines...) Expand all
625 uint32_t key, 621 uint32_t key,
626 Handle<FixedArrayBase> backing_store) { 622 Handle<FixedArrayBase> backing_store) {
627 if (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { 623 if (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) {
628 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); 624 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key);
629 } else { 625 } else {
630 return backing_store->GetIsolate()->factory()->the_hole_value(); 626 return backing_store->GetIsolate()->factory()->the_hole_value();
631 } 627 }
632 } 628 }
633 629
634 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( 630 MUST_USE_RESULT virtual PropertyAttributes GetAttributes(
635 Handle<Object> receiver, Handle<JSObject> holder, uint32_t key, 631 Handle<JSObject> holder, uint32_t key,
636 Handle<FixedArrayBase> backing_store) FINAL { 632 Handle<FixedArrayBase> backing_store) FINAL {
637 return ElementsAccessorSubclass::GetAttributesImpl( 633 return ElementsAccessorSubclass::GetAttributesImpl(holder, key,
638 receiver, holder, key, backing_store); 634 backing_store);
639 } 635 }
640 636
641 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( 637 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
642 Handle<Object> receiver,
643 Handle<JSObject> obj, 638 Handle<JSObject> obj,
644 uint32_t key, 639 uint32_t key,
645 Handle<FixedArrayBase> backing_store) { 640 Handle<FixedArrayBase> backing_store) {
646 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { 641 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) {
647 return ABSENT; 642 return ABSENT;
648 } 643 }
649 return 644 return
650 Handle<BackingStore>::cast(backing_store)->is_the_hole(key) 645 Handle<BackingStore>::cast(backing_store)->is_the_hole(key)
651 ? ABSENT : NONE; 646 ? ABSENT : NONE;
652 } 647 }
653 648
654 MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair( 649 MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair(
655 Handle<Object> receiver, Handle<JSObject> holder, uint32_t key, 650 Handle<JSObject> holder, uint32_t key,
656 Handle<FixedArrayBase> backing_store) FINAL { 651 Handle<FixedArrayBase> backing_store) FINAL {
657 return ElementsAccessorSubclass::GetAccessorPairImpl( 652 return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key,
658 receiver, holder, key, backing_store); 653 backing_store);
659 } 654 }
660 655
661 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl( 656 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl(
662 Handle<Object> receiver,
663 Handle<JSObject> obj, 657 Handle<JSObject> obj,
664 uint32_t key, 658 uint32_t key,
665 Handle<FixedArrayBase> backing_store) { 659 Handle<FixedArrayBase> backing_store) {
666 return MaybeHandle<AccessorPair>(); 660 return MaybeHandle<AccessorPair>();
667 } 661 }
668 662
669 MUST_USE_RESULT virtual MaybeHandle<Object> SetLength( 663 MUST_USE_RESULT virtual MaybeHandle<Object> SetLength(
670 Handle<JSArray> array, Handle<Object> length) FINAL { 664 Handle<JSArray> array, Handle<Object> length) FINAL {
671 return ElementsAccessorSubclass::SetLengthImpl( 665 return ElementsAccessorSubclass::SetLengthImpl(
672 array, length, handle(array->elements())); 666 array, length, handle(array->elements()));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 // We cannot optimize if 'this' is empty, as other may have holes. 753 // We cannot optimize if 'this' is empty, as other may have holes.
760 uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(from); 754 uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(from);
761 if (len1 == 0) return to; 755 if (len1 == 0) return to;
762 756
763 Isolate* isolate = from->GetIsolate(); 757 Isolate* isolate = from->GetIsolate();
764 758
765 // Compute how many elements are not in other. 759 // Compute how many elements are not in other.
766 uint32_t extra = 0; 760 uint32_t extra = 0;
767 for (uint32_t y = 0; y < len1; y++) { 761 for (uint32_t y = 0; y < len1; y++) {
768 uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(from, y); 762 uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
769 if (ElementsAccessorSubclass::HasElementImpl( 763 if (ElementsAccessorSubclass::HasElementImpl(holder, key, from)) {
770 receiver, holder, key, from)) {
771 Handle<Object> value; 764 Handle<Object> value;
772 ASSIGN_RETURN_ON_EXCEPTION( 765 ASSIGN_RETURN_ON_EXCEPTION(
773 isolate, value, 766 isolate, value,
774 ElementsAccessorSubclass::GetImpl(receiver, holder, key, from), 767 ElementsAccessorSubclass::GetImpl(receiver, holder, key, from),
775 FixedArray); 768 FixedArray);
776 769
777 DCHECK(!value->IsTheHole()); 770 DCHECK(!value->IsTheHole());
778 if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) { 771 if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) {
779 continue; 772 continue;
780 } 773 }
(...skipping 16 matching lines...) Expand all
797 Object* e = to->get(i); 790 Object* e = to->get(i);
798 DCHECK(e->IsString() || e->IsNumber()); 791 DCHECK(e->IsString() || e->IsNumber());
799 result->set(i, e, mode); 792 result->set(i, e, mode);
800 } 793 }
801 } 794 }
802 // Fill in the extra values. 795 // Fill in the extra values.
803 uint32_t index = 0; 796 uint32_t index = 0;
804 for (uint32_t y = 0; y < len1; y++) { 797 for (uint32_t y = 0; y < len1; y++) {
805 uint32_t key = 798 uint32_t key =
806 ElementsAccessorSubclass::GetKeyForIndexImpl(from, y); 799 ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
807 if (ElementsAccessorSubclass::HasElementImpl( 800 if (ElementsAccessorSubclass::HasElementImpl(holder, key, from)) {
808 receiver, holder, key, from)) {
809 Handle<Object> value; 801 Handle<Object> value;
810 ASSIGN_RETURN_ON_EXCEPTION( 802 ASSIGN_RETURN_ON_EXCEPTION(
811 isolate, value, 803 isolate, value,
812 ElementsAccessorSubclass::GetImpl(receiver, holder, key, from), 804 ElementsAccessorSubclass::GetImpl(receiver, holder, key, from),
813 FixedArray); 805 FixedArray);
814 if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) { 806 if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) {
815 continue; 807 continue;
816 } 808 }
817 if (!value->IsTheHole() && !HasKey(to, value)) { 809 if (!value->IsTheHole() && !HasKey(to, value)) {
818 result->set(len0 + index, *value); 810 result->set(len0 + index, *value);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 } 963 }
972 return isolate->factory()->true_value(); 964 return isolate->factory()->true_value();
973 } 965 }
974 966
975 virtual MaybeHandle<Object> Delete(Handle<JSObject> obj, uint32_t key, 967 virtual MaybeHandle<Object> Delete(Handle<JSObject> obj, uint32_t key,
976 LanguageMode language_mode) FINAL { 968 LanguageMode language_mode) FINAL {
977 return DeleteCommon(obj, key, language_mode); 969 return DeleteCommon(obj, key, language_mode);
978 } 970 }
979 971
980 static bool HasElementImpl( 972 static bool HasElementImpl(
981 Handle<Object> receiver,
982 Handle<JSObject> holder, 973 Handle<JSObject> holder,
983 uint32_t key, 974 uint32_t key,
984 Handle<FixedArrayBase> backing_store) { 975 Handle<FixedArrayBase> backing_store) {
985 if (key >= static_cast<uint32_t>(backing_store->length())) { 976 if (key >= static_cast<uint32_t>(backing_store->length())) {
986 return false; 977 return false;
987 } 978 }
988 return !Handle<BackingStore>::cast(backing_store)->is_the_hole(key); 979 return !Handle<BackingStore>::cast(backing_store)->is_the_hole(key);
989 } 980 }
990 981
991 static void ValidateContents(Handle<JSObject> holder, int length) { 982 static void ValidateContents(Handle<JSObject> holder, int length) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 uint32_t key, 1261 uint32_t key,
1271 Handle<FixedArrayBase> backing_store) { 1262 Handle<FixedArrayBase> backing_store) {
1272 if (key < AccessorClass::GetCapacityImpl(backing_store)) { 1263 if (key < AccessorClass::GetCapacityImpl(backing_store)) {
1273 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); 1264 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key);
1274 } else { 1265 } else {
1275 return backing_store->GetIsolate()->factory()->undefined_value(); 1266 return backing_store->GetIsolate()->factory()->undefined_value();
1276 } 1267 }
1277 } 1268 }
1278 1269
1279 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( 1270 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
1280 Handle<Object> receiver,
1281 Handle<JSObject> obj, 1271 Handle<JSObject> obj,
1282 uint32_t key, 1272 uint32_t key,
1283 Handle<FixedArrayBase> backing_store) { 1273 Handle<FixedArrayBase> backing_store) {
1284 return 1274 return
1285 key < AccessorClass::GetCapacityImpl(backing_store) 1275 key < AccessorClass::GetCapacityImpl(backing_store)
1286 ? NONE : ABSENT; 1276 ? NONE : ABSENT;
1287 } 1277 }
1288 1278
1289 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( 1279 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl(
1290 Handle<JSObject> obj, 1280 Handle<JSObject> obj,
1291 Handle<Object> length, 1281 Handle<Object> length,
1292 Handle<FixedArrayBase> backing_store) { 1282 Handle<FixedArrayBase> backing_store) {
1293 // External arrays do not support changing their length. 1283 // External arrays do not support changing their length.
1294 UNREACHABLE(); 1284 UNREACHABLE();
1295 return obj; 1285 return obj;
1296 } 1286 }
1297 1287
1298 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( 1288 MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
1299 Handle<JSObject> obj, uint32_t key, LanguageMode language_mode) FINAL { 1289 Handle<JSObject> obj, uint32_t key, LanguageMode language_mode) FINAL {
1300 // External arrays always ignore deletes. 1290 // External arrays always ignore deletes.
1301 return obj->GetIsolate()->factory()->true_value(); 1291 return obj->GetIsolate()->factory()->true_value();
1302 } 1292 }
1303 1293
1304 static bool HasElementImpl(Handle<Object> receiver, 1294 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
1305 Handle<JSObject> holder,
1306 uint32_t key,
1307 Handle<FixedArrayBase> backing_store) { 1295 Handle<FixedArrayBase> backing_store) {
1308 uint32_t capacity = 1296 uint32_t capacity =
1309 AccessorClass::GetCapacityImpl(backing_store); 1297 AccessorClass::GetCapacityImpl(backing_store);
1310 return key < capacity; 1298 return key < capacity;
1311 } 1299 }
1312 }; 1300 };
1313 1301
1314 1302
1315 1303
1316 #define EXTERNAL_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ 1304 #define EXTERNAL_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 return JSObject::GetElementWithCallback( 1454 return JSObject::GetElementWithCallback(
1467 obj, receiver, element, key, obj); 1455 obj, receiver, element, key, obj);
1468 } else { 1456 } else {
1469 return element; 1457 return element;
1470 } 1458 }
1471 } 1459 }
1472 return isolate->factory()->the_hole_value(); 1460 return isolate->factory()->the_hole_value();
1473 } 1461 }
1474 1462
1475 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( 1463 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
1476 Handle<Object> receiver,
1477 Handle<JSObject> obj, 1464 Handle<JSObject> obj,
1478 uint32_t key, 1465 uint32_t key,
1479 Handle<FixedArrayBase> backing_store) { 1466 Handle<FixedArrayBase> backing_store) {
1480 Handle<SeededNumberDictionary> dictionary = 1467 Handle<SeededNumberDictionary> dictionary =
1481 Handle<SeededNumberDictionary>::cast(backing_store); 1468 Handle<SeededNumberDictionary>::cast(backing_store);
1482 int entry = dictionary->FindEntry(key); 1469 int entry = dictionary->FindEntry(key);
1483 if (entry != SeededNumberDictionary::kNotFound) { 1470 if (entry != SeededNumberDictionary::kNotFound) {
1484 return dictionary->DetailsAt(entry).attributes(); 1471 return dictionary->DetailsAt(entry).attributes();
1485 } 1472 }
1486 return ABSENT; 1473 return ABSENT;
1487 } 1474 }
1488 1475
1489 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl( 1476 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl(
1490 Handle<Object> receiver,
1491 Handle<JSObject> obj, 1477 Handle<JSObject> obj,
1492 uint32_t key, 1478 uint32_t key,
1493 Handle<FixedArrayBase> store) { 1479 Handle<FixedArrayBase> store) {
1494 Handle<SeededNumberDictionary> backing_store = 1480 Handle<SeededNumberDictionary> backing_store =
1495 Handle<SeededNumberDictionary>::cast(store); 1481 Handle<SeededNumberDictionary>::cast(store);
1496 int entry = backing_store->FindEntry(key); 1482 int entry = backing_store->FindEntry(key);
1497 if (entry != SeededNumberDictionary::kNotFound && 1483 if (entry != SeededNumberDictionary::kNotFound &&
1498 backing_store->DetailsAt(entry).type() == ACCESSOR_CONSTANT && 1484 backing_store->DetailsAt(entry).type() == ACCESSOR_CONSTANT &&
1499 backing_store->ValueAt(entry)->IsAccessorPair()) { 1485 backing_store->ValueAt(entry)->IsAccessorPair()) {
1500 return handle(AccessorPair::cast(backing_store->ValueAt(entry))); 1486 return handle(AccessorPair::cast(backing_store->ValueAt(entry)));
1501 } 1487 }
1502 return MaybeHandle<AccessorPair>(); 1488 return MaybeHandle<AccessorPair>();
1503 } 1489 }
1504 1490
1505 static bool HasElementImpl(Handle<Object> receiver, 1491 static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
1506 Handle<JSObject> holder,
1507 uint32_t key,
1508 Handle<FixedArrayBase> store) { 1492 Handle<FixedArrayBase> store) {
1509 Handle<SeededNumberDictionary> backing_store = 1493 Handle<SeededNumberDictionary> backing_store =
1510 Handle<SeededNumberDictionary>::cast(store); 1494 Handle<SeededNumberDictionary>::cast(store);
1511 return backing_store->FindEntry(key) != SeededNumberDictionary::kNotFound; 1495 return backing_store->FindEntry(key) != SeededNumberDictionary::kNotFound;
1512 } 1496 }
1513 1497
1514 static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> store, 1498 static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> store,
1515 uint32_t index) { 1499 uint32_t index) {
1516 DisallowHeapAllocation no_gc; 1500 DisallowHeapAllocation no_gc;
1517 Handle<SeededNumberDictionary> dict = 1501 Handle<SeededNumberDictionary> dict =
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 int context_index = entry->aliased_context_slot(); 1551 int context_index = entry->aliased_context_slot();
1568 DCHECK(!context->get(context_index)->IsTheHole()); 1552 DCHECK(!context->get(context_index)->IsTheHole());
1569 return handle(context->get(context_index), isolate); 1553 return handle(context->get(context_index), isolate);
1570 } else { 1554 } else {
1571 return result; 1555 return result;
1572 } 1556 }
1573 } 1557 }
1574 } 1558 }
1575 1559
1576 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( 1560 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
1577 Handle<Object> receiver,
1578 Handle<JSObject> obj, 1561 Handle<JSObject> obj,
1579 uint32_t key, 1562 uint32_t key,
1580 Handle<FixedArrayBase> backing_store) { 1563 Handle<FixedArrayBase> backing_store) {
1581 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(backing_store); 1564 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(backing_store);
1582 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key); 1565 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key);
1583 if (!probe->IsTheHole()) { 1566 if (!probe->IsTheHole()) {
1584 return NONE; 1567 return NONE;
1585 } else { 1568 } else {
1586 // If not aliased, check the arguments. 1569 // If not aliased, check the arguments.
1587 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); 1570 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
1588 return ElementsAccessor::ForArray(arguments)->GetAttributes( 1571 return ElementsAccessor::ForArray(arguments)
1589 receiver, obj, key, arguments); 1572 ->GetAttributes(obj, key, arguments);
1590 } 1573 }
1591 } 1574 }
1592 1575
1593 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl( 1576 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl(
1594 Handle<Object> receiver,
1595 Handle<JSObject> obj, 1577 Handle<JSObject> obj,
1596 uint32_t key, 1578 uint32_t key,
1597 Handle<FixedArrayBase> parameters) { 1579 Handle<FixedArrayBase> parameters) {
1598 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); 1580 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters);
1599 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key); 1581 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key);
1600 if (!probe->IsTheHole()) { 1582 if (!probe->IsTheHole()) {
1601 return MaybeHandle<AccessorPair>(); 1583 return MaybeHandle<AccessorPair>();
1602 } else { 1584 } else {
1603 // If not aliased, check the arguments. 1585 // If not aliased, check the arguments.
1604 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); 1586 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
1605 return ElementsAccessor::ForArray(arguments)->GetAccessorPair( 1587 return ElementsAccessor::ForArray(arguments)
1606 receiver, obj, key, arguments); 1588 ->GetAccessorPair(obj, key, arguments);
1607 } 1589 }
1608 } 1590 }
1609 1591
1610 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( 1592 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl(
1611 Handle<JSObject> obj, 1593 Handle<JSObject> obj,
1612 Handle<Object> length, 1594 Handle<Object> length,
1613 Handle<FixedArrayBase> parameter_map) { 1595 Handle<FixedArrayBase> parameter_map) {
1614 // TODO(mstarzinger): This was never implemented but will be used once we 1596 // TODO(mstarzinger): This was never implemented but will be used once we
1615 // correctly implement [[DefineOwnProperty]] on arrays. 1597 // correctly implement [[DefineOwnProperty]] on arrays.
1616 UNIMPLEMENTED(); 1598 UNIMPLEMENTED();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 FixedArrayBase::cast(parameter_map->get(1))); 1638 FixedArrayBase::cast(parameter_map->get(1)));
1657 return Max(static_cast<uint32_t>(parameter_map->length() - 2), 1639 return Max(static_cast<uint32_t>(parameter_map->length() - 2),
1658 ForArray(arguments)->GetCapacity(arguments)); 1640 ForArray(arguments)->GetCapacity(arguments));
1659 } 1641 }
1660 1642
1661 static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> dict, 1643 static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> dict,
1662 uint32_t index) { 1644 uint32_t index) {
1663 return index; 1645 return index;
1664 } 1646 }
1665 1647
1666 static bool HasElementImpl(Handle<Object> receiver,
1667 Handle<JSObject> holder,
1668 uint32_t key,
1669 Handle<FixedArrayBase> parameters) {
1670 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters);
1671 Handle<Object> probe = GetParameterMapArg(holder, parameter_map, key);
1672 if (!probe->IsTheHole()) {
1673 return true;
1674 } else {
1675 Isolate* isolate = holder->GetIsolate();
1676 Handle<FixedArrayBase> arguments(FixedArrayBase::cast(
1677 Handle<FixedArray>::cast(parameter_map)->get(1)), isolate);
1678 ElementsAccessor* accessor = ElementsAccessor::ForArray(arguments);
1679 Handle<Object> value;
1680 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
1681 isolate, value,
1682 accessor->Get(receiver, holder, key, arguments),
1683 false);
1684 return !value->IsTheHole();
1685 }
1686 }
1687
1688 private: 1648 private:
1689 static Handle<Object> GetParameterMapArg(Handle<JSObject> holder, 1649 static Handle<Object> GetParameterMapArg(Handle<JSObject> holder,
1690 Handle<FixedArray> parameter_map, 1650 Handle<FixedArray> parameter_map,
1691 uint32_t key) { 1651 uint32_t key) {
1692 Isolate* isolate = holder->GetIsolate(); 1652 Isolate* isolate = holder->GetIsolate();
1693 uint32_t length = holder->IsJSArray() 1653 uint32_t length = holder->IsJSArray()
1694 ? Smi::cast(Handle<JSArray>::cast(holder)->length())->value() 1654 ? Smi::cast(Handle<JSArray>::cast(holder)->length())->value()
1695 : parameter_map->length(); 1655 : parameter_map->length();
1696 return key < (length - 2) 1656 return key < (length - 2)
1697 ? handle(parameter_map->get(key + 2), isolate) 1657 ? handle(parameter_map->get(key + 2), isolate)
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 UNREACHABLE(); 1843 UNREACHABLE();
1884 break; 1844 break;
1885 } 1845 }
1886 1846
1887 array->set_elements(*elms); 1847 array->set_elements(*elms);
1888 array->set_length(Smi::FromInt(number_of_elements)); 1848 array->set_length(Smi::FromInt(number_of_elements));
1889 return array; 1849 return array;
1890 } 1850 }
1891 1851
1892 } } // namespace v8::internal 1852 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698