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

Side by Side Diff: 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: 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
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 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 __ popl(temp); 1976 __ popl(temp);
1977 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); 1977 __ movsd(XMM0, FieldAddress(temp, Double::value_offset()));
1978 __ DoubleNegate(XMM0); 1978 __ DoubleNegate(XMM0);
1979 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); 1979 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
1980 } else { 1980 } else {
1981 UNREACHABLE(); 1981 UNREACHABLE();
1982 } 1982 }
1983 } 1983 }
1984 1984
1985 1985
1986 LocationSummary* ToDoubleComp::MakeLocationSummary() const { 1986 LocationSummary* DoubleToDoubleComp::MakeLocationSummary() const {
1987 const intptr_t kNumInputs = 1; 1987 const intptr_t kNumInputs = 1;
1988 if (from() == kDoubleCid) { 1988 const intptr_t kNumTemps = 1;
1989 const intptr_t kNumTemps = 1; 1989 LocationSummary* locs =
1990 LocationSummary* locs = 1990 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
1991 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 1991 locs->set_in(0, Location::RequiresRegister());
1992 locs->set_in(0, Location::RequiresRegister()); 1992 locs->set_temp(0, Location::RequiresRegister());
1993 locs->set_temp(0, Location::RequiresRegister()); 1993 locs->set_out(Location::SameAsFirstInput());
1994 locs->set_out(Location::SameAsFirstInput()); 1994 locs->set_temp(0, Location::RequiresRegister());
srdjan 2012/08/14 21:21:26 Remove both set_temp(0, ...), kNumTemps = 0.
Florian Schneider 2012/08/15 10:27:23 ia32 needs a temp register for the CompareClassId.
1995 locs->set_temp(0, Location::RequiresRegister()); 1995 return locs;
1996 return locs;
1997 } else {
1998 ASSERT(from() == kSmiCid);
1999 return MakeCallSummary(); // Calls a stub to allocate result.
2000 }
2001 } 1996 }
2002 1997
2003 1998
2004 void ToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1999 void DoubleToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2005 Register value = (from() == kDoubleCid) ? locs()->in(0).reg() : EBX; 2000 Register value = locs()->in(0).reg();
2006 Register result = locs()->out().reg(); 2001 Register result = locs()->out().reg();
2007 2002
2008 const DeoptReasonId deopt_reason = (from() == kDoubleCid) ?
2009 kDeoptDoubleToDouble : kDeoptIntegerToDouble;
2010 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), 2003 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
2011 instance_call()->try_index(), 2004 instance_call()->try_index(),
2012 deopt_reason, 2005 kDeoptDoubleToDouble,
2013 value); 2006 value);
2007 Register temp = locs()->temp(0).reg();
2008 __ testl(value, Immediate(kSmiTagMask));
2009 __ j(ZERO, deopt); // Deoptimize if Smi.
2010 __ CompareClassId(value, kDoubleCid, temp);
2011 __ j(NOT_EQUAL, deopt); // Deoptimize if not Double.
2012 ASSERT(value == result);
2013 }
2014 2014
2015 if (from() == kDoubleCid) {
2016 Register temp = locs()->temp(0).reg();
2017 __ testl(value, Immediate(kSmiTagMask));
2018 __ j(ZERO, deopt); // Deoptimize if Smi.
2019 __ CompareClassId(value, kDoubleCid, temp);
2020 __ j(NOT_EQUAL, deopt); // Deoptimize if not Double.
2021 ASSERT(value == result);
2022 return;
2023 }
2024 2015
2025 ASSERT(from() == kSmiCid); 2016 LocationSummary* SmiToDoubleComp::MakeLocationSummary() const {
2017 return MakeCallSummary(); // Calls a stub to allocate result.
2018 }
2019
2020
2021 void SmiToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2022 Register result = locs()->out().reg();
2023
2024 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
2025 instance_call()->try_index(),
2026 kDeoptIntegerToDouble);
2026 2027
2027 const Class& double_class = compiler->double_class(); 2028 const Class& double_class = compiler->double_class();
2028 const Code& stub = 2029 const Code& stub =
2029 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); 2030 Code::Handle(StubCode::GetAllocationStubForClass(double_class));
2030 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); 2031 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint());
2031 2032
2032 // TODO(vegorov): allocate box in the driver loop to avoid spilling. 2033 // TODO(vegorov): allocate box in the driver loop to avoid spilling.
2033 compiler->GenerateCall(instance_call()->token_pos(), 2034 compiler->GenerateCall(instance_call()->token_pos(),
2034 instance_call()->try_index(), 2035 instance_call()->try_index(),
2035 &label, 2036 &label,
2036 PcDescriptors::kOther, 2037 PcDescriptors::kOther,
2037 locs()->stack_bitmap()); 2038 locs()->stack_bitmap());
2038 ASSERT(result == EAX); 2039 ASSERT(result == EAX);
2039 __ popl(value); 2040 Register value = EBX;
srdjan 2012/08/14 21:21:26 Allocate temp for EBX and use it here.
Florian Schneider 2012/08/15 10:27:23 Since this instruction is a call, we can freely us
2041 __ movl(value, Address(ESP, 0));
srdjan 2012/08/14 21:21:26 Why not popl(value) and add value to AddDeoptStub?
Florian Schneider 2012/08/15 10:27:23 This is because of a subtle problem with deoptimia
2040 2042
2041 __ testl(value, Immediate(kSmiTagMask)); 2043 __ testl(value, Immediate(kSmiTagMask));
2042 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi. 2044 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi.
2043 __ SmiUntag(value); 2045 __ SmiUntag(value);
2044 __ cvtsi2sd(XMM0, value); 2046 __ cvtsi2sd(XMM0, value);
2045 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); 2047 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
2048 __ Drop(1);
2046 } 2049 }
2047 2050
2048 2051
2049 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const { 2052 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const {
2050 return MakeCallSummary(); 2053 return MakeCallSummary();
2051 } 2054 }
2052 2055
2053 2056
2054 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { 2057 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2055 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), 2058 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 locs()->stack_bitmap()); 2226 locs()->stack_bitmap());
2224 __ CompareObject(EAX, compiler->bool_true()); 2227 __ CompareObject(EAX, compiler->bool_true());
2225 EmitBranchOnCondition(compiler, branch_condition); 2228 EmitBranchOnCondition(compiler, branch_condition);
2226 } 2229 }
2227 2230
2228 } // namespace dart 2231 } // namespace dart
2229 2232
2230 #undef __ 2233 #undef __
2231 2234
2232 #endif // defined TARGET_ARCH_X64 2235 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698