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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: vm/intermediate_language_ia32.cc
===================================================================
--- vm/intermediate_language_ia32.cc (revision 10648)
+++ vm/intermediate_language_ia32.cc (working copy)
@@ -1983,47 +1983,48 @@
}
-LocationSummary* ToDoubleComp::MakeLocationSummary() const {
+LocationSummary* DoubleToDoubleComp::MakeLocationSummary() const {
const intptr_t kNumInputs = 1;
- if (from() == kDoubleCid) {
- const intptr_t kNumTemps = 1;
- LocationSummary* locs =
- new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
- locs->set_in(0, Location::RequiresRegister());
- locs->set_temp(0, Location::RequiresRegister());
- locs->set_out(Location::SameAsFirstInput());
- locs->set_temp(0, Location::RequiresRegister());
- return locs;
- } else {
- ASSERT(from() == kSmiCid);
- return MakeCallSummary(); // Calls a stub to allocate result.
- }
+ const intptr_t kNumTemps = 1;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RequiresRegister());
+ locs->set_temp(0, Location::RequiresRegister());
+ locs->set_out(Location::SameAsFirstInput());
+ 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.
+ return locs;
}
-void ToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
- Register value = (from() == kDoubleCid) ? locs()->in(0).reg() : EBX;
+void DoubleToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
+ Register value = locs()->in(0).reg();
Register result = locs()->out().reg();
- const DeoptReasonId deopt_reason = (from() == kDoubleCid) ?
- kDeoptDoubleToDouble : kDeoptIntegerToDouble;
Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
instance_call()->try_index(),
- deopt_reason,
+ kDeoptDoubleToDouble,
value);
+ Register temp = locs()->temp(0).reg();
+ __ testl(value, Immediate(kSmiTagMask));
+ __ j(ZERO, deopt); // Deoptimize if Smi.
+ __ CompareClassId(value, kDoubleCid, temp);
+ __ j(NOT_EQUAL, deopt); // Deoptimize if not Double.
+ ASSERT(value == result);
+}
- if (from() == kDoubleCid) {
- Register temp = locs()->temp(0).reg();
- __ testl(value, Immediate(kSmiTagMask));
- __ j(ZERO, deopt); // Deoptimize if Smi.
- __ CompareClassId(value, kDoubleCid, temp);
- __ j(NOT_EQUAL, deopt); // Deoptimize if not Double.
- ASSERT(value == result);
- return;
- }
- ASSERT(from() == kSmiCid);
+LocationSummary* SmiToDoubleComp::MakeLocationSummary() const {
+ return MakeCallSummary(); // Calls a stub to allocate result.
+}
+
+void SmiToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
+ Register result = locs()->out().reg();
+
+ Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
+ instance_call()->try_index(),
+ kDeoptIntegerToDouble);
+
const Class& double_class = compiler->double_class();
const Code& stub =
Code::Handle(StubCode::GetAllocationStubForClass(double_class));
@@ -2036,13 +2037,15 @@
PcDescriptors::kOther,
locs()->stack_bitmap());
ASSERT(result == EAX);
- __ popl(value);
+ 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
+ __ 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
__ testl(value, Immediate(kSmiTagMask));
__ j(NOT_ZERO, deopt); // Deoptimize if not Smi.
__ SmiUntag(value);
__ cvtsi2sd(XMM0, value);
__ movsd(FieldAddress(result, Double::value_offset()), XMM0);
+ __ Drop(1);
}

Powered by Google App Engine
This is Rietveld 408576698