Chromium Code Reviews| 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/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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 ASSERT(call->HasICData()); | 80 ASSERT(call->HasICData()); |
| 81 if (call->ic_data()->NumberOfChecks() > 0) { | 81 if (call->ic_data()->NumberOfChecks() > 0) { |
| 82 // This occurs when an instance call has too many checks. | 82 // This occurs when an instance call has too many checks. |
| 83 // TODO(srdjan): Replace IC call with megamorphic call. | 83 // TODO(srdjan): Replace IC call with megamorphic call. |
| 84 return false; | 84 return false; |
| 85 } | 85 } |
| 86 GrowableArray<intptr_t> class_ids(call->ic_data()->num_args_tested()); | 86 GrowableArray<intptr_t> class_ids(call->ic_data()->num_args_tested()); |
| 87 ASSERT(call->ic_data()->num_args_tested() <= call->ArgumentCount()); | 87 ASSERT(call->ic_data()->num_args_tested() <= call->ArgumentCount()); |
| 88 for (intptr_t i = 0; i < call->ic_data()->num_args_tested(); i++) { | 88 for (intptr_t i = 0; i < call->ic_data()->num_args_tested(); i++) { |
| 89 intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); | 89 intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); |
| 90 if (cid == kDynamicCid) { | |
|
Vyacheslav Egorov (Google)
2013/03/26 18:56:13
How about a bit different approach:
In Definition
srdjan
2013/03/26 20:34:52
Yes, update the type in ReplaceUsesWith. In order
| |
| 91 // Definition's type may differ from value's type as it may have been | |
| 92 // changed by guarded_cid of an inlined LoadField. | |
| 93 cid = call->PushArgumentAt(i)->value()->definition()->Type()->ToCid(); | |
| 94 } | |
| 90 class_ids.Add(cid); | 95 class_ids.Add(cid); |
| 91 } | 96 } |
| 92 // TODO(srdjan): Test for other class_ids > 1. | 97 // TODO(srdjan): Test for number of arguments checked greater than 1. |
| 93 if (class_ids.length() != 1) return false; | 98 if (class_ids.length() != 1) { |
| 99 return false; | |
| 100 } | |
| 94 if (class_ids[0] != kDynamicCid) { | 101 if (class_ids[0] != kDynamicCid) { |
| 95 const intptr_t num_named_arguments = call->argument_names().IsNull() ? | 102 const intptr_t num_named_arguments = call->argument_names().IsNull() ? |
| 96 0 : call->argument_names().Length(); | 103 0 : call->argument_names().Length(); |
| 97 const Class& receiver_class = Class::Handle( | 104 const Class& receiver_class = Class::Handle( |
| 98 Isolate::Current()->class_table()->At(class_ids[0])); | 105 Isolate::Current()->class_table()->At(class_ids[0])); |
| 99 Function& function = Function::Handle(); | 106 Function& function = Function::Handle(); |
| 100 function = Resolver::ResolveDynamicForReceiverClass( | 107 function = Resolver::ResolveDynamicForReceiverClass( |
| 101 receiver_class, | 108 receiver_class, |
| 102 call->function_name(), | 109 call->function_name(), |
| 103 call->ArgumentCount(), | 110 call->ArgumentCount(), |
| (...skipping 4523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4627 if (changed) { | 4634 if (changed) { |
| 4628 // We may have changed the block order and the dominator tree. | 4635 // We may have changed the block order and the dominator tree. |
| 4629 flow_graph->DiscoverBlocks(); | 4636 flow_graph->DiscoverBlocks(); |
| 4630 GrowableArray<BitVector*> dominance_frontier; | 4637 GrowableArray<BitVector*> dominance_frontier; |
| 4631 flow_graph->ComputeDominators(&dominance_frontier); | 4638 flow_graph->ComputeDominators(&dominance_frontier); |
| 4632 } | 4639 } |
| 4633 } | 4640 } |
| 4634 | 4641 |
| 4635 | 4642 |
| 4636 } // namespace dart | 4643 } // namespace dart |
| OLD | NEW |