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 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 name, &miss); | 1621 name, &miss); |
1622 | 1622 |
1623 if (argc == 0) { | 1623 if (argc == 0) { |
1624 // Nothing to do, just return the length. | 1624 // Nothing to do, just return the length. |
1625 __ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 1625 __ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
1626 __ Drop(argc + 1); | 1626 __ Drop(argc + 1); |
1627 __ Ret(); | 1627 __ Ret(); |
1628 } else { | 1628 } else { |
1629 Label call_builtin; | 1629 Label call_builtin; |
1630 if (argc == 1) { // Otherwise fall through to call the builtin. | 1630 if (argc == 1) { // Otherwise fall through to call the builtin. |
1631 Label attempt_to_grow_elements; | 1631 Label attempt_to_grow_elements, with_write_barrier, check_double; |
1632 | 1632 |
1633 Register elements = t2; | 1633 Register elements = t2; |
1634 Register end_elements = t1; | 1634 Register end_elements = t1; |
1635 // Get the elements array of the object. | 1635 // Get the elements array of the object. |
1636 __ lw(elements, FieldMemOperand(receiver, JSArray::kElementsOffset)); | 1636 __ lw(elements, FieldMemOperand(receiver, JSArray::kElementsOffset)); |
1637 | 1637 |
1638 // Check that the elements are in fast mode and writable. | 1638 // Check that the elements are in fast mode and writable. |
1639 __ CheckMap(elements, | 1639 __ CheckMap(elements, |
1640 v0, | 1640 v0, |
1641 Heap::kFixedArrayMapRootIndex, | 1641 Heap::kFixedArrayMapRootIndex, |
1642 &call_builtin, | 1642 &check_double, |
1643 DONT_DO_SMI_CHECK); | 1643 DONT_DO_SMI_CHECK); |
1644 | 1644 |
1645 // Get the array's length into v0 and calculate new length. | 1645 // Get the array's length into v0 and calculate new length. |
1646 __ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 1646 __ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
1647 STATIC_ASSERT(kSmiTagSize == 1); | 1647 STATIC_ASSERT(kSmiTagSize == 1); |
1648 STATIC_ASSERT(kSmiTag == 0); | 1648 STATIC_ASSERT(kSmiTag == 0); |
1649 __ Addu(v0, v0, Operand(Smi::FromInt(argc))); | 1649 __ Addu(v0, v0, Operand(Smi::FromInt(argc))); |
1650 | 1650 |
1651 // Get the elements' length. | 1651 // Get the elements' length. |
1652 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset)); | 1652 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
1653 | 1653 |
1654 // Check if we could survive without allocation. | 1654 // Check if we could survive without allocation. |
1655 __ Branch(&attempt_to_grow_elements, gt, v0, Operand(t0)); | 1655 __ Branch(&attempt_to_grow_elements, gt, v0, Operand(t0)); |
1656 | 1656 |
1657 // Check if value is a smi. | 1657 // Check if value is a smi. |
1658 Label with_write_barrier; | |
1659 __ lw(t0, MemOperand(sp, (argc - 1) * kPointerSize)); | 1658 __ lw(t0, MemOperand(sp, (argc - 1) * kPointerSize)); |
1660 __ JumpIfNotSmi(t0, &with_write_barrier); | 1659 __ JumpIfNotSmi(t0, &with_write_barrier); |
1661 | 1660 |
1662 // Save new length. | 1661 // Save new length. |
1663 __ sw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 1662 __ sw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
1664 | 1663 |
1665 // Store the value. | 1664 // Store the value. |
1666 // We may need a register containing the address end_elements below, | 1665 // We may need a register containing the address end_elements below, |
1667 // so write back the value in end_elements. | 1666 // so write back the value in end_elements. |
1668 __ sll(end_elements, v0, kPointerSizeLog2 - kSmiTagSize); | 1667 __ sll(end_elements, v0, kPointerSizeLog2 - kSmiTagSize); |
1669 __ Addu(end_elements, elements, end_elements); | 1668 __ Addu(end_elements, elements, end_elements); |
1670 const int kEndElementsOffset = | 1669 const int kEndElementsOffset = |
1671 FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize; | 1670 FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize; |
1672 __ Addu(end_elements, end_elements, kEndElementsOffset); | 1671 __ Addu(end_elements, end_elements, kEndElementsOffset); |
1673 __ sw(t0, MemOperand(end_elements)); | 1672 __ sw(t0, MemOperand(end_elements)); |
1674 | 1673 |
1675 // Check for a smi. | 1674 // Check for a smi. |
1676 __ Drop(argc + 1); | 1675 __ Drop(argc + 1); |
1677 __ Ret(); | 1676 __ Ret(); |
1678 | 1677 |
| 1678 __ bind(&check_double); |
| 1679 |
| 1680 // Check that the elements are in fast mode and writable. |
| 1681 __ CheckMap(elements, |
| 1682 a0, |
| 1683 Heap::kFixedDoubleArrayMapRootIndex, |
| 1684 &call_builtin, |
| 1685 DONT_DO_SMI_CHECK); |
| 1686 |
| 1687 // Get the array's length into r0 and calculate new length. |
| 1688 __ lw(a0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 1689 STATIC_ASSERT(kSmiTagSize == 1); |
| 1690 STATIC_ASSERT(kSmiTag == 0); |
| 1691 __ Addu(a0, a0, Operand(Smi::FromInt(argc))); |
| 1692 |
| 1693 // Get the elements' length. |
| 1694 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
| 1695 |
| 1696 // Check if we could survive without allocation. |
| 1697 __ Branch(&call_builtin, gt, a0, Operand(t0)); |
| 1698 |
| 1699 __ lw(t0, MemOperand(sp, (argc - 1) * kPointerSize)); |
| 1700 __ StoreNumberToDoubleElements( |
| 1701 t0, a0, elements, a3, t1, a2, t5, |
| 1702 &call_builtin, argc * kDoubleSize); |
| 1703 |
| 1704 // Save new length. |
| 1705 __ sw(a0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 1706 |
| 1707 // Check for a smi. |
| 1708 __ Drop(argc + 1); |
| 1709 __ Ret(); |
| 1710 |
1679 __ bind(&with_write_barrier); | 1711 __ bind(&with_write_barrier); |
1680 | 1712 |
1681 __ lw(a3, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 1713 __ lw(a3, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
1682 | 1714 |
1683 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { | 1715 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { |
1684 Label fast_object, not_fast_object; | 1716 Label fast_object, not_fast_object; |
1685 __ CheckFastObjectElements(a3, t3, ¬_fast_object); | 1717 __ CheckFastObjectElements(a3, t3, ¬_fast_object); |
1686 __ jmp(&fast_object); | 1718 __ jmp(&fast_object); |
1687 // In case of fast smi-only, convert to fast object, otherwise bail out. | 1719 // In case of fast smi-only, convert to fast object, otherwise bail out. |
1688 __ bind(¬_fast_object); | 1720 __ bind(¬_fast_object); |
1689 __ CheckFastSmiElements(a3, t3, &call_builtin); | 1721 __ CheckFastSmiElements(a3, t3, &call_builtin); |
| 1722 |
| 1723 __ lw(t3, FieldMemOperand(t0, HeapObject::kMapOffset)); |
| 1724 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); |
| 1725 __ Branch(&call_builtin, eq, t3, Operand(at)); |
1690 // edx: receiver | 1726 // edx: receiver |
1691 // r3: map | 1727 // a3: map |
1692 Label try_holey_map; | 1728 Label try_holey_map; |
1693 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, | 1729 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, |
1694 FAST_ELEMENTS, | 1730 FAST_ELEMENTS, |
1695 a3, | 1731 a3, |
1696 t3, | 1732 t3, |
1697 &try_holey_map); | 1733 &try_holey_map); |
1698 __ mov(a2, receiver); | 1734 __ mov(a2, receiver); |
1699 ElementsTransitionGenerator:: | 1735 ElementsTransitionGenerator:: |
1700 GenerateMapChangeElementsTransition(masm()); | 1736 GenerateMapChangeElementsTransition(masm()); |
1701 __ jmp(&fast_object); | 1737 __ jmp(&fast_object); |
(...skipping 3048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4750 if (grow_mode == ALLOW_JSARRAY_GROWTH) { | 4786 if (grow_mode == ALLOW_JSARRAY_GROWTH) { |
4751 __ Branch(&grow, hs, key_reg, Operand(scratch1)); | 4787 __ Branch(&grow, hs, key_reg, Operand(scratch1)); |
4752 } else { | 4788 } else { |
4753 __ Branch(&miss_force_generic, hs, key_reg, Operand(scratch1)); | 4789 __ Branch(&miss_force_generic, hs, key_reg, Operand(scratch1)); |
4754 } | 4790 } |
4755 | 4791 |
4756 __ bind(&finish_store); | 4792 __ bind(&finish_store); |
4757 | 4793 |
4758 __ StoreNumberToDoubleElements(value_reg, | 4794 __ StoreNumberToDoubleElements(value_reg, |
4759 key_reg, | 4795 key_reg, |
4760 receiver_reg, | |
4761 // All registers after this are overwritten. | 4796 // All registers after this are overwritten. |
4762 elements_reg, | 4797 elements_reg, |
4763 scratch1, | 4798 scratch1, |
4764 scratch2, | 4799 scratch2, |
4765 scratch3, | 4800 scratch3, |
4766 scratch4, | 4801 scratch4, |
4767 &transition_elements_kind); | 4802 &transition_elements_kind); |
4768 | 4803 |
4769 __ Ret(USE_DELAY_SLOT); | 4804 __ Ret(USE_DELAY_SLOT); |
4770 __ mov(v0, value_reg); // In delay slot. | 4805 __ mov(v0, value_reg); // In delay slot. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4846 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4881 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
4847 } | 4882 } |
4848 } | 4883 } |
4849 | 4884 |
4850 | 4885 |
4851 #undef __ | 4886 #undef __ |
4852 | 4887 |
4853 } } // namespace v8::internal | 4888 } } // namespace v8::internal |
4854 | 4889 |
4855 #endif // V8_TARGET_ARCH_MIPS | 4890 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |