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

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

Issue 1233563004: Avoid race in isolate shutdown; add assertions, error messages (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Move wait per suggestion; port to all platforms. Created 5 years, 5 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 | « no previous file | runtime/vm/isolate.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/gc_sweeper.h" 5 #include "vm/gc_sweeper.h"
6 6
7 #include "vm/freelist.h" 7 #include "vm/freelist.h"
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 { 131 {
132 // Notify the mutator thread that we have added elements to the free 132 // Notify the mutator thread that we have added elements to the free
133 // list or that more capacity is available. 133 // list or that more capacity is available.
134 MonitorLocker ml(old_space_->tasks_lock()); 134 MonitorLocker ml(old_space_->tasks_lock());
135 ml.Notify(); 135 ml.Notify();
136 } 136 }
137 if (page == last_) break; 137 if (page == last_) break;
138 page = next_page; 138 page = next_page;
139 } 139 }
140 // Exit isolate cleanly *before* notifying it, to avoid shutdown race.
141 Thread::ExitIsolateAsHelper();
140 // This sweeper task is done. Notify the original isolate. 142 // This sweeper task is done. Notify the original isolate.
141 { 143 {
142 MonitorLocker ml(old_space_->tasks_lock()); 144 MonitorLocker ml(old_space_->tasks_lock());
143 old_space_->set_tasks(old_space_->tasks() - 1); 145 old_space_->set_tasks(old_space_->tasks() - 1);
144 ml.Notify(); 146 ml.Notify();
145 } 147 }
146 Thread::ExitIsolateAsHelper();
147 } 148 }
148 149
149 private: 150 private:
150 Isolate* task_isolate_; 151 Isolate* task_isolate_;
151 PageSpace* old_space_; 152 PageSpace* old_space_;
152 HeapPage* first_; 153 HeapPage* first_;
153 HeapPage* last_; 154 HeapPage* last_;
154 FreeList* freelist_; 155 FreeList* freelist_;
155 }; 156 };
156 157
157 158
158 void GCSweeper::SweepConcurrent(Isolate* isolate, 159 void GCSweeper::SweepConcurrent(Isolate* isolate,
159 HeapPage* first, 160 HeapPage* first,
160 HeapPage* last, 161 HeapPage* last,
161 FreeList* freelist) { 162 FreeList* freelist) {
162 SweeperTask* task = 163 SweeperTask* task =
163 new SweeperTask(isolate, 164 new SweeperTask(isolate,
164 isolate->heap()->old_space(), 165 isolate->heap()->old_space(),
165 first, last, 166 first, last,
166 freelist); 167 freelist);
167 ThreadPool* pool = Dart::thread_pool(); 168 ThreadPool* pool = Dart::thread_pool();
168 pool->Run(task); 169 pool->Run(task);
169 } 170 }
170 171
171 } // namespace dart 172 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698