OLD | NEW |
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 Loading... |
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 |
OLD | NEW |