| 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/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 4091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4102 } | 4102 } |
| 4103 | 4103 |
| 4104 return true; // May deoptimize since we have not identified all 'true' tests. | 4104 return true; // May deoptimize since we have not identified all 'true' tests. |
| 4105 } | 4105 } |
| 4106 | 4106 |
| 4107 | 4107 |
| 4108 // TODO(srdjan): Use ICData to check if always true or false. | 4108 // TODO(srdjan): Use ICData to check if always true or false. |
| 4109 void FlowGraphOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) { | 4109 void FlowGraphOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) { |
| 4110 ASSERT(Token::IsTypeTestOperator(call->token_kind())); | 4110 ASSERT(Token::IsTypeTestOperator(call->token_kind())); |
| 4111 Definition* left = call->ArgumentAt(0); | 4111 Definition* left = call->ArgumentAt(0); |
| 4112 Definition* instantiator = call->ArgumentAt(1); | 4112 Definition* instantiator = NULL; |
| 4113 Definition* type_args = call->ArgumentAt(2); | 4113 Definition* type_args = NULL; |
| 4114 const AbstractType& type = | 4114 AbstractType& type = AbstractType::ZoneHandle(Z); |
| 4115 AbstractType::Cast(call->ArgumentAt(3)->AsConstant()->value()); | 4115 bool negate = false; |
| 4116 const bool negate = Bool::Cast( | 4116 if (call->ArgumentCount() == 2) { |
| 4117 call->ArgumentAt(4)->OriginalDefinition()->AsConstant()->value()).value(); | 4117 instantiator = flow_graph()->constant_null(); |
| 4118 type_args = flow_graph()->constant_null(); |
| 4119 if (call->function_name().raw() == |
| 4120 Library::PrivateCoreLibName(Symbols::_instanceOfNum()).raw()) { |
| 4121 type = Type::Number(); |
| 4122 } else if (call->function_name().raw() == |
| 4123 Library::PrivateCoreLibName(Symbols::_instanceOfInt()).raw()) { |
| 4124 type = Type::IntType(); |
| 4125 } else if (call->function_name().raw() == |
| 4126 Library::PrivateCoreLibName(Symbols::_instanceOfSmi()).raw()) { |
| 4127 type = Type::SmiType(); |
| 4128 } else if (call->function_name().raw() == |
| 4129 Library::PrivateCoreLibName(Symbols::_instanceOfDouble()).raw()) { |
| 4130 type = Type::Double(); |
| 4131 } else if (call->function_name().raw() == |
| 4132 Library::PrivateCoreLibName(Symbols::_instanceOfString()).raw()) { |
| 4133 type = Type::StringType(); |
| 4134 } else { |
| 4135 UNIMPLEMENTED(); |
| 4136 } |
| 4137 negate = Bool::Cast(call->ArgumentAt(1)->OriginalDefinition() |
| 4138 ->AsConstant()->value()).value(); |
| 4139 } else { |
| 4140 instantiator = call->ArgumentAt(1); |
| 4141 type_args = call->ArgumentAt(2); |
| 4142 type = AbstractType::Cast(call->ArgumentAt(3)->AsConstant()->value()).raw(); |
| 4143 negate = Bool::Cast(call->ArgumentAt(4)->OriginalDefinition() |
| 4144 ->AsConstant()->value()).value(); |
| 4145 } |
| 4118 const ICData& unary_checks = | 4146 const ICData& unary_checks = |
| 4119 ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecks()); | 4147 ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecks()); |
| 4120 if (FLAG_warn_on_javascript_compatibility && | 4148 if (FLAG_warn_on_javascript_compatibility && |
| 4121 !unary_checks.IssuedJSWarning() && | 4149 !unary_checks.IssuedJSWarning() && |
| 4122 (type.IsIntType() || type.IsDoubleType() || !type.IsInstantiated())) { | 4150 (type.IsIntType() || type.IsDoubleType() || !type.IsInstantiated())) { |
| 4123 // No warning was reported yet for this type check, either because it has | 4151 // No warning was reported yet for this type check, either because it has |
| 4124 // not been executed yet, or because no problematic combinations of instance | 4152 // not been executed yet, or because no problematic combinations of instance |
| 4125 // type and test type have been encountered so far. A warning may still be | 4153 // type and test type have been encountered so far. A warning may still be |
| 4126 // reported, so do not replace the instance call. | 4154 // reported, so do not replace the instance call. |
| 4127 return; | 4155 return; |
| (...skipping 4603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8731 | 8759 |
| 8732 // Insert materializations at environment uses. | 8760 // Insert materializations at environment uses. |
| 8733 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 8761 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 8734 CreateMaterializationAt( | 8762 CreateMaterializationAt( |
| 8735 exits_collector_.exits()[i], alloc, *slots); | 8763 exits_collector_.exits()[i], alloc, *slots); |
| 8736 } | 8764 } |
| 8737 } | 8765 } |
| 8738 | 8766 |
| 8739 | 8767 |
| 8740 } // namespace dart | 8768 } // namespace dart |
| OLD | NEW |