| 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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 | 693 |
| 694 void Heap::RecordBeforeGC(Space space, GCReason reason) { | 694 void Heap::RecordBeforeGC(Space space, GCReason reason) { |
| 695 ASSERT((space == kNew && gc_new_space_in_progress_) || | 695 ASSERT((space == kNew && gc_new_space_in_progress_) || |
| 696 (space == kOld && gc_old_space_in_progress_)); | 696 (space == kOld && gc_old_space_in_progress_)); |
| 697 stats_.num_++; | 697 stats_.num_++; |
| 698 stats_.space_ = space; | 698 stats_.space_ = space; |
| 699 stats_.reason_ = reason; | 699 stats_.reason_ = reason; |
| 700 stats_.before_.micros_ = OS::GetCurrentMonotonicMicros(); | 700 stats_.before_.micros_ = OS::GetCurrentMonotonicMicros(); |
| 701 stats_.before_.new_ = new_space_.GetCurrentUsage(); | 701 stats_.before_.new_ = new_space_.GetCurrentUsage(); |
| 702 stats_.before_.old_ = old_space_.GetCurrentUsage(); | 702 stats_.before_.old_ = old_space_.GetCurrentUsage(); |
| 703 stats_.times_[0] = 0; | 703 for (int i = 0; i < GCStats::kTimeEntries; i++) |
| 704 stats_.times_[1] = 0; | 704 stats_.times_[i] = 0; |
| 705 stats_.times_[2] = 0; | 705 for (int i = 0; i < GCStats::kDataEntries; i++) |
| 706 stats_.times_[3] = 0; | 706 stats_.data_[i] = 0; |
| 707 stats_.data_[0] = 0; | |
| 708 stats_.data_[1] = 0; | |
| 709 stats_.data_[2] = 0; | |
| 710 stats_.data_[3] = 0; | |
| 711 } | 707 } |
| 712 | 708 |
| 713 | 709 |
| 714 void Heap::RecordAfterGC(Space space) { | 710 void Heap::RecordAfterGC(Space space) { |
| 715 stats_.after_.micros_ = OS::GetCurrentMonotonicMicros(); | 711 stats_.after_.micros_ = OS::GetCurrentMonotonicMicros(); |
| 716 int64_t delta = stats_.after_.micros_ - stats_.before_.micros_; | 712 int64_t delta = stats_.after_.micros_ - stats_.before_.micros_; |
| 717 if (stats_.space_ == kNew) { | 713 if (stats_.space_ == kNew) { |
| 718 new_space_.AddGCTime(delta); | 714 new_space_.AddGCTime(delta); |
| 719 new_space_.IncrementCollections(); | 715 new_space_.IncrementCollections(); |
| 720 } else { | 716 } else { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 735 #endif // !PRODUCT | 731 #endif // !PRODUCT |
| 736 } | 732 } |
| 737 | 733 |
| 738 | 734 |
| 739 void Heap::PrintStats() { | 735 void Heap::PrintStats() { |
| 740 if (!FLAG_verbose_gc) return; | 736 if (!FLAG_verbose_gc) return; |
| 741 | 737 |
| 742 if ((FLAG_verbose_gc_hdr != 0) && | 738 if ((FLAG_verbose_gc_hdr != 0) && |
| 743 (((stats_.num_ - 1) % FLAG_verbose_gc_hdr) == 0)) { | 739 (((stats_.num_ - 1) % FLAG_verbose_gc_hdr) == 0)) { |
| 744 OS::PrintErr( | 740 OS::PrintErr( |
| 745 "[ GC | space | count | start | gc time | " | 741 "[ | | | | " |
| 746 "new gen (KB) | old gen (KB) | timers | data ]\n" | 742 "| new gen | new gen | new gen " |
| 747 "[ (isolate)| (reason)| | (s) | (ms) | " | 743 "| old gen | old gen | old gen " |
| 748 "used,cap,ext | used,cap,ext | (ms) | ]\n"); | 744 "| sweep | safe- | roots/| stbuf/| tospc/| weaks/| ]\n" |
| 745 "[ GC isolate | space (reason) | GC# | start | time " |
| 746 "| used (kB) | capacity kB | external" |
| 747 "| used (kB) | capacity (kB) | external kB " |
| 748 "| thread| point |marking| reset | sweep |swplrge| data ]\n" |
| 749 "[ | | | (s) | (ms) " |
| 750 "|before| after|before| after| b4 |aftr" |
| 751 "| before| after | before| after |before| after" |
| 752 "| (ms) | (ms) | (ms) | (ms) | (ms) | (ms) | ]\n"); |
| 749 } | 753 } |
| 750 | 754 |
| 751 // clang-format off | 755 // clang-format off |
| 752 const char* space_str = stats_.space_ == kNew ? "Scavenge" : "Mark-Sweep"; | 756 const char* space_str = stats_.space_ == kNew ? "Scavenge" : "Mark-Sweep"; |
| 753 OS::PrintErr( | 757 OS::PrintErr( |
| 754 "[ GC(%" Pd64 "): %s(%s), " // GC(isolate), space(reason) | 758 "[ GC %9" Pd64 " : %10s(%9s), " // GC(isolate), space(reason) |
| 755 "%" Pd ", " // count | 759 "%4" Pd ", " // count |
| 756 "%.3f, " // start time | 760 "%6.2f, " // start time |
| 757 "%.3f, " // total time | 761 "%5.1f, " // total time |
| 758 "%" Pd ", %" Pd ", " // new gen: in use before/after | 762 "%5" Pd ", %5" Pd ", " // new gen: in use before/after |
| 759 "%" Pd ", %" Pd ", " // new gen: capacity before/after | 763 "%5" Pd ", %5" Pd ", " // new gen: capacity before/after |
| 760 "%" Pd ", %" Pd ", " // new gen: external before/after | 764 "%3" Pd ", %3" Pd ", " // new gen: external before/after |
| 761 "%" Pd ", %" Pd ", " // old gen: in use before/after | 765 "%6" Pd ", %6" Pd ", " // old gen: in use before/after |
| 762 "%" Pd ", %" Pd ", " // old gen: capacity before/after | 766 "%6" Pd ", %6" Pd ", " // old gen: capacity before/after |
| 763 "%" Pd ", %" Pd ", " // old gen: external before/after | 767 "%5" Pd ", %5" Pd ", " // old gen: external before/after |
| 764 "%.3f, %.3f, %.3f, %.3f, " // times | 768 "%6.2f, %6.2f, %6.2f, %6.2f, %6.2f, %6.2f, " // times |
| 765 "%" Pd ", %" Pd ", %" Pd ", %" Pd ", " // data | 769 "%" Pd ", %" Pd ", %" Pd ", %" Pd ", " // data |
| 766 "]\n", // End with a comma to make it easier to import in spreadsheets. | 770 "]\n", // End with a comma to make it easier to import in spreadsheets. |
| 767 isolate()->main_port(), space_str, GCReasonToString(stats_.reason_), | 771 isolate()->main_port(), space_str, GCReasonToString(stats_.reason_), |
| 768 stats_.num_, | 772 stats_.num_, |
| 769 MicrosecondsToSeconds(isolate()->UptimeMicros()), | 773 MicrosecondsToSeconds(isolate()->UptimeMicros()), |
| 770 MicrosecondsToMilliseconds(stats_.after_.micros_ - | 774 MicrosecondsToMilliseconds(stats_.after_.micros_ - |
| 771 stats_.before_.micros_), | 775 stats_.before_.micros_), |
| 772 RoundWordsToKB(stats_.before_.new_.used_in_words), | 776 RoundWordsToKB(stats_.before_.new_.used_in_words), |
| 773 RoundWordsToKB(stats_.after_.new_.used_in_words), | 777 RoundWordsToKB(stats_.after_.new_.used_in_words), |
| 774 RoundWordsToKB(stats_.before_.new_.capacity_in_words), | 778 RoundWordsToKB(stats_.before_.new_.capacity_in_words), |
| 775 RoundWordsToKB(stats_.after_.new_.capacity_in_words), | 779 RoundWordsToKB(stats_.after_.new_.capacity_in_words), |
| 776 RoundWordsToKB(stats_.before_.new_.external_in_words), | 780 RoundWordsToKB(stats_.before_.new_.external_in_words), |
| 777 RoundWordsToKB(stats_.after_.new_.external_in_words), | 781 RoundWordsToKB(stats_.after_.new_.external_in_words), |
| 778 RoundWordsToKB(stats_.before_.old_.used_in_words), | 782 RoundWordsToKB(stats_.before_.old_.used_in_words), |
| 779 RoundWordsToKB(stats_.after_.old_.used_in_words), | 783 RoundWordsToKB(stats_.after_.old_.used_in_words), |
| 780 RoundWordsToKB(stats_.before_.old_.capacity_in_words), | 784 RoundWordsToKB(stats_.before_.old_.capacity_in_words), |
| 781 RoundWordsToKB(stats_.after_.old_.capacity_in_words), | 785 RoundWordsToKB(stats_.after_.old_.capacity_in_words), |
| 782 RoundWordsToKB(stats_.before_.old_.external_in_words), | 786 RoundWordsToKB(stats_.before_.old_.external_in_words), |
| 783 RoundWordsToKB(stats_.after_.old_.external_in_words), | 787 RoundWordsToKB(stats_.after_.old_.external_in_words), |
| 784 MicrosecondsToMilliseconds(stats_.times_[0]), | 788 MicrosecondsToMilliseconds(stats_.times_[0]), |
| 785 MicrosecondsToMilliseconds(stats_.times_[1]), | 789 MicrosecondsToMilliseconds(stats_.times_[1]), |
| 786 MicrosecondsToMilliseconds(stats_.times_[2]), | 790 MicrosecondsToMilliseconds(stats_.times_[2]), |
| 787 MicrosecondsToMilliseconds(stats_.times_[3]), | 791 MicrosecondsToMilliseconds(stats_.times_[3]), |
| 792 MicrosecondsToMilliseconds(stats_.times_[4]), |
| 793 MicrosecondsToMilliseconds(stats_.times_[5]), |
| 788 stats_.data_[0], | 794 stats_.data_[0], |
| 789 stats_.data_[1], | 795 stats_.data_[1], |
| 790 stats_.data_[2], | 796 stats_.data_[2], |
| 791 stats_.data_[3]); | 797 stats_.data_[3]); |
| 792 // clang-format on | 798 // clang-format on |
| 793 } | 799 } |
| 794 | 800 |
| 795 | 801 |
| 796 void Heap::PrintStatsToTimeline(TimelineEventScope* event) { | 802 void Heap::PrintStatsToTimeline(TimelineEventScope* event) { |
| 797 #if !defined(PRODUCT) | 803 #if !defined(PRODUCT) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 Dart::vm_isolate()->heap()->WriteProtect(false); | 854 Dart::vm_isolate()->heap()->WriteProtect(false); |
| 849 } | 855 } |
| 850 | 856 |
| 851 | 857 |
| 852 WritableVMIsolateScope::~WritableVMIsolateScope() { | 858 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 853 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 859 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 854 Dart::vm_isolate()->heap()->WriteProtect(true); | 860 Dart::vm_isolate()->heap()->WriteProtect(true); |
| 855 } | 861 } |
| 856 | 862 |
| 857 } // namespace dart | 863 } // namespace dart |
| OLD | NEW |