Chromium Code Reviews| 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 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1985 __ popq(temp); | 1985 __ popq(temp); |
| 1986 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); | 1986 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); |
| 1987 __ DoubleNegate(XMM0); | 1987 __ DoubleNegate(XMM0); |
| 1988 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); | 1988 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); |
| 1989 } else { | 1989 } else { |
| 1990 UNREACHABLE(); | 1990 UNREACHABLE(); |
| 1991 } | 1991 } |
| 1992 } | 1992 } |
| 1993 | 1993 |
| 1994 | 1994 |
| 1995 LocationSummary* ToDoubleComp::MakeLocationSummary() const { | 1995 LocationSummary* DoubleToDoubleComp::MakeLocationSummary() const { |
| 1996 const intptr_t kNumInputs = 1; | 1996 const intptr_t kNumInputs = 1; |
| 1997 if (from() == kDoubleCid) { | 1997 const intptr_t kNumTemps = 0; |
| 1998 const intptr_t kNumTemps = 0; | 1998 LocationSummary* locs = |
| 1999 LocationSummary* locs = | 1999 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2000 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2000 locs->set_in(0, Location::RequiresRegister()); |
| 2001 locs->set_in(0, Location::RequiresRegister()); | 2001 locs->set_out(Location::SameAsFirstInput()); |
| 2002 locs->set_out(Location::SameAsFirstInput()); | 2002 return locs; |
| 2003 return locs; | |
| 2004 } else { | |
| 2005 ASSERT(from() == kSmiCid); | |
| 2006 return MakeCallSummary(); // Calls a stub to allocate result. | |
| 2007 } | |
| 2008 } | 2003 } |
| 2009 | 2004 |
| 2010 | 2005 |
| 2011 void ToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2006 void DoubleToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2012 Register value = (from() == kDoubleCid) ? locs()->in(0).reg() : RBX; | 2007 Register value = locs()->in(0).reg(); |
| 2013 Register result = locs()->out().reg(); | 2008 Register result = locs()->out().reg(); |
| 2014 | 2009 |
| 2015 const DeoptReasonId deopt_reason = (from() == kDoubleCid) ? | |
| 2016 kDeoptDoubleToDouble : kDeoptIntegerToDouble; | |
| 2017 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), | 2010 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), |
| 2018 instance_call()->try_index(), | 2011 instance_call()->try_index(), |
| 2019 deopt_reason, | 2012 kDeoptDoubleToDouble, |
| 2020 value); | 2013 value); |
| 2021 | 2014 |
| 2022 if (from() == kDoubleCid) { | 2015 __ testq(value, Immediate(kSmiTagMask)); |
| 2023 __ testq(value, Immediate(kSmiTagMask)); | 2016 __ j(ZERO, deopt); // Deoptimize if Smi. |
| 2024 __ j(ZERO, deopt); // Deoptimize if Smi. | 2017 __ CompareClassId(value, kDoubleCid); |
| 2025 __ CompareClassId(value, kDoubleCid); | 2018 __ j(NOT_EQUAL, deopt); // Deoptimize if not Double. |
| 2026 __ j(NOT_EQUAL, deopt); // Deoptimize if not Double. | 2019 ASSERT(value == result); |
| 2027 ASSERT(value == result); | 2020 } |
| 2028 return; | |
| 2029 } | |
| 2030 | 2021 |
| 2031 ASSERT(from() == kSmiCid); | 2022 |
| 2023 LocationSummary* SmiToDoubleComp::MakeLocationSummary() const { | |
| 2024 return MakeCallSummary(); // Calls a stub to allocate result. | |
| 2025 } | |
| 2026 | |
| 2027 | |
| 2028 void SmiToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 2029 Register result = locs()->out().reg(); | |
| 2030 | |
| 2031 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), | |
| 2032 instance_call()->try_index(), | |
| 2033 kDeoptIntegerToDouble); | |
| 2032 | 2034 |
| 2033 const Class& double_class = compiler->double_class(); | 2035 const Class& double_class = compiler->double_class(); |
| 2034 const Code& stub = | 2036 const Code& stub = |
| 2035 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); | 2037 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); |
| 2036 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); | 2038 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); |
| 2037 | 2039 |
| 2038 // TODO(vegorov): allocate box in the driver loop to avoid spilling. | 2040 // TODO(fschneider): Inline new-space allocation and move the call into |
| 2041 // deferred code. | |
| 2039 compiler->GenerateCall(instance_call()->token_pos(), | 2042 compiler->GenerateCall(instance_call()->token_pos(), |
| 2040 instance_call()->try_index(), | 2043 instance_call()->try_index(), |
| 2041 &label, | 2044 &label, |
| 2042 PcDescriptors::kOther, | 2045 PcDescriptors::kOther, |
| 2043 locs()->stack_bitmap()); | 2046 locs()->stack_bitmap()); |
| 2044 ASSERT(result == RAX); | 2047 ASSERT(result == RAX); |
| 2045 __ popq(value); | 2048 Register value = RBX; |
|
srdjan
2012/08/14 21:21:26
Ditto as for ia32 version.
Florian Schneider
2012/08/15 10:27:23
Same as x64.
| |
| 2049 __ movq(value, Address(RSP, 0)); | |
| 2046 | 2050 |
| 2047 __ testq(value, Immediate(kSmiTagMask)); | 2051 __ testq(value, Immediate(kSmiTagMask)); |
| 2048 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi. | 2052 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi. |
| 2049 __ SmiUntag(value); | 2053 __ SmiUntag(value); |
| 2050 __ cvtsi2sd(XMM0, value); | 2054 __ cvtsi2sd(XMM0, value); |
| 2051 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); | 2055 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); |
| 2056 __ Drop(1); | |
| 2052 } | 2057 } |
| 2053 | 2058 |
| 2054 | 2059 |
| 2055 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const { | 2060 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const { |
| 2056 return MakeCallSummary(); | 2061 return MakeCallSummary(); |
| 2057 } | 2062 } |
| 2058 | 2063 |
| 2059 | 2064 |
| 2060 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2065 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2061 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), | 2066 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2228 locs()->stack_bitmap()); | 2233 locs()->stack_bitmap()); |
| 2229 __ CompareObject(RAX, compiler->bool_true()); | 2234 __ CompareObject(RAX, compiler->bool_true()); |
| 2230 EmitBranchOnCondition(compiler, branch_condition); | 2235 EmitBranchOnCondition(compiler, branch_condition); |
| 2231 } | 2236 } |
| 2232 | 2237 |
| 2233 } // namespace dart | 2238 } // namespace dart |
| 2234 | 2239 |
| 2235 #undef __ | 2240 #undef __ |
| 2236 | 2241 |
| 2237 #endif // defined TARGET_ARCH_X64 | 2242 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |