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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 public: | 698 public: |
699 FreeList(); | 699 FreeList(); |
700 | 700 |
701 void addToFreeList(Address, size_t); | 701 void addToFreeList(Address, size_t); |
702 void clear(); | 702 void clear(); |
703 | 703 |
704 // Returns a bucket number for inserting a FreeListEntry of a given size. | 704 // Returns a bucket number for inserting a FreeListEntry of a given size. |
705 // All FreeListEntries in the given bucket, n, have size >= 2^n. | 705 // All FreeListEntries in the given bucket, n, have size >= 2^n. |
706 static int bucketIndexForSize(size_t); | 706 static int bucketIndexForSize(size_t); |
707 | 707 |
| 708 #if ENABLE(GC_PROFILING) |
| 709 struct PerBucketFreeListStats { |
| 710 size_t entryCount; |
| 711 size_t freeSize; |
| 712 }; |
| 713 |
| 714 void getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& totalSiz
e) const; |
| 715 #endif |
| 716 |
708 private: | 717 private: |
709 int m_biggestFreeListIndex; | 718 int m_biggestFreeListIndex; |
710 | 719 |
711 // All FreeListEntries in the nth list have size >= 2^n. | 720 // All FreeListEntries in the nth list have size >= 2^n. |
712 FreeListEntry* m_freeLists[blinkPageSizeLog2]; | 721 FreeListEntry* m_freeLists[blinkPageSizeLog2]; |
713 | 722 |
714 friend class ThreadHeap; | 723 friend class ThreadHeap; |
715 }; | 724 }; |
716 | 725 |
717 // Thread heaps represent a part of the per-thread Blink heap. | 726 // Thread heaps represent a part of the per-thread Blink heap. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 void completeSweep(); | 774 void completeSweep(); |
766 | 775 |
767 void freePage(HeapPage*); | 776 void freePage(HeapPage*); |
768 void freeLargeObject(LargeObject*); | 777 void freeLargeObject(LargeObject*); |
769 | 778 |
770 void promptlyFreeObject(HeapObjectHeader*); | 779 void promptlyFreeObject(HeapObjectHeader*); |
771 bool expandObject(HeapObjectHeader*, size_t); | 780 bool expandObject(HeapObjectHeader*, size_t); |
772 void shrinkObject(HeapObjectHeader*, size_t); | 781 void shrinkObject(HeapObjectHeader*, size_t); |
773 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; } | 782 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; } |
774 | 783 |
| 784 #if ENABLE(GC_PROFILING) |
| 785 void snapshotFreeList(TracedValue&); |
| 786 #endif |
| 787 |
775 private: | 788 private: |
776 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex); | 789 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex); |
777 Address currentAllocationPoint() const { return m_currentAllocationPoint; } | 790 Address currentAllocationPoint() const { return m_currentAllocationPoint; } |
778 size_t remainingAllocationSize() const { return m_remainingAllocationSize; } | 791 size_t remainingAllocationSize() const { return m_remainingAllocationSize; } |
779 bool hasCurrentAllocationArea() const { return currentAllocationPoint() && r
emainingAllocationSize(); } | 792 bool hasCurrentAllocationArea() const { return currentAllocationPoint() && r
emainingAllocationSize(); } |
780 inline void setAllocationPoint(Address, size_t); | 793 inline void setAllocationPoint(Address, size_t); |
781 void updateRemainingAllocationSize(); | 794 void updateRemainingAllocationSize(); |
782 Address allocateFromFreeList(size_t, size_t gcInfoIndex); | 795 Address allocateFromFreeList(size_t, size_t gcInfoIndex); |
783 Address lazySweepPages(size_t, size_t gcInfoIndex); | 796 Address lazySweepPages(size_t, size_t gcInfoIndex); |
784 bool lazySweepLargeObjects(size_t); | 797 bool lazySweepLargeObjects(size_t); |
(...skipping 22 matching lines...) Expand all Loading... |
807 ThreadState* m_threadState; | 820 ThreadState* m_threadState; |
808 | 821 |
809 FreeList m_freeList; | 822 FreeList m_freeList; |
810 | 823 |
811 // Index into the page pools. This is used to ensure that the pages of the | 824 // Index into the page pools. This is used to ensure that the pages of the |
812 // same type go into the correct page pool and thus avoid type confusion. | 825 // same type go into the correct page pool and thus avoid type confusion. |
813 int m_index; | 826 int m_index; |
814 | 827 |
815 // The size of promptly freed objects in the heap. | 828 // The size of promptly freed objects in the heap. |
816 size_t m_promptlyFreedSize; | 829 size_t m_promptlyFreedSize; |
| 830 |
| 831 #if ENABLE(GC_PROFILING) |
| 832 size_t m_cumulativeAllocationSize; |
| 833 size_t m_allocationCount; |
| 834 size_t m_inlineAllocationCount; |
| 835 #endif |
817 }; | 836 }; |
818 | 837 |
819 // Mask an address down to the enclosing oilpan heap base page. All oilpan heap | 838 // Mask an address down to the enclosing oilpan heap base page. All oilpan heap |
820 // pages are aligned at blinkPageBase plus an OS page size. | 839 // pages are aligned at blinkPageBase plus an OS page size. |
821 // FIXME: Remove PLATFORM_EXPORT once we get a proper public interface to our | 840 // FIXME: Remove PLATFORM_EXPORT once we get a proper public interface to our |
822 // typed heaps. This is only exported to enable tests in HeapTest.cpp. | 841 // typed heaps. This is only exported to enable tests in HeapTest.cpp. |
823 PLATFORM_EXPORT inline BaseHeapPage* pageFromObject(const void* object) | 842 PLATFORM_EXPORT inline BaseHeapPage* pageFromObject(const void* object) |
824 { | 843 { |
825 Address address = reinterpret_cast<Address>(const_cast<void*>(object)); | 844 Address address = reinterpret_cast<Address>(const_cast<void*>(object)); |
826 BaseHeapPage* page = reinterpret_cast<BaseHeapPage*>(blinkPageAddress(addres
s) + WTF::kSystemPageSize); | 845 BaseHeapPage* page = reinterpret_cast<BaseHeapPage*>(blinkPageAddress(addres
s) + WTF::kSystemPageSize); |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 | 1344 |
1326 // Add space for header. | 1345 // Add space for header. |
1327 size_t allocationSize = size + sizeof(HeapObjectHeader); | 1346 size_t allocationSize = size + sizeof(HeapObjectHeader); |
1328 // Align size with allocation granularity. | 1347 // Align size with allocation granularity. |
1329 allocationSize = (allocationSize + allocationMask) & ~allocationMask; | 1348 allocationSize = (allocationSize + allocationMask) & ~allocationMask; |
1330 return allocationSize; | 1349 return allocationSize; |
1331 } | 1350 } |
1332 | 1351 |
1333 Address ThreadHeap::allocateObject(size_t allocationSize, size_t gcInfoIndex) | 1352 Address ThreadHeap::allocateObject(size_t allocationSize, size_t gcInfoIndex) |
1334 { | 1353 { |
| 1354 #if ENABLE(GC_PROFILING) |
| 1355 m_cumulativeAllocationSize += allocationSize; |
| 1356 ++m_allocationCount; |
| 1357 #endif |
| 1358 |
1335 if (LIKELY(allocationSize <= m_remainingAllocationSize)) { | 1359 if (LIKELY(allocationSize <= m_remainingAllocationSize)) { |
| 1360 #if ENABLE(GC_PROFILING) |
| 1361 ++m_inlineAllocationCount; |
| 1362 #endif |
1336 Address headerAddress = m_currentAllocationPoint; | 1363 Address headerAddress = m_currentAllocationPoint; |
1337 m_currentAllocationPoint += allocationSize; | 1364 m_currentAllocationPoint += allocationSize; |
1338 m_remainingAllocationSize -= allocationSize; | 1365 m_remainingAllocationSize -= allocationSize; |
1339 ASSERT(gcInfoIndex > 0); | 1366 ASSERT(gcInfoIndex > 0); |
1340 new (NotNull, headerAddress) HeapObjectHeader(allocationSize, gcInfoInde
x); | 1367 new (NotNull, headerAddress) HeapObjectHeader(allocationSize, gcInfoInde
x); |
1341 Address result = headerAddress + sizeof(HeapObjectHeader); | 1368 Address result = headerAddress + sizeof(HeapObjectHeader); |
1342 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask)); | 1369 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask)); |
1343 | 1370 |
1344 // Unpoison the memory used for the object (payload). | 1371 // Unpoison the memory used for the object (payload). |
1345 ASAN_UNPOISON_MEMORY_REGION(result, allocationSize - sizeof(HeapObjectHe
ader)); | 1372 ASAN_UNPOISON_MEMORY_REGION(result, allocationSize - sizeof(HeapObjectHe
ader)); |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2422 template<typename T, size_t inlineCapacity> | 2449 template<typename T, size_t inlineCapacity> |
2423 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T,
inlineCapacity, HeapAllocator>> { }; | 2450 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T,
inlineCapacity, HeapAllocator>> { }; |
2424 template<typename T, size_t inlineCapacity> | 2451 template<typename T, size_t inlineCapacity> |
2425 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i
nlineCapacity, HeapAllocator>> { }; | 2452 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i
nlineCapacity, HeapAllocator>> { }; |
2426 template<typename T, typename U, typename V> | 2453 template<typename T, typename U, typename V> |
2427 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted
Set<T, U, V, HeapAllocator>> { }; | 2454 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted
Set<T, U, V, HeapAllocator>> { }; |
2428 | 2455 |
2429 } // namespace blink | 2456 } // namespace blink |
2430 | 2457 |
2431 #endif // Heap_h | 2458 #endif // Heap_h |
OLD | NEW |