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/heap_trace.h" |
10 #include "vm/object.h" | 11 #include "vm/object.h" |
11 #include "vm/virtual_memory.h" | 12 #include "vm/virtual_memory.h" |
12 | 13 |
13 namespace dart { | 14 namespace dart { |
14 | 15 |
15 DEFINE_FLAG(int, heap_growth_space_ratio, 10, | 16 DEFINE_FLAG(int, heap_growth_space_ratio, 10, |
16 "The desired maximum percentage of free space after GC"); | 17 "The desired maximum percentage of free space after GC"); |
17 DEFINE_FLAG(int, heap_growth_time_ratio, 3, | 18 DEFINE_FLAG(int, heap_growth_time_ratio, 3, |
18 "The desired maximum percentage of time spent in GC"); | 19 "The desired maximum percentage of time spent in GC"); |
19 DEFINE_FLAG(int, heap_growth_rate, 4, | 20 DEFINE_FLAG(int, heap_growth_rate, 4, |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 393 } |
393 | 394 |
394 | 395 |
395 void PageSpace::MarkSweep(bool invoke_api_callbacks, const char* gc_reason) { | 396 void PageSpace::MarkSweep(bool invoke_api_callbacks, const char* gc_reason) { |
396 // MarkSweep is not reentrant. Make sure that is the case. | 397 // MarkSweep is not reentrant. Make sure that is the case. |
397 ASSERT(!sweeping_); | 398 ASSERT(!sweeping_); |
398 sweeping_ = true; | 399 sweeping_ = true; |
399 Isolate* isolate = Isolate::Current(); | 400 Isolate* isolate = Isolate::Current(); |
400 NoHandleScope no_handles(isolate); | 401 NoHandleScope no_handles(isolate); |
401 | 402 |
| 403 if (HeapTrace::is_enabled()) { |
| 404 isolate->heap()->trace()->TraceMarkSweepStart(); |
| 405 } |
| 406 |
402 if (FLAG_print_free_list_before_gc) { | 407 if (FLAG_print_free_list_before_gc) { |
403 OS::Print("Data Freelist:\n"); | 408 OS::Print("Data Freelist:\n"); |
404 freelist_[HeapPage::kData].Print(); | 409 freelist_[HeapPage::kData].Print(); |
405 OS::Print("Executable Freelist:\n"); | 410 OS::Print("Executable Freelist:\n"); |
406 freelist_[HeapPage::kExecutable].Print(); | 411 freelist_[HeapPage::kExecutable].Print(); |
407 } | 412 } |
408 | 413 |
409 if (FLAG_verify_before_gc) { | 414 if (FLAG_verify_before_gc) { |
410 OS::PrintErr("Verifying before MarkSweep..."); | 415 OS::PrintErr("Verifying before MarkSweep..."); |
411 heap_->Verify(); | 416 heap_->Verify(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 OS::Print("Executable Freelist:\n"); | 492 OS::Print("Executable Freelist:\n"); |
488 freelist_[HeapPage::kExecutable].Print(); | 493 freelist_[HeapPage::kExecutable].Print(); |
489 } | 494 } |
490 | 495 |
491 if (FLAG_verify_after_gc) { | 496 if (FLAG_verify_after_gc) { |
492 OS::PrintErr("Verifying after MarkSweep..."); | 497 OS::PrintErr("Verifying after MarkSweep..."); |
493 heap_->Verify(); | 498 heap_->Verify(); |
494 OS::PrintErr(" done.\n"); | 499 OS::PrintErr(" done.\n"); |
495 } | 500 } |
496 | 501 |
| 502 if (HeapTrace::is_enabled()) { |
| 503 isolate->heap()->trace()->TraceMarkSweepFinish(); |
| 504 } |
| 505 |
497 count_++; | 506 count_++; |
498 // Done, reset the marker. | 507 // Done, reset the marker. |
499 ASSERT(sweeping_); | 508 ASSERT(sweeping_); |
500 sweeping_ = false; | 509 sweeping_ = false; |
501 } | 510 } |
502 | 511 |
503 | 512 |
504 PageSpaceController::PageSpaceController(int heap_growth_ratio, | 513 PageSpaceController::PageSpaceController(int heap_growth_ratio, |
505 int heap_growth_rate, | 514 int heap_growth_rate, |
506 int garbage_collection_time_ratio) | 515 int garbage_collection_time_ratio) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 return 0; | 628 return 0; |
620 } else { | 629 } else { |
621 ASSERT(total_time >= gc_time); | 630 ASSERT(total_time >= gc_time); |
622 int result= static_cast<int>((static_cast<double>(gc_time) / | 631 int result= static_cast<int>((static_cast<double>(gc_time) / |
623 static_cast<double>(total_time)) * 100); | 632 static_cast<double>(total_time)) * 100); |
624 return result; | 633 return result; |
625 } | 634 } |
626 } | 635 } |
627 | 636 |
628 } // namespace dart | 637 } // namespace dart |
OLD | NEW |