| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 | 1218 |
| 1219 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && | 1219 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && |
| 1220 (class_ids[0] == kSmiCid)) { | 1220 (class_ids[0] == kSmiCid)) { |
| 1221 SmiToDoubleInstr* s2d_instr = new SmiToDoubleInstr(call); | 1221 SmiToDoubleInstr* s2d_instr = new SmiToDoubleInstr(call); |
| 1222 call->ReplaceWith(s2d_instr, current_iterator()); | 1222 call->ReplaceWith(s2d_instr, current_iterator()); |
| 1223 // Pushed arguments are not removed because SmiToDouble is implemented | 1223 // Pushed arguments are not removed because SmiToDouble is implemented |
| 1224 // as a call. | 1224 // as a call. |
| 1225 return true; | 1225 return true; |
| 1226 } | 1226 } |
| 1227 | 1227 |
| 1228 if ((recognized_kind == MethodRecognizer::kDoubleToInteger) && | 1228 if (class_ids[0] == kDoubleCid) { |
| 1229 (class_ids[0] == kDoubleCid)) { | 1229 if (recognized_kind == MethodRecognizer::kDoubleToInteger) { |
| 1230 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy()); | 1230 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy()); |
| 1231 ASSERT(call->HasICData()); | 1231 ASSERT(call->HasICData()); |
| 1232 const ICData& ic_data = *call->ic_data(); | 1232 const ICData& ic_data = *call->ic_data(); |
| 1233 Definition* d2i_instr = NULL; | 1233 Definition* d2i_instr = NULL; |
| 1234 if (ic_data.deopt_reason() == kDeoptDoubleToSmi) { | 1234 if (ic_data.deopt_reason() == kDeoptDoubleToSmi) { |
| 1235 // Do not repeatedly deoptimize because result didn't fit into Smi. | 1235 // Do not repeatedly deoptimize because result didn't fit into Smi. |
| 1236 d2i_instr = new DoubleToIntegerInstr(call->ArgumentAt(0)->value(), call); | 1236 d2i_instr = new DoubleToIntegerInstr(call->ArgumentAt(0)->value(), |
| 1237 } else { | 1237 call); |
| 1238 // Optimistically assume result fits into Smi. | 1238 } else { |
| 1239 d2i_instr = new DoubleToSmiInstr(call->ArgumentAt(0)->value(), call); | 1239 // Optimistically assume result fits into Smi. |
| 1240 d2i_instr = new DoubleToSmiInstr(call->ArgumentAt(0)->value(), call); |
| 1241 } |
| 1242 call->ReplaceWith(d2i_instr, current_iterator()); |
| 1243 RemovePushArguments(call); |
| 1244 return true; |
| 1240 } | 1245 } |
| 1241 call->ReplaceWith(d2i_instr, current_iterator()); | 1246 if ((recognized_kind == MethodRecognizer::kDoubleTruncate) || |
| 1242 RemovePushArguments(call); | 1247 (recognized_kind == MethodRecognizer::kDoubleRound)) { |
| 1243 return true; | 1248 if (!CPUFeatures::sse4_1_supported()) { |
| 1249 return false; |
| 1250 } |
| 1251 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy()); |
| 1252 DoubleToDoubleInstr* d2d_instr = |
| 1253 new DoubleToDoubleInstr(call->ArgumentAt(0)->value(), |
| 1254 call, |
| 1255 recognized_kind); |
| 1256 call->ReplaceWith(d2d_instr, current_iterator()); |
| 1257 RemovePushArguments(call); |
| 1258 return true; |
| 1259 } |
| 1244 } | 1260 } |
| 1245 | 1261 |
| 1246 return false; | 1262 return false; |
| 1247 } | 1263 } |
| 1248 | 1264 |
| 1249 | 1265 |
| 1250 // Returns a Boolean constant if all classes in ic_data yield the same type-test | 1266 // Returns a Boolean constant if all classes in ic_data yield the same type-test |
| 1251 // result and the type tests do not depend on type arguments. Otherwise return | 1267 // result and the type tests do not depend on type arguments. Otherwise return |
| 1252 // Bool::null(). | 1268 // Bool::null(). |
| 1253 RawBool* FlowGraphOptimizer::InstanceOfAsBool(const ICData& ic_data, | 1269 RawBool* FlowGraphOptimizer::InstanceOfAsBool(const ICData& ic_data, |
| (...skipping 2930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4184 SetValue(instr, non_constant_); | 4200 SetValue(instr, non_constant_); |
| 4185 } | 4201 } |
| 4186 | 4202 |
| 4187 | 4203 |
| 4188 void ConstantPropagator::VisitDoubleToSmi(DoubleToSmiInstr* instr) { | 4204 void ConstantPropagator::VisitDoubleToSmi(DoubleToSmiInstr* instr) { |
| 4189 // TODO(kmillikin): Handle conversion. | 4205 // TODO(kmillikin): Handle conversion. |
| 4190 SetValue(instr, non_constant_); | 4206 SetValue(instr, non_constant_); |
| 4191 } | 4207 } |
| 4192 | 4208 |
| 4193 | 4209 |
| 4210 void ConstantPropagator::VisitDoubleToDouble(DoubleToDoubleInstr* instr) { |
| 4211 // TODO(kmillikin): Handle conversion. |
| 4212 SetValue(instr, non_constant_); |
| 4213 } |
| 4214 |
| 4215 |
| 4194 void ConstantPropagator::VisitConstant(ConstantInstr* instr) { | 4216 void ConstantPropagator::VisitConstant(ConstantInstr* instr) { |
| 4195 SetValue(instr, instr->value()); | 4217 SetValue(instr, instr->value()); |
| 4196 } | 4218 } |
| 4197 | 4219 |
| 4198 | 4220 |
| 4199 void ConstantPropagator::VisitConstraint(ConstraintInstr* instr) { | 4221 void ConstantPropagator::VisitConstraint(ConstraintInstr* instr) { |
| 4200 // Should not be used outside of range analysis. | 4222 // Should not be used outside of range analysis. |
| 4201 UNREACHABLE(); | 4223 UNREACHABLE(); |
| 4202 } | 4224 } |
| 4203 | 4225 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4411 | 4433 |
| 4412 if (FLAG_trace_constant_propagation) { | 4434 if (FLAG_trace_constant_propagation) { |
| 4413 OS::Print("\n==== After constant propagation ====\n"); | 4435 OS::Print("\n==== After constant propagation ====\n"); |
| 4414 FlowGraphPrinter printer(*graph_); | 4436 FlowGraphPrinter printer(*graph_); |
| 4415 printer.PrintBlocks(); | 4437 printer.PrintBlocks(); |
| 4416 } | 4438 } |
| 4417 } | 4439 } |
| 4418 | 4440 |
| 4419 | 4441 |
| 4420 } // namespace dart | 4442 } // namespace dart |
| OLD | NEW |