OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 HeapObjectCallback size_func) { | 1770 HeapObjectCallback size_func) { |
1771 SemiSpace::AssertValidRange(start, end); | 1771 SemiSpace::AssertValidRange(start, end); |
1772 current_ = start; | 1772 current_ = start; |
1773 limit_ = end; | 1773 limit_ = end; |
1774 size_func_ = size_func; | 1774 size_func_ = size_func; |
1775 } | 1775 } |
1776 | 1776 |
1777 | 1777 |
1778 #ifdef DEBUG | 1778 #ifdef DEBUG |
1779 // heap_histograms is shared, always clear it before using it. | 1779 // heap_histograms is shared, always clear it before using it. |
1780 static void ClearHistograms() { | 1780 static void ClearHistograms(Isolate* isolate) { |
1781 Isolate* isolate = Isolate::Current(); | |
1782 // We reset the name each time, though it hasn't changed. | 1781 // We reset the name each time, though it hasn't changed. |
1783 #define DEF_TYPE_NAME(name) isolate->heap_histograms()[name].set_name(#name); | 1782 #define DEF_TYPE_NAME(name) isolate->heap_histograms()[name].set_name(#name); |
1784 INSTANCE_TYPE_LIST(DEF_TYPE_NAME) | 1783 INSTANCE_TYPE_LIST(DEF_TYPE_NAME) |
1785 #undef DEF_TYPE_NAME | 1784 #undef DEF_TYPE_NAME |
1786 | 1785 |
1787 #define CLEAR_HISTOGRAM(name) isolate->heap_histograms()[name].clear(); | 1786 #define CLEAR_HISTOGRAM(name) isolate->heap_histograms()[name].clear(); |
1788 INSTANCE_TYPE_LIST(CLEAR_HISTOGRAM) | 1787 INSTANCE_TYPE_LIST(CLEAR_HISTOGRAM) |
1789 #undef CLEAR_HISTOGRAM | 1788 #undef CLEAR_HISTOGRAM |
1790 | 1789 |
1791 isolate->js_spill_information()->Clear(); | 1790 isolate->js_spill_information()->Clear(); |
(...skipping 30 matching lines...) Expand all Loading... |
1822 | 1821 |
1823 if (FLAG_collect_heap_spill_statistics && obj->IsJSObject()) { | 1822 if (FLAG_collect_heap_spill_statistics && obj->IsJSObject()) { |
1824 JSObject::cast(obj)->IncrementSpillStatistics( | 1823 JSObject::cast(obj)->IncrementSpillStatistics( |
1825 isolate->js_spill_information()); | 1824 isolate->js_spill_information()); |
1826 } | 1825 } |
1827 | 1826 |
1828 return obj->Size(); | 1827 return obj->Size(); |
1829 } | 1828 } |
1830 | 1829 |
1831 | 1830 |
1832 static void ReportHistogram(bool print_spill) { | 1831 static void ReportHistogram(Isolate* isolate, bool print_spill) { |
1833 Isolate* isolate = Isolate::Current(); | |
1834 PrintF("\n Object Histogram:\n"); | 1832 PrintF("\n Object Histogram:\n"); |
1835 for (int i = 0; i <= LAST_TYPE; i++) { | 1833 for (int i = 0; i <= LAST_TYPE; i++) { |
1836 if (isolate->heap_histograms()[i].number() > 0) { | 1834 if (isolate->heap_histograms()[i].number() > 0) { |
1837 PrintF(" %-34s%10d (%10d bytes)\n", | 1835 PrintF(" %-34s%10d (%10d bytes)\n", |
1838 isolate->heap_histograms()[i].name(), | 1836 isolate->heap_histograms()[i].name(), |
1839 isolate->heap_histograms()[i].number(), | 1837 isolate->heap_histograms()[i].number(), |
1840 isolate->heap_histograms()[i].bytes()); | 1838 isolate->heap_histograms()[i].bytes()); |
1841 } | 1839 } |
1842 } | 1840 } |
1843 PrintF("\n"); | 1841 PrintF("\n"); |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2678 HeapObject* object = free_list_.Allocate(size_in_bytes); | 2676 HeapObject* object = free_list_.Allocate(size_in_bytes); |
2679 if (object != NULL) return object; | 2677 if (object != NULL) return object; |
2680 } | 2678 } |
2681 | 2679 |
2682 // Finally, fail. | 2680 // Finally, fail. |
2683 return NULL; | 2681 return NULL; |
2684 } | 2682 } |
2685 | 2683 |
2686 | 2684 |
2687 #ifdef DEBUG | 2685 #ifdef DEBUG |
2688 void PagedSpace::ReportCodeStatistics() { | 2686 void PagedSpace::ReportCodeStatistics(Isolate* isolate) { |
2689 Isolate* isolate = Isolate::Current(); | |
2690 CommentStatistic* comments_statistics = | 2687 CommentStatistic* comments_statistics = |
2691 isolate->paged_space_comments_statistics(); | 2688 isolate->paged_space_comments_statistics(); |
2692 ReportCodeKindStatistics(isolate->code_kind_statistics()); | 2689 ReportCodeKindStatistics(isolate->code_kind_statistics()); |
2693 PrintF("Code comment statistics (\" [ comment-txt : size/ " | 2690 PrintF("Code comment statistics (\" [ comment-txt : size/ " |
2694 "count (average)\"):\n"); | 2691 "count (average)\"):\n"); |
2695 for (int i = 0; i <= CommentStatistic::kMaxComments; i++) { | 2692 for (int i = 0; i <= CommentStatistic::kMaxComments; i++) { |
2696 const CommentStatistic& cs = comments_statistics[i]; | 2693 const CommentStatistic& cs = comments_statistics[i]; |
2697 if (cs.size > 0) { | 2694 if (cs.size > 0) { |
2698 PrintF(" %-30s: %10d/%6d (%d)\n", cs.comment, cs.size, cs.count, | 2695 PrintF(" %-30s: %10d/%6d (%d)\n", cs.comment, cs.size, cs.count, |
2699 cs.size/cs.count); | 2696 cs.size/cs.count); |
2700 } | 2697 } |
2701 } | 2698 } |
2702 PrintF("\n"); | 2699 PrintF("\n"); |
2703 } | 2700 } |
2704 | 2701 |
2705 | 2702 |
2706 void PagedSpace::ResetCodeStatistics() { | 2703 void PagedSpace::ResetCodeStatistics(Isolate* isolate) { |
2707 Isolate* isolate = Isolate::Current(); | |
2708 CommentStatistic* comments_statistics = | 2704 CommentStatistic* comments_statistics = |
2709 isolate->paged_space_comments_statistics(); | 2705 isolate->paged_space_comments_statistics(); |
2710 ClearCodeKindStatistics(isolate->code_kind_statistics()); | 2706 ClearCodeKindStatistics(isolate->code_kind_statistics()); |
2711 for (int i = 0; i < CommentStatistic::kMaxComments; i++) { | 2707 for (int i = 0; i < CommentStatistic::kMaxComments; i++) { |
2712 comments_statistics[i].Clear(); | 2708 comments_statistics[i].Clear(); |
2713 } | 2709 } |
2714 comments_statistics[CommentStatistic::kMaxComments].comment = "Unknown"; | 2710 comments_statistics[CommentStatistic::kMaxComments].comment = "Unknown"; |
2715 comments_statistics[CommentStatistic::kMaxComments].size = 0; | 2711 comments_statistics[CommentStatistic::kMaxComments].size = 0; |
2716 comments_statistics[CommentStatistic::kMaxComments].count = 0; | 2712 comments_statistics[CommentStatistic::kMaxComments].count = 0; |
2717 } | 2713 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2812 | 2808 |
2813 | 2809 |
2814 void PagedSpace::ReportStatistics() { | 2810 void PagedSpace::ReportStatistics() { |
2815 int pct = static_cast<int>(Available() * 100 / Capacity()); | 2811 int pct = static_cast<int>(Available() * 100 / Capacity()); |
2816 PrintF(" capacity: %" V8_PTR_PREFIX "d" | 2812 PrintF(" capacity: %" V8_PTR_PREFIX "d" |
2817 ", waste: %" V8_PTR_PREFIX "d" | 2813 ", waste: %" V8_PTR_PREFIX "d" |
2818 ", available: %" V8_PTR_PREFIX "d, %%%d\n", | 2814 ", available: %" V8_PTR_PREFIX "d, %%%d\n", |
2819 Capacity(), Waste(), Available(), pct); | 2815 Capacity(), Waste(), Available(), pct); |
2820 | 2816 |
2821 if (was_swept_conservatively_) return; | 2817 if (was_swept_conservatively_) return; |
2822 ClearHistograms(); | 2818 ClearHistograms(heap()->isolate()); |
2823 HeapObjectIterator obj_it(this); | 2819 HeapObjectIterator obj_it(this); |
2824 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) | 2820 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) |
2825 CollectHistogramInfo(obj); | 2821 CollectHistogramInfo(obj); |
2826 ReportHistogram(true); | 2822 ReportHistogram(heap()->isolate(), true); |
2827 } | 2823 } |
2828 #endif | 2824 #endif |
2829 | 2825 |
2830 // ----------------------------------------------------------------------------- | 2826 // ----------------------------------------------------------------------------- |
2831 // FixedSpace implementation | 2827 // FixedSpace implementation |
2832 | 2828 |
2833 void FixedSpace::PrepareForMarkCompact() { | 2829 void FixedSpace::PrepareForMarkCompact() { |
2834 // Call prepare of the super class. | 2830 // Call prepare of the super class. |
2835 PagedSpace::PrepareForMarkCompact(); | 2831 PagedSpace::PrepareForMarkCompact(); |
2836 | 2832 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3153 LargeObjectIterator it(this); | 3149 LargeObjectIterator it(this); |
3154 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 3150 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
3155 obj->Print(); | 3151 obj->Print(); |
3156 } | 3152 } |
3157 } | 3153 } |
3158 | 3154 |
3159 | 3155 |
3160 void LargeObjectSpace::ReportStatistics() { | 3156 void LargeObjectSpace::ReportStatistics() { |
3161 PrintF(" size: %" V8_PTR_PREFIX "d\n", size_); | 3157 PrintF(" size: %" V8_PTR_PREFIX "d\n", size_); |
3162 int num_objects = 0; | 3158 int num_objects = 0; |
3163 ClearHistograms(); | 3159 ClearHistograms(heap()->isolate()); |
3164 LargeObjectIterator it(this); | 3160 LargeObjectIterator it(this); |
3165 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 3161 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
3166 num_objects++; | 3162 num_objects++; |
3167 CollectHistogramInfo(obj); | 3163 CollectHistogramInfo(obj); |
3168 } | 3164 } |
3169 | 3165 |
3170 PrintF(" number of objects %d, " | 3166 PrintF(" number of objects %d, " |
3171 "size of objects %" V8_PTR_PREFIX "d\n", num_objects, objects_size_); | 3167 "size of objects %" V8_PTR_PREFIX "d\n", num_objects, objects_size_); |
3172 if (num_objects > 0) ReportHistogram(false); | 3168 if (num_objects > 0) ReportHistogram(heap()->isolate(), false); |
3173 } | 3169 } |
3174 | 3170 |
3175 | 3171 |
3176 void LargeObjectSpace::CollectCodeStatistics() { | 3172 void LargeObjectSpace::CollectCodeStatistics() { |
3177 Isolate* isolate = heap()->isolate(); | 3173 Isolate* isolate = heap()->isolate(); |
3178 LargeObjectIterator obj_it(this); | 3174 LargeObjectIterator obj_it(this); |
3179 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { | 3175 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { |
3180 if (obj->IsCode()) { | 3176 if (obj->IsCode()) { |
3181 Code* code = Code::cast(obj); | 3177 Code* code = Code::cast(obj); |
3182 isolate->code_kind_statistics()[code->kind()] += code->Size(); | 3178 isolate->code_kind_statistics()[code->kind()] += code->Size(); |
(...skipping 21 matching lines...) Expand all Loading... |
3204 object->ShortPrint(); | 3200 object->ShortPrint(); |
3205 PrintF("\n"); | 3201 PrintF("\n"); |
3206 } | 3202 } |
3207 printf(" --------------------------------------\n"); | 3203 printf(" --------------------------------------\n"); |
3208 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3204 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3209 } | 3205 } |
3210 | 3206 |
3211 #endif // DEBUG | 3207 #endif // DEBUG |
3212 | 3208 |
3213 } } // namespace v8::internal | 3209 } } // namespace v8::internal |
OLD | NEW |