| 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" | |
| 12 #include "vm/object.h" | 11 #include "vm/object.h" |
| 13 #include "vm/virtual_memory.h" | 12 #include "vm/virtual_memory.h" |
| 14 | 13 |
| 15 namespace dart { | 14 namespace dart { |
| 16 | 15 |
| 17 DEFINE_FLAG(int, heap_growth_space_ratio, 10, | 16 DEFINE_FLAG(int, heap_growth_space_ratio, 10, |
| 18 "The desired maximum percentage of free space after GC"); | 17 "The desired maximum percentage of free space after GC"); |
| 19 DEFINE_FLAG(int, heap_growth_time_ratio, 3, | 18 DEFINE_FLAG(int, heap_growth_time_ratio, 3, |
| 20 "The desired maximum percentage of time spent in GC"); | 19 "The desired maximum percentage of time spent in GC"); |
| 21 DEFINE_FLAG(int, heap_growth_rate, 4, | 20 DEFINE_FLAG(int, heap_growth_rate, 4, |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } | 400 } |
| 402 | 401 |
| 403 | 402 |
| 404 void PageSpace::MarkSweep(bool invoke_api_callbacks) { | 403 void PageSpace::MarkSweep(bool invoke_api_callbacks) { |
| 405 // MarkSweep is not reentrant. Make sure that is the case. | 404 // MarkSweep is not reentrant. Make sure that is the case. |
| 406 ASSERT(!sweeping_); | 405 ASSERT(!sweeping_); |
| 407 sweeping_ = true; | 406 sweeping_ = true; |
| 408 Isolate* isolate = Isolate::Current(); | 407 Isolate* isolate = Isolate::Current(); |
| 409 NoHandleScope no_handles(isolate); | 408 NoHandleScope no_handles(isolate); |
| 410 | 409 |
| 411 if (HeapTrace::is_enabled()) { | |
| 412 isolate->heap()->trace()->TraceMarkSweepStart(); | |
| 413 } | |
| 414 | |
| 415 if (FLAG_print_free_list_before_gc) { | 410 if (FLAG_print_free_list_before_gc) { |
| 416 OS::Print("Data Freelist (before GC):\n"); | 411 OS::Print("Data Freelist (before GC):\n"); |
| 417 freelist_[HeapPage::kData].Print(); | 412 freelist_[HeapPage::kData].Print(); |
| 418 OS::Print("Executable Freelist (before GC):\n"); | 413 OS::Print("Executable Freelist (before GC):\n"); |
| 419 freelist_[HeapPage::kExecutable].Print(); | 414 freelist_[HeapPage::kExecutable].Print(); |
| 420 } | 415 } |
| 421 | 416 |
| 422 if (FLAG_verify_before_gc) { | 417 if (FLAG_verify_before_gc) { |
| 423 OS::PrintErr("Verifying before MarkSweep..."); | 418 OS::PrintErr("Verifying before MarkSweep..."); |
| 424 heap_->Verify(); | 419 heap_->Verify(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 OS::Print("Executable Freelist (after GC):\n"); | 491 OS::Print("Executable Freelist (after GC):\n"); |
| 497 freelist_[HeapPage::kExecutable].Print(); | 492 freelist_[HeapPage::kExecutable].Print(); |
| 498 } | 493 } |
| 499 | 494 |
| 500 if (FLAG_verify_after_gc) { | 495 if (FLAG_verify_after_gc) { |
| 501 OS::PrintErr("Verifying after MarkSweep..."); | 496 OS::PrintErr("Verifying after MarkSweep..."); |
| 502 heap_->Verify(); | 497 heap_->Verify(); |
| 503 OS::PrintErr(" done.\n"); | 498 OS::PrintErr(" done.\n"); |
| 504 } | 499 } |
| 505 | 500 |
| 506 if (HeapTrace::is_enabled()) { | |
| 507 isolate->heap()->trace()->TraceMarkSweepFinish(); | |
| 508 } | |
| 509 | |
| 510 // Done, reset the marker. | 501 // Done, reset the marker. |
| 511 ASSERT(sweeping_); | 502 ASSERT(sweeping_); |
| 512 sweeping_ = false; | 503 sweeping_ = false; |
| 513 } | 504 } |
| 514 | 505 |
| 515 | 506 |
| 516 PageSpaceController::PageSpaceController(int heap_growth_ratio, | 507 PageSpaceController::PageSpaceController(int heap_growth_ratio, |
| 517 int heap_growth_rate, | 508 int heap_growth_rate, |
| 518 int garbage_collection_time_ratio) | 509 int garbage_collection_time_ratio) |
| 519 : is_enabled_(false), | 510 : is_enabled_(false), |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 return 0; | 608 return 0; |
| 618 } else { | 609 } else { |
| 619 ASSERT(total_time >= gc_time); | 610 ASSERT(total_time >= gc_time); |
| 620 int result= static_cast<int>((static_cast<double>(gc_time) / | 611 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 621 static_cast<double>(total_time)) * 100); | 612 static_cast<double>(total_time)) * 100); |
| 622 return result; | 613 return result; |
| 623 } | 614 } |
| 624 } | 615 } |
| 625 | 616 |
| 626 } // namespace dart | 617 } // namespace dart |
| OLD | NEW |