| 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/aot_optimizer.h" | 5 #include "vm/aot_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/branch_optimizer.h" | 8 #include "vm/branch_optimizer.h" |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 // TODO(srdjan): Test/support other number types as well. | 120 // TODO(srdjan): Test/support other number types as well. |
| 121 static bool IsNumberCid(intptr_t cid) { | 121 static bool IsNumberCid(intptr_t cid) { |
| 122 return (cid == kSmiCid) || (cid == kDoubleCid); | 122 return (cid == kSmiCid) || (cid == kDoubleCid); |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| 126 // Returns named function that is a unique dynamic target, i.e., |
| 127 // - the target is identified by its name alone, since it occurs only once. |
| 128 // - target's class has no subclasses, and neither is subclassed, i.e., |
| 129 // the receiver type can be only the function's class. |
| 130 // Returns Function::null() if there is no unique dynamic target for |
| 131 // given 'fname'. 'fname' must be a symbol. |
| 126 static void GetUniqueDynamicTarget(Isolate* isolate, | 132 static void GetUniqueDynamicTarget(Isolate* isolate, |
| 127 const String& fname, | 133 const String& fname, |
| 128 Object* function) { | 134 Object* function) { |
| 129 UniqueFunctionsSet functions_set( | 135 UniqueFunctionsSet functions_set( |
| 130 isolate->object_store()->unique_dynamic_targets()); | 136 isolate->object_store()->unique_dynamic_targets()); |
| 131 ASSERT(fname.IsSymbol()); | 137 ASSERT(fname.IsSymbol()); |
| 132 *function = functions_set.GetOrNull(fname); | 138 *function = functions_set.GetOrNull(fname); |
| 133 ASSERT(functions_set.Release().raw() == | 139 ASSERT(functions_set.Release().raw() == |
| 134 isolate->object_store()->unique_dynamic_targets()); | 140 isolate->object_store()->unique_dynamic_targets()); |
| 135 } | 141 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 216 } |
| 211 call->set_ic_data(&ic_data); | 217 call->set_ic_data(&ic_data); |
| 212 return true; | 218 return true; |
| 213 } | 219 } |
| 214 | 220 |
| 215 if (isolate()->object_store()->unique_dynamic_targets() != Array::null()) { | 221 if (isolate()->object_store()->unique_dynamic_targets() != Array::null()) { |
| 216 // Check if the target is unique. | 222 // Check if the target is unique. |
| 217 Function& target_function = Function::Handle(Z); | 223 Function& target_function = Function::Handle(Z); |
| 218 GetUniqueDynamicTarget(isolate(), call->function_name(), &target_function); | 224 GetUniqueDynamicTarget(isolate(), call->function_name(), &target_function); |
| 219 // Calls with named arguments must be resolved/checked at runtime. | 225 // Calls with named arguments must be resolved/checked at runtime. |
| 220 String& error_message = String::Handle(Z); | |
| 221 if (!target_function.IsNull() && | 226 if (!target_function.IsNull() && |
| 222 !target_function.HasOptionalNamedParameters() && | 227 !target_function.HasOptionalNamedParameters() && |
| 223 target_function.AreValidArgumentCounts(call->ArgumentCount(), 0, | 228 target_function.AreValidArgumentCounts(call->ArgumentCount(), 0, |
| 224 &error_message)) { | 229 /* error_message = */ NULL)) { |
| 225 const intptr_t cid = Class::Handle(Z, target_function.Owner()).id(); | 230 const intptr_t cid = Class::Handle(Z, target_function.Owner()).id(); |
| 226 const ICData& ic_data = ICData::ZoneHandle(Z, | 231 const ICData& ic_data = ICData::ZoneHandle(Z, |
| 227 ICData::NewFrom(*call->ic_data(), 1)); | 232 ICData::NewFrom(*call->ic_data(), 1)); |
| 228 ic_data.AddReceiverCheck(cid, target_function); | 233 ic_data.AddReceiverCheck(cid, target_function); |
| 229 call->set_ic_data(&ic_data); | 234 call->set_ic_data(&ic_data); |
| 230 return true; | 235 return true; |
| 231 } | 236 } |
| 232 } | 237 } |
| 233 | 238 |
| 234 return false; | 239 return false; |
| (...skipping 2536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2771 | 2776 |
| 2772 // Discard the environment from the original instruction because the store | 2777 // Discard the environment from the original instruction because the store |
| 2773 // can't deoptimize. | 2778 // can't deoptimize. |
| 2774 instr->RemoveEnvironment(); | 2779 instr->RemoveEnvironment(); |
| 2775 ReplaceCall(instr, store); | 2780 ReplaceCall(instr, store); |
| 2776 return true; | 2781 return true; |
| 2777 } | 2782 } |
| 2778 | 2783 |
| 2779 | 2784 |
| 2780 } // namespace dart | 2785 } // namespace dart |
| OLD | NEW |