Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 10834311: Split ToDouble into two IL instruction to make it work with SSA. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: rebased... Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 __ popq(temp); 1987 __ popq(temp);
1988 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); 1988 __ movsd(XMM0, FieldAddress(temp, Double::value_offset()));
1989 __ DoubleNegate(XMM0); 1989 __ DoubleNegate(XMM0);
1990 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); 1990 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
1991 } else { 1991 } else {
1992 UNREACHABLE(); 1992 UNREACHABLE();
1993 } 1993 }
1994 } 1994 }
1995 1995
1996 1996
1997 LocationSummary* ToDoubleComp::MakeLocationSummary() const { 1997 LocationSummary* DoubleToDoubleComp::MakeLocationSummary() const {
1998 const intptr_t kNumInputs = 1; 1998 const intptr_t kNumInputs = 1;
1999 if (from() == kDoubleCid) { 1999 const intptr_t kNumTemps = 0;
2000 const intptr_t kNumTemps = 0; 2000 LocationSummary* locs =
2001 LocationSummary* locs = 2001 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
2002 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 2002 locs->set_in(0, Location::RequiresRegister());
2003 locs->set_in(0, Location::RequiresRegister()); 2003 locs->set_out(Location::SameAsFirstInput());
2004 locs->set_out(Location::SameAsFirstInput()); 2004 return locs;
2005 return locs;
2006 } else {
2007 ASSERT(from() == kSmiCid);
2008 return MakeCallSummary(); // Calls a stub to allocate result.
2009 }
2010 } 2005 }
2011 2006
2012 2007
2013 void ToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) { 2008 void DoubleToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2014 Register value = (from() == kDoubleCid) ? locs()->in(0).reg() : RBX; 2009 Register value = locs()->in(0).reg();
2015 Register result = locs()->out().reg(); 2010 Register result = locs()->out().reg();
2016 2011
2017 const DeoptReasonId deopt_reason = (from() == kDoubleCid) ?
2018 kDeoptDoubleToDouble : kDeoptIntegerToDouble;
2019 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), 2012 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
2020 instance_call()->try_index(), 2013 instance_call()->try_index(),
2021 deopt_reason, 2014 kDeoptDoubleToDouble,
2022 value); 2015 value);
2023 2016
2024 if (from() == kDoubleCid) { 2017 __ testq(value, Immediate(kSmiTagMask));
2025 __ testq(value, Immediate(kSmiTagMask)); 2018 __ j(ZERO, deopt); // Deoptimize if Smi.
2026 __ j(ZERO, deopt); // Deoptimize if Smi. 2019 __ CompareClassId(value, kDoubleCid);
2027 __ CompareClassId(value, kDoubleCid); 2020 __ j(NOT_EQUAL, deopt); // Deoptimize if not Double.
2028 __ j(NOT_EQUAL, deopt); // Deoptimize if not Double. 2021 ASSERT(value == result);
2029 ASSERT(value == result); 2022 }
2030 return;
2031 }
2032 2023
2033 ASSERT(from() == kSmiCid); 2024
2025 LocationSummary* SmiToDoubleComp::MakeLocationSummary() const {
2026 return MakeCallSummary(); // Calls a stub to allocate result.
2027 }
2028
2029
2030 void SmiToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2031 Register result = locs()->out().reg();
2032
2033 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
2034 instance_call()->try_index(),
2035 kDeoptIntegerToDouble);
2034 2036
2035 const Class& double_class = compiler->double_class(); 2037 const Class& double_class = compiler->double_class();
2036 const Code& stub = 2038 const Code& stub =
2037 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); 2039 Code::Handle(StubCode::GetAllocationStubForClass(double_class));
2038 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); 2040 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint());
2039 2041
2040 // TODO(vegorov): allocate box in the driver loop to avoid spilling. 2042 // TODO(fschneider): Inline new-space allocation and move the call into
2043 // deferred code.
2041 compiler->GenerateCall(instance_call()->token_pos(), 2044 compiler->GenerateCall(instance_call()->token_pos(),
2042 instance_call()->try_index(), 2045 instance_call()->try_index(),
2043 &label, 2046 &label,
2044 PcDescriptors::kOther, 2047 PcDescriptors::kOther,
2045 locs()->stack_bitmap()); 2048 locs()->stack_bitmap());
2046 ASSERT(result == RAX); 2049 ASSERT(result == RAX);
2047 __ popq(value); 2050 Register value = RBX;
2051 // Preserve argument on the stack until after the deoptimization point.
2052 __ movq(value, Address(RSP, 0));
2048 2053
2049 __ testq(value, Immediate(kSmiTagMask)); 2054 __ testq(value, Immediate(kSmiTagMask));
2050 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi. 2055 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi.
2051 __ SmiUntag(value); 2056 __ SmiUntag(value);
2052 __ cvtsi2sd(XMM0, value); 2057 __ cvtsi2sd(XMM0, value);
2053 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); 2058 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
2059 __ Drop(1);
2054 } 2060 }
2055 2061
2056 2062
2057 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const { 2063 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const {
2058 return MakeCallSummary(); 2064 return MakeCallSummary();
2059 } 2065 }
2060 2066
2061 2067
2062 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { 2068 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2063 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), 2069 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 locs()->stack_bitmap()); 2236 locs()->stack_bitmap());
2231 __ CompareObject(RAX, compiler->bool_true()); 2237 __ CompareObject(RAX, compiler->bool_true());
2232 EmitBranchOnCondition(compiler, branch_condition); 2238 EmitBranchOnCondition(compiler, branch_condition);
2233 } 2239 }
2234 2240
2235 } // namespace dart 2241 } // namespace dart
2236 2242
2237 #undef __ 2243 #undef __
2238 2244
2239 #endif // defined TARGET_ARCH_X64 2245 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698