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 #ifndef DART_PRECOMPILED_RUNTIME | 4 #ifndef DART_PRECOMPILED_RUNTIME |
| 5 #include "vm/jit_optimizer.h" | 5 #include "vm/jit_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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 if (!receiver_class.is_finalized()) { | 134 if (!receiver_class.is_finalized()) { |
| 135 // Do not eagerly finalize classes. ResolveDynamicForReceiverClass can | 135 // Do not eagerly finalize classes. ResolveDynamicForReceiverClass can |
| 136 // cause class finalization, since callee's receiver class may not be | 136 // cause class finalization, since callee's receiver class may not be |
| 137 // finalized yet. | 137 // finalized yet. |
| 138 return false; | 138 return false; |
| 139 } | 139 } |
| 140 const Array& args_desc_array = | 140 const Array& args_desc_array = |
| 141 Array::Handle(Z, ArgumentsDescriptor::New(call->ArgumentCount(), | 141 Array::Handle(Z, ArgumentsDescriptor::New(call->ArgumentCount(), |
| 142 call->argument_names())); | 142 call->argument_names())); |
| 143 ArgumentsDescriptor args_desc(args_desc_array); | 143 ArgumentsDescriptor args_desc(args_desc_array); |
| 144 const Function& function = | 144 bool allow_add = false; |
| 145 Function::Handle(Z, Resolver::ResolveDynamicForReceiverClass( | 145 const Function& function = Function::Handle( |
| 146 receiver_class, call->function_name(), | 146 Z, Resolver::ResolveDynamicForReceiverClass( |
| 147 args_desc, false /* allow add */)); | 147 receiver_class, call->function_name(), args_desc, allow_add)); |
| 148 if (function.IsNull()) { | 148 if (function.IsNull()) { |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Create new ICData, do not modify the one attached to the instruction | 152 // Create new ICData, do not modify the one attached to the instruction |
| 153 // since it is attached to the assembly instruction itself. | 153 // since it is attached to the assembly instruction itself. |
| 154 // TODO(srdjan): Prevent modification of ICData object that is | 154 // TODO(srdjan): Prevent modification of ICData object that is |
| 155 // referenced in assembly code. | 155 // referenced in assembly code. |
| 156 const ICData& ic_data = ICData::ZoneHandle( | 156 const ICData& ic_data = ICData::ZoneHandle( |
| 157 Z, ICData::NewFrom(*call->ic_data(), class_ids.length())); | 157 Z, ICData::NewFrom(*call->ic_data(), class_ids.length())); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 168 // Check if getter or setter in function's class and class is currently leaf. | 168 // Check if getter or setter in function's class and class is currently leaf. |
| 169 if (FLAG_guess_icdata_cid && ((call->token_kind() == Token::kGET) || | 169 if (FLAG_guess_icdata_cid && ((call->token_kind() == Token::kGET) || |
| 170 (call->token_kind() == Token::kSET))) { | 170 (call->token_kind() == Token::kSET))) { |
| 171 const Class& owner_class = Class::Handle(Z, function().Owner()); | 171 const Class& owner_class = Class::Handle(Z, function().Owner()); |
| 172 if (!owner_class.is_abstract() && !CHA::HasSubclasses(owner_class) && | 172 if (!owner_class.is_abstract() && !CHA::HasSubclasses(owner_class) && |
| 173 !CHA::IsImplemented(owner_class)) { | 173 !CHA::IsImplemented(owner_class)) { |
| 174 const Array& args_desc_array = | 174 const Array& args_desc_array = |
| 175 Array::Handle(Z, ArgumentsDescriptor::New(call->ArgumentCount(), | 175 Array::Handle(Z, ArgumentsDescriptor::New(call->ArgumentCount(), |
| 176 call->argument_names())); | 176 call->argument_names())); |
| 177 ArgumentsDescriptor args_desc(args_desc_array); | 177 ArgumentsDescriptor args_desc(args_desc_array); |
| 178 const Function& function = | 178 bool allow_add = false; |
| 179 Function::Handle(Z, Resolver::ResolveDynamicForReceiverClass( | 179 const Function& function = Function::Handle( |
| 180 owner_class, call->function_name(), args_desc, | 180 Z, Resolver::ResolveDynamicForReceiverClass( |
| 181 false /* allow_add */)); | 181 owner_class, call->function_name(), args_desc, allow_add)); |
| 182 if (!function.IsNull()) { | 182 if (!function.IsNull()) { |
| 183 const ICData& ic_data = ICData::ZoneHandle( | 183 const ICData& ic_data = ICData::ZoneHandle( |
| 184 Z, ICData::NewFrom(*call->ic_data(), class_ids.length())); | 184 Z, ICData::NewFrom(*call->ic_data(), class_ids.length())); |
| 185 ic_data.AddReceiverCheck(owner_class.id(), function); | 185 ic_data.AddReceiverCheck(owner_class.id(), function); |
| 186 call->set_ic_data(&ic_data); | 186 call->set_ic_data(&ic_data); |
| 187 return true; | 187 return true; |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1451 if (class_id < 0) return false; | 1451 if (class_id < 0) return false; |
| 1452 if (class_id >= I->class_table()->NumCids()) return false; | 1452 if (class_id >= I->class_table()->NumCids()) return false; |
| 1453 | 1453 |
| 1454 RawClass* raw_class = I->class_table()->At(class_id); | 1454 RawClass* raw_class = I->class_table()->At(class_id); |
| 1455 if (raw_class == NULL) return false; | 1455 if (raw_class == NULL) return false; |
| 1456 Class& cls = Class::Handle(Z, raw_class); | 1456 Class& cls = Class::Handle(Z, raw_class); |
| 1457 if (cls.IsNull()) return false; | 1457 if (cls.IsNull()) return false; |
| 1458 if (!cls.is_finalized()) return false; | 1458 if (!cls.is_finalized()) return false; |
| 1459 if (Array::Handle(cls.functions()).IsNull()) return false; | 1459 if (Array::Handle(cls.functions()).IsNull()) return false; |
| 1460 | 1460 |
| 1461 Function& target_function = Function::Handle( | 1461 bool allow_add = false; |
| 1462 Z, Resolver::ResolveDynamicForReceiverClass(cls, name, args_desc)); | 1462 Function& target_function = |
| 1463 Function::Handle(Z, Resolver::ResolveDynamicForReceiverClass( | |
|
Vyacheslav Egorov (Google)
2017/04/07 05:53:00
How about adding an assertion into ResolveDynamicF
rmacnak
2017/04/07 16:42:57
It fails. I created https://github.com/dart-lang/s
| |
| 1464 cls, name, args_desc, allow_add)); | |
| 1463 if (target_function.IsNull()) return false; | 1465 if (target_function.IsNull()) return false; |
| 1464 *fn_return ^= target_function.raw(); | 1466 *fn_return ^= target_function.raw(); |
| 1465 return true; | 1467 return true; |
| 1466 } | 1468 } |
| 1467 | 1469 |
| 1468 | 1470 |
| 1469 static int OrderById(const intptr_t* a, const intptr_t* b) { | 1471 static int OrderById(const intptr_t* a, const intptr_t* b) { |
| 1470 // Negative if 'a' should sort before 'b'. | 1472 // Negative if 'a' should sort before 'b'. |
| 1471 return *a - *b; | 1473 return *a - *b; |
| 1472 } | 1474 } |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1870 // Discard the environment from the original instruction because the store | 1872 // Discard the environment from the original instruction because the store |
| 1871 // can't deoptimize. | 1873 // can't deoptimize. |
| 1872 instr->RemoveEnvironment(); | 1874 instr->RemoveEnvironment(); |
| 1873 ReplaceCall(instr, store); | 1875 ReplaceCall(instr, store); |
| 1874 return true; | 1876 return true; |
| 1875 } | 1877 } |
| 1876 | 1878 |
| 1877 | 1879 |
| 1878 } // namespace dart | 1880 } // namespace dart |
| 1879 #endif // DART_PRECOMPILED_RUNTIME | 1881 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |