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

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

Issue 11014013: Added slow_assert macro and flag for slow development assertions in the VM. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
« runtime/vm/flow_graph.cc ('K') | « runtime/vm/flow_graph.cc ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_inliner.h" 5 #include "vm/flow_graph_inliner.h"
6 6
7 #include "vm/assert.h"
7 #include "vm/compiler.h" 8 #include "vm/compiler.h"
8 #include "vm/flags.h" 9 #include "vm/flags.h"
9 #include "vm/flow_graph.h" 10 #include "vm/flow_graph.h"
10 #include "vm/flow_graph_builder.h" 11 #include "vm/flow_graph_builder.h"
11 #include "vm/flow_graph_optimizer.h" 12 #include "vm/flow_graph_optimizer.h"
12 #include "vm/il_printer.h" 13 #include "vm/il_printer.h"
13 #include "vm/intrinsifier.h" 14 #include "vm/intrinsifier.h"
14 #include "vm/longjump.h" 15 #include "vm/longjump.h"
15 #include "vm/object.h" 16 #include "vm/object.h"
16 #include "vm/object_store.h" 17 #include "vm/object_store.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 139 }
139 140
140 // TODO(zerny): If result is more than size threshold then abort. 141 // TODO(zerny): If result is more than size threshold then abort.
141 142
142 // TODO(zerny): If effort is less than threshold then inline recursively. 143 // TODO(zerny): If effort is less than threshold then inline recursively.
143 144
144 // Plug result in the caller graph. 145 // Plug result in the caller graph.
145 caller_graph_->InlineCall(call, callee_graph); 146 caller_graph_->InlineCall(call, callee_graph);
146 next_ssa_temp_index_ = caller_graph_->max_virtual_register_number(); 147 next_ssa_temp_index_ = caller_graph_->max_virtual_register_number();
147 148
148 // Check that inlining maintains use lists.
149 DEBUG_ASSERT(caller_graph_->ValidateUseLists());
150
151 // Remove push arguments of the call. 149 // Remove push arguments of the call.
152 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) { 150 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) {
153 PushArgumentInstr* push = call->ArgumentAt(i); 151 PushArgumentInstr* push = call->ArgumentAt(i);
154 push->ReplaceUsesWith(push->value()->definition()); 152 push->ReplaceUsesWith(push->value()->definition());
155 push->RemoveFromGraph(); 153 push->RemoveFromGraph();
156 } 154 }
157 155
158 // Replace formal parameters with actuals. 156 // Replace formal parameters with actuals.
159 intptr_t arg_index = 0; 157 intptr_t arg_index = 0;
160 GrowableArray<Definition*>* defns = 158 GrowableArray<Definition*>* defns =
161 callee_graph->graph_entry()->initial_definitions(); 159 callee_graph->graph_entry()->initial_definitions();
162 for (intptr_t i = 0; i < defns->length(); ++i) { 160 for (intptr_t i = 0; i < defns->length(); ++i) {
163 ParameterInstr* param = (*defns)[i]->AsParameter(); 161 ParameterInstr* param = (*defns)[i]->AsParameter();
164 if (param != NULL) { 162 if (param != NULL) {
165 param->ReplaceUsesWith((*arguments)[arg_index++]->definition()); 163 param->ReplaceUsesWith((*arguments)[arg_index++]->definition());
166 } 164 }
167 } 165 }
168 ASSERT(arg_index == arguments->length()); 166 ASSERT(arg_index == arguments->length());
169 167
170 // Replace callee's null constant with caller's null constant. 168 // Replace callee's null constant with caller's null constant.
171 callee_graph->graph_entry()->constant_null()->ReplaceUsesWith( 169 callee_graph->graph_entry()->constant_null()->ReplaceUsesWith(
172 caller_graph_->graph_entry()->constant_null()); 170 caller_graph_->graph_entry()->constant_null());
173 171
174 TRACE_INLINING(OS::Print(" Success\n")); 172 TRACE_INLINING(OS::Print(" Success\n"));
175 173
174 // Check that inlining maintains use lists.
175 SLOW_ASSERT(caller_graph_->ValidateUseLists());
176
176 // Build succeeded so we restore the bailout jump. 177 // Build succeeded so we restore the bailout jump.
177 inlined_ = true; 178 inlined_ = true;
178 isolate->set_long_jump_base(base); 179 isolate->set_long_jump_base(base);
179 isolate->set_deopt_id(prev_deopt_id); 180 isolate->set_deopt_id(prev_deopt_id);
180 isolate->set_ic_data_array(prev_ic_data.raw()); 181 isolate->set_ic_data_array(prev_ic_data.raw());
181 return true; 182 return true;
182 } else { 183 } else {
183 Error& error = Error::Handle(); 184 Error& error = Error::Handle();
184 error = isolate->object_store()->sticky_error(); 185 error = isolate->object_store()->sticky_error();
185 isolate->object_store()->clear_sticky_error(); 186 isolate->object_store()->clear_sticky_error();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 if (FLAG_trace_inlining && FLAG_print_flow_graph) { 272 if (FLAG_trace_inlining && FLAG_print_flow_graph) {
272 OS::Print("After Inlining of %s\n", flow_graph_-> 273 OS::Print("After Inlining of %s\n", flow_graph_->
273 parsed_function().function().ToFullyQualifiedCString()); 274 parsed_function().function().ToFullyQualifiedCString());
274 FlowGraphPrinter printer(*flow_graph_); 275 FlowGraphPrinter printer(*flow_graph_);
275 printer.PrintBlocks(); 276 printer.PrintBlocks();
276 } 277 }
277 } 278 }
278 } 279 }
279 280
280 } // namespace dart 281 } // namespace dart
OLDNEW
« runtime/vm/flow_graph.cc ('K') | « runtime/vm/flow_graph.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698