Chromium Code Reviews| Index: runtime/vm/flow_graph_optimizer.cc |
| =================================================================== |
| --- runtime/vm/flow_graph_optimizer.cc (revision 23800) |
| +++ runtime/vm/flow_graph_optimizer.cc (working copy) |
| @@ -450,35 +450,6 @@ |
| } |
| -void FlowGraphOptimizer::UnboxPhis() { |
| - GrowableArray<PhiInstr*> worklist(5); |
| - |
| - // Convervatively unbox all phis that were proven to be of Double, |
| - // Float32x4, or Uint32x4 type. |
| - for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| - JoinEntryInstr* join_entry = block_order_[i]->AsJoinEntry(); |
| - if (join_entry != NULL) { |
| - for (PhiIterator it(join_entry); !it.Done(); it.Advance()) { |
| - PhiInstr* phi = it.Current(); |
| - if (UnboxPhi(phi)) { |
| - worklist.Add(phi); |
| - } |
| - } |
| - } |
| - } |
| - |
| - while (!worklist.is_empty()) { |
| - PhiInstr* phi = worklist.RemoveLast(); |
| - InsertConversionsFor(phi); |
| - |
| - for (intptr_t i = 0; i < phi->InputCount(); i++) { |
| - ConvertUse(phi->InputAt(i), |
| - phi->InputAt(i)->definition()->representation()); |
| - } |
| - } |
| -} |
| - |
| - |
| void FlowGraphOptimizer::SelectRepresentations() { |
| // Convervatively unbox all phis that were proven to be of Double, |
| // Float32x4, or Uint32x4 type. |
| @@ -4822,6 +4793,7 @@ |
| void ConstantPropagator::OptimizeBranches(FlowGraph* graph) { |
| GrowableArray<BlockEntryInstr*> ignored; |
| ConstantPropagator cp(graph, ignored); |
| + cp.Analyze(); |
| cp.VisitBranches(); |
| cp.Transform(); |
| } |
| @@ -5160,6 +5132,15 @@ |
| const Object& left = instr->left()->definition()->constant_value(); |
| const Object& right = instr->right()->definition()->constant_value(); |
| + if (instr->left()->definition() == instr->right()->definition()) { |
| + // Fold x === x, and x !== x to true/false. |
| + SetValue(instr, |
| + (instr->kind() == Token::kEQ_STRICT) |
| + ? Bool::True() |
| + : Bool::False()); |
| + return; |
| + } |
| + |
| if (IsNonConstant(left) || IsNonConstant(right)) { |
| // TODO(vegorov): incorporate nullability information into the lattice. |
| if ((left.IsNull() && instr->right()->Type()->HasDecidableNullability()) || |
| @@ -5200,6 +5181,23 @@ |
| void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) { |
| const Object& left = instr->left()->definition()->constant_value(); |
| const Object& right = instr->right()->definition()->constant_value(); |
| + |
| + if (instr->left()->definition() == instr->right()->definition()) { |
| + // Fold x == x, and x != x to true/false for numbers and checked strict |
| + // comparisons. |
| + switch (instr->receiver_class_id()) { |
| + default: |
| + if (!instr->is_checked_strict_equal()) break; |
|
Kevin Millikin (Google)
2013/06/12 10:02:44
I have two things to say about this.
1. It is rea
Florian Schneider
2013/06/12 10:11:20
Undone. Using IsNumberCid instead of the switch.
|
| + // Fall through. |
| + case kSmiCid: |
| + case kMintCid: |
| + case kDoubleCid: |
| + SetValue(instr, |
| + (instr->kind() == Token::kEQ) ? Bool::True() : Bool::False()); |
| + return; |
| + } |
| + } |
| + |
| if (IsNonConstant(left) || IsNonConstant(right)) { |
| SetValue(instr, non_constant_); |
| } else if (IsConstant(left) && IsConstant(right)) { |