| 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/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 // Insert two smi checks and attach a copy of the original | 968 // Insert two smi checks and attach a copy of the original |
| 969 // environment because the smi operation can still deoptimize. | 969 // environment because the smi operation can still deoptimize. |
| 970 InsertBefore(call, | 970 InsertBefore(call, |
| 971 new CheckSmiInstr(left->Copy(), call->deopt_id()), | 971 new CheckSmiInstr(left->Copy(), call->deopt_id()), |
| 972 call->env(), | 972 call->env(), |
| 973 Definition::kEffect); | 973 Definition::kEffect); |
| 974 InsertBefore(call, | 974 InsertBefore(call, |
| 975 new CheckSmiInstr(right->Copy(), call->deopt_id()), | 975 new CheckSmiInstr(right->Copy(), call->deopt_id()), |
| 976 call->env(), | 976 call->env(), |
| 977 Definition::kEffect); | 977 Definition::kEffect); |
| 978 if (left->BindsToConstant() && |
| 979 ((op_kind == Token::kADD) || (op_kind == Token::kMUL))) { |
| 980 // Constant should be on the right side. |
| 981 Value* temp = left; |
| 982 left = right; |
| 983 right = temp; |
| 984 } |
| 978 BinarySmiOpInstr* bin_op = new BinarySmiOpInstr(op_kind, call, left, right); | 985 BinarySmiOpInstr* bin_op = new BinarySmiOpInstr(op_kind, call, left, right); |
| 979 call->ReplaceWith(bin_op, current_iterator()); | 986 call->ReplaceWith(bin_op, current_iterator()); |
| 980 RemovePushArguments(call); | 987 RemovePushArguments(call); |
| 981 } | 988 } |
| 982 return true; | 989 return true; |
| 983 } | 990 } |
| 984 | 991 |
| 985 | 992 |
| 986 bool FlowGraphOptimizer::TryReplaceWithUnaryOp(InstanceCallInstr* call, | 993 bool FlowGraphOptimizer::TryReplaceWithUnaryOp(InstanceCallInstr* call, |
| 987 Token::Kind op_kind) { | 994 Token::Kind op_kind) { |
| (...skipping 3620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4608 | 4615 |
| 4609 if (FLAG_trace_constant_propagation) { | 4616 if (FLAG_trace_constant_propagation) { |
| 4610 OS::Print("\n==== After constant propagation ====\n"); | 4617 OS::Print("\n==== After constant propagation ====\n"); |
| 4611 FlowGraphPrinter printer(*graph_); | 4618 FlowGraphPrinter printer(*graph_); |
| 4612 printer.PrintBlocks(); | 4619 printer.PrintBlocks(); |
| 4613 } | 4620 } |
| 4614 } | 4621 } |
| 4615 | 4622 |
| 4616 | 4623 |
| 4617 } // namespace dart | 4624 } // namespace dart |
| OLD | NEW |