Chromium Code Reviews| 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 8487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8498 UNREACHABLE(); | 8498 UNREACHABLE(); |
| 8499 } | 8499 } |
| 8500 | 8500 |
| 8501 | 8501 |
| 8502 void ConstantPropagator::VisitMaterializeObject(MaterializeObjectInstr* instr) { | 8502 void ConstantPropagator::VisitMaterializeObject(MaterializeObjectInstr* instr) { |
| 8503 // Should not be used outside of allocation elimination pass. | 8503 // Should not be used outside of allocation elimination pass. |
| 8504 UNREACHABLE(); | 8504 UNREACHABLE(); |
| 8505 } | 8505 } |
| 8506 | 8506 |
| 8507 | 8507 |
| 8508 static bool IsIntegerOrDouble(const Object& value) { | |
| 8509 return value.IsInteger() || value.IsDouble(); | |
| 8510 } | |
| 8511 | |
| 8512 | |
| 8513 static double ToDouble(const Object& value) { | |
| 8514 return value.IsInteger() ? Integer::Cast(value).AsDoubleValue() | |
| 8515 : Double::Cast(value).value(); | |
|
Florian Schneider
2014/09/18 12:33:14
Please align : and ?.
Vyacheslav Egorov (Google)
2014/09/18 12:46:53
Done.
| |
| 8516 } | |
| 8517 | |
| 8518 | |
| 8508 void ConstantPropagator::VisitBinaryDoubleOp( | 8519 void ConstantPropagator::VisitBinaryDoubleOp( |
| 8509 BinaryDoubleOpInstr* instr) { | 8520 BinaryDoubleOpInstr* instr) { |
| 8510 const Object& left = instr->left()->definition()->constant_value(); | 8521 const Object& left = instr->left()->definition()->constant_value(); |
| 8511 const Object& right = instr->right()->definition()->constant_value(); | 8522 const Object& right = instr->right()->definition()->constant_value(); |
| 8512 if (IsNonConstant(left) || IsNonConstant(right)) { | 8523 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 8513 SetValue(instr, non_constant_); | 8524 SetValue(instr, non_constant_); |
| 8514 } else if (IsConstant(left) && IsConstant(right)) { | 8525 } else if (left.IsInteger() && right.IsInteger()) { |
| 8515 ASSERT(left.IsSmi() || left.IsDouble()); | 8526 SetValue(instr, non_constant_); |
| 8516 ASSERT(right.IsSmi() || right.IsDouble()); | 8527 } else if (IsIntegerOrDouble(left) && IsIntegerOrDouble(right)) { |
| 8517 double left_val = left.IsSmi() | 8528 const double left_val = ToDouble(left); |
| 8518 ? Smi::Cast(left).AsDoubleValue() : Double::Cast(left).value(); | 8529 const double right_val = ToDouble(right); |
| 8519 double right_val = right.IsSmi() | |
| 8520 ? Smi::Cast(right).AsDoubleValue() : Double::Cast(right).value(); | |
| 8521 double result_val = 0.0; | 8530 double result_val = 0.0; |
| 8522 switch (instr->op_kind()) { | 8531 switch (instr->op_kind()) { |
| 8523 case Token::kADD: | 8532 case Token::kADD: |
| 8524 result_val = left_val + right_val; | 8533 result_val = left_val + right_val; |
| 8525 break; | 8534 break; |
| 8526 case Token::kSUB: | 8535 case Token::kSUB: |
| 8527 result_val = left_val - right_val; | 8536 result_val = left_val - right_val; |
| 8528 break; | 8537 break; |
| 8529 case Token::kMUL: | 8538 case Token::kMUL: |
| 8530 result_val = left_val * right_val; | 8539 result_val = left_val * right_val; |
| (...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10075 | 10084 |
| 10076 // Insert materializations at environment uses. | 10085 // Insert materializations at environment uses. |
| 10077 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 10086 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 10078 CreateMaterializationAt( | 10087 CreateMaterializationAt( |
| 10079 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); | 10088 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); |
| 10080 } | 10089 } |
| 10081 } | 10090 } |
| 10082 | 10091 |
| 10083 | 10092 |
| 10084 } // namespace dart | 10093 } // namespace dart |
| OLD | NEW |