| 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 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 case Token::kBIT_NOT: | 1983 case Token::kBIT_NOT: |
| 1984 __ notl(value); | 1984 __ notl(value); |
| 1985 __ andl(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag. | 1985 __ andl(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag. |
| 1986 break; | 1986 break; |
| 1987 default: | 1987 default: |
| 1988 UNREACHABLE(); | 1988 UNREACHABLE(); |
| 1989 } | 1989 } |
| 1990 } | 1990 } |
| 1991 | 1991 |
| 1992 | 1992 |
| 1993 LocationSummary* NumberNegateInstr::MakeLocationSummary() const { | |
| 1994 const intptr_t kNumInputs = 1; | |
| 1995 const intptr_t kNumTemps = 1; // Needed for doubles. | |
| 1996 LocationSummary* summary = | |
| 1997 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | |
| 1998 summary->set_in(0, Location::RegisterLocation(EAX)); | |
| 1999 summary->set_temp(0, Location::RegisterLocation(ECX)); | |
| 2000 summary->set_out(Location::RegisterLocation(EAX)); | |
| 2001 return summary; | |
| 2002 } | |
| 2003 | |
| 2004 | |
| 2005 void NumberNegateInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 2006 const ICData& ic_data = *instance_call()->ic_data(); | |
| 2007 ASSERT(!ic_data.IsNull()); | |
| 2008 ASSERT(ic_data.num_args_tested() == 1); | |
| 2009 | |
| 2010 // TODO(srdjan): Implement for more checks. | |
| 2011 ASSERT(ic_data.NumberOfChecks() == 1); | |
| 2012 intptr_t test_class_id; | |
| 2013 Function& target = Function::Handle(); | |
| 2014 ic_data.GetOneClassCheckAt(0, &test_class_id, &target); | |
| 2015 | |
| 2016 Register value = locs()->in(0).reg(); | |
| 2017 Register result = locs()->out().reg(); | |
| 2018 ASSERT(value == result); | |
| 2019 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), | |
| 2020 kDeoptUnaryOp); | |
| 2021 if (test_class_id == kDoubleCid) { | |
| 2022 Register temp = locs()->temp(0).reg(); | |
| 2023 __ testl(value, Immediate(kSmiTagMask)); | |
| 2024 __ j(ZERO, deopt); // Smi. | |
| 2025 __ CompareClassId(value, kDoubleCid, temp); | |
| 2026 __ j(NOT_EQUAL, deopt); | |
| 2027 // Allocate result object. | |
| 2028 const Class& double_class = compiler->double_class(); | |
| 2029 const Code& stub = | |
| 2030 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); | |
| 2031 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); | |
| 2032 __ pushl(value); | |
| 2033 compiler->GenerateCall(instance_call()->token_pos(), | |
| 2034 &label, | |
| 2035 PcDescriptors::kOther, | |
| 2036 locs()); | |
| 2037 // Result is in EAX. | |
| 2038 ASSERT(result != temp); | |
| 2039 __ movl(result, EAX); | |
| 2040 __ popl(temp); | |
| 2041 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); | |
| 2042 __ DoubleNegate(XMM0); | |
| 2043 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); | |
| 2044 } else { | |
| 2045 UNREACHABLE(); | |
| 2046 } | |
| 2047 ASSERT(ResultCid() == kDoubleCid); | |
| 2048 } | |
| 2049 | |
| 2050 | |
| 2051 LocationSummary* DoubleToDoubleInstr::MakeLocationSummary() const { | 1993 LocationSummary* DoubleToDoubleInstr::MakeLocationSummary() const { |
| 2052 const intptr_t kNumInputs = 1; | 1994 const intptr_t kNumInputs = 1; |
| 2053 const intptr_t kNumTemps = 1; | 1995 const intptr_t kNumTemps = 1; |
| 2054 LocationSummary* locs = | 1996 LocationSummary* locs = |
| 2055 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 1997 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2056 locs->set_in(0, Location::RequiresRegister()); | 1998 locs->set_in(0, Location::RequiresRegister()); |
| 2057 locs->set_temp(0, Location::RequiresRegister()); | 1999 locs->set_temp(0, Location::RequiresRegister()); |
| 2058 locs->set_out(Location::SameAsFirstInput()); | 2000 locs->set_out(Location::SameAsFirstInput()); |
| 2059 return locs; | 2001 return locs; |
| 2060 } | 2002 } |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2281 __ j(ABOVE_EQUAL, deopt); | 2223 __ j(ABOVE_EQUAL, deopt); |
| 2282 } | 2224 } |
| 2283 } | 2225 } |
| 2284 | 2226 |
| 2285 | 2227 |
| 2286 } // namespace dart | 2228 } // namespace dart |
| 2287 | 2229 |
| 2288 #undef __ | 2230 #undef __ |
| 2289 | 2231 |
| 2290 #endif // defined TARGET_ARCH_X64 | 2232 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |