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 return AccessorPair::cast(backing_store->ValueAt(entry)); | |
Michael Starzinger
2012/11/14 17:30:39
This could potentially also be a Foreign callback
Sven Panne
2012/11/15 06:36:32
The Foreign case is completely under our control a
rossberg
2012/11/15 11:25:43
That was an oversight. Added IsAccessorPair condit
| |
1552 } | |
1553 return NULL; | |
1554 } | |
1555 | |
1478 static bool HasElementImpl(Object* receiver, | 1556 static bool HasElementImpl(Object* receiver, |
1479 JSObject* holder, | 1557 JSObject* holder, |
1480 uint32_t key, | 1558 uint32_t key, |
1481 SeededNumberDictionary* backing_store) { | 1559 SeededNumberDictionary* backing_store) { |
1482 return backing_store->FindEntry(key) != | 1560 return backing_store->FindEntry(key) != |
1483 SeededNumberDictionary::kNotFound; | 1561 SeededNumberDictionary::kNotFound; |
1484 } | 1562 } |
1485 | 1563 |
1486 static uint32_t GetKeyForIndexImpl(SeededNumberDictionary* dict, | 1564 static uint32_t GetKeyForIndexImpl(SeededNumberDictionary* dict, |
1487 uint32_t index) { | 1565 uint32_t index) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1543 if (!probe->IsTheHole()) { | 1621 if (!probe->IsTheHole()) { |
1544 return NONE; | 1622 return NONE; |
1545 } else { | 1623 } else { |
1546 // If not aliased, check the arguments. | 1624 // If not aliased, check the arguments. |
1547 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 1625 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
1548 return ElementsAccessor::ForArray(arguments)->GetAttributes( | 1626 return ElementsAccessor::ForArray(arguments)->GetAttributes( |
1549 receiver, obj, key, arguments); | 1627 receiver, obj, key, arguments); |
1550 } | 1628 } |
1551 } | 1629 } |
1552 | 1630 |
1631 MUST_USE_RESULT static PropertyType GetTypeImpl( | |
1632 Object* receiver, | |
1633 JSObject* obj, | |
1634 uint32_t key, | |
1635 FixedArray* parameter_map) { | |
1636 Object* probe = GetParameterMapArg(obj, parameter_map, key); | |
1637 if (!probe->IsTheHole()) { | |
1638 return FIELD; | |
1639 } else { | |
1640 // If not aliased, check the arguments. | |
1641 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | |
1642 return ElementsAccessor::ForArray(arguments)->GetType( | |
1643 receiver, obj, key, arguments); | |
1644 } | |
1645 } | |
1646 | |
1647 MUST_USE_RESULT static AccessorPair* GetAccessorPairImpl( | |
1648 Object* receiver, | |
1649 JSObject* obj, | |
1650 uint32_t key, | |
1651 FixedArray* parameter_map) { | |
1652 Object* probe = GetParameterMapArg(obj, parameter_map, key); | |
1653 if (!probe->IsTheHole()) { | |
1654 return NULL; | |
1655 } else { | |
1656 // If not aliased, check the arguments. | |
1657 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | |
1658 return ElementsAccessor::ForArray(arguments)->GetAccessorPair( | |
1659 receiver, obj, key, arguments); | |
1660 } | |
1661 } | |
1662 | |
1553 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 1663 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
1554 JSObject* obj, | 1664 JSObject* obj, |
1555 Object* length, | 1665 Object* length, |
1556 FixedArray* parameter_map) { | 1666 FixedArray* parameter_map) { |
1557 // TODO(mstarzinger): This was never implemented but will be used once we | 1667 // TODO(mstarzinger): This was never implemented but will be used once we |
1558 // correctly implement [[DefineOwnProperty]] on arrays. | 1668 // correctly implement [[DefineOwnProperty]] on arrays. |
1559 UNIMPLEMENTED(); | 1669 UNIMPLEMENTED(); |
1560 return obj; | 1670 return obj; |
1561 } | 1671 } |
1562 | 1672 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1747 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; | 1857 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; |
1748 new_backing_store->set(0, length); | 1858 new_backing_store->set(0, length); |
1749 { MaybeObject* result = array->SetContent(new_backing_store); | 1859 { MaybeObject* result = array->SetContent(new_backing_store); |
1750 if (result->IsFailure()) return result; | 1860 if (result->IsFailure()) return result; |
1751 } | 1861 } |
1752 return array; | 1862 return array; |
1753 } | 1863 } |
1754 | 1864 |
1755 | 1865 |
1756 } } // namespace v8::internal | 1866 } } // namespace v8::internal |
OLD | NEW |