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

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

Issue 23583054: Revert (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | « no previous file | runtime/vm/flow_graph.h » ('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) 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/compiler.h" 5 #include "vm/compiler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 8
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/block_scheduler.h" 10 #include "vm/block_scheduler.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // volatile because the variable may be clobbered by a longjmp. 264 // volatile because the variable may be clobbered by a longjmp.
265 volatile bool use_far_branches = false; 265 volatile bool use_far_branches = false;
266 while (!done) { 266 while (!done) {
267 const intptr_t prev_deopt_id = isolate->deopt_id(); 267 const intptr_t prev_deopt_id = isolate->deopt_id();
268 isolate->set_deopt_id(0); 268 isolate->set_deopt_id(0);
269 LongJump* old_base = isolate->long_jump_base(); 269 LongJump* old_base = isolate->long_jump_base();
270 LongJump bailout_jump; 270 LongJump bailout_jump;
271 isolate->set_long_jump_base(&bailout_jump); 271 isolate->set_long_jump_base(&bailout_jump);
272 if (setjmp(*bailout_jump.Set()) == 0) { 272 if (setjmp(*bailout_jump.Set()) == 0) {
273 FlowGraph* flow_graph = NULL; 273 FlowGraph* flow_graph = NULL;
274 GrowableArray<const Field*> guarded_fields;
275 // TimerScope needs an isolate to be properly terminated in case of a 274 // TimerScope needs an isolate to be properly terminated in case of a
276 // LongJump. 275 // LongJump.
277 { 276 {
278 TimerScope timer(FLAG_compiler_stats, 277 TimerScope timer(FLAG_compiler_stats,
279 &CompilerStats::graphbuilder_timer, 278 &CompilerStats::graphbuilder_timer,
280 isolate); 279 isolate);
281 Array& ic_data_array = Array::Handle(); 280 Array& ic_data_array = Array::Handle();
282 if (optimized) { 281 if (optimized) {
283 ASSERT(function.HasCode()); 282 ASSERT(function.HasCode());
284 // Extract type feedback before the graph is built, as the graph 283 // Extract type feedback before the graph is built, as the graph
285 // builder uses it to attach it to nodes. 284 // builder uses it to attach it to nodes.
286 ASSERT(function.deoptimization_counter() < 285 ASSERT(function.deoptimization_counter() <
287 FLAG_deoptimization_counter_threshold); 286 FLAG_deoptimization_counter_threshold);
288 const Code& unoptimized_code = 287 const Code& unoptimized_code =
289 Code::Handle(function.unoptimized_code()); 288 Code::Handle(function.unoptimized_code());
290 ic_data_array = unoptimized_code.ExtractTypeFeedbackArray(); 289 ic_data_array = unoptimized_code.ExtractTypeFeedbackArray();
291 } 290 }
292 291
293 // Build the flow graph. 292 // Build the flow graph.
294 FlowGraphBuilder builder(parsed_function, 293 FlowGraphBuilder builder(parsed_function,
295 ic_data_array, 294 ic_data_array,
296 NULL, // NULL = not inlining. 295 NULL, // NULL = not inlining.
297 &guarded_fields,
298 osr_id); 296 osr_id);
299 flow_graph = builder.BuildGraph(); 297 flow_graph = builder.BuildGraph();
300 } 298 }
301 299
302 if (FLAG_print_flow_graph || 300 if (FLAG_print_flow_graph ||
303 (optimized && FLAG_print_flow_graph_optimized)) { 301 (optimized && FLAG_print_flow_graph_optimized)) {
304 if (osr_id == Isolate::kNoDeoptId) { 302 if (osr_id == Isolate::kNoDeoptId) {
305 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph); 303 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph);
306 } else { 304 } else {
307 FlowGraphPrinter::PrintGraph("For OSR", flow_graph); 305 FlowGraphPrinter::PrintGraph("For OSR", flow_graph);
(...skipping 13 matching lines...) Expand all
321 flow_graph->ComputeSSA(0, NULL); 319 flow_graph->ComputeSSA(0, NULL);
322 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 320 DEBUG_ASSERT(flow_graph->VerifyUseLists());
323 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { 321 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) {
324 FlowGraphPrinter::PrintGraph("After SSA", flow_graph); 322 FlowGraphPrinter::PrintGraph("After SSA", flow_graph);
325 } 323 }
326 } 324 }
327 325
328 // Collect all instance fields that are loaded in the graph and 326 // Collect all instance fields that are loaded in the graph and
329 // have non-generic type feedback attached to them that can 327 // have non-generic type feedback attached to them that can
330 // potentially affect optimizations. 328 // potentially affect optimizations.
329 GrowableArray<const Field*> guarded_fields(10);
331 if (optimized) { 330 if (optimized) {
332 TimerScope timer(FLAG_compiler_stats, 331 TimerScope timer(FLAG_compiler_stats,
333 &CompilerStats::graphoptimizer_timer, 332 &CompilerStats::graphoptimizer_timer,
334 isolate); 333 isolate);
335 334
336 FlowGraphOptimizer optimizer(flow_graph); 335 FlowGraphOptimizer optimizer(flow_graph, &guarded_fields);
337 optimizer.ApplyICData(); 336 optimizer.ApplyICData();
338 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 337 DEBUG_ASSERT(flow_graph->VerifyUseLists());
339 338
340 // Optimize (a << b) & c patterns. Must occur before 339 // Optimize (a << b) & c patterns. Must occur before
341 // 'SelectRepresentations' which inserts conversion nodes. 340 // 'SelectRepresentations' which inserts conversion nodes.
342 // TODO(srdjan): Moved before inlining until environment use list can 341 // TODO(srdjan): Moved before inlining until environment use list can
343 // be used to detect when shift-left is outside the scope of bit-and. 342 // be used to detect when shift-left is outside the scope of bit-and.
344 optimizer.TryOptimizeLeftShiftWithBitAndPattern(); 343 optimizer.TryOptimizeLeftShiftWithBitAndPattern();
345 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 344 DEBUG_ASSERT(flow_graph->VerifyUseLists());
346 345
347 // Inlining (mutates the flow graph) 346 // Inlining (mutates the flow graph)
348 if (FLAG_use_inlining) { 347 if (FLAG_use_inlining) {
349 TimerScope timer(FLAG_compiler_stats, 348 TimerScope timer(FLAG_compiler_stats,
350 &CompilerStats::graphinliner_timer); 349 &CompilerStats::graphinliner_timer);
351 // Propagate types to create more inlining opportunities. 350 // Propagate types to create more inlining opportunities.
352 if (FLAG_propagate_types) { 351 if (FLAG_propagate_types) {
353 FlowGraphTypePropagator propagator(flow_graph); 352 FlowGraphTypePropagator propagator(flow_graph);
354 propagator.Propagate(); 353 propagator.Propagate();
355 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 354 DEBUG_ASSERT(flow_graph->VerifyUseLists());
356 } 355 }
357 356
358 // Use propagated class-ids to create more inlining opportunities. 357 // Use propagated class-ids to create more inlining opportunities.
359 optimizer.ApplyClassIds(); 358 optimizer.ApplyClassIds();
360 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 359 DEBUG_ASSERT(flow_graph->VerifyUseLists());
361 360
362 FlowGraphInliner inliner(flow_graph); 361 FlowGraphInliner inliner(flow_graph, &guarded_fields);
363 inliner.Inline(); 362 inliner.Inline();
364 // Use lists are maintained and validated by the inliner. 363 // Use lists are maintained and validated by the inliner.
365 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 364 DEBUG_ASSERT(flow_graph->VerifyUseLists());
366 } 365 }
367 366
368 // Propagate types and eliminate more type tests. 367 // Propagate types and eliminate more type tests.
369 if (FLAG_propagate_types) { 368 if (FLAG_propagate_types) {
370 FlowGraphTypePropagator propagator(flow_graph); 369 FlowGraphTypePropagator propagator(flow_graph);
371 propagator.Propagate(); 370 propagator.Propagate();
372 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 371 DEBUG_ASSERT(flow_graph->VerifyUseLists());
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 Object::Handle(isolate->object_store()->sticky_error()); 923 Object::Handle(isolate->object_store()->sticky_error());
925 isolate->object_store()->clear_sticky_error(); 924 isolate->object_store()->clear_sticky_error();
926 isolate->set_long_jump_base(base); 925 isolate->set_long_jump_base(base);
927 return result.raw(); 926 return result.raw();
928 } 927 }
929 UNREACHABLE(); 928 UNREACHABLE();
930 return Object::null(); 929 return Object::null();
931 } 930 }
932 931
933 } // namespace dart 932 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698