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 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1244 RemovePushArguments(instr); | 1244 RemovePushArguments(instr); |
| 1245 return true; | 1245 return true; |
| 1246 } | 1246 } |
| 1247 | 1247 |
| 1248 | 1248 |
| 1249 // TODO(fschneider): Once we get rid of the distinction between Instruction | 1249 // TODO(fschneider): Once we get rid of the distinction between Instruction |
| 1250 // and computation, this helper can go away. | 1250 // and computation, this helper can go away. |
| 1251 static void HandleRelationalOp(FlowGraphOptimizer* optimizer, | 1251 static void HandleRelationalOp(FlowGraphOptimizer* optimizer, |
| 1252 RelationalOpInstr* comp, | 1252 RelationalOpInstr* comp, |
| 1253 Instruction* instr) { | 1253 Instruction* instr) { |
| 1254 if (!comp->HasICData()) return; | 1254 if (!comp->HasICData() || (comp->ic_data()->NumberOfChecks() == 0)) { |
| 1255 | 1255 return; |
| 1256 } | |
| 1256 const ICData& ic_data = *comp->ic_data(); | 1257 const ICData& ic_data = *comp->ic_data(); |
| 1257 if (ic_data.NumberOfChecks() == 0) return; | 1258 if (ic_data.NumberOfChecks() == 1) { |
| 1258 // TODO(srdjan): Add multiple receiver type support. | 1259 ASSERT(ic_data.HasOneTarget()); |
| 1259 if (ic_data.NumberOfChecks() != 1) return; | 1260 if (HasOnlyTwoSmis(ic_data)) { |
| 1260 ASSERT(ic_data.HasOneTarget()); | 1261 optimizer->InsertBefore( |
| 1261 | 1262 instr, |
| 1262 if (HasOnlyTwoSmis(ic_data)) { | 1263 new CheckSmiInstr(comp->left()->Copy(), comp->deopt_id()), |
| 1263 optimizer->InsertBefore( | 1264 instr->env(), |
| 1264 instr, | 1265 Definition::kEffect); |
| 1265 new CheckSmiInstr(comp->left()->Copy(), comp->deopt_id()), | 1266 optimizer->InsertBefore( |
| 1266 instr->env(), | 1267 instr, |
| 1267 Definition::kEffect); | 1268 new CheckSmiInstr(comp->right()->Copy(), comp->deopt_id()), |
| 1268 optimizer->InsertBefore( | 1269 instr->env(), |
| 1269 instr, | 1270 Definition::kEffect); |
| 1270 new CheckSmiInstr(comp->right()->Copy(), comp->deopt_id()), | 1271 comp->set_operands_class_id(kSmiCid); |
| 1271 instr->env(), | 1272 } else if (ShouldSpecializeForDouble(ic_data)) { |
| 1272 Definition::kEffect); | 1273 comp->set_operands_class_id(kDoubleCid); |
| 1273 comp->set_operands_class_id(kSmiCid); | 1274 } else if (HasTwoMintOrSmi(*comp->ic_data()) && |
| 1274 } else if (ShouldSpecializeForDouble(ic_data)) { | 1275 FlowGraphCompiler::SupportsUnboxedMints()) { |
| 1275 comp->set_operands_class_id(kDoubleCid); | 1276 comp->set_operands_class_id(kMintCid); |
| 1277 } else if (comp->ic_data()->AllReceiversAreNumbers()) { | |
| 1278 comp->set_operands_class_id(kNumberCid); | |
|
srdjan
2012/10/29 19:30:25
What do we need the kNumberCid-s for (here and bel
Florian Schneider
2012/10/30 12:09:04
Removed. Actually not needed anymore.
| |
| 1279 } else { | |
| 1280 ASSERT(comp->operands_class_id() == kIllegalCid); | |
| 1281 } | |
| 1282 } else if (HasTwoMintOrSmi(*comp->ic_data()) && | |
| 1283 FlowGraphCompiler::SupportsUnboxedMints()) { | |
| 1284 comp->set_operands_class_id(kMintCid); | |
| 1276 } else if (comp->ic_data()->AllReceiversAreNumbers()) { | 1285 } else if (comp->ic_data()->AllReceiversAreNumbers()) { |
| 1277 comp->set_operands_class_id(kNumberCid); | 1286 comp->set_operands_class_id(kNumberCid); |
| 1278 } | 1287 } |
| 1279 } | 1288 } |
| 1280 | 1289 |
| 1290 | |
| 1281 void FlowGraphOptimizer::VisitRelationalOp(RelationalOpInstr* instr) { | 1291 void FlowGraphOptimizer::VisitRelationalOp(RelationalOpInstr* instr) { |
| 1282 HandleRelationalOp(this, instr, instr); | 1292 HandleRelationalOp(this, instr, instr); |
| 1283 } | 1293 } |
| 1284 | 1294 |
| 1285 | 1295 |
| 1286 // TODO(fschneider): Once we get rid of the distinction between Instruction | 1296 // TODO(fschneider): Once we get rid of the distinction between Instruction |
| 1287 // and computation, this helper can go away. | 1297 // and computation, this helper can go away. |
| 1288 template <typename T> | 1298 template <typename T> |
| 1289 static void HandleEqualityCompare(FlowGraphOptimizer* optimizer, | 1299 static void HandleEqualityCompare(FlowGraphOptimizer* optimizer, |
| 1290 EqualityCompareInstr* comp, | 1300 EqualityCompareInstr* comp, |
| (...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3523 | 3533 |
| 3524 if (FLAG_trace_constant_propagation) { | 3534 if (FLAG_trace_constant_propagation) { |
| 3525 OS::Print("\n==== After constant propagation ====\n"); | 3535 OS::Print("\n==== After constant propagation ====\n"); |
| 3526 FlowGraphPrinter printer(*graph_); | 3536 FlowGraphPrinter printer(*graph_); |
| 3527 printer.PrintBlocks(); | 3537 printer.PrintBlocks(); |
| 3528 } | 3538 } |
| 3529 } | 3539 } |
| 3530 | 3540 |
| 3531 | 3541 |
| 3532 } // namespace dart | 3542 } // namespace dart |
| OLD | NEW |