Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: runtime/vm/flow_graph_compiler.cc

Issue 1149713002: With --noopt run unoptimized code through optimizer, more optimizations can be done later. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cleanup Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/globals.h" // Needed here to get TARGET_ARCH_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/cha.h" 10 #include "vm/cha.h"
11 #include "vm/compiler.h"
11 #include "vm/dart_entry.h" 12 #include "vm/dart_entry.h"
12 #include "vm/debugger.h" 13 #include "vm/debugger.h"
13 #include "vm/deopt_instructions.h" 14 #include "vm/deopt_instructions.h"
14 #include "vm/exceptions.h" 15 #include "vm/exceptions.h"
15 #include "vm/flow_graph_allocator.h" 16 #include "vm/flow_graph_allocator.h"
16 #include "vm/il_printer.h" 17 #include "vm/il_printer.h"
17 #include "vm/intrinsifier.h" 18 #include "vm/intrinsifier.h"
18 #include "vm/locations.h" 19 #include "vm/locations.h"
19 #include "vm/log.h" 20 #include "vm/log.h"
20 #include "vm/longjump.h" 21 #include "vm/longjump.h"
(...skipping 26 matching lines...) Expand all
47 DECLARE_FLAG(bool, disassemble_optimized); 48 DECLARE_FLAG(bool, disassemble_optimized);
48 DECLARE_FLAG(bool, emit_edge_counters); 49 DECLARE_FLAG(bool, emit_edge_counters);
49 DECLARE_FLAG(bool, intrinsify); 50 DECLARE_FLAG(bool, intrinsify);
50 DECLARE_FLAG(int, optimization_counter_threshold); 51 DECLARE_FLAG(int, optimization_counter_threshold);
51 DECLARE_FLAG(bool, propagate_ic_data); 52 DECLARE_FLAG(bool, propagate_ic_data);
52 DECLARE_FLAG(int, regexp_optimization_counter_threshold); 53 DECLARE_FLAG(int, regexp_optimization_counter_threshold);
53 DECLARE_FLAG(int, reoptimization_counter_threshold); 54 DECLARE_FLAG(int, reoptimization_counter_threshold);
54 DECLARE_FLAG(int, stacktrace_every); 55 DECLARE_FLAG(int, stacktrace_every);
55 DECLARE_FLAG(charp, stacktrace_filter); 56 DECLARE_FLAG(charp, stacktrace_filter);
56 DECLARE_FLAG(bool, support_debugger); 57 DECLARE_FLAG(bool, support_debugger);
57 DECLARE_FLAG(bool, use_cha);
58 DECLARE_FLAG(bool, use_field_guards); 58 DECLARE_FLAG(bool, use_field_guards);
59 DECLARE_FLAG(bool, use_osr); 59 DECLARE_FLAG(bool, use_osr);
60 DECLARE_FLAG(bool, warn_on_javascript_compatibility); 60 DECLARE_FLAG(bool, warn_on_javascript_compatibility);
61 DECLARE_FLAG(bool, ic_range_profiling); 61 DECLARE_FLAG(bool, ic_range_profiling);
62 62
63 static void NooptModeHandler(bool value) { 63 static void NooptModeHandler(bool value) {
64 if (value) { 64 if (value) {
65 FLAG_always_megamorphic_calls = value; 65 FLAG_always_megamorphic_calls = value;
66 FLAG_optimization_counter_threshold = -1; 66 FLAG_optimization_counter_threshold = -1;
67 FLAG_use_field_guards = false; 67 FLAG_use_field_guards = false;
68 FLAG_use_osr = false; 68 FLAG_use_osr = false;
69 FLAG_emit_edge_counters = false; 69 FLAG_emit_edge_counters = false;
70 FLAG_support_debugger = false; 70 FLAG_support_debugger = false;
71 FLAG_ic_range_profiling = false; 71 FLAG_ic_range_profiling = false;
72 FLAG_collect_code = false; 72 FLAG_collect_code = false;
73 Compiler::set_always_optimize(true);
74 Compiler::set_guess_other_cid(false);
73 } 75 }
74 } 76 }
75 77
76 78
77 // --noopt disables optimizer and tunes unoptimized code to run as fast 79 // --noopt disables optimizer and tunes unoptimized code to run as fast
78 // as possible. 80 // as possible.
79 DEFINE_FLAG_HANDLER(NooptModeHandler, 81 DEFINE_FLAG_HANDLER(NooptModeHandler,
80 noopt, 82 noopt,
81 "Run fast unoptimized code only."); 83 "Run fast unoptimized code only.");
82 84
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 BlockEntryInstr* entry = block_order_[i]; 201 BlockEntryInstr* entry = block_order_[i];
200 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { 202 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
201 Instruction* current = it.Current(); 203 Instruction* current = it.Current();
202 if (current->IsBranch()) { 204 if (current->IsBranch()) {
203 current = current->AsBranch()->comparison(); 205 current = current->AsBranch()->comparison();
204 } 206 }
205 // In optimized code, ICData is always set in the instructions. 207 // In optimized code, ICData is always set in the instructions.
206 const ICData* ic_data = NULL; 208 const ICData* ic_data = NULL;
207 if (current->IsInstanceCall()) { 209 if (current->IsInstanceCall()) {
208 ic_data = current->AsInstanceCall()->ic_data(); 210 ic_data = current->AsInstanceCall()->ic_data();
209 ASSERT(ic_data != NULL);
210 } 211 }
211 if ((ic_data != NULL) && (ic_data->NumberOfUsedChecks() == 0)) { 212 if ((ic_data != NULL) && (ic_data->NumberOfUsedChecks() == 0)) {
212 may_reoptimize_ = true; 213 may_reoptimize_ = true;
213 } 214 }
214 if (is_leaf && 215 if (is_leaf &&
215 !current->IsCheckStackOverflow() && 216 !current->IsCheckStackOverflow() &&
216 !current->IsParallelMove()) { 217 !current->IsParallelMove()) {
217 // Note that we do not care if the code contains instructions that 218 // Note that we do not care if the code contains instructions that
218 // can deoptimize. 219 // can deoptimize.
219 LocationSummary* locs = current->locs(); 220 LocationSummary* locs = current->locs();
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 } 840 }
840 841
841 842
842 Label* FlowGraphCompiler::AddDeoptStub(intptr_t deopt_id, 843 Label* FlowGraphCompiler::AddDeoptStub(intptr_t deopt_id,
843 ICData::DeoptReasonId reason, 844 ICData::DeoptReasonId reason,
844 uint32_t flags) { 845 uint32_t flags) {
845 if (intrinsic_mode()) { 846 if (intrinsic_mode()) {
846 return &intrinsic_slow_path_label_; 847 return &intrinsic_slow_path_label_;
847 } 848 }
848 849
850 // No deoptimization allowed when 'always_optimize' is set.
851 ASSERT(!Compiler::always_optimize());
849 ASSERT(is_optimizing_); 852 ASSERT(is_optimizing_);
850 CompilerDeoptInfoWithStub* stub = 853 CompilerDeoptInfoWithStub* stub =
851 new CompilerDeoptInfoWithStub(deopt_id, 854 new CompilerDeoptInfoWithStub(deopt_id,
852 reason, 855 reason,
853 flags, 856 flags,
854 pending_deoptimization_env_); 857 pending_deoptimization_env_);
855 deopt_infos_.Add(stub); 858 deopt_infos_.Add(stub);
856 return stub->entry_label(); 859 return stub->entry_label();
857 } 860 }
858 861
(...skipping 15 matching lines...) Expand all
874 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint())); 877 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint()));
875 if (!is_optimizing_) descriptors.Verify(parsed_function_.function()); 878 if (!is_optimizing_) descriptors.Verify(parsed_function_.function());
876 code.set_pc_descriptors(descriptors); 879 code.set_pc_descriptors(descriptors);
877 code.set_entry_patch_pc_offset(entry_patch_pc_offset_); 880 code.set_entry_patch_pc_offset(entry_patch_pc_offset_);
878 code.set_patch_code_pc_offset(patch_code_pc_offset_); 881 code.set_patch_code_pc_offset(patch_code_pc_offset_);
879 code.set_lazy_deopt_pc_offset(lazy_deopt_pc_offset_); 882 code.set_lazy_deopt_pc_offset(lazy_deopt_pc_offset_);
880 } 883 }
881 884
882 885
883 RawArray* FlowGraphCompiler::CreateDeoptInfo(Assembler* assembler) { 886 RawArray* FlowGraphCompiler::CreateDeoptInfo(Assembler* assembler) {
887 // No deopt information if we 'always_optimize' (no deoptimization allowed).
888 if (Compiler::always_optimize()) {
889 return Array::empty_array().raw();
890 }
884 // For functions with optional arguments, all incoming arguments are copied 891 // For functions with optional arguments, all incoming arguments are copied
885 // to spill slots. The deoptimization environment does not track them. 892 // to spill slots. The deoptimization environment does not track them.
886 const Function& function = parsed_function().function(); 893 const Function& function = parsed_function().function();
887 const intptr_t incoming_arg_count = 894 const intptr_t incoming_arg_count =
888 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); 895 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters();
889 DeoptInfoBuilder builder(zone(), incoming_arg_count, assembler); 896 DeoptInfoBuilder builder(zone(), incoming_arg_count, assembler);
890 897
891 intptr_t deopt_info_table_size = DeoptTable::SizeFor(deopt_infos_.length()); 898 intptr_t deopt_info_table_size = DeoptTable::SizeFor(deopt_infos_.length());
892 if (deopt_info_table_size == 0) { 899 if (deopt_info_table_size == 0) {
893 return Object::empty_array().raw(); 900 return Object::empty_array().raw();
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 1734
1728 1735
1729 void FlowGraphCompiler::FrameStateClear() { 1736 void FlowGraphCompiler::FrameStateClear() {
1730 ASSERT(!is_optimizing()); 1737 ASSERT(!is_optimizing());
1731 frame_state_.TruncateTo(0); 1738 frame_state_.TruncateTo(0);
1732 } 1739 }
1733 #endif 1740 #endif
1734 1741
1735 1742
1736 } // namespace dart 1743 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698