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

Unified Diff: runtime/vm/intermediate_language_x64.cc

Issue 10541135: Some cleanups, started implementing checked instance calls, better equality operation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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: runtime/vm/intermediate_language_x64.cc
===================================================================
--- runtime/vm/intermediate_language_x64.cc (revision 8588)
+++ runtime/vm/intermediate_language_x64.cc (working copy)
@@ -192,22 +192,102 @@
LocationSummary* EqualityCompareComp::MakeLocationSummary() const {
- LocationSummary* locs = new LocationSummary(2, 0);
- locs->set_in(0, Location::RequiresRegister());
- locs->set_in(1, Location::RequiresRegister());
- locs->set_out(Location::RegisterLocation(RAX));
- return locs;
+ const intptr_t kNumInputs = 2;
+ if (operands_class_id() == kSmi) {
+ const intptr_t kNumTemps = 1;
+ LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps);
+ locs->set_in(0, Location::RequiresRegister());
+ locs->set_in(1, Location::RequiresRegister());
+ locs->set_temp(0, Location::RequiresRegister());
+ locs->set_out(Location::RequiresRegister());
+ return locs;
+ } else {
+ const intptr_t kNumTemps = 0;
+ LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps);
+ locs->set_in(0, Location::RequiresRegister());
+ locs->set_in(1, Location::RequiresRegister());
+ locs->set_out(Location::RegisterLocation(RAX));
+ return locs;
+ }
}
void EqualityCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) {
+ const Bool& bool_true = Bool::ZoneHandle(Bool::True());
+ const Bool& bool_false = Bool::ZoneHandle(Bool::False());
+ if (operands_class_id() == kObject) {
+ Register left = locs()->in(0).reg();
+ Register right = locs()->in(1).reg();
+ Register result = locs()->out().reg();
+ const Immediate raw_null =
+ Immediate(reinterpret_cast<intptr_t>(Object::null()));
+ // Inline null comparison.
+ __ cmpq(left, raw_null);
+ Label not_null, done, is_true;
+ __ j(NOT_EQUAL, &not_null, Assembler::kNearJump);
+ __ cmpq(left, right);
+ __ j(EQUAL, &is_true, Assembler::kNearJump);
+ __ LoadObject(result, bool_false);
+ __ jmp(&done, Assembler::kNearJump);
+ __ Bind(&is_true);
+ __ LoadObject(result, bool_true);
+ __ jmp(&done, Assembler::kNearJump);
+
+ __ Bind(&not_null);
+ __ pushq(left);
+ __ pushq(right);
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
+ cid(),
+ token_index(),
+ try_index());
+ const String& operator_name = String::ZoneHandle(String::NewSymbol("=="));
+ const int kNumberOfArguments = 2;
+ const Array& kNoArgumentNames = Array::Handle();
+ const int kNumArgumentsChecked = 2;
+
+ compiler->GenerateInstanceCall(cid(),
+ token_index(),
+ try_index(),
+ operator_name,
+ kNumberOfArguments,
+ kNoArgumentNames,
+ kNumArgumentsChecked);
+ ASSERT(locs()->out().reg() == RAX);
+ __ Bind(&done);
+ return;
+ }
+ if (operands_class_id() == kSmi) {
+ // TODO(srdjan): Should we always include NULL test (common case)?
+ Register left = locs()->in(0).reg();
+ Register right = locs()->in(1).reg();
+ Register result = locs()->out().reg();
+ Register temp = locs()->temp(0).reg();
+ Label* deopt = compiler->AddDeoptStub(cid(),
+ token_index(),
+ try_index(),
+ kDeoptSmiCompareSmis,
+ left,
+ right);
+ __ movq(temp, left);
+ __ orq(temp, right);
+ __ testq(temp, Immediate(kSmiTagMask));
+ __ j(NOT_ZERO, deopt);
+ __ cmpq(left, right);
+ Label load_true, done;
+ __ j(EQUAL, &load_true, Assembler::kNearJump);
+ __ LoadObject(result, bool_false);
+ __ jmp(&done, Assembler::kNearJump);
+ __ Bind(&load_true);
+ __ LoadObject(result, bool_true);
+ __ Bind(&done);
+ return;
+ }
+ UNIMPLEMENTED();
Register left = locs()->in(0).reg();
Vyacheslav Egorov (Google) 2012/06/13 09:02:27 Please remove dead code.
srdjan 2012/06/13 18:34:24 Done.
Register right = locs()->in(1).reg();
Register result = locs()->out().reg();
ASSERT(locs()->out().reg() == RAX);
- const Bool& bool_true = Bool::ZoneHandle(Bool::True());
- const Bool& bool_false = Bool::ZoneHandle(Bool::False());
const Immediate raw_null =
Immediate(reinterpret_cast<intptr_t>(Object::null()));
Label done, load_true, non_null_compare;
« runtime/vm/intermediate_language_ia32.cc ('K') | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698