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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/constant_propagator.h" | 10 #include "vm/constant_propagator.h" |
(...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2942 | 2942 |
2943 Function& fn = Function::Handle(zone); | 2943 Function& fn = Function::Handle(zone); |
2944 | 2944 |
2945 intptr_t length = targets.length(); | 2945 intptr_t length = targets.length(); |
2946 | 2946 |
2947 // Spread class-ids to preceding classes where a lookup yields the same | 2947 // Spread class-ids to preceding classes where a lookup yields the same |
2948 // method. | 2948 // method. |
2949 for (int idx = 0; idx < length; idx++) { | 2949 for (int idx = 0; idx < length; idx++) { |
2950 int lower_limit_cid = (idx == 0) ? -1 : targets[idx - 1].cid_end; | 2950 int lower_limit_cid = (idx == 0) ? -1 : targets[idx - 1].cid_end; |
2951 const Function& target = *targets.TargetAt(idx)->target; | 2951 const Function& target = *targets.TargetAt(idx)->target; |
2952 if (MethodRecognizer::PolymorphicTarget(target)) continue; | |
2952 for (int i = targets[idx].cid_start - 1; i > lower_limit_cid; i--) { | 2953 for (int i = targets[idx].cid_start - 1; i > lower_limit_cid; i--) { |
2953 if (FlowGraphCompiler::LookupMethodFor(i, name, args_desc, &fn) && | 2954 if (FlowGraphCompiler::LookupMethodFor(i, name, args_desc, &fn) && |
2954 fn.raw() == target.raw()) { | 2955 fn.raw() == target.raw()) { |
2955 targets[idx].cid_start = i; | 2956 targets[idx].cid_start = i; |
2956 } else { | 2957 } else { |
2957 break; | 2958 break; |
2958 } | 2959 } |
2959 } | 2960 } |
2960 } | 2961 } |
2961 // Spread class-ids to following classes where a lookup yields the same | 2962 // Spread class-ids to following classes where a lookup yields the same |
2962 // method. | 2963 // method. |
2963 for (int idx = 0; idx < length; idx++) { | 2964 for (int idx = 0; idx < length; idx++) { |
2964 int upper_limit_cid = | 2965 int upper_limit_cid = |
2965 (idx == length - 1) ? 1000000000 : targets[idx + 1].cid_start; | 2966 (idx == length - 1) ? 1000000000 : targets[idx + 1].cid_start; |
2966 const Function& target = *targets.TargetAt(idx)->target; | 2967 const Function& target = *targets.TargetAt(idx)->target; |
2968 if (MethodRecognizer::PolymorphicTarget(target)) continue; | |
2967 for (int i = targets[idx].cid_end + 1; i < upper_limit_cid; i++) { | 2969 for (int i = targets[idx].cid_end + 1; i < upper_limit_cid; i++) { |
2968 if (FlowGraphCompiler::LookupMethodFor(i, name, args_desc, &fn) && | 2970 if (FlowGraphCompiler::LookupMethodFor(i, name, args_desc, &fn) && |
2969 fn.raw() == target.raw()) { | 2971 fn.raw() == target.raw()) { |
2970 targets[idx].cid_end = i; | 2972 targets[idx].cid_end = i; |
2971 } else { | 2973 } else { |
2972 break; | 2974 break; |
2973 } | 2975 } |
2974 } | 2976 } |
2975 } | 2977 } |
2976 targets.MergeIntoRanges(); | 2978 targets.MergeIntoRanges(); |
Vyacheslav Egorov (Google)
2017/06/23 16:09:46
This will merge stuff together if you have two pol
erikcorry
2017/06/23 17:10:22
Done.
| |
2977 return &targets; | 2979 return &targets; |
2978 } | 2980 } |
2979 | 2981 |
2980 | 2982 |
2981 void CallTargets::MergeIntoRanges() { | 2983 void CallTargets::MergeIntoRanges() { |
2982 // Merge adjacent class id ranges. | 2984 // Merge adjacent class id ranges. |
2983 int dest = 0; | 2985 int dest = 0; |
2984 for (int src = 1; src < length(); src++) { | 2986 for (int src = 1; src < length(); src++) { |
2985 if (TargetAt(dest)->cid_end + 1 >= TargetAt(src)->cid_start && | 2987 if (TargetAt(dest)->cid_end + 1 >= TargetAt(src)->cid_start && |
2986 TargetAt(dest)->target->raw() == TargetAt(src)->target->raw()) { | 2988 TargetAt(dest)->target->raw() == TargetAt(src)->target->raw()) { |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4359 "native function '%s' (%" Pd " arguments) cannot be found", | 4361 "native function '%s' (%" Pd " arguments) cannot be found", |
4360 native_name().ToCString(), function().NumParameters()); | 4362 native_name().ToCString(), function().NumParameters()); |
4361 } | 4363 } |
4362 set_is_auto_scope(auto_setup_scope); | 4364 set_is_auto_scope(auto_setup_scope); |
4363 set_native_c_function(native_function); | 4365 set_native_c_function(native_function); |
4364 } | 4366 } |
4365 | 4367 |
4366 #undef __ | 4368 #undef __ |
4367 | 4369 |
4368 } // namespace dart | 4370 } // namespace dart |
OLD | NEW |