| 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/heap.h" | 5 #include "vm/heap.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 438 } |
| 439 | 439 |
| 440 void Heap::WaitForSweeperTasks(Thread* thread) { | 440 void Heap::WaitForSweeperTasks(Thread* thread) { |
| 441 MonitorLocker ml(old_space_.tasks_lock()); | 441 MonitorLocker ml(old_space_.tasks_lock()); |
| 442 while (old_space_.tasks() > 0) { | 442 while (old_space_.tasks() > 0) { |
| 443 ml.WaitWithSafepointCheck(thread); | 443 ml.WaitWithSafepointCheck(thread); |
| 444 } | 444 } |
| 445 } | 445 } |
| 446 | 446 |
| 447 void Heap::UpdateGlobalMaxUsed() { | 447 void Heap::UpdateGlobalMaxUsed() { |
| 448 #if !defined(PRODUCT) |
| 448 ASSERT(isolate_ != NULL); | 449 ASSERT(isolate_ != NULL); |
| 449 // We are accessing the used in words count for both new and old space | 450 // We are accessing the used in words count for both new and old space |
| 450 // without synchronizing. The value of this metric is approximate. | 451 // without synchronizing. The value of this metric is approximate. |
| 451 isolate_->GetHeapGlobalUsedMaxMetric()->SetValue( | 452 isolate_->GetHeapGlobalUsedMaxMetric()->SetValue( |
| 452 (UsedInWords(Heap::kNew) * kWordSize) + | 453 (UsedInWords(Heap::kNew) * kWordSize) + |
| 453 (UsedInWords(Heap::kOld) * kWordSize)); | 454 (UsedInWords(Heap::kOld) * kWordSize)); |
| 455 #endif // !defined(PRODUCT) |
| 454 } | 456 } |
| 455 | 457 |
| 456 void Heap::InitGrowthControl() { | 458 void Heap::InitGrowthControl() { |
| 457 old_space_.InitGrowthControl(); | 459 old_space_.InitGrowthControl(); |
| 458 } | 460 } |
| 459 | 461 |
| 460 void Heap::SetGrowthControlState(bool state) { | 462 void Heap::SetGrowthControlState(bool state) { |
| 461 old_space_.SetGrowthControlState(state); | 463 old_space_.SetGrowthControlState(state); |
| 462 } | 464 } |
| 463 | 465 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 475 intptr_t max_new_gen_words, | 477 intptr_t max_new_gen_words, |
| 476 intptr_t max_old_gen_words, | 478 intptr_t max_old_gen_words, |
| 477 intptr_t max_external_words) { | 479 intptr_t max_external_words) { |
| 478 ASSERT(isolate->heap() == NULL); | 480 ASSERT(isolate->heap() == NULL); |
| 479 Heap* heap = new Heap(isolate, max_new_gen_words, max_old_gen_words, | 481 Heap* heap = new Heap(isolate, max_new_gen_words, max_old_gen_words, |
| 480 max_external_words); | 482 max_external_words); |
| 481 isolate->set_heap(heap); | 483 isolate->set_heap(heap); |
| 482 } | 484 } |
| 483 | 485 |
| 484 void Heap::RegionName(Heap* heap, Space space, char* name, intptr_t name_size) { | 486 void Heap::RegionName(Heap* heap, Space space, char* name, intptr_t name_size) { |
| 487 #if defined(PRODUCT) |
| 488 const bool no_isolate_name = (heap == NULL) || (heap->isolate() == NULL) || |
| 489 (heap->isolate()->name() == NULL); |
| 490 const char* isolate_name = |
| 491 no_isolate_name ? "<unknown>" : heap->isolate()->name(); |
| 492 #else |
| 485 const bool no_isolate_name = (heap == NULL) || (heap->isolate() == NULL) || | 493 const bool no_isolate_name = (heap == NULL) || (heap->isolate() == NULL) || |
| 486 (heap->isolate()->debugger_name() == NULL); | 494 (heap->isolate()->debugger_name() == NULL); |
| 487 const char* isolate_name = | 495 const char* isolate_name = |
| 488 no_isolate_name ? "<unknown>" : heap->isolate()->debugger_name(); | 496 no_isolate_name ? "<unknown>" : heap->isolate()->debugger_name(); |
| 497 #endif // !defined(PRODUCT) |
| 489 const char* space_name = NULL; | 498 const char* space_name = NULL; |
| 490 switch (space) { | 499 switch (space) { |
| 491 case kNew: | 500 case kNew: |
| 492 space_name = "newspace"; | 501 space_name = "newspace"; |
| 493 break; | 502 break; |
| 494 case kOld: | 503 case kOld: |
| 495 space_name = "oldspace"; | 504 space_name = "oldspace"; |
| 496 break; | 505 break; |
| 497 case kCode: | 506 case kCode: |
| 498 space_name = "codespace"; | 507 space_name = "codespace"; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 if (FLAG_support_service && Service::gc_stream.enabled() && | 704 if (FLAG_support_service && Service::gc_stream.enabled() && |
| 696 !ServiceIsolate::IsServiceIsolateDescendant(Isolate::Current())) { | 705 !ServiceIsolate::IsServiceIsolateDescendant(Isolate::Current())) { |
| 697 ServiceEvent event(Isolate::Current(), ServiceEvent::kGC); | 706 ServiceEvent event(Isolate::Current(), ServiceEvent::kGC); |
| 698 event.set_gc_stats(&stats_); | 707 event.set_gc_stats(&stats_); |
| 699 Service::HandleEvent(&event); | 708 Service::HandleEvent(&event); |
| 700 } | 709 } |
| 701 #endif // !PRODUCT | 710 #endif // !PRODUCT |
| 702 } | 711 } |
| 703 | 712 |
| 704 void Heap::PrintStats() { | 713 void Heap::PrintStats() { |
| 714 #if !defined(PRODUCT) |
| 705 if (!FLAG_verbose_gc) return; | 715 if (!FLAG_verbose_gc) return; |
| 706 | 716 |
| 707 if ((FLAG_verbose_gc_hdr != 0) && | 717 if ((FLAG_verbose_gc_hdr != 0) && |
| 708 (((stats_.num_ - 1) % FLAG_verbose_gc_hdr) == 0)) { | 718 (((stats_.num_ - 1) % FLAG_verbose_gc_hdr) == 0)) { |
| 709 OS::PrintErr( | 719 OS::PrintErr( |
| 710 "[ | | | | " | 720 "[ | | | | " |
| 711 "| new gen | new gen | new gen " | 721 "| new gen | new gen | new gen " |
| 712 "| old gen | old gen | old gen " | 722 "| old gen | old gen | old gen " |
| 713 "| sweep | safe- | roots/| stbuf/| tospc/| weaks/| ]\n" | 723 "| sweep | safe- | roots/| stbuf/| tospc/| weaks/| ]\n" |
| 714 "[ GC isolate | space (reason) | GC# | start | time " | 724 "[ GC isolate | space (reason) | GC# | start | time " |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 MicrosecondsToMilliseconds(stats_.times_[1]), | 768 MicrosecondsToMilliseconds(stats_.times_[1]), |
| 759 MicrosecondsToMilliseconds(stats_.times_[2]), | 769 MicrosecondsToMilliseconds(stats_.times_[2]), |
| 760 MicrosecondsToMilliseconds(stats_.times_[3]), | 770 MicrosecondsToMilliseconds(stats_.times_[3]), |
| 761 MicrosecondsToMilliseconds(stats_.times_[4]), | 771 MicrosecondsToMilliseconds(stats_.times_[4]), |
| 762 MicrosecondsToMilliseconds(stats_.times_[5]), | 772 MicrosecondsToMilliseconds(stats_.times_[5]), |
| 763 stats_.data_[0], | 773 stats_.data_[0], |
| 764 stats_.data_[1], | 774 stats_.data_[1], |
| 765 stats_.data_[2], | 775 stats_.data_[2], |
| 766 stats_.data_[3]); | 776 stats_.data_[3]); |
| 767 // clang-format on | 777 // clang-format on |
| 778 #endif // !defined(PRODUCT) |
| 768 } | 779 } |
| 769 | 780 |
| 770 void Heap::PrintStatsToTimeline(TimelineEventScope* event) { | 781 void Heap::PrintStatsToTimeline(TimelineEventScope* event) { |
| 771 #if !defined(PRODUCT) | 782 #if !defined(PRODUCT) |
| 772 if ((event == NULL) || !event->enabled()) { | 783 if ((event == NULL) || !event->enabled()) { |
| 773 return; | 784 return; |
| 774 } | 785 } |
| 775 event->SetNumArguments(12); | 786 event->SetNumArguments(12); |
| 776 event->FormatArgument(0, "Before.New.Used (kB)", "%" Pd "", | 787 event->FormatArgument(0, "Before.New.Used (kB)", "%" Pd "", |
| 777 RoundWordsToKB(stats_.before_.new_.used_in_words)); | 788 RoundWordsToKB(stats_.before_.new_.used_in_words)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 : StackResource(thread) { | 829 : StackResource(thread) { |
| 819 Dart::vm_isolate()->heap()->WriteProtect(false); | 830 Dart::vm_isolate()->heap()->WriteProtect(false); |
| 820 } | 831 } |
| 821 | 832 |
| 822 WritableVMIsolateScope::~WritableVMIsolateScope() { | 833 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 823 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 834 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 824 Dart::vm_isolate()->heap()->WriteProtect(true); | 835 Dart::vm_isolate()->heap()->WriteProtect(true); |
| 825 } | 836 } |
| 826 | 837 |
| 827 } // namespace dart | 838 } // namespace dart |
| OLD | NEW |