| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 UNREACHABLE(); | 1744 UNREACHABLE(); |
| 1745 break; | 1745 break; |
| 1746 } | 1746 } |
| 1747 default: | 1747 default: |
| 1748 UNREACHABLE(); | 1748 UNREACHABLE(); |
| 1749 break; | 1749 break; |
| 1750 } | 1750 } |
| 1751 } | 1751 } |
| 1752 | 1752 |
| 1753 | 1753 |
| 1754 LocationSummary* BinaryMintOpInstr::MakeLocationSummary() const { | |
| 1755 const intptr_t kNumInputs = 2; | |
| 1756 ASSERT(op_kind() == Token::kBIT_AND); | |
| 1757 const intptr_t kNumTemps = 1; | |
| 1758 LocationSummary* summary = | |
| 1759 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | |
| 1760 summary->set_in(0, Location::RegisterLocation(EAX)); | |
| 1761 summary->set_in(1, Location::RegisterLocation(ECX)); | |
| 1762 summary->set_temp(0, Location::RegisterLocation(EDX)); | |
| 1763 summary->set_out(Location::RegisterLocation(EAX)); | |
| 1764 return summary; | |
| 1765 } | |
| 1766 | |
| 1767 | |
| 1768 void BinaryMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 1769 // TODO(regis): For now, we only support Token::kBIT_AND for a Mint or Smi | |
| 1770 // receiver and a Mint or Smi argument. We fall back to the run time call if | |
| 1771 // both receiver and argument are Mint or if one of them is Mint and the other | |
| 1772 // is a negative Smi. | |
| 1773 Register left = locs()->in(0).reg(); | |
| 1774 Register right = locs()->in(1).reg(); | |
| 1775 Register result = locs()->out().reg(); | |
| 1776 Register temp = locs()->temp(0).reg(); | |
| 1777 ASSERT(left == result); | |
| 1778 ASSERT(op_kind() == Token::kBIT_AND); | |
| 1779 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), | |
| 1780 kDeoptBinaryMintOp); | |
| 1781 Label mint_static_call, smi_static_call, non_smi, smi_smi, done; | |
| 1782 __ testl(left, Immediate(kSmiTagMask)); // Is receiver Smi? | |
| 1783 __ j(NOT_ZERO, &non_smi); | |
| 1784 __ testl(right, Immediate(kSmiTagMask)); // Is argument Smi? | |
| 1785 __ j(ZERO, &smi_smi); | |
| 1786 __ CompareClassId(right, kMintCid, temp); // Is argument Mint? | |
| 1787 __ j(NOT_EQUAL, deopt); // Argument neither Smi nor Mint. | |
| 1788 __ cmpl(left, Immediate(0)); | |
| 1789 __ j(LESS, &smi_static_call); // Negative Smi receiver, Mint argument. | |
| 1790 | |
| 1791 // Positive Smi receiver, Mint argument. | |
| 1792 // Load lower argument Mint word, convert to Smi. It is OK to loose bits. | |
| 1793 __ movl(right, FieldAddress(right, Mint::value_offset())); | |
| 1794 __ SmiTag(right); | |
| 1795 __ andl(result, right); | |
| 1796 __ jmp(&done); | |
| 1797 | |
| 1798 __ Bind(&non_smi); // Receiver is non-Smi. | |
| 1799 __ CompareClassId(left, kMintCid, temp); // Is receiver Mint? | |
| 1800 __ j(NOT_EQUAL, deopt); // Receiver neither Smi nor Mint. | |
| 1801 __ testl(right, Immediate(kSmiTagMask)); // Is argument Smi? | |
| 1802 __ j(NOT_ZERO, &mint_static_call); // Mint receiver, non-Smi argument. | |
| 1803 __ cmpl(right, Immediate(0)); | |
| 1804 __ j(LESS, &mint_static_call); // Mint receiver, negative Smi argument. | |
| 1805 | |
| 1806 // Mint receiver, positive Smi argument. | |
| 1807 // Load lower receiver Mint word, convert to Smi. It is OK to loose bits. | |
| 1808 __ movl(result, FieldAddress(left, Mint::value_offset())); | |
| 1809 __ SmiTag(result); | |
| 1810 __ Bind(&smi_smi); | |
| 1811 __ andl(result, right); | |
| 1812 __ jmp(&done); | |
| 1813 | |
| 1814 __ Bind(&smi_static_call); | |
| 1815 { | |
| 1816 Function& target = Function::ZoneHandle( | |
| 1817 ic_data()->GetTargetForReceiverClassId(kSmiCid)); | |
| 1818 if (target.IsNull()) { | |
| 1819 __ jmp(deopt); | |
| 1820 } else { | |
| 1821 __ pushl(left); | |
| 1822 __ pushl(right); | |
| 1823 compiler->GenerateStaticCall( | |
| 1824 instance_call()->deopt_id(), | |
| 1825 instance_call()->token_pos(), | |
| 1826 target, | |
| 1827 instance_call()->ArgumentCount(), | |
| 1828 instance_call()->argument_names(), | |
| 1829 locs()); | |
| 1830 ASSERT(result == EAX); | |
| 1831 __ jmp(&done); | |
| 1832 } | |
| 1833 } | |
| 1834 | |
| 1835 __ Bind(&mint_static_call); | |
| 1836 { | |
| 1837 Function& target = Function::ZoneHandle( | |
| 1838 ic_data()->GetTargetForReceiverClassId(kMintCid)); | |
| 1839 if (target.IsNull()) { | |
| 1840 __ jmp(deopt); | |
| 1841 } else { | |
| 1842 __ pushl(left); | |
| 1843 __ pushl(right); | |
| 1844 compiler->GenerateStaticCall( | |
| 1845 instance_call()->deopt_id(), | |
| 1846 instance_call()->token_pos(), | |
| 1847 target, | |
| 1848 instance_call()->ArgumentCount(), | |
| 1849 instance_call()->argument_names(), | |
| 1850 locs()); | |
| 1851 ASSERT(result == EAX); | |
| 1852 } | |
| 1853 } | |
| 1854 __ Bind(&done); | |
| 1855 } | |
| 1856 | |
| 1857 | |
| 1858 LocationSummary* CheckEitherNonSmiInstr::MakeLocationSummary() const { | 1754 LocationSummary* CheckEitherNonSmiInstr::MakeLocationSummary() const { |
| 1859 ASSERT((left()->ResultCid() != kDoubleCid) && | 1755 ASSERT((left()->ResultCid() != kDoubleCid) && |
| 1860 (right()->ResultCid() != kDoubleCid)); | 1756 (right()->ResultCid() != kDoubleCid)); |
| 1861 const intptr_t kNumInputs = 2; | 1757 const intptr_t kNumInputs = 2; |
| 1862 const intptr_t kNumTemps = 1; | 1758 const intptr_t kNumTemps = 1; |
| 1863 LocationSummary* summary = | 1759 LocationSummary* summary = |
| 1864 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1760 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1865 summary->set_in(0, Location::RequiresRegister()); | 1761 summary->set_in(0, Location::RequiresRegister()); |
| 1866 summary->set_in(1, Location::RequiresRegister()); | 1762 summary->set_in(1, Location::RequiresRegister()); |
| 1867 summary->set_temp(0, Location::RequiresRegister()); | 1763 summary->set_temp(0, Location::RequiresRegister()); |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2442 } | 2338 } |
| 2443 } | 2339 } |
| 2444 | 2340 |
| 2445 | 2341 |
| 2446 | 2342 |
| 2447 } // namespace dart | 2343 } // namespace dart |
| 2448 | 2344 |
| 2449 #undef __ | 2345 #undef __ |
| 2450 | 2346 |
| 2451 #endif // defined TARGET_ARCH_X64 | 2347 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |