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

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

Issue 1541073002: Implement safepointing of threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix-typo Created 4 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 | « runtime/vm/code_descriptors_test.cc ('k') | runtime/vm/compiler_test.cc » ('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 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 if (thread()->IsMutatorThread()) { 1051 if (thread()->IsMutatorThread()) {
1052 FinalizeCompilation(&assembler, &graph_compiler, flow_graph); 1052 FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
1053 } else { 1053 } else {
1054 // This part of compilation must be at a safepoint. 1054 // This part of compilation must be at a safepoint.
1055 // Stop mutator thread before creating the instruction object and 1055 // Stop mutator thread before creating the instruction object and
1056 // installing code. 1056 // installing code.
1057 // Mutator thread may not run code while we are creating the 1057 // Mutator thread may not run code while we are creating the
1058 // instruction object, since the creation of instruction object 1058 // instruction object, since the creation of instruction object
1059 // changes code page access permissions (makes them temporary not 1059 // changes code page access permissions (makes them temporary not
1060 // executable). 1060 // executable).
1061 isolate()->thread_registry()->SafepointThreads();
1062 { 1061 {
1062 SafepointOperationScope safepoint_scope(thread());
1063 // Do not Garbage collect during this stage and instead allow the 1063 // Do not Garbage collect during this stage and instead allow the
1064 // heap to grow. 1064 // heap to grow.
1065 NoHeapGrowthControlScope no_growth_control; 1065 NoHeapGrowthControlScope no_growth_control;
1066 FinalizeCompilation(&assembler, &graph_compiler, flow_graph); 1066 FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
1067 } 1067 }
1068 isolate()->thread_registry()->ResumeAllThreads();
1069 if (isolate()->heap()->NeedsGarbageCollection()) { 1068 if (isolate()->heap()->NeedsGarbageCollection()) {
1070 isolate()->heap()->CollectAllGarbage(); 1069 isolate()->heap()->CollectAllGarbage();
1071 } 1070 }
1072 } 1071 }
1073 } 1072 }
1074 // Mark that this isolate now has compiled code. 1073 // Mark that this isolate now has compiled code.
1075 isolate()->set_has_compiled_code(true); 1074 isolate()->set_has_compiled_code(true);
1076 // Exit the loop and the function with the correct result value. 1075 // Exit the loop and the function with the correct result value.
1077 is_compiled = true; 1076 is_compiled = true;
1078 done = true; 1077 done = true;
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 MonitorLocker ml(task->queue_monitor_); 1891 MonitorLocker ml(task->queue_monitor_);
1893 task->running_ = false; 1892 task->running_ = false;
1894 // 'task' will be deleted by thread pool. 1893 // 'task' will be deleted by thread pool.
1895 task = NULL; 1894 task = NULL;
1896 ml.Notify(); // Stop waiting for the queue. 1895 ml.Notify(); // Stop waiting for the queue.
1897 } 1896 }
1898 1897
1899 { 1898 {
1900 MonitorLocker ml_done(done_monitor); 1899 MonitorLocker ml_done(done_monitor);
1901 while (!(*task_done)) { 1900 while (!(*task_done)) {
1902 // In case that the compiler is waiting for safepoint. 1901 ml_done.WaitWithSafepointCheck(Thread::Current());
1903 Isolate::Current()->thread_registry()->CheckSafepoint();
1904 ml_done.Wait(1);
1905 } 1902 }
1906 } 1903 }
1907 delete task_done; 1904 delete task_done;
1908 delete done_monitor; 1905 delete done_monitor;
1909 delete queue_monitor; 1906 delete queue_monitor;
1910 delete function_queue; 1907 delete function_queue;
1911 Isolate::Current()->set_background_compiler(NULL); 1908 Isolate::Current()->set_background_compiler(NULL);
1912 } 1909 }
1913 1910
1914 1911
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 } 2039 }
2043 2040
2044 2041
2045 void BackgroundCompiler::EnsureInit(Thread* thread) { 2042 void BackgroundCompiler::EnsureInit(Thread* thread) {
2046 UNREACHABLE(); 2043 UNREACHABLE();
2047 } 2044 }
2048 2045
2049 #endif // DART_PRECOMPILED_RUNTIME 2046 #endif // DART_PRECOMPILED_RUNTIME
2050 2047
2051 } // namespace dart 2048 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors_test.cc ('k') | runtime/vm/compiler_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698