Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(795)

Side by Side Diff: src/arm/stub-cache-arm.cc

Issue 11377132: Support all fast elements kinds in the major array operations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments (and rebased) Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/builtins.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
1641 // Get the array's length into r0 and calculate new length. 1640 // Get the array's length into r0 and calculate new length.
1642 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); 1641 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
1643 STATIC_ASSERT(kSmiTagSize == 1); 1642 STATIC_ASSERT(kSmiTagSize == 1);
1644 STATIC_ASSERT(kSmiTag == 0); 1643 STATIC_ASSERT(kSmiTag == 0);
1645 __ add(r0, r0, Operand(Smi::FromInt(argc))); 1644 __ add(r0, r0, Operand(Smi::FromInt(argc)));
1646 1645
1647 // Get the elements' length. 1646 // Get the elements' length.
1648 __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); 1647 __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset));
1649 1648
1650 // Check if we could survive without allocation. 1649 // Check if we could survive without allocation.
1651 __ cmp(r0, r4); 1650 __ cmp(r0, r4);
1652 __ b(gt, &attempt_to_grow_elements); 1651 __ b(gt, &attempt_to_grow_elements);
1653 1652
1654 // Check if value is a smi. 1653 // Check if value is a smi.
1655 Label with_write_barrier;
1656 __ ldr(r4, MemOperand(sp, (argc - 1) * kPointerSize)); 1654 __ ldr(r4, MemOperand(sp, (argc - 1) * kPointerSize));
1657 __ JumpIfNotSmi(r4, &with_write_barrier); 1655 __ JumpIfNotSmi(r4, &with_write_barrier);
1658 1656
1659 // Save new length. 1657 // Save new length.
1660 __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); 1658 __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
1661 1659
1662 // Store the value. 1660 // Store the value.
1663 // We may need a register containing the address end_elements below, 1661 // We may need a register containing the address end_elements below,
1664 // so write back the value in end_elements. 1662 // so write back the value in end_elements.
1665 __ add(end_elements, elements, 1663 __ add(end_elements, elements,
1666 Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize)); 1664 Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize));
1667 const int kEndElementsOffset = 1665 const int kEndElementsOffset =
1668 FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize; 1666 FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize;
1669 __ str(r4, MemOperand(end_elements, kEndElementsOffset, PreIndex)); 1667 __ str(r4, MemOperand(end_elements, kEndElementsOffset, PreIndex));
1670 1668
1671 // Check for a smi. 1669 // Check for a smi.
1672 __ Drop(argc + 1); 1670 __ Drop(argc + 1);
1673 __ Ret(); 1671 __ Ret();
1674 1672
1673 __ bind(&check_double);
1674
1675 // Check that the elements are in fast mode and writable.
1676 __ CheckMap(elements,
1677 r0,
1678 Heap::kFixedDoubleArrayMapRootIndex,
1679 &call_builtin,
1680 DONT_DO_SMI_CHECK);
1681
1682 // Get the array's length into r0 and calculate new length.
1683 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
1684 STATIC_ASSERT(kSmiTagSize == 1);
1685 STATIC_ASSERT(kSmiTag == 0);
1686 __ add(r0, r0, Operand(Smi::FromInt(argc)));
1687
1688 // Get the elements' length.
1689 __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset));
1690
1691 // Check if we could survive without allocation.
1692 __ cmp(r0, r4);
1693 __ b(gt, &call_builtin);
1694
1695 __ ldr(r4, MemOperand(sp, (argc - 1) * kPointerSize));
1696 __ StoreNumberToDoubleElements(
1697 r4, r0, elements, r3, r5, r2, r9,
1698 &call_builtin, argc * kDoubleSize);
1699
1700 // Save new length.
1701 __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
1702
1703 // Check for a smi.
1704 __ Drop(argc + 1);
1705 __ Ret();
1706
1675 __ bind(&with_write_barrier); 1707 __ bind(&with_write_barrier);
1676 1708
1677 __ ldr(r3, FieldMemOperand(receiver, HeapObject::kMapOffset)); 1709 __ ldr(r3, FieldMemOperand(receiver, HeapObject::kMapOffset));
1678 1710
1679 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { 1711 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) {
1680 Label fast_object, not_fast_object; 1712 Label fast_object, not_fast_object;
1681 __ CheckFastObjectElements(r3, r7, &not_fast_object); 1713 __ CheckFastObjectElements(r3, r7, &not_fast_object);
1682 __ jmp(&fast_object); 1714 __ jmp(&fast_object);
1683 // In case of fast smi-only, convert to fast object, otherwise bail out. 1715 // In case of fast smi-only, convert to fast object, otherwise bail out.
1684 __ bind(&not_fast_object); 1716 __ bind(&not_fast_object);
1685 __ CheckFastSmiElements(r3, r7, &call_builtin); 1717 __ CheckFastSmiElements(r3, r7, &call_builtin);
1718
1719 __ ldr(r7, FieldMemOperand(r4, HeapObject::kMapOffset));
1720 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex);
1721 __ cmp(r7, ip);
1722 __ b(eq, &call_builtin);
1686 // edx: receiver 1723 // edx: receiver
1687 // r3: map 1724 // r3: map
1688 Label try_holey_map; 1725 Label try_holey_map;
1689 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, 1726 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS,
1690 FAST_ELEMENTS, 1727 FAST_ELEMENTS,
1691 r3, 1728 r3,
1692 r7, 1729 r7,
1693 &try_holey_map); 1730 &try_holey_map);
1694 __ mov(r2, receiver); 1731 __ mov(r2, receiver);
1695 ElementsTransitionGenerator:: 1732 ElementsTransitionGenerator::
(...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after
4691 __ cmp(key_reg, scratch1); 4728 __ cmp(key_reg, scratch1);
4692 if (grow_mode == ALLOW_JSARRAY_GROWTH) { 4729 if (grow_mode == ALLOW_JSARRAY_GROWTH) {
4693 __ b(hs, &grow); 4730 __ b(hs, &grow);
4694 } else { 4731 } else {
4695 __ b(hs, &miss_force_generic); 4732 __ b(hs, &miss_force_generic);
4696 } 4733 }
4697 4734
4698 __ bind(&finish_store); 4735 __ bind(&finish_store);
4699 __ StoreNumberToDoubleElements(value_reg, 4736 __ StoreNumberToDoubleElements(value_reg,
4700 key_reg, 4737 key_reg,
4701 receiver_reg,
4702 // All registers after this are overwritten. 4738 // All registers after this are overwritten.
4703 elements_reg, 4739 elements_reg,
4704 scratch1, 4740 scratch1,
4705 scratch2, 4741 scratch2,
4706 scratch3, 4742 scratch3,
4707 scratch4, 4743 scratch4,
4708 &transition_elements_kind); 4744 &transition_elements_kind);
4709 __ Ret(); 4745 __ Ret();
4710 4746
4711 // Handle store cache miss, replacing the ic with the generic stub. 4747 // Handle store cache miss, replacing the ic with the generic stub.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
4787 __ Jump(ic_slow, RelocInfo::CODE_TARGET); 4823 __ Jump(ic_slow, RelocInfo::CODE_TARGET);
4788 } 4824 }
4789 } 4825 }
4790 4826
4791 4827
4792 #undef __ 4828 #undef __
4793 4829
4794 } } // namespace v8::internal 4830 } } // namespace v8::internal
4795 4831
4796 #endif // V8_TARGET_ARCH_ARM 4832 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698