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/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2268 // callee functions, then no class check is needed. | 2268 // callee functions, then no class check is needed. |
2269 bool FlowGraphOptimizer::InstanceCallNeedsClassCheck( | 2269 bool FlowGraphOptimizer::InstanceCallNeedsClassCheck( |
2270 InstanceCallInstr* call) const { | 2270 InstanceCallInstr* call) const { |
2271 if (!FLAG_use_cha) return true; | 2271 if (!FLAG_use_cha) return true; |
2272 Definition* callee_receiver = call->ArgumentAt(0); | 2272 Definition* callee_receiver = call->ArgumentAt(0); |
2273 ASSERT(callee_receiver != NULL); | 2273 ASSERT(callee_receiver != NULL); |
2274 const Function& function = flow_graph_->parsed_function().function(); | 2274 const Function& function = flow_graph_->parsed_function().function(); |
2275 if (function.IsDynamicFunction() && | 2275 if (function.IsDynamicFunction() && |
2276 callee_receiver->IsParameter() && | 2276 callee_receiver->IsParameter() && |
2277 (callee_receiver->AsParameter()->index() == 0)) { | 2277 (callee_receiver->AsParameter()->index() == 0)) { |
2278 return CHA::HasOverride(Class::Handle(I, function.Owner()), | 2278 return isolate()->cha()->HasOverride(Class::Handle(I, function.Owner()), |
2279 call->function_name()); | 2279 call->function_name()); |
2280 } | 2280 } |
2281 return true; | 2281 return true; |
2282 } | 2282 } |
2283 | 2283 |
2284 | 2284 |
2285 bool FlowGraphOptimizer::MethodExtractorNeedsClassCheck( | 2285 bool FlowGraphOptimizer::MethodExtractorNeedsClassCheck( |
2286 InstanceCallInstr* call) const { | 2286 InstanceCallInstr* call) const { |
2287 if (!FLAG_use_cha) return true; | 2287 if (!FLAG_use_cha) return true; |
2288 Definition* callee_receiver = call->ArgumentAt(0); | 2288 Definition* callee_receiver = call->ArgumentAt(0); |
2289 ASSERT(callee_receiver != NULL); | 2289 ASSERT(callee_receiver != NULL); |
2290 const Function& function = flow_graph_->parsed_function().function(); | 2290 const Function& function = flow_graph_->parsed_function().function(); |
2291 if (function.IsDynamicFunction() && | 2291 if (function.IsDynamicFunction() && |
2292 callee_receiver->IsParameter() && | 2292 callee_receiver->IsParameter() && |
2293 (callee_receiver->AsParameter()->index() == 0)) { | 2293 (callee_receiver->AsParameter()->index() == 0)) { |
2294 const String& field_name = | 2294 const String& field_name = |
2295 String::Handle(I, Field::NameFromGetter(call->function_name())); | 2295 String::Handle(I, Field::NameFromGetter(call->function_name())); |
2296 return CHA::HasOverride(Class::Handle(I, function.Owner()), field_name); | 2296 return isolate()->cha()->HasOverride( |
2297 Class::Handle(I, function.Owner()), field_name); | |
2297 } | 2298 } |
2298 return true; | 2299 return true; |
2299 } | 2300 } |
2300 | 2301 |
2301 | 2302 |
2302 void FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call) { | 2303 void FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call) { |
2303 ASSERT(call->HasICData()); | 2304 ASSERT(call->HasICData()); |
2304 const ICData& ic_data = *call->ic_data(); | 2305 const ICData& ic_data = *call->ic_data(); |
2305 ASSERT(ic_data.HasOneTarget()); | 2306 ASSERT(ic_data.HasOneTarget()); |
2306 Function& target = Function::Handle(I); | 2307 Function& target = Function::Handle(I); |
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3886 if (is_subtype != prev.value()) { | 3887 if (is_subtype != prev.value()) { |
3887 results_differ = true; | 3888 results_differ = true; |
3888 } | 3889 } |
3889 } | 3890 } |
3890 } | 3891 } |
3891 return results_differ ? Bool::null() : prev.raw(); | 3892 return results_differ ? Bool::null() : prev.raw(); |
3892 } | 3893 } |
3893 | 3894 |
3894 | 3895 |
3895 // Returns true if checking against this type is a direct class id comparison. | 3896 // Returns true if checking against this type is a direct class id comparison. |
3896 static bool TypeCheckAsClassEquality(const AbstractType& type) { | 3897 bool FlowGraphOptimizer::TypeCheckAsClassEquality(const AbstractType& type) { |
3897 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); | 3898 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); |
3898 // Requires CHA. | 3899 // Requires CHA. |
3899 if (!FLAG_use_cha) return false; | 3900 if (!FLAG_use_cha) return false; |
3900 if (!type.IsInstantiated()) return false; | 3901 if (!type.IsInstantiated()) return false; |
3901 const Class& type_class = Class::Handle(type.type_class()); | 3902 const Class& type_class = Class::ZoneHandle(type.type_class()); |
Vyacheslav Egorov (Google)
2014/08/12 12:16:56
Why ZoneHandle?
Florian Schneider
2014/08/13 10:34:40
Done.
| |
3902 // Signature classes have different type checking rules. | 3903 // Signature classes have different type checking rules. |
3903 if (type_class.IsSignatureClass()) return false; | 3904 if (type_class.IsSignatureClass()) return false; |
3904 // Could be an interface check? | 3905 // Could be an interface check? |
3905 if (type_class.is_implemented()) return false; | 3906 if (type_class.is_implemented()) return false; |
3906 const intptr_t type_cid = type_class.id(); | 3907 const intptr_t type_cid = type_class.id(); |
3907 if (CHA::HasSubclasses(type_cid)) return false; | 3908 if (isolate()->cha()->HasSubclasses(type_cid)) return false; |
3908 const intptr_t num_type_args = type_class.NumTypeArguments(); | 3909 const intptr_t num_type_args = type_class.NumTypeArguments(); |
3909 if (num_type_args > 0) { | 3910 if (num_type_args > 0) { |
3910 // Only raw types can be directly compared, thus disregarding type | 3911 // Only raw types can be directly compared, thus disregarding type |
3911 // arguments. | 3912 // arguments. |
3912 const intptr_t num_type_params = type_class.NumTypeParameters(); | 3913 const intptr_t num_type_params = type_class.NumTypeParameters(); |
3913 const intptr_t from_index = num_type_args - num_type_params; | 3914 const intptr_t from_index = num_type_args - num_type_params; |
3914 const TypeArguments& type_arguments = | 3915 const TypeArguments& type_arguments = |
3915 TypeArguments::Handle(type.arguments()); | 3916 TypeArguments::Handle(type.arguments()); |
3916 const bool is_raw_type = type_arguments.IsNull() || | 3917 const bool is_raw_type = type_arguments.IsNull() || |
3917 type_arguments.IsRaw(from_index, num_type_params); | 3918 type_arguments.IsRaw(from_index, num_type_params); |
(...skipping 5582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9500 | 9501 |
9501 // Insert materializations at environment uses. | 9502 // Insert materializations at environment uses. |
9502 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 9503 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
9503 CreateMaterializationAt( | 9504 CreateMaterializationAt( |
9504 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); | 9505 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); |
9505 } | 9506 } |
9506 } | 9507 } |
9507 | 9508 |
9508 | 9509 |
9509 } // namespace dart | 9510 } // namespace dart |
OLD | NEW |