| 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/jump-threading.h" |
| 24 #include "src/compiler/machine-operator-reducer.h" | 25 #include "src/compiler/machine-operator-reducer.h" |
| 25 #include "src/compiler/pipeline-statistics.h" | 26 #include "src/compiler/pipeline-statistics.h" |
| 26 #include "src/compiler/register-allocator.h" | 27 #include "src/compiler/register-allocator.h" |
| 27 #include "src/compiler/register-allocator-verifier.h" | 28 #include "src/compiler/register-allocator-verifier.h" |
| 28 #include "src/compiler/schedule.h" | 29 #include "src/compiler/schedule.h" |
| 29 #include "src/compiler/scheduler.h" | 30 #include "src/compiler/scheduler.h" |
| 30 #include "src/compiler/select-lowering.h" | 31 #include "src/compiler/select-lowering.h" |
| 31 #include "src/compiler/simplified-lowering.h" | 32 #include "src/compiler/simplified-lowering.h" |
| 32 #include "src/compiler/simplified-operator-reducer.h" | 33 #include "src/compiler/simplified-operator-reducer.h" |
| 33 #include "src/compiler/typer.h" | 34 #include "src/compiler/typer.h" |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 | 572 |
| 572 struct ResolveControlFlowPhase { | 573 struct ResolveControlFlowPhase { |
| 573 static const char* phase_name() { return "resolve control flow"; } | 574 static const char* phase_name() { return "resolve control flow"; } |
| 574 | 575 |
| 575 void Run(PipelineData* data, Zone* temp_zone) { | 576 void Run(PipelineData* data, Zone* temp_zone) { |
| 576 data->register_allocator()->ResolveControlFlow(); | 577 data->register_allocator()->ResolveControlFlow(); |
| 577 } | 578 } |
| 578 }; | 579 }; |
| 579 | 580 |
| 580 | 581 |
| 582 struct JumpThreadingPhase { |
| 583 static const char* phase_name() { return "jump threading"; } |
| 584 |
| 585 void Run(PipelineData* data, Zone* temp_zone) { |
| 586 ZoneVector<BasicBlock::RpoNumber> result(temp_zone); |
| 587 if (JumpThreading::ComputeForwarding(temp_zone, result, data->sequence())) { |
| 588 JumpThreading::ApplyForwarding(result, data->sequence()); |
| 589 } |
| 590 } |
| 591 }; |
| 592 |
| 593 |
| 581 struct GenerateCodePhase { | 594 struct GenerateCodePhase { |
| 582 static const char* phase_name() { return "generate code"; } | 595 static const char* phase_name() { return "generate code"; } |
| 583 | 596 |
| 584 void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) { | 597 void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) { |
| 585 CodeGenerator generator(data->frame(), linkage, data->sequence(), | 598 CodeGenerator generator(data->frame(), linkage, data->sequence(), |
| 586 data->info()); | 599 data->info()); |
| 587 data->set_code(generator.GenerateCode()); | 600 data->set_code(generator.GenerateCode()); |
| 588 } | 601 } |
| 589 }; | 602 }; |
| 590 | 603 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 #endif | 908 #endif |
| 896 // Allocate registers. | 909 // Allocate registers. |
| 897 AllocateRegisters(RegisterConfiguration::ArchDefault(), run_verifier); | 910 AllocateRegisters(RegisterConfiguration::ArchDefault(), run_verifier); |
| 898 if (data->compilation_failed()) { | 911 if (data->compilation_failed()) { |
| 899 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); | 912 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); |
| 900 return; | 913 return; |
| 901 } | 914 } |
| 902 | 915 |
| 903 BeginPhaseKind("code generation"); | 916 BeginPhaseKind("code generation"); |
| 904 | 917 |
| 905 // Generate native sequence. | 918 // Optimimize jumps. |
| 919 if (FLAG_turbo_jt) { |
| 920 Run<JumpThreadingPhase>(); |
| 921 } |
| 922 |
| 923 // Generate final machine code. |
| 906 Run<GenerateCodePhase>(linkage); | 924 Run<GenerateCodePhase>(linkage); |
| 907 | 925 |
| 908 if (profiler_data != NULL) { | 926 if (profiler_data != NULL) { |
| 909 #if ENABLE_DISASSEMBLER | 927 #if ENABLE_DISASSEMBLER |
| 910 std::ostringstream os; | 928 std::ostringstream os; |
| 911 data->code()->Disassemble(NULL, os); | 929 data->code()->Disassemble(NULL, os); |
| 912 profiler_data->SetCode(&os); | 930 profiler_data->SetCode(&os); |
| 913 #endif | 931 #endif |
| 914 } | 932 } |
| 915 } | 933 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 } | 1012 } |
| 995 | 1013 |
| 996 | 1014 |
| 997 void Pipeline::TearDown() { | 1015 void Pipeline::TearDown() { |
| 998 InstructionOperand::TearDownCaches(); | 1016 InstructionOperand::TearDownCaches(); |
| 999 } | 1017 } |
| 1000 | 1018 |
| 1001 } // namespace compiler | 1019 } // namespace compiler |
| 1002 } // namespace internal | 1020 } // namespace internal |
| 1003 } // namespace v8 | 1021 } // namespace v8 |
| OLD | NEW |