| 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/flow_graph_builder.h" | 7 #include "vm/flow_graph_builder.h" |
| 8 #include "vm/il_printer.h" | 8 #include "vm/il_printer.h" |
| 9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
| 10 | 10 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 323 |
| 324 | 324 |
| 325 void FlowGraphOptimizer::VisitInstanceSetter(InstanceSetterComp* comp) { | 325 void FlowGraphOptimizer::VisitInstanceSetter(InstanceSetterComp* comp) { |
| 326 // TODO(srdjan): Add assigneable check node if --enable_type_checks. | 326 // TODO(srdjan): Add assigneable check node if --enable_type_checks. |
| 327 if (comp->HasICData() && !FLAG_enable_type_checks) { | 327 if (comp->HasICData() && !FLAG_enable_type_checks) { |
| 328 TryInlineInstanceSetter(comp); | 328 TryInlineInstanceSetter(comp); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 | 332 |
| 333 void FlowGraphOptimizer::VisitLoadIndexed(LoadIndexedComp* comp) { | 333 enum IndexedAccessType { |
| 334 if (!comp->HasICData()) return; | 334 kIndexedLoad, |
| 335 kIndexedStore |
| 336 }; |
| 337 |
| 338 |
| 339 static intptr_t ReceiverClassId(Computation* comp) { |
| 340 if (!comp->HasICData()) return kIllegalObjectKind; |
| 335 | 341 |
| 336 const ICData& ic_data = *comp->ic_data(); | 342 const ICData& ic_data = *comp->ic_data(); |
| 337 if (ic_data.NumberOfChecks() == 0) return; | 343 |
| 344 if (ic_data.NumberOfChecks() == 0) return kIllegalObjectKind; |
| 338 // TODO(vegorov): Add multiple receiver type support. | 345 // TODO(vegorov): Add multiple receiver type support. |
| 339 if (ic_data.NumberOfChecks() != 1) return; | 346 if (ic_data.NumberOfChecks() != 1) return kIllegalObjectKind; |
| 340 ASSERT(HasOneTarget(ic_data)); | 347 ASSERT(HasOneTarget(ic_data)); |
| 341 | 348 |
| 342 Function& target = Function::Handle(); | 349 Function& target = Function::Handle(); |
| 343 Class& cls = Class::Handle(); | 350 Class& cls = Class::Handle(); |
| 344 ic_data.GetOneClassCheckAt(0, &cls, &target); | 351 ic_data.GetOneClassCheckAt(0, &cls, &target); |
| 345 | 352 |
| 346 switch (cls.id()) { | 353 return cls.id(); |
| 354 } |
| 355 |
| 356 |
| 357 void FlowGraphOptimizer::VisitLoadIndexed(LoadIndexedComp* comp) { |
| 358 const intptr_t class_id = ReceiverClassId(comp); |
| 359 switch (class_id) { |
| 347 case kArray: | 360 case kArray: |
| 348 case kImmutableArray: | 361 case kImmutableArray: |
| 349 case kGrowableObjectArray: | 362 case kGrowableObjectArray: |
| 350 comp->set_receiver_type(static_cast<ObjectKind>(cls.id())); | 363 comp->set_receiver_type(static_cast<ObjectKind>(class_id)); |
| 351 } | 364 } |
| 352 } | 365 } |
| 353 | 366 |
| 367 |
| 368 void FlowGraphOptimizer::VisitStoreIndexed(StoreIndexedComp* comp) { |
| 369 if (FLAG_enable_type_checks) return; |
| 370 |
| 371 const intptr_t class_id = ReceiverClassId(comp); |
| 372 switch (class_id) { |
| 373 case kArray: |
| 374 case kGrowableObjectArray: |
| 375 comp->set_receiver_type(static_cast<ObjectKind>(class_id)); |
| 376 } |
| 377 } |
| 378 |
| 354 | 379 |
| 355 void FlowGraphOptimizer::VisitRelationalOp(RelationalOpComp* comp) { | 380 void FlowGraphOptimizer::VisitRelationalOp(RelationalOpComp* comp) { |
| 356 if (!comp->HasICData()) return; | 381 if (!comp->HasICData()) return; |
| 357 | 382 |
| 358 const ICData& ic_data = *comp->ic_data(); | 383 const ICData& ic_data = *comp->ic_data(); |
| 359 if (ic_data.NumberOfChecks() == 0) return; | 384 if (ic_data.NumberOfChecks() == 0) return; |
| 360 // TODO(srdjan): Add multiple receiver type support. | 385 // TODO(srdjan): Add multiple receiver type support. |
| 361 if (ic_data.NumberOfChecks() != 1) return; | 386 if (ic_data.NumberOfChecks() != 1) return; |
| 362 ASSERT(HasOneTarget(ic_data)); | 387 ASSERT(HasOneTarget(ic_data)); |
| 363 | 388 |
| 364 if (HasTwoSmi(ic_data)) { | 389 if (HasTwoSmi(ic_data)) { |
| 365 comp->set_operands_class_id(kSmi); | 390 comp->set_operands_class_id(kSmi); |
| 366 } else if (HasTwoDouble(ic_data)) { | 391 } else if (HasTwoDouble(ic_data)) { |
| 367 comp->set_operands_class_id(kDouble); | 392 comp->set_operands_class_id(kDouble); |
| 368 } | 393 } |
| 369 } | 394 } |
| 370 | 395 |
| 371 | 396 |
| 372 void FlowGraphOptimizer::VisitDo(DoInstr* instr) { | 397 void FlowGraphOptimizer::VisitDo(DoInstr* instr) { |
| 373 instr->computation()->Accept(this); | 398 instr->computation()->Accept(this); |
| 374 } | 399 } |
| 375 | 400 |
| 376 | 401 |
| 377 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { | 402 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { |
| 378 instr->computation()->Accept(this); | 403 instr->computation()->Accept(this); |
| 379 } | 404 } |
| 380 | 405 |
| 381 | 406 |
| 382 } // namespace dart | 407 } // namespace dart |
| OLD | NEW |