@@ -454,15 +454,6 @@ static Condition TokenKindToIntCondition(Token::Kind kind) {
454
454
LocationSummary* EqualityCompareInstr::MakeLocationSummary (Zone* zone,
455
455
bool opt) const {
456
456
const intptr_t kNumInputs = 2 ;
457
- if (operation_cid () == kMintCid ) {
458
- const intptr_t kNumTemps = 0 ;
459
- LocationSummary* locs = new (zone)
460
- LocationSummary (zone, kNumInputs , kNumTemps , LocationSummary::kNoCall );
461
- locs->set_in (0 , Location::RequiresRegister ());
462
- locs->set_in (1 , Location::RequiresRegister ());
463
- locs->set_out (0 , Location::RequiresRegister ());
464
- return locs;
465
- }
466
457
if (operation_cid () == kDoubleCid ) {
467
458
const intptr_t kNumTemps = 0 ;
468
459
LocationSummary* locs = new (zone)
@@ -472,7 +463,7 @@ LocationSummary* EqualityCompareInstr::MakeLocationSummary(Zone* zone,
472
463
locs->set_out (0 , Location::RequiresRegister ());
473
464
return locs;
474
465
}
475
- if (operation_cid () == kSmiCid ) {
466
+ if (operation_cid () == kSmiCid || operation_cid () == kMintCid ) {
476
467
const intptr_t kNumTemps = 0 ;
477
468
LocationSummary* locs = new (zone)
478
469
LocationSummary (zone, kNumInputs , kNumTemps , LocationSummary::kNoCall );
@@ -562,12 +553,26 @@ static Condition EmitInt64ComparisonOp(FlowGraphCompiler* compiler,
562
553
ASSERT (!left.IsConstant () || !right.IsConstant ());
563
554
564
555
Condition true_condition = TokenKindToIntCondition (kind);
556
+ if (left.IsConstant () || right.IsConstant ()) {
557
+ // Ensure constant is on the right.
558
+ ConstantInstr* constant = NULL ;
559
+ if (left.IsConstant ()) {
560
+ constant = left.constant_instruction ();
561
+ Location tmp = right;
562
+ right = left;
563
+ left = tmp;
564
+ true_condition = FlipCondition (true_condition);
565
+ } else {
566
+ constant = right.constant_instruction ();
567
+ }
565
568
566
- if (left.IsConstant ()) {
567
- __ CompareObject (right.reg (), left.constant ());
568
- true_condition = FlipCondition (true_condition);
569
- } else if (right.IsConstant ()) {
570
- __ CompareObject (left.reg (), right.constant ());
569
+ if (constant->IsUnboxedSignedIntegerConstant ()) {
570
+ __ cmpq (left.reg (),
571
+ Immediate (constant->GetUnboxedSignedIntegerConstantValue ()));
572
+ } else {
573
+ ASSERT (constant->representation () == kTagged );
574
+ __ CompareObject (left.reg (), right.constant ());
575
+ }
571
576
} else if (right.IsStackSlot ()) {
572
577
__ cmpq (left.reg (), right.ToStackSlotAddress ());
573
578
} else {
@@ -741,30 +746,26 @@ LocationSummary* RelationalOpInstr::MakeLocationSummary(Zone* zone,
741
746
summary->set_in (1 , Location::RequiresFpuRegister ());
742
747
summary->set_out (0 , Location::RequiresRegister ());
743
748
return summary;
744
- } else if (operation_cid () == kMintCid ) {
749
+ }
750
+ if (operation_cid () == kSmiCid || operation_cid () == kMintCid ) {
745
751
LocationSummary* summary = new (zone)
746
752
LocationSummary (zone, kNumInputs , kNumTemps , LocationSummary::kNoCall );
747
- summary->set_in (0 , Location::RequiresRegister ());
748
- summary->set_in (1 , Location::RequiresRegister ());
753
+ summary->set_in (0 , Location::RegisterOrConstant (left ()));
754
+ // Only one input can be a constant operand. The case of two constant
755
+ // operands should be handled by constant propagation.
756
+ summary->set_in (1 , summary->in (0 ).IsConstant ()
757
+ ? Location::RequiresRegister ()
758
+ : Location::RegisterOrConstant (right ()));
749
759
summary->set_out (0 , Location::RequiresRegister ());
750
760
return summary;
751
761
}
752
- ASSERT (operation_cid () == kSmiCid );
753
- LocationSummary* summary = new (zone)
754
- LocationSummary (zone, kNumInputs , kNumTemps , LocationSummary::kNoCall );
755
- summary->set_in (0 , Location::RegisterOrConstant (left ()));
756
- // Only one input can be a constant operand. The case of two constant
757
- // operands should be handled by constant propagation.
758
- summary->set_in (1 , summary->in (0 ).IsConstant ()
759
- ? Location::RequiresRegister ()
760
- : Location::RegisterOrConstant (right ()));
761
- summary->set_out (0 , Location::RequiresRegister ());
762
- return summary;
762
+ UNREACHABLE ();
763
+ return NULL ;
763
764
}
764
765
765
766
Condition RelationalOpInstr::EmitComparisonCode (FlowGraphCompiler* compiler,
766
767
BranchLabels labels) {
767
- if (( operation_cid () == kSmiCid ) || ( operation_cid () == kMintCid ) ) {
768
+ if (operation_cid () == kSmiCid || operation_cid () == kMintCid ) {
768
769
return EmitInt64ComparisonOp (compiler, *locs (), kind ());
769
770
} else {
770
771
ASSERT (operation_cid () == kDoubleCid );
@@ -5158,24 +5159,30 @@ LocationSummary* BinaryInt64OpInstr::MakeLocationSummary(Zone* zone,
5158
5159
LocationSummary* summary = new (zone)
5159
5160
LocationSummary (zone, kNumInputs , kNumTemps , LocationSummary::kNoCall );
5160
5161
summary->set_in (0 , Location::RequiresRegister ());
5161
- summary->set_in (1 , Location::RequiresRegister ( ));
5162
+ summary->set_in (1 , Location::RegisterOrConstant ( right () ));
5162
5163
summary->set_out (0 , Location::SameAsFirstInput ());
5163
5164
return summary;
5164
5165
}
5165
5166
5166
5167
void BinaryInt64OpInstr::EmitNativeCode (FlowGraphCompiler* compiler) {
5167
- const Register left = locs ()->in (0 ).reg ();
5168
- const Register right = locs ()->in (1 ).reg ();
5169
- const Register out = locs ()->out (0 ).reg ();
5170
-
5171
- ASSERT (out == left);
5172
-
5173
5168
Label* deopt = NULL ;
5174
5169
if (CanDeoptimize ()) {
5175
5170
deopt = compiler->AddDeoptStub (deopt_id (), ICData::kDeoptBinaryInt64Op );
5176
5171
}
5172
+ const Location left = locs ()->in (0 );
5173
+ const Location right = locs ()->in (1 );
5174
+ const Location out = locs ()->out (0 );
5175
+ ASSERT (out.reg () == left.reg ());
5177
5176
5178
- EmitInt64Arithmetic (compiler, op_kind (), left, right, deopt);
5177
+ if (right.IsConstant ()) {
5178
+ ConstantInstr* constant_instr = right.constant_instruction ();
5179
+ const int64_t value =
5180
+ constant_instr->GetUnboxedSignedIntegerConstantValue ();
5181
+ EmitInt64Arithmetic (compiler, op_kind (), left.reg (), Immediate (value),
5182
+ deopt);
5183
+ } else {
5184
+ EmitInt64Arithmetic (compiler, op_kind (), left.reg (), right.reg (), deopt);
5185
+ }
5179
5186
}
5180
5187
5181
5188
LocationSummary* UnaryInt64OpInstr::MakeLocationSummary (Zone* zone,
0 commit comments