| 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 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1968 | 1968 |
| 1969 __ testq(value, Immediate(kSmiTagMask)); | 1969 __ testq(value, Immediate(kSmiTagMask)); |
| 1970 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi. | 1970 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi. |
| 1971 __ SmiUntag(value); | 1971 __ SmiUntag(value); |
| 1972 __ cvtsi2sd(XMM0, value); | 1972 __ cvtsi2sd(XMM0, value); |
| 1973 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); | 1973 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); |
| 1974 __ Drop(1); | 1974 __ Drop(1); |
| 1975 } | 1975 } |
| 1976 | 1976 |
| 1977 | 1977 |
| 1978 LocationSummary* DoubleToIntegerInstr::MakeLocationSummary() const { |
| 1979 const intptr_t kNumInputs = 1; |
| 1980 const intptr_t kNumTemps = 1; |
| 1981 LocationSummary* result = |
| 1982 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 1983 result->set_in(0, Location::RegisterLocation(RCX)); |
| 1984 result->set_out(Location::RegisterLocation(RAX)); |
| 1985 result->set_temp(0, Location::RegisterLocation(RBX)); |
| 1986 return result; |
| 1987 } |
| 1988 |
| 1989 |
| 1990 void DoubleToIntegerInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1991 Register result = locs()->out().reg(); |
| 1992 Register value_obj = locs()->in(0).reg(); |
| 1993 Register temp = locs()->temp(0).reg(); |
| 1994 XmmRegister value_double = XMM0; |
| 1995 ASSERT(result == RAX); |
| 1996 ASSERT(result != value_obj); |
| 1997 ASSERT(result != temp); |
| 1998 __ movsd(value_double, FieldAddress(value_obj, Double::value_offset())); |
| 1999 __ cvttsd2siq(result, value_double); |
| 2000 // Overflow is signalled with minint. |
| 2001 Label do_call, done; |
| 2002 // Check for overflow and that it fits into Smi. |
| 2003 __ movq(temp, result); |
| 2004 __ shlq(temp, Immediate(1)); |
| 2005 __ j(OVERFLOW, &do_call, Assembler::kNearJump); |
| 2006 __ SmiTag(result); |
| 2007 __ jmp(&done); |
| 2008 __ Bind(&do_call); |
| 2009 ASSERT(instance_call()->HasICData()); |
| 2010 const ICData& ic_data = *instance_call()->ic_data(); |
| 2011 ASSERT((ic_data.NumberOfChecks() == 1)); |
| 2012 const Function& target = Function::ZoneHandle(ic_data.GetTargetAt(0)); |
| 2013 |
| 2014 const intptr_t kNumberOfArguments = 1; |
| 2015 __ pushq(value_obj); |
| 2016 compiler->GenerateStaticCall(instance_call()->deopt_id(), |
| 2017 instance_call()->token_pos(), |
| 2018 target, |
| 2019 kNumberOfArguments, |
| 2020 Array::Handle(), // No argument names. |
| 2021 locs()); |
| 2022 __ Drop(1); |
| 2023 __ Bind(&done); |
| 2024 } |
| 2025 |
| 2026 |
| 1978 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { | 2027 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { |
| 1979 return MakeCallSummary(); | 2028 return MakeCallSummary(); |
| 1980 } | 2029 } |
| 1981 | 2030 |
| 1982 | 2031 |
| 1983 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2032 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1984 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), | 2033 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), |
| 1985 kDeoptPolymorphicInstanceCallTestFail); | 2034 kDeoptPolymorphicInstanceCallTestFail); |
| 1986 if (ic_data().NumberOfChecks() == 0) { | 2035 if (ic_data().NumberOfChecks() == 0) { |
| 1987 __ jmp(deopt); | 2036 __ jmp(deopt); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2206 | 2255 |
| 2207 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2256 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2208 UNIMPLEMENTED(); | 2257 UNIMPLEMENTED(); |
| 2209 } | 2258 } |
| 2210 | 2259 |
| 2211 } // namespace dart | 2260 } // namespace dart |
| 2212 | 2261 |
| 2213 #undef __ | 2262 #undef __ |
| 2214 | 2263 |
| 2215 #endif // defined TARGET_ARCH_X64 | 2264 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |