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

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

Issue 877553007: [turbofan] Gracefully bail out if OSR encounters a loop too deeply nested. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/compiler/osr.cc ('k') | test/mjsunit/compiler/osr-nested2.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 }; 407 };
408 408
409 409
410 struct OsrDeconstructionPhase { 410 struct OsrDeconstructionPhase {
411 static const char* phase_name() { return "OSR deconstruction"; } 411 static const char* phase_name() { return "OSR deconstruction"; }
412 412
413 void Run(PipelineData* data, Zone* temp_zone) { 413 void Run(PipelineData* data, Zone* temp_zone) {
414 SourcePositionTable::Scope pos(data->source_positions(), 414 SourcePositionTable::Scope pos(data->source_positions(),
415 SourcePosition::Unknown()); 415 SourcePosition::Unknown());
416 OsrHelper osr_helper(data->info()); 416 OsrHelper osr_helper(data->info());
417 osr_helper.Deconstruct(data->jsgraph(), data->common(), temp_zone); 417 bool success =
418 osr_helper.Deconstruct(data->jsgraph(), data->common(), temp_zone);
419 if (!success) data->info()->RetryOptimization(kOsrCompileFailed);
418 } 420 }
419 }; 421 };
420 422
421 423
422 struct TypedLoweringPhase { 424 struct TypedLoweringPhase {
423 static const char* phase_name() { return "typed lowering"; } 425 static const char* phase_name() { return "typed lowering"; }
424 426
425 void Run(PipelineData* data, Zone* temp_zone) { 427 void Run(PipelineData* data, Zone* temp_zone) {
426 SourcePositionTable::Scope pos(data->source_positions(), 428 SourcePositionTable::Scope pos(data->source_positions(),
427 SourcePosition::Unknown()); 429 SourcePosition::Unknown());
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 if (FLAG_trace_turbo) { 769 if (FLAG_trace_turbo) {
768 Run<PrintGraphPhase>(phase); 770 Run<PrintGraphPhase>(phase);
769 } 771 }
770 if (FLAG_turbo_verify) { 772 if (FLAG_turbo_verify) {
771 Run<VerifyGraphPhase>(untyped); 773 Run<VerifyGraphPhase>(untyped);
772 } 774 }
773 } 775 }
774 776
775 777
776 Handle<Code> Pipeline::GenerateCode() { 778 Handle<Code> Pipeline::GenerateCode() {
777 // TODO(turbofan): Make OSR work with inner loops and remove this bailout. 779 if (info()->is_osr() && !FLAG_turbo_osr) {
778 if (info()->is_osr() && !FLAG_turbo_osr) return Handle<Code>::null(); 780 // TODO(turbofan): remove this flag and always handle OSR
781 info()->RetryOptimization(kOsrCompileFailed);
782 return Handle<Code>::null();
783 }
779 784
780 // TODO(mstarzinger): This is just a temporary hack to make TurboFan work, 785 // TODO(mstarzinger): This is just a temporary hack to make TurboFan work,
781 // the correct solution is to restore the context register after invoking 786 // the correct solution is to restore the context register after invoking
782 // builtins from full-codegen. 787 // builtins from full-codegen.
783 Handle<SharedFunctionInfo> shared = info()->shared_info(); 788 Handle<SharedFunctionInfo> shared = info()->shared_info();
784 if (isolate()->bootstrapper()->IsActive() || 789 if (isolate()->bootstrapper()->IsActive() ||
785 shared->disable_optimization_reason() == 790 shared->disable_optimization_reason() ==
786 kBuiltinFunctionCannotBeOptimized) { 791 kBuiltinFunctionCannotBeOptimized) {
787 shared->DisableOptimization(kBuiltinFunctionCannotBeOptimized); 792 shared->DisableOptimization(kBuiltinFunctionCannotBeOptimized);
788 return Handle<Code>::null(); 793 return Handle<Code>::null();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 Run<TypedLoweringPhase>(); 861 Run<TypedLoweringPhase>();
857 RunPrintAndVerify("Lowered typed"); 862 RunPrintAndVerify("Lowered typed");
858 863
859 if (FLAG_turbo_stress_loop_peeling) { 864 if (FLAG_turbo_stress_loop_peeling) {
860 Run<StressLoopPeelingPhase>(); 865 Run<StressLoopPeelingPhase>();
861 RunPrintAndVerify("Loop peeled", true); 866 RunPrintAndVerify("Loop peeled", true);
862 } 867 }
863 868
864 if (info()->is_osr()) { 869 if (info()->is_osr()) {
865 Run<OsrDeconstructionPhase>(); 870 Run<OsrDeconstructionPhase>();
871 if (info()->bailout_reason() != kNoReason) return Handle<Code>::null();
866 RunPrintAndVerify("OSR deconstruction"); 872 RunPrintAndVerify("OSR deconstruction");
867 } 873 }
868 874
869 // Lower simplified operators and insert changes. 875 // Lower simplified operators and insert changes.
870 Run<SimplifiedLoweringPhase>(); 876 Run<SimplifiedLoweringPhase>();
871 RunPrintAndVerify("Lowered simplified"); 877 RunPrintAndVerify("Lowered simplified");
872 878
873 // Lower changes that have been inserted before. 879 // Lower changes that have been inserted before.
874 Run<ChangeLoweringPhase>(); 880 Run<ChangeLoweringPhase>();
875 // // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. 881 // // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
876 RunPrintAndVerify("Lowered changes", true); 882 RunPrintAndVerify("Lowered changes", true);
877 883
878 Run<LateControlReductionPhase>(); 884 Run<LateControlReductionPhase>();
879 RunPrintAndVerify("Late Control reduced"); 885 RunPrintAndVerify("Late Control reduced");
880 } else { 886 } else {
881 if (info()->is_osr()) { 887 if (info()->is_osr()) {
882 Run<OsrDeconstructionPhase>(); 888 Run<OsrDeconstructionPhase>();
889 if (info()->bailout_reason() != kNoReason) return Handle<Code>::null();
883 RunPrintAndVerify("OSR deconstruction"); 890 RunPrintAndVerify("OSR deconstruction");
884 } 891 }
885 } 892 }
886 893
887 // Lower any remaining generic JSOperators. 894 // Lower any remaining generic JSOperators.
888 Run<GenericLoweringPhase>(); 895 Run<GenericLoweringPhase>();
889 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. 896 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
890 RunPrintAndVerify("Lowered generic", true); 897 RunPrintAndVerify("Lowered generic", true);
891 898
892 BeginPhaseKind("block building"); 899 BeginPhaseKind("block building");
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 } 1121 }
1115 1122
1116 1123
1117 void Pipeline::TearDown() { 1124 void Pipeline::TearDown() {
1118 InstructionOperand::TearDownCaches(); 1125 InstructionOperand::TearDownCaches();
1119 } 1126 }
1120 1127
1121 } // namespace compiler 1128 } // namespace compiler
1122 } // namespace internal 1129 } // namespace internal
1123 } // namespace v8 1130 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/osr.cc ('k') | test/mjsunit/compiler/osr-nested2.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698