Chromium Code Reviews| 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 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1616 | 1616 |
| 1617 if (argc == 0) { | 1617 if (argc == 0) { |
| 1618 // Nothing to do, just return the length. | 1618 // Nothing to do, just return the length. |
| 1619 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 1619 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 1620 __ Drop(argc + 1); | 1620 __ Drop(argc + 1); |
| 1621 __ Ret(); | 1621 __ Ret(); |
| 1622 } else { | 1622 } else { |
| 1623 Label call_builtin; | 1623 Label call_builtin; |
| 1624 | 1624 |
| 1625 if (argc == 1) { // Otherwise fall through to call the builtin. | 1625 if (argc == 1) { // Otherwise fall through to call the builtin. |
| 1626 Label attempt_to_grow_elements; | 1626 Label attempt_to_grow_elements, with_write_barrier, check_double; |
| 1627 | 1627 |
| 1628 Register elements = r6; | 1628 Register elements = r6; |
| 1629 Register end_elements = r5; | 1629 Register end_elements = r5; |
| 1630 // Get the elements array of the object. | 1630 // Get the elements array of the object. |
| 1631 __ ldr(elements, FieldMemOperand(receiver, JSArray::kElementsOffset)); | 1631 __ ldr(elements, FieldMemOperand(receiver, JSArray::kElementsOffset)); |
| 1632 | 1632 |
| 1633 // Check that the elements are in fast mode and writable. | 1633 // Check that the elements are in fast mode and writable. |
| 1634 __ CheckMap(elements, | 1634 __ CheckMap(elements, |
| 1635 r0, | 1635 r0, |
| 1636 Heap::kFixedArrayMapRootIndex, | 1636 Heap::kFixedArrayMapRootIndex, |
| 1637 &call_builtin, | 1637 &check_double, |
| 1638 DONT_DO_SMI_CHECK); | 1638 DONT_DO_SMI_CHECK); |
| 1639 | 1639 |
| 1640 | 1640 |
| 1641 // Get the array's length into r0 and calculate new length. | 1641 // Get the array's length into r0 and calculate new length. |
| 1642 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 1642 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 1643 STATIC_ASSERT(kSmiTagSize == 1); | 1643 STATIC_ASSERT(kSmiTagSize == 1); |
| 1644 STATIC_ASSERT(kSmiTag == 0); | 1644 STATIC_ASSERT(kSmiTag == 0); |
| 1645 __ add(r0, r0, Operand(Smi::FromInt(argc))); | 1645 __ add(r0, r0, Operand(Smi::FromInt(argc))); |
| 1646 | 1646 |
| 1647 // Get the elements' length. | 1647 // Get the elements' length. |
| 1648 __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); | 1648 __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
| 1649 | 1649 |
| 1650 // Check if we could survive without allocation. | 1650 // Check if we could survive without allocation. |
| 1651 __ cmp(r0, r4); | 1651 __ cmp(r0, r4); |
| 1652 __ b(gt, &attempt_to_grow_elements); | 1652 __ b(gt, &attempt_to_grow_elements); |
| 1653 | 1653 |
| 1654 // Check if value is a smi. | 1654 // Check if value is a smi. |
| 1655 Label with_write_barrier; | |
| 1656 __ ldr(r4, MemOperand(sp, (argc - 1) * kPointerSize)); | 1655 __ ldr(r4, MemOperand(sp, (argc - 1) * kPointerSize)); |
| 1657 __ JumpIfNotSmi(r4, &with_write_barrier); | 1656 __ JumpIfNotSmi(r4, &with_write_barrier); |
| 1658 | 1657 |
| 1659 // Save new length. | 1658 // Save new length. |
| 1660 __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 1659 __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 1661 | 1660 |
| 1662 // Store the value. | 1661 // Store the value. |
| 1663 // We may need a register containing the address end_elements below, | 1662 // We may need a register containing the address end_elements below, |
| 1664 // so write back the value in end_elements. | 1663 // so write back the value in end_elements. |
| 1665 __ add(end_elements, elements, | 1664 __ add(end_elements, elements, |
| 1666 Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize)); | 1665 Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize)); |
| 1667 const int kEndElementsOffset = | 1666 const int kEndElementsOffset = |
| 1668 FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize; | 1667 FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize; |
| 1669 __ str(r4, MemOperand(end_elements, kEndElementsOffset, PreIndex)); | 1668 __ str(r4, MemOperand(end_elements, kEndElementsOffset, PreIndex)); |
| 1670 | 1669 |
| 1671 // Check for a smi. | 1670 // Check for a smi. |
| 1672 __ Drop(argc + 1); | 1671 __ Drop(argc + 1); |
| 1673 __ Ret(); | 1672 __ Ret(); |
| 1674 | 1673 |
| 1674 __ bind(&check_double); | |
| 1675 | |
| 1676 // Check that the elements are in fast mode and writable. | |
| 1677 __ CheckMap(elements, | |
| 1678 r0, | |
| 1679 Heap::kFixedDoubleArrayMapRootIndex, | |
| 1680 &call_builtin, | |
| 1681 DONT_DO_SMI_CHECK); | |
| 1682 | |
|
danno
2012/11/13 22:05:12
nit: why the double space?
Toon Verwaest
2012/11/14 11:53:13
Done.
| |
| 1683 | |
| 1684 // Get the array's length into r0 and calculate new length. | |
| 1685 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | |
| 1686 STATIC_ASSERT(kSmiTagSize == 1); | |
| 1687 STATIC_ASSERT(kSmiTag == 0); | |
| 1688 __ add(r0, r0, Operand(Smi::FromInt(argc))); | |
| 1689 | |
| 1690 // Get the elements' length. | |
| 1691 __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); | |
| 1692 | |
| 1693 // Check if we could survive without allocation. | |
| 1694 __ cmp(r0, r4); | |
| 1695 __ b(gt, &call_builtin); | |
| 1696 | |
| 1697 __ ldr(r4, MemOperand(sp, (argc - 1) * kPointerSize)); | |
| 1698 __ StoreNumberToDoubleElements( | |
| 1699 r4, r0, elements, r3, r5, r2, r9, | |
| 1700 &call_builtin, argc * kDoubleSize); | |
| 1701 | |
| 1702 // Save new length. | |
| 1703 __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | |
| 1704 | |
| 1705 // Check for a smi. | |
| 1706 __ Drop(argc + 1); | |
| 1707 __ Ret(); | |
| 1708 | |
| 1675 __ bind(&with_write_barrier); | 1709 __ bind(&with_write_barrier); |
| 1676 | 1710 |
| 1677 __ ldr(r3, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 1711 __ ldr(r3, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 1678 | 1712 |
| 1679 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { | 1713 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { |
| 1680 Label fast_object, not_fast_object; | 1714 Label fast_object, not_fast_object; |
| 1681 __ CheckFastObjectElements(r3, r7, ¬_fast_object); | 1715 __ CheckFastObjectElements(r3, r7, ¬_fast_object); |
| 1682 __ jmp(&fast_object); | 1716 __ jmp(&fast_object); |
| 1683 // In case of fast smi-only, convert to fast object, otherwise bail out. | 1717 // In case of fast smi-only, convert to fast object, otherwise bail out. |
| 1684 __ bind(¬_fast_object); | 1718 __ bind(¬_fast_object); |
| 1685 __ CheckFastSmiElements(r3, r7, &call_builtin); | 1719 __ CheckFastSmiElements(r3, r7, &call_builtin); |
| 1720 | |
| 1721 __ ldr(r7, FieldMemOperand(r4, HeapObject::kMapOffset)); | |
| 1722 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | |
| 1723 __ cmp(r7, ip); | |
| 1724 __ b(eq, &call_builtin); | |
| 1686 // edx: receiver | 1725 // edx: receiver |
| 1687 // r3: map | 1726 // r3: map |
| 1688 Label try_holey_map; | 1727 Label try_holey_map; |
| 1689 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, | 1728 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, |
| 1690 FAST_ELEMENTS, | 1729 FAST_ELEMENTS, |
| 1691 r3, | 1730 r3, |
| 1692 r7, | 1731 r7, |
| 1693 &try_holey_map); | 1732 &try_holey_map); |
| 1694 __ mov(r2, receiver); | 1733 __ mov(r2, receiver); |
| 1695 ElementsTransitionGenerator:: | 1734 ElementsTransitionGenerator:: |
| (...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4691 __ cmp(key_reg, scratch1); | 4730 __ cmp(key_reg, scratch1); |
| 4692 if (grow_mode == ALLOW_JSARRAY_GROWTH) { | 4731 if (grow_mode == ALLOW_JSARRAY_GROWTH) { |
| 4693 __ b(hs, &grow); | 4732 __ b(hs, &grow); |
| 4694 } else { | 4733 } else { |
| 4695 __ b(hs, &miss_force_generic); | 4734 __ b(hs, &miss_force_generic); |
| 4696 } | 4735 } |
| 4697 | 4736 |
| 4698 __ bind(&finish_store); | 4737 __ bind(&finish_store); |
| 4699 __ StoreNumberToDoubleElements(value_reg, | 4738 __ StoreNumberToDoubleElements(value_reg, |
| 4700 key_reg, | 4739 key_reg, |
| 4701 receiver_reg, | |
| 4702 // All registers after this are overwritten. | 4740 // All registers after this are overwritten. |
| 4703 elements_reg, | 4741 elements_reg, |
| 4704 scratch1, | 4742 scratch1, |
| 4705 scratch2, | 4743 scratch2, |
| 4706 scratch3, | 4744 scratch3, |
| 4707 scratch4, | 4745 scratch4, |
| 4708 &transition_elements_kind); | 4746 &transition_elements_kind); |
| 4709 __ Ret(); | 4747 __ Ret(); |
| 4710 | 4748 |
| 4711 // Handle store cache miss, replacing the ic with the generic stub. | 4749 // Handle store cache miss, replacing the ic with the generic stub. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4787 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4825 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
| 4788 } | 4826 } |
| 4789 } | 4827 } |
| 4790 | 4828 |
| 4791 | 4829 |
| 4792 #undef __ | 4830 #undef __ |
| 4793 | 4831 |
| 4794 } } // namespace v8::internal | 4832 } } // namespace v8::internal |
| 4795 | 4833 |
| 4796 #endif // V8_TARGET_ARCH_ARM | 4834 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |