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/objects.h" | 10 #include "src/objects.h" |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 uint32_t key, | 652 uint32_t key, |
653 Handle<FixedArrayBase> backing_store) { | 653 Handle<FixedArrayBase> backing_store) { |
654 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { | 654 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { |
655 return ABSENT; | 655 return ABSENT; |
656 } | 656 } |
657 return | 657 return |
658 Handle<BackingStore>::cast(backing_store)->is_the_hole(key) | 658 Handle<BackingStore>::cast(backing_store)->is_the_hole(key) |
659 ? ABSENT : NONE; | 659 ? ABSENT : NONE; |
660 } | 660 } |
661 | 661 |
662 MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair( | 662 MUST_USE_RESULT virtual MaybeHandle<Object> GetStructure( |
663 Handle<Object> receiver, | 663 Handle<Object> receiver, Handle<JSObject> holder, uint32_t key, |
664 Handle<JSObject> holder, | |
665 uint32_t key, | |
666 Handle<FixedArrayBase> backing_store) FINAL OVERRIDE { | 664 Handle<FixedArrayBase> backing_store) FINAL OVERRIDE { |
667 return ElementsAccessorSubclass::GetAccessorPairImpl( | 665 return ElementsAccessorSubclass::GetStructureImpl(receiver, holder, key, |
668 receiver, holder, key, backing_store); | 666 backing_store); |
669 } | 667 } |
670 | 668 |
671 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 669 MUST_USE_RESULT static MaybeHandle<Object> GetStructureImpl( |
672 Handle<Object> receiver, | 670 Handle<Object> receiver, Handle<JSObject> obj, uint32_t key, |
673 Handle<JSObject> obj, | |
674 uint32_t key, | |
675 Handle<FixedArrayBase> backing_store) { | 671 Handle<FixedArrayBase> backing_store) { |
676 return MaybeHandle<AccessorPair>(); | 672 return MaybeHandle<Object>(); |
677 } | 673 } |
678 | 674 |
679 MUST_USE_RESULT virtual MaybeHandle<Object> SetLength( | 675 MUST_USE_RESULT virtual MaybeHandle<Object> SetLength( |
680 Handle<JSArray> array, | 676 Handle<JSArray> array, |
681 Handle<Object> length) FINAL OVERRIDE { | 677 Handle<Object> length) FINAL OVERRIDE { |
682 return ElementsAccessorSubclass::SetLengthImpl( | 678 return ElementsAccessorSubclass::SetLengthImpl( |
683 array, length, handle(array->elements())); | 679 array, length, handle(array->elements())); |
684 } | 680 } |
685 | 681 |
686 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( | 682 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 Handle<FixedArrayBase> backing_store) { | 1503 Handle<FixedArrayBase> backing_store) { |
1508 Handle<SeededNumberDictionary> dictionary = | 1504 Handle<SeededNumberDictionary> dictionary = |
1509 Handle<SeededNumberDictionary>::cast(backing_store); | 1505 Handle<SeededNumberDictionary>::cast(backing_store); |
1510 int entry = dictionary->FindEntry(key); | 1506 int entry = dictionary->FindEntry(key); |
1511 if (entry != SeededNumberDictionary::kNotFound) { | 1507 if (entry != SeededNumberDictionary::kNotFound) { |
1512 return dictionary->DetailsAt(entry).attributes(); | 1508 return dictionary->DetailsAt(entry).attributes(); |
1513 } | 1509 } |
1514 return ABSENT; | 1510 return ABSENT; |
1515 } | 1511 } |
1516 | 1512 |
1517 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 1513 MUST_USE_RESULT static MaybeHandle<Object> GetStructureImpl( |
1518 Handle<Object> receiver, | 1514 Handle<Object> receiver, Handle<JSObject> obj, uint32_t key, |
1519 Handle<JSObject> obj, | |
1520 uint32_t key, | |
1521 Handle<FixedArrayBase> store) { | 1515 Handle<FixedArrayBase> store) { |
1522 Handle<SeededNumberDictionary> backing_store = | 1516 Handle<SeededNumberDictionary> backing_store = |
1523 Handle<SeededNumberDictionary>::cast(store); | 1517 Handle<SeededNumberDictionary>::cast(store); |
1524 int entry = backing_store->FindEntry(key); | 1518 int entry = backing_store->FindEntry(key); |
1525 if (entry != SeededNumberDictionary::kNotFound && | 1519 if (entry != SeededNumberDictionary::kNotFound && |
1526 backing_store->DetailsAt(entry).type() == CALLBACKS && | 1520 backing_store->DetailsAt(entry).type() == CALLBACKS) { |
1527 backing_store->ValueAt(entry)->IsAccessorPair()) { | 1521 return handle(backing_store->ValueAt(entry), obj->GetIsolate()); |
1528 return handle(AccessorPair::cast(backing_store->ValueAt(entry))); | |
1529 } | 1522 } |
1530 return MaybeHandle<AccessorPair>(); | 1523 return MaybeHandle<Object>(); |
1531 } | 1524 } |
1532 | 1525 |
1533 static bool HasElementImpl(Handle<Object> receiver, | 1526 static bool HasElementImpl(Handle<Object> receiver, |
1534 Handle<JSObject> holder, | 1527 Handle<JSObject> holder, |
1535 uint32_t key, | 1528 uint32_t key, |
1536 Handle<FixedArrayBase> store) { | 1529 Handle<FixedArrayBase> store) { |
1537 Handle<SeededNumberDictionary> backing_store = | 1530 Handle<SeededNumberDictionary> backing_store = |
1538 Handle<SeededNumberDictionary>::cast(store); | 1531 Handle<SeededNumberDictionary>::cast(store); |
1539 return backing_store->FindEntry(key) != SeededNumberDictionary::kNotFound; | 1532 return backing_store->FindEntry(key) != SeededNumberDictionary::kNotFound; |
1540 } | 1533 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 if (!probe->IsTheHole()) { | 1604 if (!probe->IsTheHole()) { |
1612 return NONE; | 1605 return NONE; |
1613 } else { | 1606 } else { |
1614 // If not aliased, check the arguments. | 1607 // If not aliased, check the arguments. |
1615 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); | 1608 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); |
1616 return ElementsAccessor::ForArray(arguments)->GetAttributes( | 1609 return ElementsAccessor::ForArray(arguments)->GetAttributes( |
1617 receiver, obj, key, arguments); | 1610 receiver, obj, key, arguments); |
1618 } | 1611 } |
1619 } | 1612 } |
1620 | 1613 |
1621 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 1614 MUST_USE_RESULT static MaybeHandle<Object> GetStructureImpl( |
1622 Handle<Object> receiver, | 1615 Handle<Object> receiver, Handle<JSObject> obj, uint32_t key, |
1623 Handle<JSObject> obj, | |
1624 uint32_t key, | |
1625 Handle<FixedArrayBase> parameters) { | 1616 Handle<FixedArrayBase> parameters) { |
1626 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); | 1617 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); |
1627 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key); | 1618 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key); |
1628 if (!probe->IsTheHole()) { | 1619 if (!probe->IsTheHole()) { |
1629 return MaybeHandle<AccessorPair>(); | 1620 return MaybeHandle<Object>(); |
1630 } else { | 1621 } else { |
1631 // If not aliased, check the arguments. | 1622 // If not aliased, check the arguments. |
1632 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); | 1623 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); |
1633 return ElementsAccessor::ForArray(arguments)->GetAccessorPair( | 1624 return ElementsAccessor::ForArray(arguments) |
1634 receiver, obj, key, arguments); | 1625 ->GetStructure(receiver, obj, key, arguments); |
1635 } | 1626 } |
1636 } | 1627 } |
1637 | 1628 |
1638 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( | 1629 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( |
1639 Handle<JSObject> obj, | 1630 Handle<JSObject> obj, |
1640 Handle<Object> length, | 1631 Handle<Object> length, |
1641 Handle<FixedArrayBase> parameter_map) { | 1632 Handle<FixedArrayBase> parameter_map) { |
1642 // TODO(mstarzinger): This was never implemented but will be used once we | 1633 // TODO(mstarzinger): This was never implemented but will be used once we |
1643 // correctly implement [[DefineOwnProperty]] on arrays. | 1634 // correctly implement [[DefineOwnProperty]] on arrays. |
1644 UNIMPLEMENTED(); | 1635 UNIMPLEMENTED(); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1911 UNREACHABLE(); | 1902 UNREACHABLE(); |
1912 break; | 1903 break; |
1913 } | 1904 } |
1914 | 1905 |
1915 array->set_elements(*elms); | 1906 array->set_elements(*elms); |
1916 array->set_length(Smi::FromInt(number_of_elements)); | 1907 array->set_length(Smi::FromInt(number_of_elements)); |
1917 return array; | 1908 return array; |
1918 } | 1909 } |
1919 | 1910 |
1920 } } // namespace v8::internal | 1911 } } // namespace v8::internal |
OLD | NEW |