| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 __ cmpl(ESP, | 1816 __ cmpl(ESP, |
| 1817 Address::Absolute(Isolate::Current()->stack_limit_address())); | 1817 Address::Absolute(Isolate::Current()->stack_limit_address())); |
| 1818 __ j(BELOW_EQUAL, slow_path->entry_label()); | 1818 __ j(BELOW_EQUAL, slow_path->entry_label()); |
| 1819 __ Bind(slow_path->exit_label()); | 1819 __ Bind(slow_path->exit_label()); |
| 1820 } | 1820 } |
| 1821 | 1821 |
| 1822 | 1822 |
| 1823 LocationSummary* BinarySmiOpInstr::MakeLocationSummary() const { | 1823 LocationSummary* BinarySmiOpInstr::MakeLocationSummary() const { |
| 1824 const intptr_t kNumInputs = 2; | 1824 const intptr_t kNumInputs = 2; |
| 1825 if (op_kind() == Token::kTRUNCDIV) { | 1825 if (op_kind() == Token::kTRUNCDIV) { |
| 1826 const intptr_t kNumTemps = 3; | 1826 const intptr_t kNumTemps = 1; |
| 1827 LocationSummary* summary = | 1827 LocationSummary* summary = |
| 1828 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1828 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1829 // Both inputs must be writable because they will be untagged. |
| 1829 summary->set_in(0, Location::RegisterLocation(EAX)); | 1830 summary->set_in(0, Location::RegisterLocation(EAX)); |
| 1830 summary->set_in(1, Location::RegisterLocation(ECX)); | 1831 summary->set_in(1, Location::WritableRegister()); |
| 1831 summary->set_out(Location::SameAsFirstInput()); | 1832 summary->set_out(Location::SameAsFirstInput()); |
| 1832 summary->set_temp(0, Location::RegisterLocation(EBX)); | 1833 // Will be used for sign extension and division. |
| 1833 // Will be used for for sign extension. | 1834 summary->set_temp(0, Location::RegisterLocation(EDX)); |
| 1834 summary->set_temp(1, Location::RegisterLocation(EDX)); | |
| 1835 summary->set_temp(2, Location::RequiresRegister()); | |
| 1836 return summary; | 1835 return summary; |
| 1837 } else if (op_kind() == Token::kSHR) { | 1836 } else if (op_kind() == Token::kSHR) { |
| 1838 const intptr_t kNumTemps = 0; | 1837 const intptr_t kNumTemps = 0; |
| 1839 LocationSummary* summary = | 1838 LocationSummary* summary = |
| 1840 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1839 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1841 summary->set_in(0, Location::RequiresRegister()); | 1840 summary->set_in(0, Location::RequiresRegister()); |
| 1842 summary->set_in(1, Location::FixedRegisterOrSmiConstant(right(), ECX)); | 1841 summary->set_in(1, Location::FixedRegisterOrSmiConstant(right(), ECX)); |
| 1843 summary->set_out(Location::SameAsFirstInput()); | 1842 summary->set_out(Location::SameAsFirstInput()); |
| 1844 return summary; | 1843 return summary; |
| 1845 } else if (op_kind() == Token::kSHL) { | 1844 } else if (op_kind() == Token::kSHL) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 // No overflow check. | 1986 // No overflow check. |
| 1988 __ orl(left, right); | 1987 __ orl(left, right); |
| 1989 break; | 1988 break; |
| 1990 } | 1989 } |
| 1991 case Token::kBIT_XOR: { | 1990 case Token::kBIT_XOR: { |
| 1992 // No overflow check. | 1991 // No overflow check. |
| 1993 __ xorl(left, right); | 1992 __ xorl(left, right); |
| 1994 break; | 1993 break; |
| 1995 } | 1994 } |
| 1996 case Token::kTRUNCDIV: { | 1995 case Token::kTRUNCDIV: { |
| 1997 Register temp = locs()->temp(0).reg(); | |
| 1998 // Handle divide by zero in runtime. | 1996 // Handle divide by zero in runtime. |
| 1999 // Deoptimization requires that temp and right are preserved. | |
| 2000 __ testl(right, right); | 1997 __ testl(right, right); |
| 2001 __ j(ZERO, deopt); | 1998 __ j(ZERO, deopt); |
| 2002 ASSERT(left == EAX); | 1999 ASSERT(left == EAX); |
| 2003 ASSERT((right != EDX) && (right != EAX)); | 2000 ASSERT((right != EDX) && (right != EAX)); |
| 2004 ASSERT((temp != EDX) && (temp != EAX)); | 2001 ASSERT(locs()->temp(0).reg() == EDX); |
| 2005 ASSERT(locs()->temp(1).reg() == EDX); | |
| 2006 ASSERT(result == EAX); | 2002 ASSERT(result == EAX); |
| 2007 Register right_temp = locs()->temp(2).reg(); | |
| 2008 __ movl(right_temp, right); | |
| 2009 __ SmiUntag(left); | 2003 __ SmiUntag(left); |
| 2010 __ SmiUntag(right_temp); | 2004 __ SmiUntag(right); |
| 2011 __ cdq(); // Sign extend EAX -> EDX:EAX. | 2005 __ cdq(); // Sign extend EAX -> EDX:EAX. |
| 2012 __ idivl(right_temp); // EAX: quotient, EDX: remainder. | 2006 __ idivl(right); // EAX: quotient, EDX: remainder. |
| 2013 // Check the corner case of dividing the 'MIN_SMI' with -1, in which | 2007 // Check the corner case of dividing the 'MIN_SMI' with -1, in which |
| 2014 // case we cannot tag the result. | 2008 // case we cannot tag the result. |
| 2015 __ cmpl(result, Immediate(0x40000000)); | 2009 __ cmpl(result, Immediate(0x40000000)); |
| 2016 __ j(EQUAL, deopt); | 2010 __ j(EQUAL, deopt); |
| 2017 __ SmiTag(result); | 2011 __ SmiTag(result); |
| 2018 break; | 2012 break; |
| 2019 } | 2013 } |
| 2020 case Token::kSHR: { | 2014 case Token::kSHR: { |
| 2021 if (CanDeoptimize()) { | 2015 if (CanDeoptimize()) { |
| 2022 __ cmpl(right, Immediate(0)); | 2016 __ cmpl(right, Immediate(0)); |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3215 PcDescriptors::kOther, | 3209 PcDescriptors::kOther, |
| 3216 locs()); | 3210 locs()); |
| 3217 __ Drop(2); // Discard type arguments and receiver. | 3211 __ Drop(2); // Discard type arguments and receiver. |
| 3218 } | 3212 } |
| 3219 | 3213 |
| 3220 } // namespace dart | 3214 } // namespace dart |
| 3221 | 3215 |
| 3222 #undef __ | 3216 #undef __ |
| 3223 | 3217 |
| 3224 #endif // defined TARGET_ARCH_IA32 | 3218 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |