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