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

Side by Side Diff: src/compiler/pipeline.cc

Issue 809333002: [turbofan] Implement OSR for outer loops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
OLDNEW
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/ast-loop-assignment-analyzer.h" 12 #include "src/compiler/ast-loop-assignment-analyzer.h"
13 #include "src/compiler/basic-block-instrumentor.h" 13 #include "src/compiler/basic-block-instrumentor.h"
14 #include "src/compiler/change-lowering.h" 14 #include "src/compiler/change-lowering.h"
15 #include "src/compiler/code-generator.h" 15 #include "src/compiler/code-generator.h"
16 #include "src/compiler/control-reducer.h" 16 #include "src/compiler/control-reducer.h"
17 #include "src/compiler/graph-replay.h" 17 #include "src/compiler/graph-replay.h"
18 #include "src/compiler/graph-visualizer.h" 18 #include "src/compiler/graph-visualizer.h"
19 #include "src/compiler/instruction.h" 19 #include "src/compiler/instruction.h"
20 #include "src/compiler/instruction-selector.h" 20 #include "src/compiler/instruction-selector.h"
21 #include "src/compiler/js-builtin-reducer.h" 21 #include "src/compiler/js-builtin-reducer.h"
22 #include "src/compiler/js-context-specialization.h" 22 #include "src/compiler/js-context-specialization.h"
23 #include "src/compiler/js-generic-lowering.h" 23 #include "src/compiler/js-generic-lowering.h"
24 #include "src/compiler/js-inlining.h" 24 #include "src/compiler/js-inlining.h"
25 #include "src/compiler/js-typed-lowering.h" 25 #include "src/compiler/js-typed-lowering.h"
26 #include "src/compiler/jump-threading.h" 26 #include "src/compiler/jump-threading.h"
27 #include "src/compiler/load-elimination.h" 27 #include "src/compiler/load-elimination.h"
28 #include "src/compiler/machine-operator-reducer.h" 28 #include "src/compiler/machine-operator-reducer.h"
29 #include "src/compiler/move-optimizer.h" 29 #include "src/compiler/move-optimizer.h"
30 #include "src/compiler/osr.h"
30 #include "src/compiler/pipeline-statistics.h" 31 #include "src/compiler/pipeline-statistics.h"
31 #include "src/compiler/register-allocator.h" 32 #include "src/compiler/register-allocator.h"
32 #include "src/compiler/register-allocator-verifier.h" 33 #include "src/compiler/register-allocator-verifier.h"
33 #include "src/compiler/schedule.h" 34 #include "src/compiler/schedule.h"
34 #include "src/compiler/scheduler.h" 35 #include "src/compiler/scheduler.h"
35 #include "src/compiler/select-lowering.h" 36 #include "src/compiler/select-lowering.h"
36 #include "src/compiler/simplified-lowering.h" 37 #include "src/compiler/simplified-lowering.h"
37 #include "src/compiler/simplified-operator-reducer.h" 38 #include "src/compiler/simplified-operator-reducer.h"
38 #include "src/compiler/typer.h" 39 #include "src/compiler/typer.h"
39 #include "src/compiler/value-numbering-reducer.h" 40 #include "src/compiler/value-numbering-reducer.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 }; 404 };
404 405
405 406
406 struct TyperPhase { 407 struct TyperPhase {
407 static const char* phase_name() { return "typer"; } 408 static const char* phase_name() { return "typer"; }
408 409
409 void Run(PipelineData* data, Zone* temp_zone) { data->typer()->Run(); } 410 void Run(PipelineData* data, Zone* temp_zone) { data->typer()->Run(); }
410 }; 411 };
411 412
412 413
414 struct OsrDeconstructionPhase {
415 static const char* phase_name() { return "OSR deconstruction"; }
416
417 void Run(PipelineData* data, Zone* temp_zone) {
418 SourcePositionTable::Scope pos(data->source_positions(),
419 SourcePosition::Unknown());
420 OsrHelper osr_helper(data->info());
421 osr_helper.Deconstruct(data->graph(), data->common(), temp_zone);
422 ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), data->common());
423 }
424 };
425
426
413 struct TypedLoweringPhase { 427 struct TypedLoweringPhase {
414 static const char* phase_name() { return "typed lowering"; } 428 static const char* phase_name() { return "typed lowering"; }
415 429
416 void Run(PipelineData* data, Zone* temp_zone) { 430 void Run(PipelineData* data, Zone* temp_zone) {
417 SourcePositionTable::Scope pos(data->source_positions(), 431 SourcePositionTable::Scope pos(data->source_positions(),
418 SourcePosition::Unknown()); 432 SourcePosition::Unknown());
419 ValueNumberingReducer vn_reducer(temp_zone); 433 ValueNumberingReducer vn_reducer(temp_zone);
420 LoadElimination load_elimination; 434 LoadElimination load_elimination;
421 JSBuiltinReducer builtin_reducer(data->jsgraph()); 435 JSBuiltinReducer builtin_reducer(data->jsgraph());
422 JSTypedLowering typed_lowering(data->jsgraph()); 436 JSTypedLowering typed_lowering(data->jsgraph());
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 Handle<Code> Pipeline::GenerateCode() { 755 Handle<Code> Pipeline::GenerateCode() {
742 // This list must be kept in sync with DONT_TURBOFAN_NODE in ast.cc. 756 // This list must be kept in sync with DONT_TURBOFAN_NODE in ast.cc.
743 if (info()->function()->dont_optimize_reason() == kTryCatchStatement || 757 if (info()->function()->dont_optimize_reason() == kTryCatchStatement ||
744 info()->function()->dont_optimize_reason() == kTryFinallyStatement || 758 info()->function()->dont_optimize_reason() == kTryFinallyStatement ||
745 // TODO(turbofan): Make ES6 for-of work and remove this bailout. 759 // TODO(turbofan): Make ES6 for-of work and remove this bailout.
746 info()->function()->dont_optimize_reason() == kForOfStatement || 760 info()->function()->dont_optimize_reason() == kForOfStatement ||
747 // TODO(turbofan): Make super work and remove this bailout. 761 // TODO(turbofan): Make super work and remove this bailout.
748 info()->function()->dont_optimize_reason() == kSuperReference || 762 info()->function()->dont_optimize_reason() == kSuperReference ||
749 // TODO(turbofan): Make class literals work and remove this bailout. 763 // TODO(turbofan): Make class literals work and remove this bailout.
750 info()->function()->dont_optimize_reason() == kClassLiteral || 764 info()->function()->dont_optimize_reason() == kClassLiteral ||
751 // TODO(turbofan): Make OSR work and remove this bailout. 765 // TODO(turbofan): Make OSR work with inner loops and remove this bailout.
752 info()->is_osr()) { 766 (info()->is_osr() && !FLAG_turbo_osr)) {
753 return Handle<Code>::null(); 767 return Handle<Code>::null();
754 } 768 }
755 769
756 ZonePool zone_pool(isolate()); 770 ZonePool zone_pool(isolate());
757 SmartPointer<PipelineStatistics> pipeline_statistics; 771 SmartPointer<PipelineStatistics> pipeline_statistics;
758 772
759 if (FLAG_turbo_stats) { 773 if (FLAG_turbo_stats) {
760 pipeline_statistics.Reset(new PipelineStatistics(info(), &zone_pool)); 774 pipeline_statistics.Reset(new PipelineStatistics(info(), &zone_pool));
761 pipeline_statistics->BeginPhaseKind("initializing"); 775 pipeline_statistics->BeginPhaseKind("initializing");
762 } 776 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 RunPrintAndVerify("Typed"); 828 RunPrintAndVerify("Typed");
815 } 829 }
816 830
817 BeginPhaseKind("lowering"); 831 BeginPhaseKind("lowering");
818 832
819 if (info()->is_typing_enabled()) { 833 if (info()->is_typing_enabled()) {
820 // Lower JSOperators where we can determine types. 834 // Lower JSOperators where we can determine types.
821 Run<TypedLoweringPhase>(); 835 Run<TypedLoweringPhase>();
822 RunPrintAndVerify("Lowered typed"); 836 RunPrintAndVerify("Lowered typed");
823 837
838 if (info()->is_osr()) {
839 Run<OsrDeconstructionPhase>();
840 RunPrintAndVerify("OSR deconstruction");
841 }
842
824 // Lower simplified operators and insert changes. 843 // Lower simplified operators and insert changes.
825 Run<SimplifiedLoweringPhase>(); 844 Run<SimplifiedLoweringPhase>();
826 RunPrintAndVerify("Lowered simplified"); 845 RunPrintAndVerify("Lowered simplified");
827 846
828 // Lower changes that have been inserted before. 847 // Lower changes that have been inserted before.
829 Run<ChangeLoweringPhase>(); 848 Run<ChangeLoweringPhase>();
830 // // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. 849 // // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
831 RunPrintAndVerify("Lowered changes", true); 850 RunPrintAndVerify("Lowered changes", true);
832 851
833 Run<LateControlReductionPhase>(); 852 Run<LateControlReductionPhase>();
834 RunPrintAndVerify("Late Control reduced"); 853 RunPrintAndVerify("Late Control reduced");
854 } else {
855 if (info()->is_osr()) {
856 Run<OsrDeconstructionPhase>();
857 RunPrintAndVerify("OSR deconstruction");
858 }
835 } 859 }
836 860
837 // Lower any remaining generic JSOperators. 861 // Lower any remaining generic JSOperators.
838 Run<GenericLoweringPhase>(); 862 Run<GenericLoweringPhase>();
839 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. 863 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
840 RunPrintAndVerify("Lowered generic", true); 864 RunPrintAndVerify("Lowered generic", true);
841 865
842 BeginPhaseKind("block building"); 866 BeginPhaseKind("block building");
843 867
844 data.source_positions()->RemoveDecorator(); 868 data.source_positions()->RemoveDecorator();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 } 1036 }
1013 1037
1014 SmartArrayPointer<char> debug_name; 1038 SmartArrayPointer<char> debug_name;
1015 #ifdef DEBUG 1039 #ifdef DEBUG
1016 debug_name = GetDebugName(data->info()); 1040 debug_name = GetDebugName(data->info());
1017 #endif 1041 #endif
1018 1042
1019 ZonePool::Scope zone_scope(data->zone_pool()); 1043 ZonePool::Scope zone_scope(data->zone_pool());
1020 data->InitializeRegisterAllocator(zone_scope.zone(), config, 1044 data->InitializeRegisterAllocator(zone_scope.zone(), config,
1021 debug_name.get()); 1045 debug_name.get());
1046 if (info()->is_osr()) {
1047 OsrHelper osr_helper(info());
1048 osr_helper.SetupFrame(data->frame());
1049 }
1022 1050
1023 Run<MeetRegisterConstraintsPhase>(); 1051 Run<MeetRegisterConstraintsPhase>();
1024 Run<ResolvePhisPhase>(); 1052 Run<ResolvePhisPhase>();
1025 Run<BuildLiveRangesPhase>(); 1053 Run<BuildLiveRangesPhase>();
1026 if (FLAG_trace_turbo_graph) { 1054 if (FLAG_trace_turbo_graph) {
1027 OFStream os(stdout); 1055 OFStream os(stdout);
1028 PrintableInstructionSequence printable = {config, data->sequence()}; 1056 PrintableInstructionSequence printable = {config, data->sequence()};
1029 os << "----- Instruction sequence before register allocation -----\n" 1057 os << "----- Instruction sequence before register allocation -----\n"
1030 << printable; 1058 << printable;
1031 } 1059 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 } 1105 }
1078 1106
1079 1107
1080 void Pipeline::TearDown() { 1108 void Pipeline::TearDown() {
1081 InstructionOperand::TearDownCaches(); 1109 InstructionOperand::TearDownCaches();
1082 } 1110 }
1083 1111
1084 } // namespace compiler 1112 } // namespace compiler
1085 } // namespace internal 1113 } // namespace internal
1086 } // namespace v8 1114 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698