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

Unified Diff: runtime/vm/compiler.cc

Issue 1870753002: Clear background compilation queue and abort background compilation when stopping the background co… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/compiler.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/compiler.cc
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
index 21d572122dc9fe241ee3ac94c61a28a47781f9e5..9f3c02fe43aad0407ae535f5999b0f6d4bae07d4 100644
--- a/runtime/vm/compiler.cc
+++ b/runtime/vm/compiler.cc
@@ -1035,6 +1035,10 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
// Do not Garbage collect during this stage and instead allow the
// heap to grow.
NoHeapGrowthControlScope no_growth_control;
+ if (!isolate()->background_compiler()->is_running()) {
+ // The background compiler is being stopped.
+ Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId);
+ }
FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
}
if (isolate()->heap()->NeedsGarbageCollection()) {
@@ -1594,11 +1598,7 @@ class BackgroundCompilationQueue {
public:
BackgroundCompilationQueue() : first_(NULL), last_(NULL) {}
virtual ~BackgroundCompilationQueue() {
- while (!IsEmpty()) {
- QueueElement* e = Remove();
- delete e;
- }
- ASSERT((first_ == NULL) && (last_ == NULL));
+ Clear();
}
void VisitObjectPointers(ObjectPointerVisitor* visitor) {
@@ -1660,6 +1660,14 @@ class BackgroundCompilationQueue {
return false;
}
+ void Clear() {
+ while (!IsEmpty()) {
+ QueueElement* e = Remove();
+ delete e;
+ }
+ ASSERT((first_ == NULL) && (last_ == NULL));
+ }
+
private:
QueueElement* first_;
QueueElement* last_;
@@ -1725,10 +1733,17 @@ void BackgroundCompiler::Run() {
QueueElement* qelem = NULL;
{ MonitorLocker ml(queue_monitor_);
- qelem = function_queue()->Remove();
- function = function_queue()->PeekFunction();
+ if (function_queue()->IsEmpty()) {
+ // We are shutting down, queue was cleared.
+ function = Function::null();
+ } else {
+ qelem = function_queue()->Remove();
+ function = function_queue()->PeekFunction();
+ }
+ }
+ if (qelem != NULL) {
+ delete qelem;
}
- delete qelem;
}
}
Thread::ExitIsolateAsHelper();
@@ -1778,8 +1793,9 @@ void BackgroundCompiler::Stop(BackgroundCompiler* task) {
bool* task_done = task->done_;
// Wake up compiler task and stop it.
{
- MonitorLocker ml(task->queue_monitor_);
+ MonitorLocker ml(queue_monitor);
task->running_ = false;
+ function_queue->Clear();
// 'task' will be deleted by thread pool.
task = NULL;
ml.Notify(); // Stop waiting for the queue.
« no previous file with comments | « runtime/vm/compiler.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698