| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
| 6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
| 7 | 7 |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/elements.h" | 9 #include "src/elements.h" |
| 10 | 10 |
| (...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 ¬_nan_loop); | 1641 ¬_nan_loop); |
| 1642 | 1642 |
| 1643 // Search for HeapNumber | 1643 // Search for HeapNumber |
| 1644 assembler->Bind(¬_nan_loop); | 1644 assembler->Bind(¬_nan_loop); |
| 1645 { | 1645 { |
| 1646 Label continue_loop(assembler); | 1646 Label continue_loop(assembler); |
| 1647 assembler->GotoUnless( | 1647 assembler->GotoUnless( |
| 1648 assembler->UintPtrLessThan(index_var.value(), len_var.value()), | 1648 assembler->UintPtrLessThan(index_var.value(), len_var.value()), |
| 1649 &return_false); | 1649 &return_false); |
| 1650 | 1650 |
| 1651 if (kPointerSize == kDoubleSize) { | 1651 // Load double value or continue if it contains a double hole. |
| 1652 Node* element = assembler->LoadFixedDoubleArrayElement( | |
| 1653 elements, index_var.value(), MachineType::Uint64(), 0, | |
| 1654 CodeStubAssembler::INTPTR_PARAMETERS); | |
| 1655 Node* the_hole = assembler->Int64Constant(kHoleNanInt64); | |
| 1656 assembler->GotoIf(assembler->Word64Equal(element, the_hole), | |
| 1657 &continue_loop); | |
| 1658 } else { | |
| 1659 Node* element_upper = assembler->LoadFixedDoubleArrayElement( | |
| 1660 elements, index_var.value(), MachineType::Uint32(), | |
| 1661 kIeeeDoubleExponentWordOffset, | |
| 1662 CodeStubAssembler::INTPTR_PARAMETERS); | |
| 1663 assembler->GotoIf( | |
| 1664 assembler->Word32Equal(element_upper, | |
| 1665 assembler->Int32Constant(kHoleNanUpper32)), | |
| 1666 &continue_loop); | |
| 1667 } | |
| 1668 | |
| 1669 Node* element_k = assembler->LoadFixedDoubleArrayElement( | 1652 Node* element_k = assembler->LoadFixedDoubleArrayElement( |
| 1670 elements, index_var.value(), MachineType::Float64(), 0, | 1653 elements, index_var.value(), MachineType::Float64(), 0, |
| 1671 CodeStubAssembler::INTPTR_PARAMETERS); | 1654 CodeStubAssembler::INTPTR_PARAMETERS, &continue_loop); |
| 1655 |
| 1672 assembler->BranchIfFloat64Equal(element_k, search_num.value(), | 1656 assembler->BranchIfFloat64Equal(element_k, search_num.value(), |
| 1673 &return_true, &continue_loop); | 1657 &return_true, &continue_loop); |
| 1674 assembler->Bind(&continue_loop); | 1658 assembler->Bind(&continue_loop); |
| 1675 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one)); | 1659 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one)); |
| 1676 assembler->Goto(¬_nan_loop); | 1660 assembler->Goto(¬_nan_loop); |
| 1677 } | 1661 } |
| 1678 | 1662 |
| 1679 // Search for NaN | 1663 // Search for NaN |
| 1680 assembler->Bind(&nan_loop); | 1664 assembler->Bind(&nan_loop); |
| 1681 { | 1665 { |
| 1682 Label continue_loop(assembler); | 1666 Label continue_loop(assembler); |
| 1683 assembler->GotoUnless( | 1667 assembler->GotoUnless( |
| 1684 assembler->UintPtrLessThan(index_var.value(), len_var.value()), | 1668 assembler->UintPtrLessThan(index_var.value(), len_var.value()), |
| 1685 &return_false); | 1669 &return_false); |
| 1686 | 1670 |
| 1687 if (kPointerSize == kDoubleSize) { | 1671 // Load double value or continue if it contains a double hole. |
| 1688 Node* element = assembler->LoadFixedDoubleArrayElement( | |
| 1689 elements, index_var.value(), MachineType::Uint64(), 0, | |
| 1690 CodeStubAssembler::INTPTR_PARAMETERS); | |
| 1691 Node* the_hole = assembler->Int64Constant(kHoleNanInt64); | |
| 1692 assembler->GotoIf(assembler->Word64Equal(element, the_hole), | |
| 1693 &continue_loop); | |
| 1694 } else { | |
| 1695 Node* element_upper = assembler->LoadFixedDoubleArrayElement( | |
| 1696 elements, index_var.value(), MachineType::Uint32(), | |
| 1697 kIeeeDoubleExponentWordOffset, | |
| 1698 CodeStubAssembler::INTPTR_PARAMETERS); | |
| 1699 assembler->GotoIf( | |
| 1700 assembler->Word32Equal(element_upper, | |
| 1701 assembler->Int32Constant(kHoleNanUpper32)), | |
| 1702 &continue_loop); | |
| 1703 } | |
| 1704 | |
| 1705 Node* element_k = assembler->LoadFixedDoubleArrayElement( | 1672 Node* element_k = assembler->LoadFixedDoubleArrayElement( |
| 1706 elements, index_var.value(), MachineType::Float64(), 0, | 1673 elements, index_var.value(), MachineType::Float64(), 0, |
| 1707 CodeStubAssembler::INTPTR_PARAMETERS); | 1674 CodeStubAssembler::INTPTR_PARAMETERS, &continue_loop); |
| 1675 |
| 1708 assembler->BranchIfFloat64IsNaN(element_k, &return_true, &continue_loop); | 1676 assembler->BranchIfFloat64IsNaN(element_k, &return_true, &continue_loop); |
| 1709 assembler->Bind(&continue_loop); | 1677 assembler->Bind(&continue_loop); |
| 1710 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one)); | 1678 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one)); |
| 1711 assembler->Goto(&nan_loop); | 1679 assembler->Goto(&nan_loop); |
| 1712 } | 1680 } |
| 1713 | 1681 |
| 1714 // Search for the Hole | 1682 // Search for the Hole |
| 1715 assembler->Bind(&hole_loop); | 1683 assembler->Bind(&hole_loop); |
| 1716 { | 1684 { |
| 1717 assembler->GotoUnless( | 1685 assembler->GotoUnless( |
| 1718 assembler->UintPtrLessThan(index_var.value(), len_var.value()), | 1686 assembler->UintPtrLessThan(index_var.value(), len_var.value()), |
| 1719 &return_false); | 1687 &return_false); |
| 1720 | 1688 |
| 1721 if (kPointerSize == kDoubleSize) { | 1689 // Check if the element is a double hole, but don't load it. |
| 1722 Node* element = assembler->LoadFixedDoubleArrayElement( | 1690 assembler->LoadFixedDoubleArrayElement( |
| 1723 elements, index_var.value(), MachineType::Uint64(), 0, | 1691 elements, index_var.value(), MachineType::None(), 0, |
| 1724 CodeStubAssembler::INTPTR_PARAMETERS); | 1692 CodeStubAssembler::INTPTR_PARAMETERS, &return_true); |
| 1725 Node* the_hole = assembler->Int64Constant(kHoleNanInt64); | |
| 1726 assembler->GotoIf(assembler->Word64Equal(element, the_hole), | |
| 1727 &return_true); | |
| 1728 } else { | |
| 1729 Node* element_upper = assembler->LoadFixedDoubleArrayElement( | |
| 1730 elements, index_var.value(), MachineType::Uint32(), | |
| 1731 kIeeeDoubleExponentWordOffset, | |
| 1732 CodeStubAssembler::INTPTR_PARAMETERS); | |
| 1733 assembler->GotoIf( | |
| 1734 assembler->Word32Equal(element_upper, | |
| 1735 assembler->Int32Constant(kHoleNanUpper32)), | |
| 1736 &return_true); | |
| 1737 } | |
| 1738 | 1693 |
| 1739 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one)); | 1694 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one)); |
| 1740 assembler->Goto(&hole_loop); | 1695 assembler->Goto(&hole_loop); |
| 1741 } | 1696 } |
| 1742 } | 1697 } |
| 1743 | 1698 |
| 1744 assembler->Bind(&return_true); | 1699 assembler->Bind(&return_true); |
| 1745 assembler->Return(assembler->BooleanConstant(true)); | 1700 assembler->Return(assembler->BooleanConstant(true)); |
| 1746 | 1701 |
| 1747 assembler->Bind(&return_false); | 1702 assembler->Bind(&return_false); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2089 ¬_nan_loop); | 2044 ¬_nan_loop); |
| 2090 | 2045 |
| 2091 // Search for HeapNumber | 2046 // Search for HeapNumber |
| 2092 assembler->Bind(¬_nan_loop); | 2047 assembler->Bind(¬_nan_loop); |
| 2093 { | 2048 { |
| 2094 Label continue_loop(assembler); | 2049 Label continue_loop(assembler); |
| 2095 assembler->GotoUnless( | 2050 assembler->GotoUnless( |
| 2096 assembler->UintPtrLessThan(index_var.value(), len_var.value()), | 2051 assembler->UintPtrLessThan(index_var.value(), len_var.value()), |
| 2097 &return_not_found); | 2052 &return_not_found); |
| 2098 | 2053 |
| 2099 if (kPointerSize == kDoubleSize) { | 2054 // Load double value or continue if it contains a double hole. |
| 2100 Node* element = assembler->LoadFixedDoubleArrayElement( | |
| 2101 elements, index_var.value(), MachineType::Uint64(), 0, | |
| 2102 CodeStubAssembler::INTPTR_PARAMETERS); | |
| 2103 Node* the_hole = assembler->Int64Constant(kHoleNanInt64); | |
| 2104 assembler->GotoIf(assembler->Word64Equal(element, the_hole), | |
| 2105 &continue_loop); | |
| 2106 } else { | |
| 2107 Node* element_upper = assembler->LoadFixedDoubleArrayElement( | |
| 2108 elements, index_var.value(), MachineType::Uint32(), | |
| 2109 kIeeeDoubleExponentWordOffset, | |
| 2110 CodeStubAssembler::INTPTR_PARAMETERS); | |
| 2111 assembler->GotoIf( | |
| 2112 assembler->Word32Equal(element_upper, | |
| 2113 assembler->Int32Constant(kHoleNanUpper32)), | |
| 2114 &continue_loop); | |
| 2115 } | |
| 2116 | |
| 2117 Node* element_k = assembler->LoadFixedDoubleArrayElement( | 2055 Node* element_k = assembler->LoadFixedDoubleArrayElement( |
| 2118 elements, index_var.value(), MachineType::Float64(), 0, | 2056 elements, index_var.value(), MachineType::Float64(), 0, |
| 2119 CodeStubAssembler::INTPTR_PARAMETERS); | 2057 CodeStubAssembler::INTPTR_PARAMETERS, &continue_loop); |
| 2058 |
| 2120 assembler->BranchIfFloat64Equal(element_k, search_num.value(), | 2059 assembler->BranchIfFloat64Equal(element_k, search_num.value(), |
| 2121 &return_found, &continue_loop); | 2060 &return_found, &continue_loop); |
| 2122 assembler->Bind(&continue_loop); | 2061 assembler->Bind(&continue_loop); |
| 2123 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one)); | 2062 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one)); |
| 2124 assembler->Goto(¬_nan_loop); | 2063 assembler->Goto(¬_nan_loop); |
| 2125 } | 2064 } |
| 2126 } | 2065 } |
| 2127 | 2066 |
| 2128 assembler->Bind(&return_found); | 2067 assembler->Bind(&return_found); |
| 2129 assembler->Return(assembler->ChangeInt32ToTagged(index_var.value())); | 2068 assembler->Return(assembler->ChangeInt32ToTagged(index_var.value())); |
| 2130 | 2069 |
| 2131 assembler->Bind(&return_not_found); | 2070 assembler->Bind(&return_not_found); |
| 2132 assembler->Return(assembler->NumberConstant(-1)); | 2071 assembler->Return(assembler->NumberConstant(-1)); |
| 2133 | 2072 |
| 2134 assembler->Bind(&call_runtime); | 2073 assembler->Bind(&call_runtime); |
| 2135 assembler->Return(assembler->CallRuntime(Runtime::kArrayIndexOf, context, | 2074 assembler->Return(assembler->CallRuntime(Runtime::kArrayIndexOf, context, |
| 2136 array, search_element, start_from)); | 2075 array, search_element, start_from)); |
| 2137 } | 2076 } |
| 2138 | 2077 |
| 2139 } // namespace internal | 2078 } // namespace internal |
| 2140 } // namespace v8 | 2079 } // namespace v8 |
| OLD | NEW |