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

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

Issue 14308009: Detect leaf optimized methods and skip stack check overflow test in those, unless it is in a loop (… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cha.h" 9 #include "vm/cha.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder->CreateDeoptInfo()); 122 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder->CreateDeoptInfo());
123 return deopt_info.raw(); 123 return deopt_info.raw();
124 } 124 }
125 125
126 126
127 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, 127 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler,
128 const FlowGraph& flow_graph, 128 const FlowGraph& flow_graph,
129 bool is_optimizing) 129 bool is_optimizing)
130 : assembler_(assembler), 130 : assembler_(assembler),
131 parsed_function_(flow_graph.parsed_function()), 131 parsed_function_(flow_graph.parsed_function()),
132 flow_graph_(flow_graph),
132 block_order_(flow_graph.reverse_postorder()), 133 block_order_(flow_graph.reverse_postorder()),
133 current_block_(NULL), 134 current_block_(NULL),
134 exception_handlers_list_(NULL), 135 exception_handlers_list_(NULL),
135 pc_descriptors_list_(NULL), 136 pc_descriptors_list_(NULL),
136 stackmap_table_builder_( 137 stackmap_table_builder_(
137 is_optimizing ? new StackmapTableBuilder() : NULL), 138 is_optimizing ? new StackmapTableBuilder() : NULL),
138 block_info_(block_order_.length()), 139 block_info_(block_order_.length()),
139 deopt_infos_(), 140 deopt_infos_(),
140 static_calls_target_table_(GrowableObjectArray::ZoneHandle( 141 static_calls_target_table_(GrowableObjectArray::ZoneHandle(
141 GrowableObjectArray::New())), 142 GrowableObjectArray::New())),
(...skipping 11 matching lines...) Expand all
153 154
154 bool FlowGraphCompiler::HasFinally() const { 155 bool FlowGraphCompiler::HasFinally() const {
155 return parsed_function().function().has_finally(); 156 return parsed_function().function().has_finally();
156 } 157 }
157 158
158 159
159 void FlowGraphCompiler::InitCompiler() { 160 void FlowGraphCompiler::InitCompiler() {
160 pc_descriptors_list_ = new DescriptorList(64); 161 pc_descriptors_list_ = new DescriptorList(64);
161 exception_handlers_list_ = new ExceptionHandlerList(); 162 exception_handlers_list_ = new ExceptionHandlerList();
162 block_info_.Clear(); 163 block_info_.Clear();
164 bool is_leaf = !parsed_function().function().IsClosureFunction() &&
165 is_optimizing();
163 for (int i = 0; i < block_order_.length(); ++i) { 166 for (int i = 0; i < block_order_.length(); ++i) {
164 block_info_.Add(new BlockInfo()); 167 block_info_.Add(new BlockInfo());
165 if (is_optimizing()) { 168 if (is_optimizing()) {
166 BlockEntryInstr* entry = block_order_[i]; 169 BlockEntryInstr* entry = block_order_[i];
167 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { 170 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
168 Instruction* current = it.Current(); 171 Instruction* current = it.Current();
169 const ICData* ic_data = NULL; 172 const ICData* ic_data = NULL;
170 if (current->IsBranch()) { 173 if (current->IsBranch()) {
171 current = current->AsBranch()->comparison(); 174 current = current->AsBranch()->comparison();
172 } 175 }
173 // In optimized code, ICData is always set in the instructions. 176 // In optimized code, ICData is always set in the instructions.
174 if (current->IsInstanceCall()) { 177 if (current->IsInstanceCall()) {
175 ic_data = current->AsInstanceCall()->ic_data(); 178 ic_data = current->AsInstanceCall()->ic_data();
176 ASSERT(ic_data != NULL); 179 ASSERT(ic_data != NULL);
177 } else if (current->IsRelationalOp()) { 180 } else if (current->IsRelationalOp()) {
178 ic_data = current->AsRelationalOp()->ic_data(); 181 ic_data = current->AsRelationalOp()->ic_data();
179 ASSERT(ic_data != NULL); 182 ASSERT(ic_data != NULL);
180 } else if (current->IsEqualityCompare()) { 183 } else if (current->IsEqualityCompare()) {
181 ic_data = current->AsEqualityCompare()->ic_data(); 184 ic_data = current->AsEqualityCompare()->ic_data();
182 ASSERT(ic_data != NULL); 185 ASSERT(ic_data != NULL);
183 } 186 }
184 if ((ic_data != NULL) && (ic_data->NumberOfChecks() == 0)) { 187 if ((ic_data != NULL) && (ic_data->NumberOfChecks() == 0)) {
185 may_reoptimize_ = true; 188 may_reoptimize_ = true;
186 break; 189 break;
187 } 190 }
191 if (is_leaf && !current->IsCheckStackOverflow()) {
192 // Note that we do no care if the code contains instructions that
193 // can deoptimize.
194 LocationSummary* locs = current->locs();
195 if ((locs != NULL) && locs->can_call()) {
196 is_leaf = false;
197 }
198 }
188 } 199 }
189 } 200 }
190 } 201 }
202 if (is_leaf) {
203 // Remove check stack overflow at entry.
204 CheckStackOverflowInstr* check = flow_graph_.graph_entry()->normal_entry()
205 ->next()->AsCheckStackOverflow();
206 ASSERT(check != NULL);
207 check->RemoveFromGraph();
208 }
191 } 209 }
192 210
193 211
194 bool FlowGraphCompiler::CanOptimize() { 212 bool FlowGraphCompiler::CanOptimize() {
195 return !FLAG_report_usage_count && 213 return !FLAG_report_usage_count &&
196 (FLAG_optimization_counter_threshold >= 0); 214 (FLAG_optimization_counter_threshold >= 0);
197 } 215 }
198 216
199 217
200 bool FlowGraphCompiler::CanOptimizeFunction() const { 218 bool FlowGraphCompiler::CanOptimizeFunction() const {
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 if (i != largest_ix) { 1146 if (i != largest_ix) {
1129 // Swap. 1147 // Swap.
1130 CidTarget temp = (*sorted)[i]; 1148 CidTarget temp = (*sorted)[i];
1131 (*sorted)[i] = (*sorted)[largest_ix]; 1149 (*sorted)[i] = (*sorted)[largest_ix];
1132 (*sorted)[largest_ix] = temp; 1150 (*sorted)[largest_ix] = temp;
1133 } 1151 }
1134 } 1152 }
1135 } 1153 }
1136 1154
1137 } // namespace dart 1155 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698