| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/pipeline.h" | 5 #include "src/compiler/pipeline.h" |
| 6 | 6 |
| 7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/base/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" |
| 11 #include "src/compiler/ast-graph-builder.h" | 11 #include "src/compiler/ast-graph-builder.h" |
| 12 #include "src/compiler/basic-block-instrumentor.h" | 12 #include "src/compiler/basic-block-instrumentor.h" |
| 13 #include "src/compiler/change-lowering.h" | 13 #include "src/compiler/change-lowering.h" |
| 14 #include "src/compiler/code-generator.h" | 14 #include "src/compiler/code-generator.h" |
| 15 #include "src/compiler/control-reducer.h" | 15 #include "src/compiler/control-reducer.h" |
| 16 #include "src/compiler/graph-replay.h" | 16 #include "src/compiler/graph-replay.h" |
| 17 #include "src/compiler/graph-visualizer.h" | 17 #include "src/compiler/graph-visualizer.h" |
| 18 #include "src/compiler/instruction.h" | 18 #include "src/compiler/instruction.h" |
| 19 #include "src/compiler/instruction-selector.h" | 19 #include "src/compiler/instruction-selector.h" |
| 20 #include "src/compiler/js-context-specialization.h" | 20 #include "src/compiler/js-context-specialization.h" |
| 21 #include "src/compiler/js-generic-lowering.h" | 21 #include "src/compiler/js-generic-lowering.h" |
| 22 #include "src/compiler/js-inlining.h" | 22 #include "src/compiler/js-inlining.h" |
| 23 #include "src/compiler/js-typed-lowering.h" | 23 #include "src/compiler/js-typed-lowering.h" |
| 24 #include "src/compiler/machine-operator-reducer.h" | 24 #include "src/compiler/machine-operator-reducer.h" |
| 25 #include "src/compiler/phi-reducer.h" | |
| 26 #include "src/compiler/pipeline-statistics.h" | 25 #include "src/compiler/pipeline-statistics.h" |
| 27 #include "src/compiler/register-allocator.h" | 26 #include "src/compiler/register-allocator.h" |
| 28 #include "src/compiler/schedule.h" | 27 #include "src/compiler/schedule.h" |
| 29 #include "src/compiler/scheduler.h" | 28 #include "src/compiler/scheduler.h" |
| 30 #include "src/compiler/simplified-lowering.h" | 29 #include "src/compiler/simplified-lowering.h" |
| 31 #include "src/compiler/simplified-operator-reducer.h" | 30 #include "src/compiler/simplified-operator-reducer.h" |
| 32 #include "src/compiler/typer.h" | 31 #include "src/compiler/typer.h" |
| 33 #include "src/compiler/value-numbering-reducer.h" | 32 #include "src/compiler/value-numbering-reducer.h" |
| 34 #include "src/compiler/verifier.h" | 33 #include "src/compiler/verifier.h" |
| 35 #include "src/compiler/zone-pool.h" | 34 #include "src/compiler/zone-pool.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 315 |
| 317 Node* context_node; | 316 Node* context_node; |
| 318 { | 317 { |
| 319 PhaseScope phase_scope(pipeline_statistics.get(), "graph builder"); | 318 PhaseScope phase_scope(pipeline_statistics.get(), "graph builder"); |
| 320 ZonePool::Scope zone_scope(data.zone_pool()); | 319 ZonePool::Scope zone_scope(data.zone_pool()); |
| 321 AstGraphBuilderWithPositions graph_builder( | 320 AstGraphBuilderWithPositions graph_builder( |
| 322 zone_scope.zone(), info(), data.jsgraph(), data.source_positions()); | 321 zone_scope.zone(), info(), data.jsgraph(), data.source_positions()); |
| 323 graph_builder.CreateGraph(); | 322 graph_builder.CreateGraph(); |
| 324 context_node = graph_builder.GetFunctionContext(); | 323 context_node = graph_builder.GetFunctionContext(); |
| 325 } | 324 } |
| 326 { | |
| 327 PhaseScope phase_scope(pipeline_statistics.get(), "phi reduction"); | |
| 328 PhiReducer phi_reducer; | |
| 329 GraphReducer graph_reducer(data.graph()); | |
| 330 graph_reducer.AddReducer(&phi_reducer); | |
| 331 graph_reducer.ReduceGraph(); | |
| 332 // TODO(mstarzinger): Running reducer once ought to be enough for everyone. | |
| 333 graph_reducer.ReduceGraph(); | |
| 334 graph_reducer.ReduceGraph(); | |
| 335 } | |
| 336 | 325 |
| 337 VerifyAndPrintGraph(data.graph(), "Initial untyped", true); | 326 VerifyAndPrintGraph(data.graph(), "Initial untyped", true); |
| 338 | 327 |
| 328 { |
| 329 PhaseScope phase_scope(pipeline_statistics.get(), |
| 330 "early control reduction"); |
| 331 SourcePositionTable::Scope pos(data.source_positions(), |
| 332 SourcePosition::Unknown()); |
| 333 ZonePool::Scope zone_scope(data.zone_pool()); |
| 334 ControlReducer::ReduceGraph(zone_scope.zone(), data.jsgraph(), |
| 335 data.common()); |
| 336 |
| 337 VerifyAndPrintGraph(data.graph(), "Early Control reduced", true); |
| 338 } |
| 339 |
| 339 if (info()->is_context_specializing()) { | 340 if (info()->is_context_specializing()) { |
| 340 SourcePositionTable::Scope pos(data.source_positions(), | 341 SourcePositionTable::Scope pos(data.source_positions(), |
| 341 SourcePosition::Unknown()); | 342 SourcePosition::Unknown()); |
| 342 // Specialize the code to the context as aggressively as possible. | 343 // Specialize the code to the context as aggressively as possible. |
| 343 JSContextSpecializer spec(info(), data.jsgraph(), context_node); | 344 JSContextSpecializer spec(info(), data.jsgraph(), context_node); |
| 344 spec.SpecializeToContext(); | 345 spec.SpecializeToContext(); |
| 345 VerifyAndPrintGraph(data.graph(), "Context specialized", true); | 346 VerifyAndPrintGraph(data.graph(), "Context specialized", true); |
| 346 } | 347 } |
| 347 | 348 |
| 348 if (info()->is_inlining_enabled()) { | 349 if (info()->is_inlining_enabled()) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 graph_reducer.AddReducer(&simple_reducer); | 426 graph_reducer.AddReducer(&simple_reducer); |
| 426 graph_reducer.AddReducer(&lowering); | 427 graph_reducer.AddReducer(&lowering); |
| 427 graph_reducer.AddReducer(&mach_reducer); | 428 graph_reducer.AddReducer(&mach_reducer); |
| 428 graph_reducer.ReduceGraph(); | 429 graph_reducer.ReduceGraph(); |
| 429 | 430 |
| 430 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 431 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 431 VerifyAndPrintGraph(data.graph(), "Lowered changes", true); | 432 VerifyAndPrintGraph(data.graph(), "Lowered changes", true); |
| 432 } | 433 } |
| 433 | 434 |
| 434 { | 435 { |
| 435 PhaseScope phase_scope(pipeline_statistics.get(), "control reduction"); | 436 PhaseScope phase_scope(pipeline_statistics.get(), |
| 437 "late control reduction"); |
| 436 SourcePositionTable::Scope pos(data.source_positions(), | 438 SourcePositionTable::Scope pos(data.source_positions(), |
| 437 SourcePosition::Unknown()); | 439 SourcePosition::Unknown()); |
| 438 ZonePool::Scope zone_scope(data.zone_pool()); | 440 ZonePool::Scope zone_scope(data.zone_pool()); |
| 439 ControlReducer::ReduceGraph(zone_scope.zone(), data.jsgraph(), | 441 ControlReducer::ReduceGraph(zone_scope.zone(), data.jsgraph(), |
| 440 data.common()); | 442 data.common()); |
| 441 | 443 |
| 442 VerifyAndPrintGraph(data.graph(), "Control reduced"); | 444 VerifyAndPrintGraph(data.graph(), "Late Control reduced"); |
| 443 } | 445 } |
| 444 } | 446 } |
| 445 | 447 |
| 446 { | 448 { |
| 447 // Lower any remaining generic JSOperators. | 449 // Lower any remaining generic JSOperators. |
| 448 PhaseScope phase_scope(pipeline_statistics.get(), "generic lowering"); | 450 PhaseScope phase_scope(pipeline_statistics.get(), "generic lowering"); |
| 449 SourcePositionTable::Scope pos(data.source_positions(), | 451 SourcePositionTable::Scope pos(data.source_positions(), |
| 450 SourcePosition::Unknown()); | 452 SourcePosition::Unknown()); |
| 451 JSGenericLowering lowering(info(), data.jsgraph()); | 453 JSGenericLowering lowering(info(), data.jsgraph()); |
| 452 GraphReducer graph_reducer(data.graph()); | 454 GraphReducer graph_reducer(data.graph()); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 } | 625 } |
| 624 | 626 |
| 625 | 627 |
| 626 void Pipeline::TearDown() { | 628 void Pipeline::TearDown() { |
| 627 InstructionOperand::TearDownCaches(); | 629 InstructionOperand::TearDownCaches(); |
| 628 } | 630 } |
| 629 | 631 |
| 630 } // namespace compiler | 632 } // namespace compiler |
| 631 } // namespace internal | 633 } // namespace internal |
| 632 } // namespace v8 | 634 } // namespace v8 |
| OLD | NEW |