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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_ia32.cc
===================================================================
--- runtime/vm/intermediate_language_ia32.cc (revision 10708)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -1985,47 +1985,47 @@
}
-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());
+ 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));
@@ -2038,13 +2038,16 @@
PcDescriptors::kOther,
locs()->stack_bitmap());
ASSERT(result == EAX);
- __ popl(value);
+ Register value = EBX;
+ // Preserve argument on the stack until after the deoptimization point.
+ __ movl(value, Address(ESP, 0));
__ 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);
}
« 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