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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 11098009: Implement SmiToInt and DoubleToInt. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 13429)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -1985,7 +1985,7 @@
const Class& double_class = compiler->double_class();
const Code& stub =
- Code::Handle(StubCode::GetAllocationStubForClass(double_class));
+ 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.
@@ -2007,6 +2007,51 @@
}
+LocationSummary* DoubleToIntegerInstr::MakeLocationSummary() const {
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* result =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
+ result->set_in(0, Location::RegisterLocation(ECX));
+ result->set_out(Location::RegisterLocation(EAX));
+ return result;
+}
+
+
+void DoubleToIntegerInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ Register result = locs()->out().reg();
+ Register value_obj = locs()->in(0).reg();
+ XmmRegister value_double = XMM0;
+ ASSERT(result == EAX);
+ ASSERT(result != value_obj);
+ __ movsd(value_double, FieldAddress(value_obj, Double::value_offset()));
+ __ cvttsd2si(result, value_double);
+ // Overflow is signalled with minint.
+ Label do_call, done;
+ // Check for overflow and that it fits into Smi.
+ __ cmpl(result, Immediate(0xC0000000));
+ __ j(NEGATIVE, &do_call, Assembler::kNearJump);
+ __ SmiTag(result);
+ __ jmp(&done);
+ __ Bind(&do_call);
+ __ pushl(value_obj);
+ ASSERT(instance_call()->HasICData());
+ const ICData& ic_data = *instance_call()->ic_data();
+ ASSERT((ic_data.NumberOfChecks() == 1));
+ const Function& target = Function::ZoneHandle(ic_data.GetTargetAt(0));
+
+ const intptr_t kNumberOfArguments = 1;
+ compiler->GenerateStaticCall(instance_call()->deopt_id(),
+ instance_call()->token_pos(),
+ target,
+ kNumberOfArguments,
+ Array::Handle(), // No argument names.,
+ locs());
+ __ Drop(1);
+ __ Bind(&done);
+}
+
+
LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const {
return MakeCallSummary();
}
« 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