| 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 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 new (Z) PolymorphicInstanceCallInstr(instr, ic_data, | 1826 new (Z) PolymorphicInstanceCallInstr(instr, ic_data, |
| 1827 /* with_checks = */ false, | 1827 /* with_checks = */ false, |
| 1828 /* complete = */ true); | 1828 /* complete = */ true); |
| 1829 instr->ReplaceWith(call, current_iterator()); | 1829 instr->ReplaceWith(call, current_iterator()); |
| 1830 return; | 1830 return; |
| 1831 } | 1831 } |
| 1832 } | 1832 } |
| 1833 | 1833 |
| 1834 Definition* callee_receiver = instr->ArgumentAt(0); | 1834 Definition* callee_receiver = instr->ArgumentAt(0); |
| 1835 const Function& function = flow_graph_->function(); | 1835 const Function& function = flow_graph_->function(); |
| 1836 Class& receiver_class = Class::Handle(Z); |
| 1837 |
| 1836 if (function.IsDynamicFunction() && | 1838 if (function.IsDynamicFunction() && |
| 1837 flow_graph_->IsReceiver(callee_receiver)) { | 1839 flow_graph_->IsReceiver(callee_receiver)) { |
| 1838 // Call receiver is method receiver. | 1840 // Call receiver is method receiver. |
| 1839 Class& receiver_class = Class::Handle(Z, function.Owner()); | 1841 receiver_class = function.Owner(); |
| 1840 | 1842 } else { |
| 1843 CompileType* type = instr->ArgumentAt(0)->Type(); |
| 1844 if (type->ToAbstractType()->IsType() && |
| 1845 !type->ToAbstractType()->IsDynamicType() && !type->is_nullable()) { |
| 1846 receiver_class = type->ToAbstractType()->type_class(); |
| 1847 if (receiver_class.is_implemented()) { |
| 1848 receiver_class = Class::null(); |
| 1849 } |
| 1850 } |
| 1851 } |
| 1852 if (!receiver_class.IsNull()) { |
| 1841 GrowableArray<intptr_t> class_ids(6); | 1853 GrowableArray<intptr_t> class_ids(6); |
| 1842 if (thread()->cha()->ConcreteSubclasses(receiver_class, &class_ids)) { | 1854 if (thread()->cha()->ConcreteSubclasses(receiver_class, &class_ids)) { |
| 1843 // First check if all subclasses end up calling the same method. | 1855 // First check if all subclasses end up calling the same method. |
| 1844 // If this is the case we will replace instance call with a direct | 1856 // If this is the case we will replace instance call with a direct |
| 1845 // static call. | 1857 // static call. |
| 1846 // Otherwise we will try to create ICData that contains all possible | 1858 // Otherwise we will try to create ICData that contains all possible |
| 1847 // targets with appropriate checks. | 1859 // targets with appropriate checks. |
| 1848 Function& single_target = Function::Handle(Z); | 1860 Function& single_target = Function::Handle(Z); |
| 1849 ICData& ic_data = ICData::Handle(Z); | 1861 ICData& ic_data = ICData::Handle(Z); |
| 1850 | 1862 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 FlowGraph::kEffect); | 2161 FlowGraph::kEffect); |
| 2150 current_iterator()->RemoveCurrentFromGraph(); | 2162 current_iterator()->RemoveCurrentFromGraph(); |
| 2151 } | 2163 } |
| 2152 } | 2164 } |
| 2153 } | 2165 } |
| 2154 } | 2166 } |
| 2155 | 2167 |
| 2156 #endif // DART_PRECOMPILER | 2168 #endif // DART_PRECOMPILER |
| 2157 | 2169 |
| 2158 } // namespace dart | 2170 } // namespace dart |
| OLD | NEW |