| 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" |
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 12 #include "vm/exceptions.h" | 12 #include "vm/exceptions.h" |
| 13 #include "vm/flow_graph_builder.h" | 13 #include "vm/flow_graph_builder.h" |
| 14 #include "vm/flow_graph_compiler.h" | 14 #include "vm/flow_graph_compiler.h" |
| 15 #include "vm/flow_graph_range_analysis.h" | 15 #include "vm/flow_graph_range_analysis.h" |
| 16 #include "vm/hash_map.h" | 16 #include "vm/hash_map.h" |
| 17 #include "vm/il_printer.h" | 17 #include "vm/il_printer.h" |
| 18 #include "vm/intermediate_language.h" | 18 #include "vm/intermediate_language.h" |
| 19 #include "vm/object_store.h" | 19 #include "vm/object_store.h" |
| 20 #include "vm/parser.h" | 20 #include "vm/parser.h" |
| 21 #include "vm/precompiler.h" |
| 21 #include "vm/resolver.h" | 22 #include "vm/resolver.h" |
| 22 #include "vm/scopes.h" | 23 #include "vm/scopes.h" |
| 23 #include "vm/stack_frame.h" | 24 #include "vm/stack_frame.h" |
| 24 #include "vm/symbols.h" | 25 #include "vm/symbols.h" |
| 25 | 26 |
| 26 namespace dart { | 27 namespace dart { |
| 27 | 28 |
| 28 DEFINE_FLAG(int, getter_setter_ratio, 13, | 29 DEFINE_FLAG(int, getter_setter_ratio, 13, |
| 29 "Ratio of getter/setter usage used for double field unboxing heuristics"); | 30 "Ratio of getter/setter usage used for double field unboxing heuristics"); |
| 30 DEFINE_FLAG(bool, guess_other_cid, true, | 31 DEFINE_FLAG(bool, guess_other_cid, true, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 42 "Print live sets for load optimization pass."); | 43 "Print live sets for load optimization pass."); |
| 43 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); | 44 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); |
| 44 DEFINE_FLAG(bool, truncating_left_shift, true, | 45 DEFINE_FLAG(bool, truncating_left_shift, true, |
| 45 "Optimize left shift to truncate if possible"); | 46 "Optimize left shift to truncate if possible"); |
| 46 DEFINE_FLAG(bool, use_cha_deopt, true, | 47 DEFINE_FLAG(bool, use_cha_deopt, true, |
| 47 "Use class hierarchy analysis even if it can cause deoptimization."); | 48 "Use class hierarchy analysis even if it can cause deoptimization."); |
| 48 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_IA32) | 49 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_IA32) |
| 49 DEFINE_FLAG(bool, trace_smi_widening, false, "Trace Smi->Int32 widening pass."); | 50 DEFINE_FLAG(bool, trace_smi_widening, false, "Trace Smi->Int32 widening pass."); |
| 50 #endif | 51 #endif |
| 51 | 52 |
| 53 DECLARE_FLAG(bool, precompilation); |
| 52 DECLARE_FLAG(bool, polymorphic_with_deopt); | 54 DECLARE_FLAG(bool, polymorphic_with_deopt); |
| 53 DECLARE_FLAG(bool, source_lines); | 55 DECLARE_FLAG(bool, source_lines); |
| 54 DECLARE_FLAG(bool, trace_cha); | 56 DECLARE_FLAG(bool, trace_cha); |
| 55 DECLARE_FLAG(bool, trace_field_guards); | 57 DECLARE_FLAG(bool, trace_field_guards); |
| 56 DECLARE_FLAG(bool, trace_type_check_elimination); | 58 DECLARE_FLAG(bool, trace_type_check_elimination); |
| 57 DECLARE_FLAG(bool, warn_on_javascript_compatibility); | 59 DECLARE_FLAG(bool, warn_on_javascript_compatibility); |
| 58 DECLARE_FLAG(bool, fields_may_be_reset); | 60 DECLARE_FLAG(bool, fields_may_be_reset); |
| 59 | 61 |
| 60 // Quick access to the current isolate and zone. | 62 // Quick access to the current isolate and zone. |
| 61 #define I (isolate()) | 63 #define I (isolate()) |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 !CHA::HasSubclasses(owner_class) && | 262 !CHA::HasSubclasses(owner_class) && |
| 261 !CHA::IsImplemented(owner_class)) { | 263 !CHA::IsImplemented(owner_class)) { |
| 262 const Array& args_desc_array = Array::Handle(Z, | 264 const Array& args_desc_array = Array::Handle(Z, |
| 263 ArgumentsDescriptor::New(call->ArgumentCount(), | 265 ArgumentsDescriptor::New(call->ArgumentCount(), |
| 264 call->argument_names())); | 266 call->argument_names())); |
| 265 ArgumentsDescriptor args_desc(args_desc_array); | 267 ArgumentsDescriptor args_desc(args_desc_array); |
| 266 const Function& function = Function::Handle(Z, | 268 const Function& function = Function::Handle(Z, |
| 267 Resolver::ResolveDynamicForReceiverClass(owner_class, | 269 Resolver::ResolveDynamicForReceiverClass(owner_class, |
| 268 call->function_name(), | 270 call->function_name(), |
| 269 args_desc)); | 271 args_desc)); |
| 270 if (function.IsNull()) { | 272 if (!function.IsNull()) { |
| 271 return false; | 273 const ICData& ic_data = ICData::ZoneHandle(Z, |
| 274 ICData::NewFrom(*call->ic_data(), class_ids.length())); |
| 275 ic_data.AddReceiverCheck(owner_class.id(), function); |
| 276 call->set_ic_data(&ic_data); |
| 277 return true; |
| 272 } | 278 } |
| 279 } |
| 280 } |
| 281 |
| 282 if (FLAG_precompilation && |
| 283 (isolate()->object_store()->unique_dynamic_targets() != Array::null())) { |
| 284 // Check if the target is unique. |
| 285 Function& target_function = Function::Handle(Z); |
| 286 Precompiler::GetUniqueDynamicTarget( |
| 287 isolate(), call->function_name(), &target_function); |
| 288 // Calls with named arguments must be resolved/checked at runtime. |
| 289 String& error_message = String::Handle(Z); |
| 290 if (!target_function.IsNull() && |
| 291 !target_function.HasOptionalNamedParameters() && |
| 292 target_function.AreValidArgumentCounts(call->ArgumentCount(), 0, |
| 293 &error_message)) { |
| 294 const intptr_t cid = Class::Handle(Z, target_function.Owner()).id(); |
| 273 const ICData& ic_data = ICData::ZoneHandle(Z, | 295 const ICData& ic_data = ICData::ZoneHandle(Z, |
| 274 ICData::NewFrom(*call->ic_data(), class_ids.length())); | 296 ICData::NewFrom(*call->ic_data(), 1)); |
| 275 ic_data.AddReceiverCheck(owner_class.id(), function); | 297 ic_data.AddReceiverCheck(cid, target_function); |
| 276 call->set_ic_data(&ic_data); | 298 call->set_ic_data(&ic_data); |
| 277 return true; | 299 return true; |
| 278 } | 300 } |
| 279 } | 301 } |
| 280 | 302 |
| 281 return false; | 303 return false; |
| 282 } | 304 } |
| 283 | 305 |
| 284 | 306 |
| 285 const ICData& FlowGraphOptimizer::TrySpecializeICData(const ICData& ic_data, | 307 const ICData& FlowGraphOptimizer::TrySpecializeICData(const ICData& ic_data, |
| (...skipping 8545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8831 | 8853 |
| 8832 // Insert materializations at environment uses. | 8854 // Insert materializations at environment uses. |
| 8833 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 8855 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 8834 CreateMaterializationAt( | 8856 CreateMaterializationAt( |
| 8835 exits_collector_.exits()[i], alloc, *slots); | 8857 exits_collector_.exits()[i], alloc, *slots); |
| 8836 } | 8858 } |
| 8837 } | 8859 } |
| 8838 | 8860 |
| 8839 | 8861 |
| 8840 } // namespace dart | 8862 } // namespace dart |
| OLD | NEW |