| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/constant_propagator.h" | 5 #include "vm/constant_propagator.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
| 9 #include "vm/flow_graph_compiler.h" | 9 #include "vm/flow_graph_compiler.h" |
| 10 #include "vm/flow_graph_range_analysis.h" | 10 #include "vm/flow_graph_range_analysis.h" |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 case Token::kGT: return (result > 0); | 501 case Token::kGT: return (result > 0); |
| 502 case Token::kLTE: return (result <= 0); | 502 case Token::kLTE: return (result <= 0); |
| 503 case Token::kGTE: return (result >= 0); | 503 case Token::kGTE: return (result >= 0); |
| 504 default: | 504 default: |
| 505 UNREACHABLE(); | 505 UNREACHABLE(); |
| 506 return false; | 506 return false; |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 | 509 |
| 510 | 510 |
| 511 // Comparison instruction that is equivalent to the (left & right) == 0 |
| 512 // comparison pattern. |
| 511 void ConstantPropagator::VisitTestSmi(TestSmiInstr* instr) { | 513 void ConstantPropagator::VisitTestSmi(TestSmiInstr* instr) { |
| 512 const Object& left = instr->left()->definition()->constant_value(); | 514 const Object& left = instr->left()->definition()->constant_value(); |
| 513 const Object& right = instr->right()->definition()->constant_value(); | 515 const Object& right = instr->right()->definition()->constant_value(); |
| 514 if (IsNonConstant(left) || IsNonConstant(right)) { | 516 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 515 SetValue(instr, non_constant_); | 517 SetValue(instr, non_constant_); |
| 516 } else if (IsConstant(left) && IsConstant(right)) { | 518 } else if (IsConstant(left) && IsConstant(right)) { |
| 517 if (left.IsInteger() && right.IsInteger()) { | 519 // BitOp does not work on Bigints. |
| 520 if (left.IsInteger() && right.IsInteger() && |
| 521 !left.IsBigint() && !right.IsBigint()) { |
| 518 const bool result = CompareIntegers( | 522 const bool result = CompareIntegers( |
| 519 instr->kind(), | 523 instr->kind(), |
| 520 Integer::Handle(I, Integer::Cast(left).BitOp(Token::kBIT_AND, | 524 Integer::Handle(I, Integer::Cast(left).BitOp(Token::kBIT_AND, |
| 521 Integer::Cast(right))), | 525 Integer::Cast(right))), |
| 522 Smi::Handle(I, Smi::New(0))); | 526 Smi::Handle(I, Smi::New(0))); |
| 523 SetValue(instr, result ? Bool::True() : Bool::False()); | 527 SetValue(instr, result ? Bool::True() : Bool::False()); |
| 524 } else { | 528 } else { |
| 525 SetValue(instr, non_constant_); | 529 SetValue(instr, non_constant_); |
| 526 } | 530 } |
| 527 } | 531 } |
| (...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 graph_->MergeBlocks(); | 1679 graph_->MergeBlocks(); |
| 1676 GrowableArray<BitVector*> dominance_frontier; | 1680 GrowableArray<BitVector*> dominance_frontier; |
| 1677 graph_->ComputeDominators(&dominance_frontier); | 1681 graph_->ComputeDominators(&dominance_frontier); |
| 1678 | 1682 |
| 1679 if (FLAG_trace_constant_propagation) { | 1683 if (FLAG_trace_constant_propagation) { |
| 1680 FlowGraphPrinter::PrintGraph("After CP", graph_); | 1684 FlowGraphPrinter::PrintGraph("After CP", graph_); |
| 1681 } | 1685 } |
| 1682 } | 1686 } |
| 1683 | 1687 |
| 1684 } // namespace dart | 1688 } // namespace dart |
| OLD | NEW |