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 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 | 1637 |
1638 Handle<Code> KeyedIC::ComputeMonomorphicStubWithoutMapCheck( | 1638 Handle<Code> KeyedIC::ComputeMonomorphicStubWithoutMapCheck( |
1639 Handle<Map> receiver_map, | 1639 Handle<Map> receiver_map, |
1640 StrictModeFlag strict_mode, | 1640 StrictModeFlag strict_mode, |
1641 KeyedAccessGrowMode grow_mode) { | 1641 KeyedAccessGrowMode grow_mode) { |
1642 if ((receiver_map->instance_type() & kNotStringTag) == 0) { | 1642 if ((receiver_map->instance_type() & kNotStringTag) == 0) { |
1643 ASSERT(!string_stub().is_null()); | 1643 ASSERT(!string_stub().is_null()); |
1644 return string_stub(); | 1644 return string_stub(); |
1645 } else { | 1645 } else { |
1646 ASSERT(receiver_map->has_dictionary_elements() || | 1646 ASSERT(receiver_map->has_dictionary_elements() || |
1647 receiver_map->has_fast_elements() || | 1647 receiver_map->has_fast_smi_or_object_elements() || |
1648 receiver_map->has_fast_smi_only_elements() || | |
1649 receiver_map->has_fast_double_elements() || | 1648 receiver_map->has_fast_double_elements() || |
1650 receiver_map->has_external_array_elements()); | 1649 receiver_map->has_external_array_elements()); |
1651 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; | 1650 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; |
1652 return GetElementStubWithoutMapCheck(is_js_array, | 1651 return GetElementStubWithoutMapCheck(is_js_array, |
1653 receiver_map->elements_kind(), | 1652 receiver_map->elements_kind(), |
1654 grow_mode); | 1653 grow_mode); |
1655 } | 1654 } |
1656 } | 1655 } |
1657 | 1656 |
1658 | 1657 |
1659 Handle<Code> KeyedIC::ComputeMonomorphicStub(Handle<JSObject> receiver, | 1658 Handle<Code> KeyedIC::ComputeMonomorphicStub(Handle<JSObject> receiver, |
1660 StubKind stub_kind, | 1659 StubKind stub_kind, |
1661 StrictModeFlag strict_mode, | 1660 StrictModeFlag strict_mode, |
1662 Handle<Code> generic_stub) { | 1661 Handle<Code> generic_stub) { |
1663 if (receiver->HasFastElements() || | 1662 if (receiver->HasFastSmiOrObjectElements() || |
1664 receiver->HasFastSmiOnlyElements() || | |
1665 receiver->HasExternalArrayElements() || | 1663 receiver->HasExternalArrayElements() || |
1666 receiver->HasFastDoubleElements() || | 1664 receiver->HasFastDoubleElements() || |
1667 receiver->HasDictionaryElements()) { | 1665 receiver->HasDictionaryElements()) { |
1668 return isolate()->stub_cache()->ComputeKeyedLoadOrStoreElement( | 1666 return isolate()->stub_cache()->ComputeKeyedLoadOrStoreElement( |
1669 receiver, stub_kind, strict_mode); | 1667 receiver, stub_kind, strict_mode); |
1670 } else { | 1668 } else { |
1671 return generic_stub; | 1669 return generic_stub; |
1672 } | 1670 } |
1673 } | 1671 } |
1674 | 1672 |
1675 | 1673 |
1676 Handle<Map> KeyedIC::ComputeTransitionedMap(Handle<JSObject> receiver, | 1674 Handle<Map> KeyedIC::ComputeTransitionedMap(Handle<JSObject> receiver, |
1677 StubKind stub_kind) { | 1675 StubKind stub_kind) { |
1678 switch (stub_kind) { | 1676 switch (stub_kind) { |
1679 case KeyedIC::STORE_TRANSITION_SMI_TO_OBJECT: | 1677 case KeyedIC::STORE_TRANSITION_SMI_TO_OBJECT: |
1680 case KeyedIC::STORE_TRANSITION_DOUBLE_TO_OBJECT: | 1678 case KeyedIC::STORE_TRANSITION_DOUBLE_TO_OBJECT: |
1681 case KeyedIC::STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT: | 1679 case KeyedIC::STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT: |
1682 case KeyedIC::STORE_AND_GROW_TRANSITION_DOUBLE_TO_OBJECT: | 1680 case KeyedIC::STORE_AND_GROW_TRANSITION_DOUBLE_TO_OBJECT: |
1683 return JSObject::GetElementsTransitionMap(receiver, FAST_ELEMENTS); | 1681 return JSObject::GetElementsTransitionMap(receiver, FAST_ELEMENTS); |
1684 break; | |
1685 case KeyedIC::STORE_TRANSITION_SMI_TO_DOUBLE: | 1682 case KeyedIC::STORE_TRANSITION_SMI_TO_DOUBLE: |
1686 case KeyedIC::STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE: | 1683 case KeyedIC::STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE: |
1687 return JSObject::GetElementsTransitionMap(receiver, FAST_DOUBLE_ELEMENTS); | 1684 return JSObject::GetElementsTransitionMap(receiver, FAST_DOUBLE_ELEMENTS); |
| 1685 case KeyedIC::STORE_TRANSITION_HOLEY_SMI_TO_OBJECT: |
| 1686 case KeyedIC::STORE_TRANSITION_HOLEY_DOUBLE_TO_OBJECT: |
| 1687 case KeyedIC::STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_OBJECT: |
| 1688 case KeyedIC::STORE_AND_GROW_TRANSITION_HOLEY_DOUBLE_TO_OBJECT: |
| 1689 return JSObject::GetElementsTransitionMap(receiver, |
| 1690 FAST_HOLEY_ELEMENTS); |
| 1691 case KeyedIC::STORE_TRANSITION_HOLEY_SMI_TO_DOUBLE: |
| 1692 case KeyedIC::STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_DOUBLE: |
| 1693 return JSObject::GetElementsTransitionMap(receiver, |
| 1694 FAST_HOLEY_DOUBLE_ELEMENTS); |
| 1695 case KeyedIC::LOAD: |
| 1696 case KeyedIC::STORE_NO_TRANSITION: |
| 1697 case KeyedIC::STORE_AND_GROW_NO_TRANSITION: |
| 1698 UNREACHABLE(); |
1688 break; | 1699 break; |
1689 default: | |
1690 UNREACHABLE(); | |
1691 return Handle<Map>::null(); | |
1692 } | 1700 } |
| 1701 return Handle<Map>::null(); |
1693 } | 1702 } |
1694 | 1703 |
1695 | 1704 |
1696 Handle<Code> KeyedStoreIC::GetElementStubWithoutMapCheck( | 1705 Handle<Code> KeyedStoreIC::GetElementStubWithoutMapCheck( |
1697 bool is_js_array, | 1706 bool is_js_array, |
1698 ElementsKind elements_kind, | 1707 ElementsKind elements_kind, |
1699 KeyedAccessGrowMode grow_mode) { | 1708 KeyedAccessGrowMode grow_mode) { |
1700 return KeyedStoreElementStub(is_js_array, elements_kind, grow_mode).GetCode(); | 1709 return KeyedStoreElementStub(is_js_array, elements_kind, grow_mode).GetCode(); |
1701 } | 1710 } |
1702 | 1711 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 Handle<Object> key, | 1751 Handle<Object> key, |
1743 Handle<Object> value) { | 1752 Handle<Object> value) { |
1744 ASSERT(key->IsSmi()); | 1753 ASSERT(key->IsSmi()); |
1745 int index = Smi::cast(*key)->value(); | 1754 int index = Smi::cast(*key)->value(); |
1746 bool allow_growth = receiver->IsJSArray() && | 1755 bool allow_growth = receiver->IsJSArray() && |
1747 JSArray::cast(*receiver)->length()->IsSmi() && | 1756 JSArray::cast(*receiver)->length()->IsSmi() && |
1748 index >= Smi::cast(JSArray::cast(*receiver)->length())->value(); | 1757 index >= Smi::cast(JSArray::cast(*receiver)->length())->value(); |
1749 | 1758 |
1750 if (allow_growth) { | 1759 if (allow_growth) { |
1751 // Handle growing array in stub if necessary. | 1760 // Handle growing array in stub if necessary. |
1752 if (receiver->HasFastSmiOnlyElements()) { | 1761 if (receiver->HasFastSmiElements()) { |
1753 if (value->IsHeapNumber()) { | 1762 if (value->IsHeapNumber()) { |
1754 return STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE; | 1763 if (receiver->HasFastHoleyElements()) { |
| 1764 return STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_DOUBLE; |
| 1765 } else { |
| 1766 return STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE; |
| 1767 } |
1755 } | 1768 } |
1756 if (value->IsHeapObject()) { | 1769 if (value->IsHeapObject()) { |
1757 return STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT; | 1770 if (receiver->HasFastHoleyElements()) { |
| 1771 return STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_OBJECT; |
| 1772 } else { |
| 1773 return STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT; |
| 1774 } |
1758 } | 1775 } |
1759 } else if (receiver->HasFastDoubleElements()) { | 1776 } else if (receiver->HasFastDoubleElements()) { |
1760 if (!value->IsSmi() && !value->IsHeapNumber()) { | 1777 if (!value->IsSmi() && !value->IsHeapNumber()) { |
1761 return STORE_AND_GROW_TRANSITION_DOUBLE_TO_OBJECT; | 1778 if (receiver->HasFastHoleyElements()) { |
| 1779 return STORE_AND_GROW_TRANSITION_HOLEY_DOUBLE_TO_OBJECT; |
| 1780 } else { |
| 1781 return STORE_AND_GROW_TRANSITION_DOUBLE_TO_OBJECT; |
| 1782 } |
1762 } | 1783 } |
1763 } | 1784 } |
1764 return STORE_AND_GROW_NO_TRANSITION; | 1785 return STORE_AND_GROW_NO_TRANSITION; |
1765 } else { | 1786 } else { |
1766 // Handle only in-bounds elements accesses. | 1787 // Handle only in-bounds elements accesses. |
1767 if (receiver->HasFastSmiOnlyElements()) { | 1788 if (receiver->HasFastSmiElements()) { |
1768 if (value->IsHeapNumber()) { | 1789 if (value->IsHeapNumber()) { |
1769 return STORE_TRANSITION_SMI_TO_DOUBLE; | 1790 if (receiver->HasFastHoleyElements()) { |
| 1791 return STORE_TRANSITION_HOLEY_SMI_TO_DOUBLE; |
| 1792 } else { |
| 1793 return STORE_TRANSITION_SMI_TO_DOUBLE; |
| 1794 } |
1770 } else if (value->IsHeapObject()) { | 1795 } else if (value->IsHeapObject()) { |
1771 return STORE_TRANSITION_SMI_TO_OBJECT; | 1796 if (receiver->HasFastHoleyElements()) { |
| 1797 return STORE_TRANSITION_HOLEY_SMI_TO_OBJECT; |
| 1798 } else { |
| 1799 return STORE_TRANSITION_SMI_TO_OBJECT; |
| 1800 } |
1772 } | 1801 } |
1773 } else if (receiver->HasFastDoubleElements()) { | 1802 } else if (receiver->HasFastDoubleElements()) { |
1774 if (!value->IsSmi() && !value->IsHeapNumber()) { | 1803 if (!value->IsSmi() && !value->IsHeapNumber()) { |
1775 return STORE_TRANSITION_DOUBLE_TO_OBJECT; | 1804 if (receiver->HasFastHoleyElements()) { |
| 1805 return STORE_TRANSITION_HOLEY_DOUBLE_TO_OBJECT; |
| 1806 } else { |
| 1807 return STORE_TRANSITION_DOUBLE_TO_OBJECT; |
| 1808 } |
1776 } | 1809 } |
1777 } | 1810 } |
1778 return STORE_NO_TRANSITION; | 1811 return STORE_NO_TRANSITION; |
1779 } | 1812 } |
1780 } | 1813 } |
1781 | 1814 |
1782 | 1815 |
1783 MaybeObject* KeyedStoreIC::Store(State state, | 1816 MaybeObject* KeyedStoreIC::Store(State state, |
1784 StrictModeFlag strict_mode, | 1817 StrictModeFlag strict_mode, |
1785 Handle<Object> object, | 1818 Handle<Object> object, |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 #undef ADDR | 2639 #undef ADDR |
2607 }; | 2640 }; |
2608 | 2641 |
2609 | 2642 |
2610 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2643 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2611 return IC_utilities[id]; | 2644 return IC_utilities[id]; |
2612 } | 2645 } |
2613 | 2646 |
2614 | 2647 |
2615 } } // namespace v8::internal | 2648 } } // namespace v8::internal |
OLD | NEW |