| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 page = page->next(); | 353 page = page->next(); |
| 354 } | 354 } |
| 355 page = large_pages_; | 355 page = large_pages_; |
| 356 while (page != NULL) { | 356 while (page != NULL) { |
| 357 page->WriteProtect(read_only); | 357 page->WriteProtect(read_only); |
| 358 page = page->next(); | 358 page = page->next(); |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 | 362 |
| 363 void PageSpace::MarkSweep(bool invoke_api_callbacks) { | 363 void PageSpace::MarkSweep(bool invoke_api_callbacks, const char* reason) { |
| 364 // MarkSweep is not reentrant. Make sure that is the case. | 364 // MarkSweep is not reentrant. Make sure that is the case. |
| 365 ASSERT(!sweeping_); | 365 ASSERT(!sweeping_); |
| 366 sweeping_ = true; | 366 sweeping_ = true; |
| 367 Isolate* isolate = Isolate::Current(); | 367 Isolate* isolate = Isolate::Current(); |
| 368 NoHandleScope no_handles(isolate); | 368 NoHandleScope no_handles(isolate); |
| 369 | 369 |
| 370 if (FLAG_print_free_list_before_gc) { | 370 if (FLAG_print_free_list_before_gc) { |
| 371 freelist_.Print(); | 371 freelist_.Print(); |
| 372 } | 372 } |
| 373 | 373 |
| 374 if (FLAG_verify_before_gc) { | 374 if (FLAG_verify_before_gc) { |
| 375 OS::PrintErr("Verifying before MarkSweep..."); | 375 OS::PrintErr("Verifying before MarkSweep..."); |
| 376 heap_->Verify(); | 376 heap_->Verify(); |
| 377 OS::PrintErr(" done.\n"); | 377 OS::PrintErr(" done.\n"); |
| 378 } | 378 } |
| 379 | 379 |
| 380 if (FLAG_verbose_gc) { |
| 381 OS::PrintErr("Start mark sweep for %s collection\n", reason); |
| 382 } |
| 380 Timer timer(true, "MarkSweep"); | 383 Timer timer(true, "MarkSweep"); |
| 381 timer.Start(); | 384 timer.Start(); |
| 382 int64_t start = OS::GetCurrentTimeMillis(); | 385 int64_t start = OS::GetCurrentTimeMillis(); |
| 383 | 386 |
| 384 // Mark all reachable old-gen objects. | 387 // Mark all reachable old-gen objects. |
| 385 GCMarker marker(heap_); | 388 GCMarker marker(heap_); |
| 386 marker.MarkObjects(isolate, this, invoke_api_callbacks); | 389 marker.MarkObjects(isolate, this, invoke_api_callbacks); |
| 387 | 390 |
| 388 // Reset the bump allocation page to unused. | 391 // Reset the bump allocation page to unused. |
| 389 bump_page_ = NULL; | 392 bump_page_ = NULL; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 return 0; | 570 return 0; |
| 568 } else { | 571 } else { |
| 569 ASSERT(total_time >= gc_time); | 572 ASSERT(total_time >= gc_time); |
| 570 int result= static_cast<int>((static_cast<double>(gc_time) / | 573 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 571 static_cast<double>(total_time)) * 100); | 574 static_cast<double>(total_time)) * 100); |
| 572 return result; | 575 return result; |
| 573 } | 576 } |
| 574 } | 577 } |
| 575 | 578 |
| 576 } // namespace dart | 579 } // namespace dart |
| OLD | NEW |