Chromium Code Reviews| Index: runtime/vm/intermediate_language_ia32.cc |
| diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc |
| index 7401558616be9b06feec9e589c368dd6798a0b75..84bce10f4eaa0fdc8a7b0caf9cc620150804dda3 100644 |
| --- a/runtime/vm/intermediate_language_ia32.cc |
| +++ b/runtime/vm/intermediate_language_ia32.cc |
| @@ -271,7 +271,16 @@ LocationSummary* EqualityCompareInstr::MakeLocationSummary() const { |
| locs->set_out(Location::RequiresRegister()); |
| return locs; |
| } |
| - if ((receiver_class_id() == kSmiCid) || is_checked_strict_equal) { |
| + if (receiver_class_id() == kSmiCid) { |
| + const intptr_t kNumTemps = 0; |
| + LocationSummary* locs = |
| + new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| + locs->set_in(0, Location::RegisterOrConstant(left())); |
| + locs->set_in(1, Location::RegisterOrConstant(right())); |
| + locs->set_out(Location::RequiresRegister()); |
| + return locs; |
| + } |
| + if (is_checked_strict_equal) { |
| const intptr_t kNumTemps = 1; |
| LocationSummary* locs = |
| new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| @@ -552,15 +561,46 @@ static void EmitGenericEqualityCompare(FlowGraphCompiler* compiler, |
| } |
| +Immediate SmiConstantToImmediate(const Object& constant) { |
| + ASSERT(constant.IsSmi()); |
| + return Immediate(reinterpret_cast<int32_t>(constant.raw())); |
| +} |
| + |
| + |
| static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, |
| const LocationSummary& locs, |
| Token::Kind kind, |
| BranchInstr* branch) { |
| - Register left = locs.in(0).reg(); |
| - Register right = locs.in(1).reg(); |
| + Location left = locs.in(0); |
| + Location right = locs.in(1); |
| Condition true_condition = TokenKindToSmiCondition(kind); |
| - __ cmpl(left, right); |
| + |
| + if (left.IsConstant() && right.IsConstant()) { |
| + // TODO(vegorov): should be eliminated earlier by constant propagation. |
| + const bool result = FlowGraphCompiler::EvaluateCondition( |
| + true_condition, |
| + Smi::Cast(left.constant()).Value(), |
| + Smi::Cast(right.constant()).Value()); |
| + |
| + if (branch != NULL) { |
| + branch->EmitBranchOnValue(compiler, result); |
| + } else { |
| + __ LoadObject(locs.out().reg(), result ? compiler->bool_true() |
| + : compiler->bool_false()); |
| + } |
| + |
|
Florian Schneider
2012/09/06 13:17:30
Remove new line here?
Vyacheslav Egorov (Google)
2012/09/06 13:24:44
It makes code easier to read.
|
| + return; |
| + } |
| + |
| + if (left.IsConstant()) { |
| + __ cmpl(right.reg(), SmiConstantToImmediate(left.constant())); |
|
srdjan
2012/09/06 13:32:55
I wonder if we should add assembly instruction tha
|
| + true_condition = FlowGraphCompiler::FlipCondition(true_condition); |
| + } else if (right.IsConstant()) { |
| + __ cmpl(left.reg(), SmiConstantToImmediate(right.constant())); |
| + } else { |
| + __ cmpl(left.reg(), right.reg()); |
| + } |
| if (branch != NULL) { |
| branch->EmitBranchOnCondition(compiler, true_condition); |
| @@ -684,8 +724,8 @@ void EqualityCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
| LocationSummary* RelationalOpInstr::MakeLocationSummary() const { |
| const intptr_t kNumInputs = 2; |
| + const intptr_t kNumTemps = 0; |
| if (operands_class_id() == kDoubleCid) { |
| - const intptr_t kNumTemps = 0; |
| LocationSummary* summary = |
| new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| summary->set_in(0, Location::RequiresXmmRegister()); |
| @@ -693,16 +733,13 @@ LocationSummary* RelationalOpInstr::MakeLocationSummary() const { |
| summary->set_out(Location::RequiresRegister()); |
| return summary; |
| } else if (operands_class_id() == kSmiCid) { |
| - const intptr_t kNumTemps = 1; |
| LocationSummary* summary = |
| new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| - summary->set_in(0, Location::RequiresRegister()); |
| - summary->set_in(1, Location::RequiresRegister()); |
| + summary->set_in(0, Location::RegisterOrConstant(left())); |
| + summary->set_in(1, Location::RegisterOrConstant(right())); |
| summary->set_out(Location::RequiresRegister()); |
| - summary->set_temp(0, Location::RequiresRegister()); |
| return summary; |
| } |
| - const intptr_t kNumTemps = 0; |
| LocationSummary* locs = |
| new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| // Pick arbitrary fixed input registers because this is a call. |