| 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 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1783 #undef DEF_TYPE_NAME | 1783 #undef DEF_TYPE_NAME |
| 1784 | 1784 |
| 1785 #define CLEAR_HISTOGRAM(name) isolate->heap_histograms()[name].clear(); | 1785 #define CLEAR_HISTOGRAM(name) isolate->heap_histograms()[name].clear(); |
| 1786 INSTANCE_TYPE_LIST(CLEAR_HISTOGRAM) | 1786 INSTANCE_TYPE_LIST(CLEAR_HISTOGRAM) |
| 1787 #undef CLEAR_HISTOGRAM | 1787 #undef CLEAR_HISTOGRAM |
| 1788 | 1788 |
| 1789 isolate->js_spill_information()->Clear(); | 1789 isolate->js_spill_information()->Clear(); |
| 1790 } | 1790 } |
| 1791 | 1791 |
| 1792 | 1792 |
| 1793 static void ClearCodeKindStatistics() { | 1793 static void ClearCodeKindStatistics(int* code_kind_statistics) { |
| 1794 Isolate* isolate = Isolate::Current(); | |
| 1795 for (int i = 0; i < Code::NUMBER_OF_KINDS; i++) { | 1794 for (int i = 0; i < Code::NUMBER_OF_KINDS; i++) { |
| 1796 isolate->code_kind_statistics()[i] = 0; | 1795 code_kind_statistics[i] = 0; |
| 1797 } | 1796 } |
| 1798 } | 1797 } |
| 1799 | 1798 |
| 1800 | 1799 |
| 1801 static void ReportCodeKindStatistics() { | 1800 static void ReportCodeKindStatistics(int* code_kind_statistics) { |
| 1802 Isolate* isolate = Isolate::Current(); | |
| 1803 const char* table[Code::NUMBER_OF_KINDS] = { NULL }; | |
| 1804 | |
| 1805 #define CASE(name) \ | |
| 1806 case Code::name: table[Code::name] = #name; \ | |
| 1807 break | |
| 1808 | |
| 1809 for (int i = 0; i < Code::NUMBER_OF_KINDS; i++) { | |
| 1810 switch (static_cast<Code::Kind>(i)) { | |
| 1811 CASE(FUNCTION); | |
| 1812 CASE(OPTIMIZED_FUNCTION); | |
| 1813 CASE(STUB); | |
| 1814 CASE(BUILTIN); | |
| 1815 CASE(LOAD_IC); | |
| 1816 CASE(KEYED_LOAD_IC); | |
| 1817 CASE(STORE_IC); | |
| 1818 CASE(KEYED_STORE_IC); | |
| 1819 CASE(CALL_IC); | |
| 1820 CASE(KEYED_CALL_IC); | |
| 1821 CASE(UNARY_OP_IC); | |
| 1822 CASE(BINARY_OP_IC); | |
| 1823 CASE(COMPARE_IC); | |
| 1824 CASE(COMPARE_NIL_IC); | |
| 1825 CASE(TO_BOOLEAN_IC); | |
| 1826 CASE(REGEXP); | |
| 1827 } | |
| 1828 } | |
| 1829 | |
| 1830 #undef CASE | |
| 1831 | |
| 1832 PrintF("\n Code kind histograms: \n"); | 1801 PrintF("\n Code kind histograms: \n"); |
| 1833 for (int i = 0; i < Code::NUMBER_OF_KINDS; i++) { | 1802 for (int i = 0; i < Code::NUMBER_OF_KINDS; i++) { |
| 1834 if (isolate->code_kind_statistics()[i] > 0) { | 1803 if (code_kind_statistics[i] > 0) { |
| 1835 PrintF(" %-20s: %10d bytes\n", table[i], | 1804 PrintF(" %-20s: %10d bytes\n", |
| 1836 isolate->code_kind_statistics()[i]); | 1805 Code::Kind2String(static_cast<Code::Kind>(i)), |
| 1806 code_kind_statistics[i]); |
| 1837 } | 1807 } |
| 1838 } | 1808 } |
| 1839 PrintF("\n"); | 1809 PrintF("\n"); |
| 1840 } | 1810 } |
| 1841 | 1811 |
| 1842 | 1812 |
| 1843 static int CollectHistogramInfo(HeapObject* obj) { | 1813 static int CollectHistogramInfo(HeapObject* obj) { |
| 1844 Isolate* isolate = Isolate::Current(); | 1814 Isolate* isolate = obj->GetIsolate(); |
| 1845 InstanceType type = obj->map()->instance_type(); | 1815 InstanceType type = obj->map()->instance_type(); |
| 1846 ASSERT(0 <= type && type <= LAST_TYPE); | 1816 ASSERT(0 <= type && type <= LAST_TYPE); |
| 1847 ASSERT(isolate->heap_histograms()[type].name() != NULL); | 1817 ASSERT(isolate->heap_histograms()[type].name() != NULL); |
| 1848 isolate->heap_histograms()[type].increment_number(1); | 1818 isolate->heap_histograms()[type].increment_number(1); |
| 1849 isolate->heap_histograms()[type].increment_bytes(obj->Size()); | 1819 isolate->heap_histograms()[type].increment_bytes(obj->Size()); |
| 1850 | 1820 |
| 1851 if (FLAG_collect_heap_spill_statistics && obj->IsJSObject()) { | 1821 if (FLAG_collect_heap_spill_statistics && obj->IsJSObject()) { |
| 1852 JSObject::cast(obj)->IncrementSpillStatistics( | 1822 JSObject::cast(obj)->IncrementSpillStatistics( |
| 1853 isolate->js_spill_information()); | 1823 isolate->js_spill_information()); |
| 1854 } | 1824 } |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2708 // Finally, fail. | 2678 // Finally, fail. |
| 2709 return NULL; | 2679 return NULL; |
| 2710 } | 2680 } |
| 2711 | 2681 |
| 2712 | 2682 |
| 2713 #ifdef DEBUG | 2683 #ifdef DEBUG |
| 2714 void PagedSpace::ReportCodeStatistics() { | 2684 void PagedSpace::ReportCodeStatistics() { |
| 2715 Isolate* isolate = Isolate::Current(); | 2685 Isolate* isolate = Isolate::Current(); |
| 2716 CommentStatistic* comments_statistics = | 2686 CommentStatistic* comments_statistics = |
| 2717 isolate->paged_space_comments_statistics(); | 2687 isolate->paged_space_comments_statistics(); |
| 2718 ReportCodeKindStatistics(); | 2688 ReportCodeKindStatistics(isolate->code_kind_statistics()); |
| 2719 PrintF("Code comment statistics (\" [ comment-txt : size/ " | 2689 PrintF("Code comment statistics (\" [ comment-txt : size/ " |
| 2720 "count (average)\"):\n"); | 2690 "count (average)\"):\n"); |
| 2721 for (int i = 0; i <= CommentStatistic::kMaxComments; i++) { | 2691 for (int i = 0; i <= CommentStatistic::kMaxComments; i++) { |
| 2722 const CommentStatistic& cs = comments_statistics[i]; | 2692 const CommentStatistic& cs = comments_statistics[i]; |
| 2723 if (cs.size > 0) { | 2693 if (cs.size > 0) { |
| 2724 PrintF(" %-30s: %10d/%6d (%d)\n", cs.comment, cs.size, cs.count, | 2694 PrintF(" %-30s: %10d/%6d (%d)\n", cs.comment, cs.size, cs.count, |
| 2725 cs.size/cs.count); | 2695 cs.size/cs.count); |
| 2726 } | 2696 } |
| 2727 } | 2697 } |
| 2728 PrintF("\n"); | 2698 PrintF("\n"); |
| 2729 } | 2699 } |
| 2730 | 2700 |
| 2731 | 2701 |
| 2732 void PagedSpace::ResetCodeStatistics() { | 2702 void PagedSpace::ResetCodeStatistics() { |
| 2733 Isolate* isolate = Isolate::Current(); | 2703 Isolate* isolate = Isolate::Current(); |
| 2734 CommentStatistic* comments_statistics = | 2704 CommentStatistic* comments_statistics = |
| 2735 isolate->paged_space_comments_statistics(); | 2705 isolate->paged_space_comments_statistics(); |
| 2736 ClearCodeKindStatistics(); | 2706 ClearCodeKindStatistics(isolate->code_kind_statistics()); |
| 2737 for (int i = 0; i < CommentStatistic::kMaxComments; i++) { | 2707 for (int i = 0; i < CommentStatistic::kMaxComments; i++) { |
| 2738 comments_statistics[i].Clear(); | 2708 comments_statistics[i].Clear(); |
| 2739 } | 2709 } |
| 2740 comments_statistics[CommentStatistic::kMaxComments].comment = "Unknown"; | 2710 comments_statistics[CommentStatistic::kMaxComments].comment = "Unknown"; |
| 2741 comments_statistics[CommentStatistic::kMaxComments].size = 0; | 2711 comments_statistics[CommentStatistic::kMaxComments].size = 0; |
| 2742 comments_statistics[CommentStatistic::kMaxComments].count = 0; | 2712 comments_statistics[CommentStatistic::kMaxComments].count = 0; |
| 2743 } | 2713 } |
| 2744 | 2714 |
| 2745 | 2715 |
| 2746 // Adds comment to 'comment_statistics' table. Performance OK as long as | 2716 // Adds comment to 'comment_statistics' table. Performance OK as long as |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3235 object->ShortPrint(); | 3205 object->ShortPrint(); |
| 3236 PrintF("\n"); | 3206 PrintF("\n"); |
| 3237 } | 3207 } |
| 3238 printf(" --------------------------------------\n"); | 3208 printf(" --------------------------------------\n"); |
| 3239 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3209 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3240 } | 3210 } |
| 3241 | 3211 |
| 3242 #endif // DEBUG | 3212 #endif // DEBUG |
| 3243 | 3213 |
| 3244 } } // namespace v8::internal | 3214 } } // namespace v8::internal |
| OLD | NEW |