Chromium Code Reviews| 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 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1221 | 1221 |
| 1222 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && | 1222 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && |
| 1223 (class_ids[0] == kSmiCid)) { | 1223 (class_ids[0] == kSmiCid)) { |
| 1224 SmiToDoubleInstr* s2d_instr = new SmiToDoubleInstr(call); | 1224 SmiToDoubleInstr* s2d_instr = new SmiToDoubleInstr(call); |
| 1225 call->ReplaceWith(s2d_instr, current_iterator()); | 1225 call->ReplaceWith(s2d_instr, current_iterator()); |
| 1226 // Pushed arguments are not removed because SmiToDouble is implemented | 1226 // Pushed arguments are not removed because SmiToDouble is implemented |
| 1227 // as a call. | 1227 // as a call. |
| 1228 return true; | 1228 return true; |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 if ((recognized_kind == MethodRecognizer::kDoubleToInteger) && | 1231 if (class_ids[0] == kDoubleCid) { |
| 1232 (class_ids[0] == kDoubleCid)) { | 1232 if (recognized_kind == MethodRecognizer::kDoubleToInteger) { |
| 1233 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy()); | 1233 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy()); |
| 1234 ASSERT(call->HasICData()); | 1234 ASSERT(call->HasICData()); |
| 1235 const ICData& ic_data = *call->ic_data(); | 1235 const ICData& ic_data = *call->ic_data(); |
| 1236 Definition* d2i_instr = NULL; | 1236 Definition* d2i_instr = NULL; |
| 1237 if (ic_data.deopt_reason() == kDeoptDoubleToSmi) { | 1237 if (ic_data.deopt_reason() == kDeoptDoubleToSmi) { |
| 1238 // Do not repeatedly deoptimize because result didn't fit into Smi. | 1238 // Do not repeatedly deoptimize because result didn't fit into Smi. |
| 1239 d2i_instr = new DoubleToIntegerInstr(call->ArgumentAt(0)->value(), call); | 1239 d2i_instr = new DoubleToIntegerInstr(call->ArgumentAt(0)->value(), |
| 1240 } else { | 1240 call); |
| 1241 // Optimistically assume result fits into Smi. | 1241 } else { |
| 1242 d2i_instr = new DoubleToSmiInstr(call->ArgumentAt(0)->value(), call); | 1242 // Optimistically assume result fits into Smi. |
| 1243 d2i_instr = new DoubleToSmiInstr(call->ArgumentAt(0)->value(), call); | |
| 1244 } | |
| 1245 call->ReplaceWith(d2i_instr, current_iterator()); | |
| 1246 RemovePushArguments(call); | |
| 1247 return true; | |
| 1243 } | 1248 } |
| 1244 call->ReplaceWith(d2i_instr, current_iterator()); | 1249 if ((recognized_kind == MethodRecognizer::kDoubleTruncate) || |
| 1245 RemovePushArguments(call); | 1250 (recognized_kind == MethodRecognizer::kDoubleRound)) { |
|
Florian Schneider
2013/01/11 09:49:30
You need to check if SSE 4.1 is supported here: CP
srdjan
2013/01/11 19:48:21
Done.
| |
| 1246 return true; | 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 } | |
| 1247 } | 1260 } |
| 1248 | 1261 |
| 1249 return false; | 1262 return false; |
| 1250 } | 1263 } |
| 1251 | 1264 |
| 1252 | 1265 |
| 1253 // 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 |
| 1254 // 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 |
| 1255 // Bool::null(). | 1268 // Bool::null(). |
| 1256 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... | |
| 4187 SetValue(instr, non_constant_); | 4200 SetValue(instr, non_constant_); |
| 4188 } | 4201 } |
| 4189 | 4202 |
| 4190 | 4203 |
| 4191 void ConstantPropagator::VisitDoubleToSmi(DoubleToSmiInstr* instr) { | 4204 void ConstantPropagator::VisitDoubleToSmi(DoubleToSmiInstr* instr) { |
| 4192 // TODO(kmillikin): Handle conversion. | 4205 // TODO(kmillikin): Handle conversion. |
| 4193 SetValue(instr, non_constant_); | 4206 SetValue(instr, non_constant_); |
| 4194 } | 4207 } |
| 4195 | 4208 |
| 4196 | 4209 |
| 4210 void ConstantPropagator::VisitDoubleToDouble(DoubleToDoubleInstr* instr) { | |
| 4211 // TODO(kmillikin): Handle conversion. | |
| 4212 SetValue(instr, non_constant_); | |
| 4213 } | |
| 4214 | |
| 4215 | |
| 4197 void ConstantPropagator::VisitConstant(ConstantInstr* instr) { | 4216 void ConstantPropagator::VisitConstant(ConstantInstr* instr) { |
| 4198 SetValue(instr, instr->value()); | 4217 SetValue(instr, instr->value()); |
| 4199 } | 4218 } |
| 4200 | 4219 |
| 4201 | 4220 |
| 4202 void ConstantPropagator::VisitConstraint(ConstraintInstr* instr) { | 4221 void ConstantPropagator::VisitConstraint(ConstraintInstr* instr) { |
| 4203 // Should not be used outside of range analysis. | 4222 // Should not be used outside of range analysis. |
| 4204 UNREACHABLE(); | 4223 UNREACHABLE(); |
| 4205 } | 4224 } |
| 4206 | 4225 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4414 | 4433 |
| 4415 if (FLAG_trace_constant_propagation) { | 4434 if (FLAG_trace_constant_propagation) { |
| 4416 OS::Print("\n==== After constant propagation ====\n"); | 4435 OS::Print("\n==== After constant propagation ====\n"); |
| 4417 FlowGraphPrinter printer(*graph_); | 4436 FlowGraphPrinter printer(*graph_); |
| 4418 printer.PrintBlocks(); | 4437 printer.PrintBlocks(); |
| 4419 } | 4438 } |
| 4420 } | 4439 } |
| 4421 | 4440 |
| 4422 | 4441 |
| 4423 } // namespace dart | 4442 } // namespace dart |
| OLD | NEW |