| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 UNREACHABLE(); | 1709 UNREACHABLE(); |
| 1710 break; | 1710 break; |
| 1711 } | 1711 } |
| 1712 default: | 1712 default: |
| 1713 UNREACHABLE(); | 1713 UNREACHABLE(); |
| 1714 break; | 1714 break; |
| 1715 } | 1715 } |
| 1716 } | 1716 } |
| 1717 | 1717 |
| 1718 | 1718 |
| 1719 LocationSummary* BinaryMintOpInstr::MakeLocationSummary() const { | |
| 1720 ASSERT(op_kind() == Token::kBIT_AND); | |
| 1721 const intptr_t kNumInputs = 2; | |
| 1722 const intptr_t kNumTemps = 0; | |
| 1723 LocationSummary* summary = | |
| 1724 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | |
| 1725 summary->set_in(0, Location::RegisterLocation(RAX)); | |
| 1726 summary->set_in(1, Location::RegisterLocation(RCX)); | |
| 1727 summary->set_out(Location::RegisterLocation(RAX)); | |
| 1728 return summary; | |
| 1729 } | |
| 1730 | |
| 1731 | |
| 1732 void BinaryMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 1733 // TODO(regis): For now, we only support Token::kBIT_AND for a Mint or Smi | |
| 1734 // receiver and a Mint or Smi argument. We fall back to the run time call if | |
| 1735 // both receiver and argument are Mint or if one of them is Mint and the other | |
| 1736 // is a negative Smi. | |
| 1737 Register left = locs()->in(0).reg(); | |
| 1738 Register right = locs()->in(1).reg(); | |
| 1739 Register result = locs()->out().reg(); | |
| 1740 ASSERT(left == result); | |
| 1741 ASSERT(op_kind() == Token::kBIT_AND); | |
| 1742 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), | |
| 1743 kDeoptBinaryMintOp); | |
| 1744 Label mint_static_call, smi_static_call, non_smi, smi_smi, done; | |
| 1745 __ testq(left, Immediate(kSmiTagMask)); // Is receiver Smi? | |
| 1746 __ j(NOT_ZERO, &non_smi); | |
| 1747 __ testq(right, Immediate(kSmiTagMask)); // Is argument Smi? | |
| 1748 __ j(ZERO, &smi_smi); | |
| 1749 __ CompareClassId(right, kMintCid); // Is argument Mint? | |
| 1750 __ j(NOT_EQUAL, deopt); // Argument neither Smi nor Mint. | |
| 1751 __ cmpq(left, Immediate(0)); | |
| 1752 __ j(LESS, &smi_static_call); // Negative Smi receiver, Mint argument. | |
| 1753 | |
| 1754 // Positive Smi receiver, Mint argument. | |
| 1755 // Load lower argument Mint word, convert to Smi. It is OK to loose bits. | |
| 1756 __ movq(right, FieldAddress(right, Mint::value_offset())); | |
| 1757 __ SmiTag(right); | |
| 1758 __ andq(result, right); | |
| 1759 __ jmp(&done); | |
| 1760 | |
| 1761 __ Bind(&non_smi); // Receiver is non-Smi. | |
| 1762 __ CompareClassId(left, kMintCid); // Is receiver Mint? | |
| 1763 __ j(NOT_EQUAL, deopt); // Receiver neither Smi nor Mint. | |
| 1764 __ testq(right, Immediate(kSmiTagMask)); // Is argument Smi? | |
| 1765 __ j(NOT_ZERO, &mint_static_call); // Mint receiver, non-Smi argument. | |
| 1766 __ cmpq(right, Immediate(0)); | |
| 1767 __ j(LESS, &mint_static_call); // Mint receiver, negative Smi argument. | |
| 1768 | |
| 1769 // Mint receiver, positive Smi argument. | |
| 1770 // Load lower receiver Mint word, convert to Smi. It is OK to loose bits. | |
| 1771 __ movq(result, FieldAddress(left, Mint::value_offset())); | |
| 1772 __ SmiTag(result); | |
| 1773 __ Bind(&smi_smi); | |
| 1774 __ andq(result, right); | |
| 1775 __ jmp(&done); | |
| 1776 | |
| 1777 __ Bind(&smi_static_call); | |
| 1778 { | |
| 1779 Function& target = Function::ZoneHandle( | |
| 1780 ic_data()->GetTargetForReceiverClassId(kSmiCid)); | |
| 1781 if (target.IsNull()) { | |
| 1782 __ jmp(deopt); | |
| 1783 } else { | |
| 1784 __ pushq(left); | |
| 1785 __ pushq(right); | |
| 1786 compiler->GenerateStaticCall( | |
| 1787 instance_call()->deopt_id(), | |
| 1788 instance_call()->token_pos(), | |
| 1789 target, | |
| 1790 instance_call()->ArgumentCount(), | |
| 1791 instance_call()->argument_names(), | |
| 1792 locs()); | |
| 1793 ASSERT(result == RAX); | |
| 1794 __ jmp(&done); | |
| 1795 } | |
| 1796 } | |
| 1797 | |
| 1798 __ Bind(&mint_static_call); | |
| 1799 { | |
| 1800 Function& target = Function::ZoneHandle( | |
| 1801 ic_data()->GetTargetForReceiverClassId(kMintCid)); | |
| 1802 if (target.IsNull()) { | |
| 1803 __ jmp(deopt); | |
| 1804 } else { | |
| 1805 __ pushq(left); | |
| 1806 __ pushq(right); | |
| 1807 compiler->GenerateStaticCall( | |
| 1808 instance_call()->deopt_id(), | |
| 1809 instance_call()->token_pos(), | |
| 1810 target, | |
| 1811 instance_call()->ArgumentCount(), | |
| 1812 instance_call()->argument_names(), | |
| 1813 locs()); | |
| 1814 ASSERT(result == RAX); | |
| 1815 } | |
| 1816 } | |
| 1817 __ Bind(&done); | |
| 1818 } | |
| 1819 | |
| 1820 | |
| 1821 LocationSummary* CheckEitherNonSmiInstr::MakeLocationSummary() const { | 1719 LocationSummary* CheckEitherNonSmiInstr::MakeLocationSummary() const { |
| 1822 ASSERT((left()->ResultCid() != kDoubleCid) && | 1720 ASSERT((left()->ResultCid() != kDoubleCid) && |
| 1823 (right()->ResultCid() != kDoubleCid)); | 1721 (right()->ResultCid() != kDoubleCid)); |
| 1824 const intptr_t kNumInputs = 2; | 1722 const intptr_t kNumInputs = 2; |
| 1825 const intptr_t kNumTemps = 1; | 1723 const intptr_t kNumTemps = 1; |
| 1826 LocationSummary* summary = | 1724 LocationSummary* summary = |
| 1827 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1725 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1828 summary->set_in(0, Location::RequiresRegister()); | 1726 summary->set_in(0, Location::RequiresRegister()); |
| 1829 summary->set_in(1, Location::RequiresRegister()); | 1727 summary->set_in(1, Location::RequiresRegister()); |
| 1830 summary->set_temp(0, Location::RequiresRegister()); | 1728 summary->set_temp(0, Location::RequiresRegister()); |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2239 __ j(ABOVE_EQUAL, deopt); | 2137 __ j(ABOVE_EQUAL, deopt); |
| 2240 } else { | 2138 } else { |
| 2241 Register receiver = locs()->in(0).reg(); | 2139 Register receiver = locs()->in(0).reg(); |
| 2242 Register index = locs()->in(1).reg(); | 2140 Register index = locs()->in(1).reg(); |
| 2243 __ cmpq(index, FieldAddress(receiver, length_offset)); | 2141 __ cmpq(index, FieldAddress(receiver, length_offset)); |
| 2244 __ j(ABOVE_EQUAL, deopt); | 2142 __ j(ABOVE_EQUAL, deopt); |
| 2245 } | 2143 } |
| 2246 } | 2144 } |
| 2247 | 2145 |
| 2248 | 2146 |
| 2147 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const { |
| 2148 UNIMPLEMENTED(); |
| 2149 return NULL; |
| 2150 } |
| 2151 |
| 2152 |
| 2153 void UnboxIntegerInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2154 UNIMPLEMENTED(); |
| 2155 } |
| 2156 |
| 2157 |
| 2158 LocationSummary* BoxIntegerInstr::MakeLocationSummary() const { |
| 2159 UNIMPLEMENTED(); |
| 2160 return NULL; |
| 2161 } |
| 2162 |
| 2163 |
| 2164 void BoxIntegerInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2165 UNIMPLEMENTED(); |
| 2166 } |
| 2167 |
| 2168 |
| 2169 LocationSummary* UnboxedMintBinaryOpInstr::MakeLocationSummary() const { |
| 2170 UNIMPLEMENTED(); |
| 2171 return NULL; |
| 2172 } |
| 2173 |
| 2174 |
| 2175 void UnboxedMintBinaryOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2176 UNIMPLEMENTED(); |
| 2177 } |
| 2178 |
| 2179 |
| 2249 } // namespace dart | 2180 } // namespace dart |
| 2250 | 2181 |
| 2251 #undef __ | 2182 #undef __ |
| 2252 | 2183 |
| 2253 #endif // defined TARGET_ARCH_X64 | 2184 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |