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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 DEFINE_FLAG(bool, truncating_left_shift, true, | 44 DEFINE_FLAG(bool, truncating_left_shift, true, |
45 "Optimize left shift to truncate if possible"); | 45 "Optimize left shift to truncate if possible"); |
46 DEFINE_FLAG(bool, use_cha_deopt, true, | 46 DEFINE_FLAG(bool, use_cha_deopt, true, |
47 "Use class hierarchy analysis even if it can cause deoptimization."); | 47 "Use class hierarchy analysis even if it can cause deoptimization."); |
48 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_IA32) | 48 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_IA32) |
49 DEFINE_FLAG(bool, trace_smi_widening, false, "Trace Smi->Int32 widening pass."); | 49 DEFINE_FLAG(bool, trace_smi_widening, false, "Trace Smi->Int32 widening pass."); |
50 #endif | 50 #endif |
51 | 51 |
52 DECLARE_FLAG(bool, polymorphic_with_deopt); | 52 DECLARE_FLAG(bool, polymorphic_with_deopt); |
53 DECLARE_FLAG(bool, source_lines); | 53 DECLARE_FLAG(bool, source_lines); |
| 54 DECLARE_FLAG(bool, trace_cha); |
54 DECLARE_FLAG(bool, trace_field_guards); | 55 DECLARE_FLAG(bool, trace_field_guards); |
55 DECLARE_FLAG(bool, trace_type_check_elimination); | 56 DECLARE_FLAG(bool, trace_type_check_elimination); |
56 DECLARE_FLAG(bool, warn_on_javascript_compatibility); | 57 DECLARE_FLAG(bool, warn_on_javascript_compatibility); |
57 | 58 |
58 // Quick access to the current isolate and zone. | 59 // Quick access to the current isolate and zone. |
59 #define I (isolate()) | 60 #define I (isolate()) |
60 #define Z (zone()) | 61 #define Z (zone()) |
61 | 62 |
62 static bool ShouldInlineSimd() { | 63 static bool ShouldInlineSimd() { |
63 return FlowGraphCompiler::SupportsUnboxedSimd128(); | 64 return FlowGraphCompiler::SupportsUnboxedSimd128(); |
(...skipping 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2328 ASSERT(callee_receiver != NULL); | 2329 ASSERT(callee_receiver != NULL); |
2329 const Function& function = flow_graph_->function(); | 2330 const Function& function = flow_graph_->function(); |
2330 if (function.IsDynamicFunction() && | 2331 if (function.IsDynamicFunction() && |
2331 callee_receiver->IsParameter() && | 2332 callee_receiver->IsParameter() && |
2332 (callee_receiver->AsParameter()->index() == 0)) { | 2333 (callee_receiver->AsParameter()->index() == 0)) { |
2333 const String& name = (kind == RawFunction::kMethodExtractor) | 2334 const String& name = (kind == RawFunction::kMethodExtractor) |
2334 ? String::Handle(Z, Field::NameFromGetter(call->function_name())) | 2335 ? String::Handle(Z, Field::NameFromGetter(call->function_name())) |
2335 : call->function_name(); | 2336 : call->function_name(); |
2336 const Class& cls = Class::Handle(Z, function.Owner()); | 2337 const Class& cls = Class::Handle(Z, function.Owner()); |
2337 if (!thread()->cha()->HasOverride(cls, name)) { | 2338 if (!thread()->cha()->HasOverride(cls, name)) { |
| 2339 if (FLAG_trace_cha) { |
| 2340 ISL_Print(" **(CHA) Instance call needs no check, " |
| 2341 "no overrides of '%s' '%s'\n", |
| 2342 name.ToCString(), cls.ToCString()); |
| 2343 } |
2338 thread()->cha()->AddToLeafClasses(cls); | 2344 thread()->cha()->AddToLeafClasses(cls); |
2339 return false; | 2345 return false; |
2340 } | 2346 } |
2341 } | 2347 } |
2342 return true; | 2348 return true; |
2343 } | 2349 } |
2344 | 2350 |
2345 | 2351 |
2346 bool FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call, | 2352 bool FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call, |
2347 bool allow_check) { | 2353 bool allow_check) { |
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4022 // Could be an interface check? | 4028 // Could be an interface check? |
4023 if (CHA::IsImplemented(type_class)) return false; | 4029 if (CHA::IsImplemented(type_class)) return false; |
4024 // Check if there are subclasses. | 4030 // Check if there are subclasses. |
4025 if (CHA::HasSubclasses(type_class)) { | 4031 if (CHA::HasSubclasses(type_class)) { |
4026 return false; | 4032 return false; |
4027 } | 4033 } |
4028 | 4034 |
4029 // Private classes cannot be subclassed by later loaded libs. | 4035 // Private classes cannot be subclassed by later loaded libs. |
4030 if (!type_class.IsPrivate()) { | 4036 if (!type_class.IsPrivate()) { |
4031 if (FLAG_use_cha_deopt) { | 4037 if (FLAG_use_cha_deopt) { |
| 4038 if (FLAG_trace_cha) { |
| 4039 ISL_Print(" **(CHA) Typecheck as class equality since no " |
| 4040 "subclasses: %s\n", |
| 4041 type_class.ToCString()); |
| 4042 } |
4032 thread()->cha()->AddToLeafClasses(type_class); | 4043 thread()->cha()->AddToLeafClasses(type_class); |
4033 } else { | 4044 } else { |
4034 return false; | 4045 return false; |
4035 } | 4046 } |
4036 } | 4047 } |
4037 const intptr_t num_type_args = type_class.NumTypeArguments(); | 4048 const intptr_t num_type_args = type_class.NumTypeArguments(); |
4038 if (num_type_args > 0) { | 4049 if (num_type_args > 0) { |
4039 // Only raw types can be directly compared, thus disregarding type | 4050 // Only raw types can be directly compared, thus disregarding type |
4040 // arguments. | 4051 // arguments. |
4041 const intptr_t num_type_params = type_class.NumTypeParameters(); | 4052 const intptr_t num_type_params = type_class.NumTypeParameters(); |
(...skipping 4729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8771 | 8782 |
8772 // Insert materializations at environment uses. | 8783 // Insert materializations at environment uses. |
8773 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 8784 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
8774 CreateMaterializationAt( | 8785 CreateMaterializationAt( |
8775 exits_collector_.exits()[i], alloc, *slots); | 8786 exits_collector_.exits()[i], alloc, *slots); |
8776 } | 8787 } |
8777 } | 8788 } |
8778 | 8789 |
8779 | 8790 |
8780 } // namespace dart | 8791 } // namespace dart |
OLD | NEW |