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

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

Issue 16813002: Make constant propagation to fold x == x and re-run type propagation for better range analysis. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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_optimizer.h » ('j') | runtime/vm/flow_graph_optimizer.cc » ('J')
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/code_generator.h" 10 #include "vm/code_generator.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if (FLAG_loop_invariant_code_motion && 399 if (FLAG_loop_invariant_code_motion &&
400 (function.deoptimization_counter() < 400 (function.deoptimization_counter() <
401 (FLAG_deoptimization_counter_threshold - 1))) { 401 (FLAG_deoptimization_counter_threshold - 1))) {
402 LICM licm(flow_graph); 402 LICM licm(flow_graph);
403 licm.Optimize(); 403 licm.Optimize();
404 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 404 DEBUG_ASSERT(flow_graph->VerifyUseLists());
405 } 405 }
406 flow_graph->RemoveRedefinitions(); 406 flow_graph->RemoveRedefinitions();
407 407
408 if (FLAG_range_analysis) { 408 if (FLAG_range_analysis) {
409 if (FLAG_propagate_types) {
410 // Propagate types after store-load-forwarding. Some phis may have
411 // become smi phis that can be processed by range analysis.
412 FlowGraphTypePropagator propagator(flow_graph);
413 propagator.Propagate();
414 DEBUG_ASSERT(flow_graph->VerifyUseLists());
415 }
409 // We have to perform range analysis after LICM because it 416 // We have to perform range analysis after LICM because it
410 // optimistically moves CheckSmi through phis into loop preheaders 417 // optimistically moves CheckSmi through phis into loop preheaders
411 // making some phis smi. 418 // making some phis smi.
412 optimizer.InferSmiRanges(); 419 optimizer.InferSmiRanges();
413 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 420 DEBUG_ASSERT(flow_graph->VerifyUseLists());
414 } 421 }
415 422
416 if (FLAG_constant_propagation) { 423 if (FLAG_constant_propagation) {
417 // Constant propagation can use information from range analysis to 424 // Constant propagation can use information from range analysis to
418 // find unreachable branch targets. 425 // find unreachable branch targets.
419 ConstantPropagator::OptimizeBranches(flow_graph); 426 ConstantPropagator::OptimizeBranches(flow_graph);
420 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 427 DEBUG_ASSERT(flow_graph->VerifyUseLists());
421 } 428 }
422 429
423 // The final canonicalization pass before the code generation.
424 if (FLAG_propagate_types) { 430 if (FLAG_propagate_types) {
425 // Recompute types after code movement was done to ensure correct 431 // Recompute types after code movement was done to ensure correct
426 // reaching types for hoisted values. 432 // reaching types for hoisted values.
427 FlowGraphTypePropagator propagator(flow_graph); 433 FlowGraphTypePropagator propagator(flow_graph);
428 propagator.Propagate(); 434 propagator.Propagate();
429 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 435 DEBUG_ASSERT(flow_graph->VerifyUseLists());
430 } 436 }
431 437
432 // Optimize try-blocks. 438 // Optimize try-blocks.
433 TryCatchAnalyzer::Optimize(flow_graph); 439 TryCatchAnalyzer::Optimize(flow_graph);
434 440
435 // Detach environments from the instructions that can't deoptimize. 441 // Detach environments from the instructions that can't deoptimize.
436 // Do it before we attempt to perform allocation sinking to minimize 442 // Do it before we attempt to perform allocation sinking to minimize
437 // amount of materializations it has to perform. 443 // amount of materializations it has to perform.
438 optimizer.EliminateEnvironments(); 444 optimizer.EliminateEnvironments();
439 445
440 // Attempt to sink allocations of temporary non-escaping objects to 446 // Attempt to sink allocations of temporary non-escaping objects to
441 // the deoptimization path. 447 // the deoptimization path.
442 AllocationSinking* sinking = NULL; 448 AllocationSinking* sinking = NULL;
443 if (FLAG_allocation_sinking) { 449 if (FLAG_allocation_sinking) {
444 sinking = new AllocationSinking(flow_graph); 450 sinking = new AllocationSinking(flow_graph);
445 sinking->Optimize(); 451 sinking->Optimize();
446 } 452 }
447 453
448 // Ensure that all phis inserted by optimization passes have consistent 454 // Ensure that all phis inserted by optimization passes have consistent
449 // representations. 455 // representations.
450 optimizer.UnboxPhis(); 456 optimizer.SelectRepresentations();
451 457
452 if (optimizer.Canonicalize()) { 458 if (optimizer.Canonicalize()) {
453 // To fully remove redundant boxing (e.g. BoxDouble used only in 459 // To fully remove redundant boxing (e.g. BoxDouble used only in
454 // environments and UnboxDouble instructions) instruction we 460 // environments and UnboxDouble instructions) instruction we
455 // first need to replace all their uses and then fold them away. 461 // first need to replace all their uses and then fold them away.
456 // For now we just repeat Canonicalize twice to do that. 462 // For now we just repeat Canonicalize twice to do that.
457 // TODO(vegorov): implement a separate representation folding pass. 463 // TODO(vegorov): implement a separate representation folding pass.
458 optimizer.Canonicalize(); 464 optimizer.Canonicalize();
459 } 465 }
460 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 466 DEBUG_ASSERT(flow_graph->VerifyUseLists());
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 Object::Handle(isolate->object_store()->sticky_error()); 877 Object::Handle(isolate->object_store()->sticky_error());
872 isolate->object_store()->clear_sticky_error(); 878 isolate->object_store()->clear_sticky_error();
873 isolate->set_long_jump_base(base); 879 isolate->set_long_jump_base(base);
874 return result.raw(); 880 return result.raw();
875 } 881 }
876 UNREACHABLE(); 882 UNREACHABLE();
877 return Object::null(); 883 return Object::null();
878 } 884 }
879 885
880 } // namespace dart 886 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.h » ('j') | runtime/vm/flow_graph_optimizer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698