OLD | NEW |
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/pages.h" | 5 #include "vm/pages.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/gc_marker.h" | 8 #include "vm/gc_marker.h" |
9 #include "vm/gc_sweeper.h" | 9 #include "vm/gc_sweeper.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 199 } |
200 | 200 |
201 page = large_pages_; | 201 page = large_pages_; |
202 while (page != NULL) { | 202 while (page != NULL) { |
203 page->VisitObjectPointers(visitor); | 203 page->VisitObjectPointers(visitor); |
204 page = page->next(); | 204 page = page->next(); |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
208 | 208 |
209 void PageSpace::MarkSweep() { | 209 void PageSpace::MarkSweep(bool invoke_api_callbacks) { |
210 // MarkSweep is not reentrant. Make sure that is the case. | 210 // MarkSweep is not reentrant. Make sure that is the case. |
211 ASSERT(!sweeping_); | 211 ASSERT(!sweeping_); |
212 sweeping_ = true; | 212 sweeping_ = true; |
213 Isolate* isolate = Isolate::Current(); | 213 Isolate* isolate = Isolate::Current(); |
214 NoHandleScope no_handles(isolate); | 214 NoHandleScope no_handles(isolate); |
215 | 215 |
216 if (FLAG_verify_before_gc) { | 216 if (FLAG_verify_before_gc) { |
217 OS::PrintErr("Verifying before MarkSweep... "); | 217 OS::PrintErr("Verifying before MarkSweep... "); |
218 heap_->Verify(); | 218 heap_->Verify(); |
219 OS::PrintErr(" done.\n"); | 219 OS::PrintErr(" done.\n"); |
220 } | 220 } |
221 | 221 |
222 Timer timer(FLAG_verbose_gc, "MarkSweep"); | 222 Timer timer(FLAG_verbose_gc, "MarkSweep"); |
223 timer.Start(); | 223 timer.Start(); |
224 | 224 |
225 // Mark all reachable old-gen objects. | 225 // Mark all reachable old-gen objects. |
226 GCMarker marker(heap_); | 226 GCMarker marker(heap_); |
227 marker.MarkObjects(isolate, this); | 227 marker.MarkObjects(isolate, this, invoke_api_callbacks); |
228 | 228 |
229 // Reset the freelists and setup sweeping. | 229 // Reset the freelists and setup sweeping. |
230 freelist_.Reset(); | 230 freelist_.Reset(); |
231 GCSweeper sweeper(heap_); | 231 GCSweeper sweeper(heap_); |
232 intptr_t in_use = 0; | 232 intptr_t in_use = 0; |
233 | 233 |
234 HeapPage* page = pages_; | 234 HeapPage* page = pages_; |
235 while (page != NULL) { | 235 while (page != NULL) { |
236 in_use += sweeper.SweepPage(page, &freelist_); | 236 in_use += sweeper.SweepPage(page, &freelist_); |
237 page = page->next(); | 237 page = page->next(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 OS::PrintErr(" done.\n"); | 273 OS::PrintErr(" done.\n"); |
274 } | 274 } |
275 | 275 |
276 count_++; | 276 count_++; |
277 // Done, reset the marker. | 277 // Done, reset the marker. |
278 ASSERT(sweeping_); | 278 ASSERT(sweeping_); |
279 sweeping_ = false; | 279 sweeping_ = false; |
280 } | 280 } |
281 | 281 |
282 } // namespace dart | 282 } // namespace dart |
OLD | NEW |