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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 Object* receiver, | 579 Object* receiver, |
580 JSObject* obj, | 580 JSObject* obj, |
581 uint32_t key, | 581 uint32_t key, |
582 BackingStore* backing_store) { | 582 BackingStore* backing_store) { |
583 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { | 583 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { |
584 return ABSENT; | 584 return ABSENT; |
585 } | 585 } |
586 return backing_store->is_the_hole(key) ? ABSENT : NONE; | 586 return backing_store->is_the_hole(key) ? ABSENT : NONE; |
587 } | 587 } |
588 | 588 |
| 589 MUST_USE_RESULT virtual PropertyType GetType( |
| 590 Object* receiver, |
| 591 JSObject* holder, |
| 592 uint32_t key, |
| 593 FixedArrayBase* backing_store) { |
| 594 if (backing_store == NULL) { |
| 595 backing_store = holder->elements(); |
| 596 } |
| 597 return ElementsAccessorSubclass::GetTypeImpl( |
| 598 receiver, holder, key, BackingStore::cast(backing_store)); |
| 599 } |
| 600 |
| 601 MUST_USE_RESULT static PropertyType GetTypeImpl( |
| 602 Object* receiver, |
| 603 JSObject* obj, |
| 604 uint32_t key, |
| 605 BackingStore* backing_store) { |
| 606 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { |
| 607 return NONEXISTENT; |
| 608 } |
| 609 return backing_store->is_the_hole(key) ? NONEXISTENT : FIELD; |
| 610 } |
| 611 |
| 612 MUST_USE_RESULT virtual AccessorPair* GetAccessorPair( |
| 613 Object* receiver, |
| 614 JSObject* holder, |
| 615 uint32_t key, |
| 616 FixedArrayBase* backing_store) { |
| 617 if (backing_store == NULL) { |
| 618 backing_store = holder->elements(); |
| 619 } |
| 620 return ElementsAccessorSubclass::GetAccessorPairImpl( |
| 621 receiver, holder, key, BackingStore::cast(backing_store)); |
| 622 } |
| 623 |
| 624 MUST_USE_RESULT static AccessorPair* GetAccessorPairImpl( |
| 625 Object* receiver, |
| 626 JSObject* obj, |
| 627 uint32_t key, |
| 628 BackingStore* backing_store) { |
| 629 return NULL; |
| 630 } |
| 631 |
589 MUST_USE_RESULT virtual MaybeObject* SetLength(JSArray* array, | 632 MUST_USE_RESULT virtual MaybeObject* SetLength(JSArray* array, |
590 Object* length) { | 633 Object* length) { |
591 return ElementsAccessorSubclass::SetLengthImpl( | 634 return ElementsAccessorSubclass::SetLengthImpl( |
592 array, length, BackingStore::cast(array->elements())); | 635 array, length, BackingStore::cast(array->elements())); |
593 } | 636 } |
594 | 637 |
595 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 638 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
596 JSObject* obj, | 639 JSObject* obj, |
597 Object* length, | 640 Object* length, |
598 BackingStore* backing_store); | 641 BackingStore* backing_store); |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 : backing_store->GetHeap()->undefined_value(); | 1208 : backing_store->GetHeap()->undefined_value(); |
1166 } | 1209 } |
1167 | 1210 |
1168 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | 1211 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( |
1169 Object* receiver, | 1212 Object* receiver, |
1170 JSObject* obj, | 1213 JSObject* obj, |
1171 uint32_t key, | 1214 uint32_t key, |
1172 BackingStore* backing_store) { | 1215 BackingStore* backing_store) { |
1173 return | 1216 return |
1174 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) | 1217 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) |
1175 ? NONE : ABSENT; | 1218 ? NONE : ABSENT; |
| 1219 } |
| 1220 |
| 1221 MUST_USE_RESULT static PropertyType GetTypeImpl( |
| 1222 Object* receiver, |
| 1223 JSObject* obj, |
| 1224 uint32_t key, |
| 1225 BackingStore* backing_store) { |
| 1226 return |
| 1227 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) |
| 1228 ? FIELD : NONEXISTENT; |
1176 } | 1229 } |
1177 | 1230 |
1178 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 1231 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
1179 JSObject* obj, | 1232 JSObject* obj, |
1180 Object* length, | 1233 Object* length, |
1181 BackingStore* backing_store) { | 1234 BackingStore* backing_store) { |
1182 // External arrays do not support changing their length. | 1235 // External arrays do not support changing their length. |
1183 UNREACHABLE(); | 1236 UNREACHABLE(); |
1184 return obj; | 1237 return obj; |
1185 } | 1238 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 JSObject* obj, | 1521 JSObject* obj, |
1469 uint32_t key, | 1522 uint32_t key, |
1470 SeededNumberDictionary* backing_store) { | 1523 SeededNumberDictionary* backing_store) { |
1471 int entry = backing_store->FindEntry(key); | 1524 int entry = backing_store->FindEntry(key); |
1472 if (entry != SeededNumberDictionary::kNotFound) { | 1525 if (entry != SeededNumberDictionary::kNotFound) { |
1473 return backing_store->DetailsAt(entry).attributes(); | 1526 return backing_store->DetailsAt(entry).attributes(); |
1474 } | 1527 } |
1475 return ABSENT; | 1528 return ABSENT; |
1476 } | 1529 } |
1477 | 1530 |
| 1531 MUST_USE_RESULT static PropertyType GetTypeImpl( |
| 1532 Object* receiver, |
| 1533 JSObject* obj, |
| 1534 uint32_t key, |
| 1535 SeededNumberDictionary* backing_store) { |
| 1536 int entry = backing_store->FindEntry(key); |
| 1537 if (entry != SeededNumberDictionary::kNotFound) { |
| 1538 return backing_store->DetailsAt(entry).type(); |
| 1539 } |
| 1540 return NONEXISTENT; |
| 1541 } |
| 1542 |
| 1543 MUST_USE_RESULT static AccessorPair* GetAccessorPairImpl( |
| 1544 Object* receiver, |
| 1545 JSObject* obj, |
| 1546 uint32_t key, |
| 1547 BackingStore* backing_store) { |
| 1548 int entry = backing_store->FindEntry(key); |
| 1549 if (entry != SeededNumberDictionary::kNotFound && |
| 1550 backing_store->DetailsAt(entry).type() == CALLBACKS && |
| 1551 backing_store->ValueAt(entry)->IsAccessorPair()) { |
| 1552 return AccessorPair::cast(backing_store->ValueAt(entry)); |
| 1553 } |
| 1554 return NULL; |
| 1555 } |
| 1556 |
1478 static bool HasElementImpl(Object* receiver, | 1557 static bool HasElementImpl(Object* receiver, |
1479 JSObject* holder, | 1558 JSObject* holder, |
1480 uint32_t key, | 1559 uint32_t key, |
1481 SeededNumberDictionary* backing_store) { | 1560 SeededNumberDictionary* backing_store) { |
1482 return backing_store->FindEntry(key) != | 1561 return backing_store->FindEntry(key) != |
1483 SeededNumberDictionary::kNotFound; | 1562 SeededNumberDictionary::kNotFound; |
1484 } | 1563 } |
1485 | 1564 |
1486 static uint32_t GetKeyForIndexImpl(SeededNumberDictionary* dict, | 1565 static uint32_t GetKeyForIndexImpl(SeededNumberDictionary* dict, |
1487 uint32_t index) { | 1566 uint32_t index) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 if (!probe->IsTheHole()) { | 1622 if (!probe->IsTheHole()) { |
1544 return NONE; | 1623 return NONE; |
1545 } else { | 1624 } else { |
1546 // If not aliased, check the arguments. | 1625 // If not aliased, check the arguments. |
1547 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 1626 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
1548 return ElementsAccessor::ForArray(arguments)->GetAttributes( | 1627 return ElementsAccessor::ForArray(arguments)->GetAttributes( |
1549 receiver, obj, key, arguments); | 1628 receiver, obj, key, arguments); |
1550 } | 1629 } |
1551 } | 1630 } |
1552 | 1631 |
| 1632 MUST_USE_RESULT static PropertyType GetTypeImpl( |
| 1633 Object* receiver, |
| 1634 JSObject* obj, |
| 1635 uint32_t key, |
| 1636 FixedArray* parameter_map) { |
| 1637 Object* probe = GetParameterMapArg(obj, parameter_map, key); |
| 1638 if (!probe->IsTheHole()) { |
| 1639 return FIELD; |
| 1640 } else { |
| 1641 // If not aliased, check the arguments. |
| 1642 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 1643 return ElementsAccessor::ForArray(arguments)->GetType( |
| 1644 receiver, obj, key, arguments); |
| 1645 } |
| 1646 } |
| 1647 |
| 1648 MUST_USE_RESULT static AccessorPair* GetAccessorPairImpl( |
| 1649 Object* receiver, |
| 1650 JSObject* obj, |
| 1651 uint32_t key, |
| 1652 FixedArray* parameter_map) { |
| 1653 Object* probe = GetParameterMapArg(obj, parameter_map, key); |
| 1654 if (!probe->IsTheHole()) { |
| 1655 return NULL; |
| 1656 } else { |
| 1657 // If not aliased, check the arguments. |
| 1658 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 1659 return ElementsAccessor::ForArray(arguments)->GetAccessorPair( |
| 1660 receiver, obj, key, arguments); |
| 1661 } |
| 1662 } |
| 1663 |
1553 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 1664 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
1554 JSObject* obj, | 1665 JSObject* obj, |
1555 Object* length, | 1666 Object* length, |
1556 FixedArray* parameter_map) { | 1667 FixedArray* parameter_map) { |
1557 // TODO(mstarzinger): This was never implemented but will be used once we | 1668 // TODO(mstarzinger): This was never implemented but will be used once we |
1558 // correctly implement [[DefineOwnProperty]] on arrays. | 1669 // correctly implement [[DefineOwnProperty]] on arrays. |
1559 UNIMPLEMENTED(); | 1670 UNIMPLEMENTED(); |
1560 return obj; | 1671 return obj; |
1561 } | 1672 } |
1562 | 1673 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; | 1858 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; |
1748 new_backing_store->set(0, length); | 1859 new_backing_store->set(0, length); |
1749 { MaybeObject* result = array->SetContent(new_backing_store); | 1860 { MaybeObject* result = array->SetContent(new_backing_store); |
1750 if (result->IsFailure()) return result; | 1861 if (result->IsFailure()) return result; |
1751 } | 1862 } |
1752 return array; | 1863 return array; |
1753 } | 1864 } |
1754 | 1865 |
1755 | 1866 |
1756 } } // namespace v8::internal | 1867 } } // namespace v8::internal |
OLD | NEW |