Chromium Code Reviews| 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, ¬_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(¬_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; |