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

Side by Side Diff: runtime/vm/intermediate_language_ia32.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.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | 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_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 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 __ popl(temp); 1978 __ popl(temp);
1979 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); 1979 __ movsd(XMM0, FieldAddress(temp, Double::value_offset()));
1980 __ DoubleNegate(XMM0); 1980 __ DoubleNegate(XMM0);
1981 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); 1981 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
1982 } else { 1982 } else {
1983 UNREACHABLE(); 1983 UNREACHABLE();
1984 } 1984 }
1985 } 1985 }
1986 1986
1987 1987
1988 LocationSummary* ToDoubleComp::MakeLocationSummary() const { 1988 LocationSummary* DoubleToDoubleComp::MakeLocationSummary() const {
1989 const intptr_t kNumInputs = 1; 1989 const intptr_t kNumInputs = 1;
1990 if (from() == kDoubleCid) { 1990 const intptr_t kNumTemps = 1;
1991 const intptr_t kNumTemps = 1; 1991 LocationSummary* locs =
1992 LocationSummary* locs = 1992 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1993 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 1993 locs->set_in(0, Location::RequiresRegister());
1994 locs->set_in(0, Location::RequiresRegister()); 1994 locs->set_temp(0, Location::RequiresRegister());
1995 locs->set_temp(0, Location::RequiresRegister()); 1995 locs->set_out(Location::SameAsFirstInput());
1996 locs->set_out(Location::SameAsFirstInput()); 1996 return locs;
1997 locs->set_temp(0, Location::RequiresRegister());
1998 return locs;
1999 } else {
2000 ASSERT(from() == kSmiCid);
2001 return MakeCallSummary(); // Calls a stub to allocate result.
2002 }
2003 } 1997 }
2004 1998
2005 1999
2006 void ToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) { 2000 void DoubleToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2007 Register value = (from() == kDoubleCid) ? locs()->in(0).reg() : EBX; 2001 Register value = locs()->in(0).reg();
2008 Register result = locs()->out().reg(); 2002 Register result = locs()->out().reg();
2009 2003
2010 const DeoptReasonId deopt_reason = (from() == kDoubleCid) ?
2011 kDeoptDoubleToDouble : kDeoptIntegerToDouble;
2012 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), 2004 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
2013 instance_call()->try_index(), 2005 instance_call()->try_index(),
2014 deopt_reason, 2006 kDeoptDoubleToDouble,
2015 value); 2007 value);
2008 Register temp = locs()->temp(0).reg();
2009 __ testl(value, Immediate(kSmiTagMask));
2010 __ j(ZERO, deopt); // Deoptimize if Smi.
2011 __ CompareClassId(value, kDoubleCid, temp);
2012 __ j(NOT_EQUAL, deopt); // Deoptimize if not Double.
2013 ASSERT(value == result);
2014 }
2016 2015
2017 if (from() == kDoubleCid) {
2018 Register temp = locs()->temp(0).reg();
2019 __ testl(value, Immediate(kSmiTagMask));
2020 __ j(ZERO, deopt); // Deoptimize if Smi.
2021 __ CompareClassId(value, kDoubleCid, temp);
2022 __ j(NOT_EQUAL, deopt); // Deoptimize if not Double.
2023 ASSERT(value == result);
2024 return;
2025 }
2026 2016
2027 ASSERT(from() == kSmiCid); 2017 LocationSummary* SmiToDoubleComp::MakeLocationSummary() const {
2018 return MakeCallSummary(); // Calls a stub to allocate result.
2019 }
2020
2021
2022 void SmiToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2023 Register result = locs()->out().reg();
2024
2025 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
2026 instance_call()->try_index(),
2027 kDeoptIntegerToDouble);
2028 2028
2029 const Class& double_class = compiler->double_class(); 2029 const Class& double_class = compiler->double_class();
2030 const Code& stub = 2030 const Code& stub =
2031 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); 2031 Code::Handle(StubCode::GetAllocationStubForClass(double_class));
2032 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); 2032 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint());
2033 2033
2034 // TODO(vegorov): allocate box in the driver loop to avoid spilling. 2034 // TODO(vegorov): allocate box in the driver loop to avoid spilling.
2035 compiler->GenerateCall(instance_call()->token_pos(), 2035 compiler->GenerateCall(instance_call()->token_pos(),
2036 instance_call()->try_index(), 2036 instance_call()->try_index(),
2037 &label, 2037 &label,
2038 PcDescriptors::kOther, 2038 PcDescriptors::kOther,
2039 locs()->stack_bitmap()); 2039 locs()->stack_bitmap());
2040 ASSERT(result == EAX); 2040 ASSERT(result == EAX);
2041 __ popl(value); 2041 Register value = EBX;
2042 // Preserve argument on the stack until after the deoptimization point.
2043 __ movl(value, Address(ESP, 0));
2042 2044
2043 __ testl(value, Immediate(kSmiTagMask)); 2045 __ testl(value, Immediate(kSmiTagMask));
2044 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi. 2046 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi.
2045 __ SmiUntag(value); 2047 __ SmiUntag(value);
2046 __ cvtsi2sd(XMM0, value); 2048 __ cvtsi2sd(XMM0, value);
2047 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); 2049 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
2050 __ Drop(1);
2048 } 2051 }
2049 2052
2050 2053
2051 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const { 2054 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const {
2052 return MakeCallSummary(); 2055 return MakeCallSummary();
2053 } 2056 }
2054 2057
2055 2058
2056 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { 2059 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2057 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), 2060 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 locs()->stack_bitmap()); 2228 locs()->stack_bitmap());
2226 __ CompareObject(EAX, compiler->bool_true()); 2229 __ CompareObject(EAX, compiler->bool_true());
2227 EmitBranchOnCondition(compiler, branch_condition); 2230 EmitBranchOnCondition(compiler, branch_condition);
2228 } 2231 }
2229 2232
2230 } // namespace dart 2233 } // namespace dart
2231 2234
2232 #undef __ 2235 #undef __
2233 2236
2234 #endif // defined TARGET_ARCH_X64 2237 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698