Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: Source/platform/heap/Heap.h

Issue 883233003: Oilpan: Add free list profiler. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | Source/platform/heap/Heap.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 void countBucketSizes(size_t sizes[], size_t totalSizes[], size_t& freeSize) const;
710 #endif
711
708 private: 712 private:
709 int m_biggestFreeListIndex; 713 int m_biggestFreeListIndex;
710 714
711 // All FreeListEntries in the nth list have size >= 2^n. 715 // All FreeListEntries in the nth list have size >= 2^n.
712 FreeListEntry* m_freeLists[blinkPageSizeLog2]; 716 FreeListEntry* m_freeLists[blinkPageSizeLog2];
713 717
714 friend class ThreadHeap; 718 friend class ThreadHeap;
715 }; 719 };
716 720
717 // Thread heaps represent a part of the per-thread Blink heap. 721 // Thread heaps represent a part of the per-thread Blink heap.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 void completeSweep(); 769 void completeSweep();
766 770
767 void freePage(HeapPage*); 771 void freePage(HeapPage*);
768 void freeLargeObject(LargeObject*); 772 void freeLargeObject(LargeObject*);
769 773
770 void promptlyFreeObject(HeapObjectHeader*); 774 void promptlyFreeObject(HeapObjectHeader*);
771 bool expandObject(HeapObjectHeader*, size_t); 775 bool expandObject(HeapObjectHeader*, size_t);
772 void shrinkObject(HeapObjectHeader*, size_t); 776 void shrinkObject(HeapObjectHeader*, size_t);
773 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; } 777 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; }
774 778
779 #if ENABLE(GC_PROFILING)
780 void snapshotFreeList(TracedValue&);
781 #endif
782
775 private: 783 private:
776 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex); 784 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex);
777 Address currentAllocationPoint() const { return m_currentAllocationPoint; } 785 Address currentAllocationPoint() const { return m_currentAllocationPoint; }
778 size_t remainingAllocationSize() const { return m_remainingAllocationSize; } 786 size_t remainingAllocationSize() const { return m_remainingAllocationSize; }
779 bool hasCurrentAllocationArea() const { return currentAllocationPoint() && r emainingAllocationSize(); } 787 bool hasCurrentAllocationArea() const { return currentAllocationPoint() && r emainingAllocationSize(); }
780 inline void setAllocationPoint(Address, size_t); 788 inline void setAllocationPoint(Address, size_t);
781 void updateRemainingAllocationSize(); 789 void updateRemainingAllocationSize();
782 Address allocateFromFreeList(size_t, size_t gcInfoIndex); 790 Address allocateFromFreeList(size_t, size_t gcInfoIndex);
783 Address lazySweepPages(size_t, size_t gcInfoIndex); 791 Address lazySweepPages(size_t, size_t gcInfoIndex);
784 bool lazySweepLargeObjects(size_t); 792 bool lazySweepLargeObjects(size_t);
(...skipping 22 matching lines...) Expand all
807 ThreadState* m_threadState; 815 ThreadState* m_threadState;
808 816
809 FreeList m_freeList; 817 FreeList m_freeList;
810 818
811 // Index into the page pools. This is used to ensure that the pages of the 819 // 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. 820 // same type go into the correct page pool and thus avoid type confusion.
813 int m_index; 821 int m_index;
814 822
815 // The size of promptly freed objects in the heap. 823 // The size of promptly freed objects in the heap.
816 size_t m_promptlyFreedSize; 824 size_t m_promptlyFreedSize;
825
826 #if ENABLE(GC_PROFILING)
827 double m_totalAllocationSize;
828 size_t m_allocationCount;
829 size_t m_inlineAllocationCount;
830 size_t m_allocationPointSizeSum;
831 size_t m_setAllocationPointCount;
832 #endif
817 }; 833 };
818 834
819 // Mask an address down to the enclosing oilpan heap base page. All oilpan heap 835 // 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. 836 // pages are aligned at blinkPageBase plus an OS page size.
821 // FIXME: Remove PLATFORM_EXPORT once we get a proper public interface to our 837 // 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. 838 // typed heaps. This is only exported to enable tests in HeapTest.cpp.
823 PLATFORM_EXPORT inline BaseHeapPage* pageFromObject(const void* object) 839 PLATFORM_EXPORT inline BaseHeapPage* pageFromObject(const void* object)
824 { 840 {
825 Address address = reinterpret_cast<Address>(const_cast<void*>(object)); 841 Address address = reinterpret_cast<Address>(const_cast<void*>(object));
826 BaseHeapPage* page = reinterpret_cast<BaseHeapPage*>(blinkPageAddress(addres s) + WTF::kSystemPageSize); 842 BaseHeapPage* page = reinterpret_cast<BaseHeapPage*>(blinkPageAddress(addres s) + WTF::kSystemPageSize);
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 RELEASE_ASSERT(size < maxHeapObjectSize); 1340 RELEASE_ASSERT(size < maxHeapObjectSize);
1325 1341
1326 // Add space for header. 1342 // Add space for header.
1327 size_t allocationSize = size + sizeof(HeapObjectHeader); 1343 size_t allocationSize = size + sizeof(HeapObjectHeader);
1328 // Align size with allocation granularity. 1344 // Align size with allocation granularity.
1329 allocationSize = (allocationSize + allocationMask) & ~allocationMask; 1345 allocationSize = (allocationSize + allocationMask) & ~allocationMask;
1330 return allocationSize; 1346 return allocationSize;
1331 } 1347 }
1332 1348
1333 Address ThreadHeap::allocateObject(size_t allocationSize, size_t gcInfoIndex) 1349 Address ThreadHeap::allocateObject(size_t allocationSize, size_t gcInfoIndex)
1334 { 1350 {
keishi 2015/02/04 06:58:26 Shouldn't we be updating m_totalAllocationSize her
Yuta Kitamura 2015/02/04 09:45:42 Do'h, you are right. Fixed.
1335 if (LIKELY(allocationSize <= m_remainingAllocationSize)) { 1351 if (LIKELY(allocationSize <= m_remainingAllocationSize)) {
1336 Address headerAddress = m_currentAllocationPoint; 1352 Address headerAddress = m_currentAllocationPoint;
1337 m_currentAllocationPoint += allocationSize; 1353 m_currentAllocationPoint += allocationSize;
1338 m_remainingAllocationSize -= allocationSize; 1354 m_remainingAllocationSize -= allocationSize;
1339 ASSERT(gcInfoIndex > 0); 1355 ASSERT(gcInfoIndex > 0);
1340 new (NotNull, headerAddress) HeapObjectHeader(allocationSize, gcInfoInde x); 1356 new (NotNull, headerAddress) HeapObjectHeader(allocationSize, gcInfoInde x);
1341 Address result = headerAddress + sizeof(HeapObjectHeader); 1357 Address result = headerAddress + sizeof(HeapObjectHeader);
1342 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask)); 1358 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask));
1343 1359
1344 // Unpoison the memory used for the object (payload). 1360 // Unpoison the memory used for the object (payload).
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 template<typename T, size_t inlineCapacity> 2438 template<typename T, size_t inlineCapacity>
2423 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> { }; 2439 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> { };
2424 template<typename T, size_t inlineCapacity> 2440 template<typename T, size_t inlineCapacity>
2425 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i nlineCapacity, HeapAllocator>> { }; 2441 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i nlineCapacity, HeapAllocator>> { };
2426 template<typename T, typename U, typename V> 2442 template<typename T, typename U, typename V>
2427 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted Set<T, U, V, HeapAllocator>> { }; 2443 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted Set<T, U, V, HeapAllocator>> { };
2428 2444
2429 } // namespace blink 2445 } // namespace blink
2430 2446
2431 #endif // Heap_h 2447 #endif // Heap_h
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | Source/platform/heap/Heap.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698