| 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/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // This occurs when an instance call has too many checks. | 103 // This occurs when an instance call has too many checks. |
| 104 // TODO(srdjan): Replace IC call with megamorphic call. | 104 // TODO(srdjan): Replace IC call with megamorphic call. |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| 107 GrowableArray<intptr_t> class_ids(call->ic_data()->num_args_tested()); | 107 GrowableArray<intptr_t> class_ids(call->ic_data()->num_args_tested()); |
| 108 ASSERT(call->ic_data()->num_args_tested() <= call->ArgumentCount()); | 108 ASSERT(call->ic_data()->num_args_tested() <= call->ArgumentCount()); |
| 109 for (intptr_t i = 0; i < call->ic_data()->num_args_tested(); i++) { | 109 for (intptr_t i = 0; i < call->ic_data()->num_args_tested(); i++) { |
| 110 intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); | 110 intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); |
| 111 class_ids.Add(cid); | 111 class_ids.Add(cid); |
| 112 } | 112 } |
| 113 // TODO(srdjan): Test for number of arguments checked greater than 1. | |
| 114 if (class_ids.length() != 1) { | |
| 115 return false; | |
| 116 } | |
| 117 if (class_ids[0] != kDynamicCid) { | 113 if (class_ids[0] != kDynamicCid) { |
| 118 ArgumentsDescriptor args_desc( | 114 ArgumentsDescriptor args_desc( |
| 119 Array::Handle(ArgumentsDescriptor::New(call->ArgumentCount(), | 115 Array::Handle(ArgumentsDescriptor::New(call->ArgumentCount(), |
| 120 call->argument_names()))); | 116 call->argument_names()))); |
| 121 const Class& receiver_class = Class::Handle( | 117 const Class& receiver_class = Class::Handle( |
| 122 Isolate::Current()->class_table()->At(class_ids[0])); | 118 Isolate::Current()->class_table()->At(class_ids[0])); |
| 123 const Function& function = Function::Handle( | 119 const Function& function = Function::Handle( |
| 124 Resolver::ResolveDynamicForReceiverClass( | 120 Resolver::ResolveDynamicForReceiverClass( |
| 125 receiver_class, | 121 receiver_class, |
| 126 call->function_name(), | 122 call->function_name(), |
| 127 args_desc)); | 123 args_desc)); |
| 128 if (function.IsNull()) { | 124 if (function.IsNull()) { |
| 129 return false; | 125 return false; |
| 130 } | 126 } |
| 131 // Create new ICData, do not modify the one attached to the instruction | 127 // Create new ICData, do not modify the one attached to the instruction |
| 132 // since it is attached to the assembly instruction itself. | 128 // since it is attached to the assembly instruction itself. |
| 133 // TODO(srdjan): Prevent modification of ICData object that is | 129 // TODO(srdjan): Prevent modification of ICData object that is |
| 134 // referenced in assembly code. | 130 // referenced in assembly code. |
| 135 ICData& ic_data = ICData::ZoneHandle(ICData::New( | 131 ICData& ic_data = ICData::ZoneHandle(ICData::New( |
| 136 flow_graph_->parsed_function().function(), | 132 flow_graph_->parsed_function().function(), |
| 137 call->function_name(), | 133 call->function_name(), |
| 138 Object::empty_array(), // Dummy argument descriptor. | 134 Object::empty_array(), // Dummy argument descriptor. |
| 139 call->deopt_id(), | 135 call->deopt_id(), |
| 140 class_ids.length())); | 136 class_ids.length())); |
| 141 ic_data.AddReceiverCheck(class_ids[0], function); | 137 if (class_ids.length() > 1) { |
| 138 ic_data.AddCheck(class_ids, function); |
| 139 } else { |
| 140 ASSERT(class_ids.length() == 1); |
| 141 ic_data.AddReceiverCheck(class_ids[0], function); |
| 142 } |
| 142 call->set_ic_data(&ic_data); | 143 call->set_ic_data(&ic_data); |
| 143 return true; | 144 return true; |
| 144 } | 145 } |
| 145 return false; | 146 return false; |
| 146 } | 147 } |
| 147 | 148 |
| 148 | 149 |
| 149 static const ICData& SpecializeICData(const ICData& ic_data, intptr_t cid) { | 150 static const ICData& SpecializeICData(const ICData& ic_data, intptr_t cid) { |
| 150 ASSERT(ic_data.num_args_tested() == 1); | 151 ASSERT(ic_data.num_args_tested() == 1); |
| 151 | 152 |
| (...skipping 7893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8045 } | 8046 } |
| 8046 | 8047 |
| 8047 // Insert materializations at environment uses. | 8048 // Insert materializations at environment uses. |
| 8048 for (intptr_t i = 0; i < exits.length(); i++) { | 8049 for (intptr_t i = 0; i < exits.length(); i++) { |
| 8049 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 8050 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 8050 } | 8051 } |
| 8051 } | 8052 } |
| 8052 | 8053 |
| 8053 | 8054 |
| 8054 } // namespace dart | 8055 } // namespace dart |
| OLD | NEW |