| 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/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 8397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8408 } | 8408 } |
| 8409 | 8409 |
| 8410 | 8410 |
| 8411 void ConstantPropagator::VisitBinaryDoubleOp( | 8411 void ConstantPropagator::VisitBinaryDoubleOp( |
| 8412 BinaryDoubleOpInstr* instr) { | 8412 BinaryDoubleOpInstr* instr) { |
| 8413 const Object& left = instr->left()->definition()->constant_value(); | 8413 const Object& left = instr->left()->definition()->constant_value(); |
| 8414 const Object& right = instr->right()->definition()->constant_value(); | 8414 const Object& right = instr->right()->definition()->constant_value(); |
| 8415 if (IsNonConstant(left) || IsNonConstant(right)) { | 8415 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 8416 SetValue(instr, non_constant_); | 8416 SetValue(instr, non_constant_); |
| 8417 } else if (IsConstant(left) && IsConstant(right)) { | 8417 } else if (IsConstant(left) && IsConstant(right)) { |
| 8418 // TODO(kmillikin): Handle binary operation. | 8418 ASSERT(left.IsSmi() || left.IsDouble()); |
| 8419 SetValue(instr, non_constant_); | 8419 ASSERT(right.IsSmi() || right.IsDouble()); |
| 8420 double left_val = left.IsSmi() |
| 8421 ? Smi::Cast(left).AsDoubleValue() : Double::Cast(left).value(); |
| 8422 double right_val = right.IsSmi() |
| 8423 ? Smi::Cast(right).AsDoubleValue() : Double::Cast(right).value(); |
| 8424 double result_val = 0.0; |
| 8425 switch (instr->op_kind()) { |
| 8426 case Token::kADD: |
| 8427 result_val = left_val + right_val; |
| 8428 break; |
| 8429 case Token::kSUB: |
| 8430 result_val = left_val - right_val; |
| 8431 break; |
| 8432 case Token::kMUL: |
| 8433 result_val = left_val * right_val; |
| 8434 break; |
| 8435 case Token::kDIV: |
| 8436 result_val = left_val / right_val; |
| 8437 break; |
| 8438 default: |
| 8439 UNREACHABLE(); |
| 8440 } |
| 8441 const Double& result = Double::ZoneHandle(Double::NewCanonical(result_val)); |
| 8442 SetValue(instr, result); |
| 8420 } | 8443 } |
| 8421 } | 8444 } |
| 8422 | 8445 |
| 8423 | 8446 |
| 8424 void ConstantPropagator::VisitBinaryFloat32x4Op( | 8447 void ConstantPropagator::VisitBinaryFloat32x4Op( |
| 8425 BinaryFloat32x4OpInstr* instr) { | 8448 BinaryFloat32x4OpInstr* instr) { |
| 8426 const Object& left = instr->left()->definition()->constant_value(); | 8449 const Object& left = instr->left()->definition()->constant_value(); |
| 8427 const Object& right = instr->right()->definition()->constant_value(); | 8450 const Object& right = instr->right()->definition()->constant_value(); |
| 8428 if (IsNonConstant(left) || IsNonConstant(right)) { | 8451 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 8429 SetValue(instr, non_constant_); | 8452 SetValue(instr, non_constant_); |
| (...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9967 | 9990 |
| 9968 // Insert materializations at environment uses. | 9991 // Insert materializations at environment uses. |
| 9969 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 9992 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 9970 CreateMaterializationAt( | 9993 CreateMaterializationAt( |
| 9971 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); | 9994 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); |
| 9972 } | 9995 } |
| 9973 } | 9996 } |
| 9974 | 9997 |
| 9975 | 9998 |
| 9976 } // namespace dart | 9999 } // namespace dart |
| OLD | NEW |