| OLD | NEW |
| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // potentially affect optimizations. | 347 // potentially affect optimizations. |
| 348 if (optimized) { | 348 if (optimized) { |
| 349 TimerScope timer(FLAG_compiler_stats, | 349 TimerScope timer(FLAG_compiler_stats, |
| 350 &CompilerStats::graphoptimizer_timer, | 350 &CompilerStats::graphoptimizer_timer, |
| 351 isolate); | 351 isolate); |
| 352 | 352 |
| 353 FlowGraphOptimizer optimizer(flow_graph); | 353 FlowGraphOptimizer optimizer(flow_graph); |
| 354 optimizer.ApplyICData(); | 354 optimizer.ApplyICData(); |
| 355 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 355 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 356 | 356 |
| 357 // Optimize (a << b) & c patterns, merge operations. Must occur before | 357 // Optimize (a << b) & c patterns, merge operations. |
| 358 // 'SelectRepresentations' which inserts conversion nodes. | 358 // Run early in order to have more opportunity to optimize left shifts. |
| 359 // TODO(srdjan): Moved before inlining until environment use list can | |
| 360 // be used to detect when shift-left is outside the scope of bit-and. | |
| 361 optimizer.TryOptimizePatterns(); | 359 optimizer.TryOptimizePatterns(); |
| 362 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 360 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 363 | 361 |
| 364 // Inlining (mutates the flow graph) | 362 // Inlining (mutates the flow graph) |
| 365 if (FLAG_use_inlining) { | 363 if (FLAG_use_inlining) { |
| 366 TimerScope timer(FLAG_compiler_stats, | 364 TimerScope timer(FLAG_compiler_stats, |
| 367 &CompilerStats::graphinliner_timer); | 365 &CompilerStats::graphinliner_timer); |
| 368 // Propagate types to create more inlining opportunities. | 366 // Propagate types to create more inlining opportunities. |
| 369 FlowGraphTypePropagator::Propagate(flow_graph); | 367 FlowGraphTypePropagator::Propagate(flow_graph); |
| 370 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 368 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 if (FLAG_common_subexpression_elimination) { | 431 if (FLAG_common_subexpression_elimination) { |
| 434 if (DominatorBasedCSE::Optimize(flow_graph)) { | 432 if (DominatorBasedCSE::Optimize(flow_graph)) { |
| 435 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 433 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 436 // Do another round of CSE to take secondary effects into account: | 434 // Do another round of CSE to take secondary effects into account: |
| 437 // e.g. when eliminating dependent loads (a.x[0] + a.x[0]) | 435 // e.g. when eliminating dependent loads (a.x[0] + a.x[0]) |
| 438 // TODO(fschneider): Change to a one-pass optimization pass. | 436 // TODO(fschneider): Change to a one-pass optimization pass. |
| 439 DominatorBasedCSE::Optimize(flow_graph); | 437 DominatorBasedCSE::Optimize(flow_graph); |
| 440 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 438 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 441 } | 439 } |
| 442 } | 440 } |
| 441 |
| 442 // Optimize (a << b) & c patterns, merge operations. |
| 443 // Run after CSE in order to have more opportunity to merge |
| 444 // instructions that have same inputs. |
| 445 optimizer.TryOptimizePatterns(); |
| 446 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 447 |
| 443 if (FLAG_loop_invariant_code_motion && | 448 if (FLAG_loop_invariant_code_motion && |
| 444 (function.deoptimization_counter() < | 449 (function.deoptimization_counter() < |
| 445 FLAG_deoptimization_counter_licm_threshold)) { | 450 FLAG_deoptimization_counter_licm_threshold)) { |
| 446 LICM licm(flow_graph); | 451 LICM licm(flow_graph); |
| 447 licm.Optimize(); | 452 licm.Optimize(); |
| 448 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 453 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 449 } | 454 } |
| 450 flow_graph->RemoveRedefinitions(); | 455 flow_graph->RemoveRedefinitions(); |
| 451 | 456 |
| 452 if (FLAG_range_analysis) { | 457 if (FLAG_range_analysis) { |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 Object::Handle(isolate->object_store()->sticky_error()); | 957 Object::Handle(isolate->object_store()->sticky_error()); |
| 953 isolate->object_store()->clear_sticky_error(); | 958 isolate->object_store()->clear_sticky_error(); |
| 954 isolate->set_long_jump_base(base); | 959 isolate->set_long_jump_base(base); |
| 955 return result.raw(); | 960 return result.raw(); |
| 956 } | 961 } |
| 957 UNREACHABLE(); | 962 UNREACHABLE(); |
| 958 return Object::null(); | 963 return Object::null(); |
| 959 } | 964 } |
| 960 | 965 |
| 961 } // namespace dart | 966 } // namespace dart |
| OLD | NEW |