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

Side by Side Diff: runtime/vm/compiler.cc

Issue 1904153002: Add a stress testing flag --background-compilation-stop-alot; add an extra check if background comp… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: r Created 4 years, 8 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 | « runtime/vm/code_generator.cc ('k') | runtime/vm/flag_list.h » ('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 (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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 Isolate* isolate() const { return thread_->isolate(); } 466 Isolate* isolate() const { return thread_->isolate(); }
467 intptr_t field_invalidation_gen_at_start() const { 467 intptr_t field_invalidation_gen_at_start() const {
468 return field_invalidation_gen_at_start_; 468 return field_invalidation_gen_at_start_;
469 } 469 }
470 intptr_t loading_invalidation_gen_at_start() const { 470 intptr_t loading_invalidation_gen_at_start() const {
471 return loading_invalidation_gen_at_start_; 471 return loading_invalidation_gen_at_start_;
472 } 472 }
473 void FinalizeCompilation(Assembler* assembler, 473 void FinalizeCompilation(Assembler* assembler,
474 FlowGraphCompiler* graph_compiler, 474 FlowGraphCompiler* graph_compiler,
475 FlowGraph* flow_graph); 475 FlowGraph* flow_graph);
476 void CheckIfBackgroundCompilerIsBeingStopped();
476 477
477 ParsedFunction* parsed_function_; 478 ParsedFunction* parsed_function_;
478 const bool optimized_; 479 const bool optimized_;
479 const intptr_t osr_id_; 480 const intptr_t osr_id_;
480 Thread* const thread_; 481 Thread* const thread_;
481 const intptr_t field_invalidation_gen_at_start_; 482 const intptr_t field_invalidation_gen_at_start_;
482 const intptr_t loading_invalidation_gen_at_start_; 483 const intptr_t loading_invalidation_gen_at_start_;
483 484
484 DISALLOW_COPY_AND_ASSIGN(CompileParsedFunctionHelper); 485 DISALLOW_COPY_AND_ASSIGN(CompileParsedFunctionHelper);
485 }; 486 };
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 ASSERT(!FLAG_load_deferred_eagerly); 660 ASSERT(!FLAG_load_deferred_eagerly);
660 ZoneGrowableArray<const LibraryPrefix*>* prefixes = 661 ZoneGrowableArray<const LibraryPrefix*>* prefixes =
661 parsed_function()->deferred_prefixes(); 662 parsed_function()->deferred_prefixes();
662 for (intptr_t i = 0; i < prefixes->length(); i++) { 663 for (intptr_t i = 0; i < prefixes->length(); i++) {
663 (*prefixes)[i]->RegisterDependentCode(code); 664 (*prefixes)[i]->RegisterDependentCode(code);
664 } 665 }
665 } 666 }
666 } 667 }
667 668
668 669
670 void CompileParsedFunctionHelper::CheckIfBackgroundCompilerIsBeingStopped() {
671 ASSERT(Compiler::IsBackgroundCompilation());
672 if (!isolate()->background_compiler()->is_running()) {
673 // The background compiler is being stopped.
674 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId,
675 "Background compilation is being stopped");
676 }
677 }
678
679
669 // Return false if bailed out. 680 // Return false if bailed out.
670 // If optimized_result_code is not NULL then it is caller's responsibility 681 // If optimized_result_code is not NULL then it is caller's responsibility
671 // to install code. 682 // to install code.
672 bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { 683 bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
673 ASSERT(!FLAG_precompiled_mode); 684 ASSERT(!FLAG_precompiled_mode);
674 const Function& function = parsed_function()->function(); 685 const Function& function = parsed_function()->function();
675 if (optimized() && !function.IsOptimizable()) { 686 if (optimized() && !function.IsOptimizable()) {
676 return false; 687 return false;
677 } 688 }
678 bool is_compiled = false; 689 bool is_compiled = false;
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 FinalizeCompilation(&assembler, &graph_compiler, flow_graph); 1137 FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
1127 } else { 1138 } else {
1128 // This part of compilation must be at a safepoint. 1139 // This part of compilation must be at a safepoint.
1129 // Stop mutator thread before creating the instruction object and 1140 // Stop mutator thread before creating the instruction object and
1130 // installing code. 1141 // installing code.
1131 // Mutator thread may not run code while we are creating the 1142 // Mutator thread may not run code while we are creating the
1132 // instruction object, since the creation of instruction object 1143 // instruction object, since the creation of instruction object
1133 // changes code page access permissions (makes them temporary not 1144 // changes code page access permissions (makes them temporary not
1134 // executable). 1145 // executable).
1135 { 1146 {
1147 CheckIfBackgroundCompilerIsBeingStopped();
1136 SafepointOperationScope safepoint_scope(thread()); 1148 SafepointOperationScope safepoint_scope(thread());
1137 // Do not Garbage collect during this stage and instead allow the 1149 // Do not Garbage collect during this stage and instead allow the
1138 // heap to grow. 1150 // heap to grow.
1139 NoHeapGrowthControlScope no_growth_control; 1151 NoHeapGrowthControlScope no_growth_control;
1140 if (!isolate()->background_compiler()->is_running()) { 1152 CheckIfBackgroundCompilerIsBeingStopped();
1141 // The background compiler is being stopped.
1142 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId,
1143 "Background compilation is being stopped");
1144 }
1145 FinalizeCompilation(&assembler, &graph_compiler, flow_graph); 1153 FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
1146 } 1154 }
1147 // TODO(srdjan): Enable this and remove the one from 1155 // TODO(srdjan): Enable this and remove the one from
1148 // 'BackgroundCompiler::CompileOptimized' 1156 // 'BackgroundCompiler::CompileOptimized' once cause of time-outs
1157 // is resolved.
1149 // if (isolate()->heap()->NeedsGarbageCollection()) { 1158 // if (isolate()->heap()->NeedsGarbageCollection()) {
1150 // isolate()->heap()->CollectAllGarbage(); 1159 // isolate()->heap()->CollectAllGarbage();
1151 // } 1160 // }
1152 } 1161 }
1153 } 1162 }
1154 // Mark that this isolate now has compiled code. 1163 // Mark that this isolate now has compiled code.
1155 isolate()->set_has_compiled_code(true); 1164 isolate()->set_has_compiled_code(true);
1156 // Exit the loop and the function with the correct result value. 1165 // Exit the loop and the function with the correct result value.
1157 is_compiled = true; 1166 is_compiled = true;
1158 done = true; 1167 done = true;
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 } 1918 }
1910 1919
1911 1920
1912 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) { 1921 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) {
1913 function_queue_->VisitObjectPointers(visitor); 1922 function_queue_->VisitObjectPointers(visitor);
1914 } 1923 }
1915 1924
1916 1925
1917 void BackgroundCompiler::Stop(Isolate* isolate) { 1926 void BackgroundCompiler::Stop(Isolate* isolate) {
1918 BackgroundCompiler* task = isolate->background_compiler(); 1927 BackgroundCompiler* task = isolate->background_compiler();
1919 ASSERT(task != NULL); 1928 if (task == NULL) {
1929 // Nothing to stop.
1930 return;
1931 }
1920 BackgroundCompilationQueue* function_queue = task->function_queue(); 1932 BackgroundCompilationQueue* function_queue = task->function_queue();
1921 1933
1922 Monitor* queue_monitor = task->queue_monitor_; 1934 Monitor* queue_monitor = task->queue_monitor_;
1923 Monitor* done_monitor = task->done_monitor_; 1935 Monitor* done_monitor = task->done_monitor_;
1924 bool* task_done = task->done_; 1936 bool* task_done = task->done_;
1925 // Wake up compiler task and stop it. 1937 // Wake up compiler task and stop it.
1926 { 1938 {
1927 MonitorLocker ml(queue_monitor); 1939 MonitorLocker ml(queue_monitor);
1928 task->running_ = false; 1940 task->running_ = false;
1929 function_queue->Clear(); 1941 function_queue->Clear();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 } 2105 }
2094 2106
2095 2107
2096 void BackgroundCompiler::EnsureInit(Thread* thread) { 2108 void BackgroundCompiler::EnsureInit(Thread* thread) {
2097 UNREACHABLE(); 2109 UNREACHABLE();
2098 } 2110 }
2099 2111
2100 #endif // DART_PRECOMPILED_RUNTIME 2112 #endif // DART_PRECOMPILED_RUNTIME
2101 2113
2102 } // namespace dart 2114 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/flag_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698