| 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);
|
| }
|
|
|
|
|
|
|