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