| 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/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 | 952 |
| 953 // Returns true if ICData tests two arguments and all ICData cids are in the | 953 // Returns true if ICData tests two arguments and all ICData cids are in the |
| 954 // required sets 'receiver_class_ids' or 'argument_class_ids', respectively. | 954 // required sets 'receiver_class_ids' or 'argument_class_ids', respectively. |
| 955 static bool ICDataHasOnlyReceiverArgumentClassIds( | 955 static bool ICDataHasOnlyReceiverArgumentClassIds( |
| 956 const ICData& ic_data, | 956 const ICData& ic_data, |
| 957 const GrowableArray<intptr_t>& receiver_class_ids, | 957 const GrowableArray<intptr_t>& receiver_class_ids, |
| 958 const GrowableArray<intptr_t>& argument_class_ids) { | 958 const GrowableArray<intptr_t>& argument_class_ids) { |
| 959 if (ic_data.NumArgsTested() != 2) { | 959 if (ic_data.NumArgsTested() != 2) { |
| 960 return false; | 960 return false; |
| 961 } | 961 } |
| 962 Function& target = Function::Handle(); | |
| 963 const intptr_t len = ic_data.NumberOfChecks(); | 962 const intptr_t len = ic_data.NumberOfChecks(); |
| 964 GrowableArray<intptr_t> class_ids; | 963 GrowableArray<intptr_t> class_ids; |
| 965 for (intptr_t i = 0; i < len; i++) { | 964 for (intptr_t i = 0; i < len; i++) { |
| 966 if (ic_data.IsUsedAt(i)) { | 965 if (ic_data.IsUsedAt(i)) { |
| 967 ic_data.GetCheckAt(i, &class_ids, &target); | 966 ic_data.GetClassIdsAt(i, &class_ids); |
| 968 ASSERT(class_ids.length() == 2); | 967 ASSERT(class_ids.length() == 2); |
| 969 if (!ClassIdIsOneOf(class_ids[0], receiver_class_ids) || | 968 if (!ClassIdIsOneOf(class_ids[0], receiver_class_ids) || |
| 970 !ClassIdIsOneOf(class_ids[1], argument_class_ids)) { | 969 !ClassIdIsOneOf(class_ids[1], argument_class_ids)) { |
| 971 return false; | 970 return false; |
| 972 } | 971 } |
| 973 } | 972 } |
| 974 } | 973 } |
| 975 return true; | 974 return true; |
| 976 } | 975 } |
| 977 | 976 |
| 978 | 977 |
| 979 static bool ICDataHasReceiverArgumentClassIds(const ICData& ic_data, | 978 static bool ICDataHasReceiverArgumentClassIds(const ICData& ic_data, |
| 980 intptr_t receiver_class_id, | 979 intptr_t receiver_class_id, |
| 981 intptr_t argument_class_id) { | 980 intptr_t argument_class_id) { |
| 982 if (ic_data.NumArgsTested() != 2) { | 981 if (ic_data.NumArgsTested() != 2) { |
| 983 return false; | 982 return false; |
| 984 } | 983 } |
| 985 Function& target = Function::Handle(); | |
| 986 const intptr_t len = ic_data.NumberOfChecks(); | 984 const intptr_t len = ic_data.NumberOfChecks(); |
| 987 for (intptr_t i = 0; i < len; i++) { | 985 for (intptr_t i = 0; i < len; i++) { |
| 988 if (ic_data.IsUsedAt(i)) { | 986 if (ic_data.IsUsedAt(i)) { |
| 989 GrowableArray<intptr_t> class_ids; | 987 GrowableArray<intptr_t> class_ids; |
| 990 ic_data.GetCheckAt(i, &class_ids, &target); | 988 ic_data.GetClassIdsAt(i, &class_ids); |
| 991 ASSERT(class_ids.length() == 2); | 989 ASSERT(class_ids.length() == 2); |
| 992 if ((class_ids[0] == receiver_class_id) && | 990 if ((class_ids[0] == receiver_class_id) && |
| 993 (class_ids[1] == argument_class_id)) { | 991 (class_ids[1] == argument_class_id)) { |
| 994 return true; | 992 return true; |
| 995 } | 993 } |
| 996 } | 994 } |
| 997 } | 995 } |
| 998 return false; | 996 return false; |
| 999 } | 997 } |
| 1000 | 998 |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2351 } | 2349 } |
| 2352 return true; | 2350 return true; |
| 2353 } | 2351 } |
| 2354 | 2352 |
| 2355 | 2353 |
| 2356 bool FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call, | 2354 bool FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call, |
| 2357 bool allow_check) { | 2355 bool allow_check) { |
| 2358 ASSERT(call->HasICData()); | 2356 ASSERT(call->HasICData()); |
| 2359 const ICData& ic_data = *call->ic_data(); | 2357 const ICData& ic_data = *call->ic_data(); |
| 2360 ASSERT(ic_data.HasOneTarget()); | 2358 ASSERT(ic_data.HasOneTarget()); |
| 2361 Function& target = Function::Handle(Z); | |
| 2362 GrowableArray<intptr_t> class_ids; | 2359 GrowableArray<intptr_t> class_ids; |
| 2363 ic_data.GetCheckAt(0, &class_ids, &target); | 2360 ic_data.GetClassIdsAt(0, &class_ids); |
| 2364 ASSERT(class_ids.length() == 1); | 2361 ASSERT(class_ids.length() == 1); |
| 2365 // Inline implicit instance getter. | 2362 // Inline implicit instance getter. |
| 2366 const String& field_name = | 2363 const String& field_name = |
| 2367 String::Handle(Z, Field::NameFromGetter(call->function_name())); | 2364 String::Handle(Z, Field::NameFromGetter(call->function_name())); |
| 2368 const Field& field = | 2365 const Field& field = |
| 2369 Field::ZoneHandle(Z, GetField(class_ids[0], field_name)); | 2366 Field::ZoneHandle(Z, GetField(class_ids[0], field_name)); |
| 2370 ASSERT(!field.IsNull()); | 2367 ASSERT(!field.IsNull()); |
| 2371 | 2368 |
| 2372 if (InstanceCallNeedsClassCheck(call, RawFunction::kImplicitGetter)) { | 2369 if (InstanceCallNeedsClassCheck(call, RawFunction::kImplicitGetter)) { |
| 2373 if (!allow_check) { | 2370 if (!allow_check) { |
| (...skipping 6453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8827 | 8824 |
| 8828 // Insert materializations at environment uses. | 8825 // Insert materializations at environment uses. |
| 8829 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 8826 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 8830 CreateMaterializationAt( | 8827 CreateMaterializationAt( |
| 8831 exits_collector_.exits()[i], alloc, *slots); | 8828 exits_collector_.exits()[i], alloc, *slots); |
| 8832 } | 8829 } |
| 8833 } | 8830 } |
| 8834 | 8831 |
| 8835 | 8832 |
| 8836 } // namespace dart | 8833 } // namespace dart |
| OLD | NEW |