OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
915 json->beginArray("largeObjects"); | 915 json->beginArray("largeObjects"); |
916 for (LargeObject* largeObject = m_firstLargeObject; largeObject; largeObject = largeObject->next()) { | 916 for (LargeObject* largeObject = m_firstLargeObject; largeObject; largeObject = largeObject->next()) { |
917 json->beginDictionary(); | 917 json->beginDictionary(); |
918 largeObject->snapshot(json, info); | 918 largeObject->snapshot(json, info); |
919 json->endDictionary(); | 919 json->endDictionary(); |
920 } | 920 } |
921 json->endArray(); | 921 json->endArray(); |
922 | 922 |
923 json->setInteger("pageCount", info->pageCount - previousPageCount); | 923 json->setInteger("pageCount", info->pageCount - previousPageCount); |
924 } | 924 } |
925 | |
926 void ThreadHeap::incrementMarkedObjectsAge() | |
927 { | |
928 for (HeapPage* page = m_firstPage; page; page = page->next()) | |
929 page->incrementMarkedObjectsAge(); | |
930 for (LargeObject* largeObject = m_firstLargeObject; largeObject; largeObject = largeObject->next()) | |
931 largeObject->incrementMarkedObjectsAge(); | |
932 } | |
925 #endif | 933 #endif |
926 | 934 |
927 void FreeList::addToFreeList(Address address, size_t size) | 935 void FreeList::addToFreeList(Address address, size_t size) |
928 { | 936 { |
929 ASSERT(size < blinkPagePayloadSize()); | 937 ASSERT(size < blinkPagePayloadSize()); |
930 // The free list entries are only pointer aligned (but when we allocate | 938 // The free list entries are only pointer aligned (but when we allocate |
931 // from them we are 8 byte aligned due to the header size). | 939 // from them we are 8 byte aligned due to the header size). |
932 ASSERT(!((reinterpret_cast<uintptr_t>(address) + sizeof(HeapObjectHeader)) & allocationMask)); | 940 ASSERT(!((reinterpret_cast<uintptr_t>(address) + sizeof(HeapObjectHeader)) & allocationMask)); |
933 ASSERT(!(size & allocationMask)); | 941 ASSERT(!(size & allocationMask)); |
934 ASAN_POISON_MEMORY_REGION(address, size); | 942 ASAN_POISON_MEMORY_REGION(address, size); |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1526 json.beginArray("perBucketEntryCount"); | 1534 json.beginArray("perBucketEntryCount"); |
1527 for (size_t i = 0; i < blinkPageSizeLog2; ++i) | 1535 for (size_t i = 0; i < blinkPageSizeLog2; ++i) |
1528 json.pushInteger(bucketStats[i].entryCount); | 1536 json.pushInteger(bucketStats[i].entryCount); |
1529 json.endArray(); | 1537 json.endArray(); |
1530 | 1538 |
1531 json.beginArray("perBucketFreeSize"); | 1539 json.beginArray("perBucketFreeSize"); |
1532 for (size_t i = 0; i < blinkPageSizeLog2; ++i) | 1540 for (size_t i = 0; i < blinkPageSizeLog2; ++i) |
1533 json.pushInteger(bucketStats[i].freeSize); | 1541 json.pushInteger(bucketStats[i].freeSize); |
1534 json.endArray(); | 1542 json.endArray(); |
1535 } | 1543 } |
1544 | |
1545 void ThreadHeap::countMarkedObjects(ClassAgeCountsMap& classAgeCounts) const | |
1546 { | |
1547 for (HeapPage* page = m_firstPage; page; page = page->next()) | |
1548 page->countMarkedObjects(classAgeCounts); | |
1549 for (LargeObject* largeObject = m_firstLargeObject; largeObject; largeObject = largeObject->next()) | |
1550 largeObject->countMarkedObjects(classAgeCounts); | |
1551 } | |
1552 | |
1553 void ThreadHeap::countObjectsToSweep(ClassAgeCountsMap& classAgeCounts) const | |
1554 { | |
1555 for (HeapPage* page = m_firstPage; page; page = page->next()) | |
1556 page->countObjectsToSweep(classAgeCounts); | |
1557 for (LargeObject* largeObject = m_firstLargeObject; largeObject; largeObject = largeObject->next()) | |
1558 largeObject->countObjectsToSweep(classAgeCounts); | |
1559 } | |
1536 #endif | 1560 #endif |
1537 | 1561 |
1538 void FreeList::clear() | 1562 void FreeList::clear() |
1539 { | 1563 { |
1540 m_biggestFreeListIndex = 0; | 1564 m_biggestFreeListIndex = 0; |
1541 for (size_t i = 0; i < blinkPageSizeLog2; ++i) | 1565 for (size_t i = 0; i < blinkPageSizeLog2; ++i) |
1542 m_freeLists[i] = nullptr; | 1566 m_freeLists[i] = nullptr; |
1543 } | 1567 } |
1544 | 1568 |
1545 int FreeList::bucketIndexForSize(size_t size) | 1569 int FreeList::bucketIndexForSize(size_t size) |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1795 size_t tag = info->getClassTag(Heap::gcInfo(header->gcInfoIndex())); | 1819 size_t tag = info->getClassTag(Heap::gcInfo(header->gcInfoIndex())); |
1796 size_t age = header->age(); | 1820 size_t age = header->age(); |
1797 if (json) | 1821 if (json) |
1798 json->pushInteger(tag); | 1822 json->pushInteger(tag); |
1799 if (header->isMarked()) { | 1823 if (header->isMarked()) { |
1800 info->liveCount[tag] += 1; | 1824 info->liveCount[tag] += 1; |
1801 info->liveSize[tag] += header->size(); | 1825 info->liveSize[tag] += header->size(); |
1802 // Count objects that are live when promoted to the final generation . | 1826 // Count objects that are live when promoted to the final generation . |
1803 if (age == maxHeapObjectAge - 1) | 1827 if (age == maxHeapObjectAge - 1) |
1804 info->generations[tag][maxHeapObjectAge] += 1; | 1828 info->generations[tag][maxHeapObjectAge] += 1; |
1805 header->incrementAge(); | |
1806 } else { | 1829 } else { |
1807 info->deadCount[tag] += 1; | 1830 info->deadCount[tag] += 1; |
1808 info->deadSize[tag] += header->size(); | 1831 info->deadSize[tag] += header->size(); |
1809 // Count objects that are dead before the final generation. | 1832 // Count objects that are dead before the final generation. |
1810 if (age < maxHeapObjectAge) | 1833 if (age < maxHeapObjectAge) |
1811 info->generations[tag][age] += 1; | 1834 info->generations[tag][age] += 1; |
1812 } | 1835 } |
1813 } | 1836 } |
1814 } | 1837 } |
1838 | |
1839 void HeapPage::incrementMarkedObjectsAge() | |
1840 { | |
1841 HeapObjectHeader* header = nullptr; | |
haraken
2015/02/06 06:39:20
You can declare HeapObjectHeader* inside the loop.
Yuta Kitamura
2015/02/06 07:45:45
It is used in the third part of the "for" expressi
| |
1842 for (Address address = payload(); address < payloadEnd(); address += header- >size()) { | |
1843 header = reinterpret_cast<HeapObjectHeader*>(address); | |
1844 if (header->isMarked()) | |
1845 header->incrementAge(); | |
1846 } | |
1847 } | |
1848 | |
1849 void HeapPage::countMarkedObjects(ClassAgeCountsMap& classAgeCounts) | |
1850 { | |
1851 HeapObjectHeader* header = nullptr; | |
1852 for (Address address = payload(); address < payloadEnd(); address += header- >size()) { | |
1853 header = reinterpret_cast<HeapObjectHeader*>(address); | |
1854 if (header->isMarked()) { | |
1855 String className(classOf(header->payload())); | |
1856 ++(classAgeCounts.add(className, AgeCounts()).storedValue->value.age s[header->age()]); | |
1857 } | |
1858 } | |
1859 } | |
1860 | |
1861 void HeapPage::countObjectsToSweep(ClassAgeCountsMap& classAgeCounts) | |
1862 { | |
1863 HeapObjectHeader* header = nullptr; | |
1864 for (Address address = payload(); address < payloadEnd(); address += header- >size()) { | |
1865 header = reinterpret_cast<HeapObjectHeader*>(address); | |
1866 if (!header->isFree() && !header->isMarked()) { | |
1867 String className(classOf(header->payload())); | |
1868 ++(classAgeCounts.add(className, AgeCounts()).storedValue->value.age s[header->age()]); | |
1869 } | |
1870 } | |
1871 } | |
1815 #endif | 1872 #endif |
1816 | 1873 |
1817 size_t LargeObject::objectPayloadSizeForTesting() | 1874 size_t LargeObject::objectPayloadSizeForTesting() |
1818 { | 1875 { |
1819 markAsSwept(); | 1876 markAsSwept(); |
1820 return payloadSize(); | 1877 return payloadSize(); |
1821 } | 1878 } |
1822 | 1879 |
1823 #if ENABLE(GC_PROFILING) | 1880 #if ENABLE(GC_PROFILING) |
1824 const GCInfo* LargeObject::findGCInfo(Address address) | 1881 const GCInfo* LargeObject::findGCInfo(Address address) |
1825 { | 1882 { |
1826 if (!containedInObjectPayload(address)) | 1883 if (!containedInObjectPayload(address)) |
1827 return nullptr; | 1884 return nullptr; |
1828 HeapObjectHeader* header = heapObjectHeader(); | 1885 HeapObjectHeader* header = heapObjectHeader(); |
1829 return Heap::gcInfo(header->gcInfoIndex()); | 1886 return Heap::gcInfo(header->gcInfoIndex()); |
1830 } | 1887 } |
1831 | 1888 |
1832 void LargeObject::snapshot(TracedValue* json, ThreadState::SnapshotInfo* info) | 1889 void LargeObject::snapshot(TracedValue* json, ThreadState::SnapshotInfo* info) |
1833 { | 1890 { |
1834 HeapObjectHeader* header = heapObjectHeader(); | 1891 HeapObjectHeader* header = heapObjectHeader(); |
1835 size_t tag = info->getClassTag(Heap::gcInfo(header->gcInfoIndex())); | 1892 size_t tag = info->getClassTag(Heap::gcInfo(header->gcInfoIndex())); |
1836 size_t age = header->age(); | 1893 size_t age = header->age(); |
1837 if (header->isMarked()) { | 1894 if (header->isMarked()) { |
1838 info->liveCount[tag] += 1; | 1895 info->liveCount[tag] += 1; |
1839 info->liveSize[tag] += header->size(); | 1896 info->liveSize[tag] += header->size(); |
1840 // Count objects that are live when promoted to the final generation. | 1897 // Count objects that are live when promoted to the final generation. |
1841 if (age == maxHeapObjectAge - 1) | 1898 if (age == maxHeapObjectAge - 1) |
1842 info->generations[tag][maxHeapObjectAge] += 1; | 1899 info->generations[tag][maxHeapObjectAge] += 1; |
1843 header->incrementAge(); | |
1844 } else { | 1900 } else { |
1845 info->deadCount[tag] += 1; | 1901 info->deadCount[tag] += 1; |
1846 info->deadSize[tag] += header->size(); | 1902 info->deadSize[tag] += header->size(); |
1847 // Count objects that are dead before the final generation. | 1903 // Count objects that are dead before the final generation. |
1848 if (age < maxHeapObjectAge) | 1904 if (age < maxHeapObjectAge) |
1849 info->generations[tag][age] += 1; | 1905 info->generations[tag][age] += 1; |
1850 } | 1906 } |
1851 | 1907 |
1852 if (json) { | 1908 if (json) { |
1853 json->setInteger("class", tag); | 1909 json->setInteger("class", tag); |
1854 json->setInteger("size", header->size()); | 1910 json->setInteger("size", header->size()); |
1855 json->setInteger("isMarked", header->isMarked()); | 1911 json->setInteger("isMarked", header->isMarked()); |
1856 } | 1912 } |
1857 } | 1913 } |
1914 | |
1915 void LargeObject::incrementMarkedObjectsAge() | |
1916 { | |
1917 HeapObjectHeader* header = heapObjectHeader(); | |
1918 if (header->isMarked()) | |
1919 header->incrementAge(); | |
1920 } | |
1921 | |
1922 void LargeObject::countMarkedObjects(ClassAgeCountsMap& classAgeCounts) | |
1923 { | |
1924 HeapObjectHeader* header = heapObjectHeader(); | |
1925 if (header->isMarked()) { | |
1926 String className(classOf(header->payload())); | |
1927 ++(classAgeCounts.add(className, AgeCounts()).storedValue->value.ages[he ader->age()]); | |
1928 } | |
1929 } | |
1930 | |
1931 void LargeObject::countObjectsToSweep(ClassAgeCountsMap& classAgeCounts) | |
1932 { | |
1933 HeapObjectHeader* header = heapObjectHeader(); | |
1934 if (!header->isFree() && !header->isMarked()) { | |
1935 String className(classOf(header->payload())); | |
1936 ++(classAgeCounts.add(className, AgeCounts()).storedValue->value.ages[he ader->age()]); | |
1937 } | |
1938 } | |
1858 #endif | 1939 #endif |
1859 | 1940 |
1860 void HeapDoesNotContainCache::flush() | 1941 void HeapDoesNotContainCache::flush() |
1861 { | 1942 { |
1862 if (m_hasEntries) { | 1943 if (m_hasEntries) { |
1863 for (int i = 0; i < numberOfEntries; ++i) | 1944 for (int i = 0; i < numberOfEntries; ++i) |
1864 m_entries[i] = nullptr; | 1945 m_entries[i] = nullptr; |
1865 m_hasEntries = false; | 1946 m_hasEntries = false; |
1866 } | 1947 } |
1867 } | 1948 } |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2778 bool Heap::s_shutdownCalled = false; | 2859 bool Heap::s_shutdownCalled = false; |
2779 bool Heap::s_lastGCWasConservative = false; | 2860 bool Heap::s_lastGCWasConservative = false; |
2780 FreePagePool* Heap::s_freePagePool; | 2861 FreePagePool* Heap::s_freePagePool; |
2781 OrphanedPagePool* Heap::s_orphanedPagePool; | 2862 OrphanedPagePool* Heap::s_orphanedPagePool; |
2782 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2863 Heap::RegionTree* Heap::s_regionTree = nullptr; |
2783 size_t Heap::s_allocatedObjectSize = 0; | 2864 size_t Heap::s_allocatedObjectSize = 0; |
2784 size_t Heap::s_allocatedSpace = 0; | 2865 size_t Heap::s_allocatedSpace = 0; |
2785 size_t Heap::s_markedObjectSize = 0; | 2866 size_t Heap::s_markedObjectSize = 0; |
2786 | 2867 |
2787 } // namespace blink | 2868 } // namespace blink |
OLD | NEW |