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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_x64.cc
===================================================================
--- runtime/vm/intermediate_language_x64.cc (revision 10708)
+++ runtime/vm/intermediate_language_x64.cc (working copy)
@@ -1994,63 +1994,69 @@
}
-LocationSummary* ToDoubleComp::MakeLocationSummary() const {
+LocationSummary* DoubleToDoubleComp::MakeLocationSummary() const {
const intptr_t kNumInputs = 1;
- if (from() == kDoubleCid) {
- const intptr_t kNumTemps = 0;
- LocationSummary* locs =
- new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
- locs->set_in(0, Location::RequiresRegister());
- locs->set_out(Location::SameAsFirstInput());
- return locs;
- } else {
- ASSERT(from() == kSmiCid);
- return MakeCallSummary(); // Calls a stub to allocate result.
- }
+ const intptr_t kNumTemps = 0;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RequiresRegister());
+ locs->set_out(Location::SameAsFirstInput());
+ return locs;
}
-void ToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
- Register value = (from() == kDoubleCid) ? locs()->in(0).reg() : RBX;
+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);
- if (from() == kDoubleCid) {
- __ testq(value, Immediate(kSmiTagMask));
- __ j(ZERO, deopt); // Deoptimize if Smi.
- __ CompareClassId(value, kDoubleCid);
- __ j(NOT_EQUAL, deopt); // Deoptimize if not Double.
- ASSERT(value == result);
- return;
- }
+ __ testq(value, Immediate(kSmiTagMask));
+ __ j(ZERO, deopt); // Deoptimize if Smi.
+ __ CompareClassId(value, kDoubleCid);
+ __ j(NOT_EQUAL, deopt); // Deoptimize if not Double.
+ ASSERT(value == result);
+}
- 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));
const ExternalLabel label(double_class.ToCString(), stub.EntryPoint());
- // TODO(vegorov): allocate box in the driver loop to avoid spilling.
+ // TODO(fschneider): Inline new-space allocation and move the call into
+ // deferred code.
compiler->GenerateCall(instance_call()->token_pos(),
instance_call()->try_index(),
&label,
PcDescriptors::kOther,
locs()->stack_bitmap());
ASSERT(result == RAX);
- __ popq(value);
+ Register value = RBX;
+ // Preserve argument on the stack until after the deoptimization point.
+ __ movq(value, Address(RSP, 0));
__ testq(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_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698