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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapPage.h

Issue 1477023003: Refactor the Heap into ThreadHeap to prepare for per thread heaps Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored Created 4 years, 11 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
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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 void completeSweep(); 676 void completeSweep();
677 677
678 ThreadState* threadState() { return m_threadState; } 678 ThreadState* threadState() { return m_threadState; }
679 int heapIndex() const { return m_index; } 679 int heapIndex() const { return m_index; }
680 680
681 protected: 681 protected:
682 BasePage* m_firstPage; 682 BasePage* m_firstPage;
683 BasePage* m_firstUnsweptPage; 683 BasePage* m_firstUnsweptPage;
684 684
685 private: 685 private:
686 virtual Address lazySweepPages(size_t, size_t gcInfoIndex) = 0; 686 virtual Address lazySweepPages(size_t, size_t gcInfoIndex, GCGroup*) = 0;
687 687
688 ThreadState* m_threadState; 688 ThreadState* m_threadState;
689 689
690 // Index into the page pools. This is used to ensure that the pages of the 690 // Index into the page pools. This is used to ensure that the pages of the
691 // same type go into the correct page pool and thus avoid type confusion. 691 // same type go into the correct page pool and thus avoid type confusion.
692 int m_index; 692 int m_index;
693 }; 693 };
694 694
695 class PLATFORM_EXPORT NormalPageHeap final : public BaseHeap { 695 class PLATFORM_EXPORT NormalPageHeap final : public BaseHeap {
696 public: 696 public:
(...skipping 24 matching lines...) Expand all
721 bool isObjectAllocatedAtAllocationPoint(HeapObjectHeader* header) 721 bool isObjectAllocatedAtAllocationPoint(HeapObjectHeader* header)
722 { 722 {
723 return header->payloadEnd() == m_currentAllocationPoint; 723 return header->payloadEnd() == m_currentAllocationPoint;
724 } 724 }
725 725
726 private: 726 private:
727 void allocatePage(); 727 void allocatePage();
728 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex); 728 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex);
729 Address allocateFromFreeList(size_t, size_t gcInfoIndex); 729 Address allocateFromFreeList(size_t, size_t gcInfoIndex);
730 730
731 Address lazySweepPages(size_t, size_t gcInfoIndex) override; 731 Address lazySweepPages(size_t, size_t gcInfoIndex, GCGroup*) override;
732 732
733 Address currentAllocationPoint() const { return m_currentAllocationPoint; } 733 Address currentAllocationPoint() const { return m_currentAllocationPoint; }
734 bool hasCurrentAllocationArea() const { return currentAllocationPoint() && r emainingAllocationSize(); } 734 bool hasCurrentAllocationArea() const { return currentAllocationPoint() && r emainingAllocationSize(); }
735 void setAllocationPoint(Address, size_t); 735 void setAllocationPoint(Address, size_t);
736 736
737 size_t remainingAllocationSize() const { return m_remainingAllocationSize; } 737 size_t remainingAllocationSize() const { return m_remainingAllocationSize; }
738 void setRemainingAllocationSize(size_t); 738 void setRemainingAllocationSize(size_t);
739 void updateRemainingAllocationSize(); 739 void updateRemainingAllocationSize();
740 740
741 FreeList m_freeList; 741 FreeList m_freeList;
742 Address m_currentAllocationPoint; 742 Address m_currentAllocationPoint;
743 size_t m_remainingAllocationSize; 743 size_t m_remainingAllocationSize;
744 size_t m_lastRemainingAllocationSize; 744 size_t m_lastRemainingAllocationSize;
745 745
746 // The size of promptly freed objects in the heap. 746 // The size of promptly freed objects in the heap.
747 size_t m_promptlyFreedSize; 747 size_t m_promptlyFreedSize;
748 }; 748 };
749 749
750 class LargeObjectHeap final : public BaseHeap { 750 class LargeObjectHeap final : public BaseHeap {
751 public: 751 public:
752 LargeObjectHeap(ThreadState*, int); 752 LargeObjectHeap(ThreadState*, int);
753 Address allocateLargeObjectPage(size_t, size_t gcInfoIndex); 753 Address allocateLargeObjectPage(size_t, size_t gcInfoIndex, GCGroup*);
754 void freeLargeObjectPage(LargeObjectPage*); 754 void freeLargeObjectPage(LargeObjectPage*);
755 #if ENABLE(ASSERT) 755 #if ENABLE(ASSERT)
756 bool isConsistentForGC() override { return true; } 756 bool isConsistentForGC() override { return true; }
757 #endif 757 #endif
758 private: 758 private:
759 Address doAllocateLargeObjectPage(size_t, size_t gcInfoIndex); 759 Address doAllocateLargeObjectPage(size_t, size_t gcInfoIndex, GCGroup*);
760 Address lazySweepPages(size_t, size_t gcInfoIndex) override; 760 Address lazySweepPages(size_t, size_t gcInfoIndex, GCGroup*) override;
761 }; 761 };
762 762
763 // Mask an address down to the enclosing oilpan heap base page. All oilpan heap 763 // Mask an address down to the enclosing oilpan heap base page. All oilpan heap
764 // pages are aligned at blinkPageBase plus the size of a guard size. 764 // pages are aligned at blinkPageBase plus the size of a guard size.
765 // FIXME: Remove PLATFORM_EXPORT once we get a proper public interface to our 765 // FIXME: Remove PLATFORM_EXPORT once we get a proper public interface to our
766 // typed heaps. This is only exported to enable tests in HeapTest.cpp. 766 // typed heaps. This is only exported to enable tests in HeapTest.cpp.
767 PLATFORM_EXPORT inline BasePage* pageFromObject(const void* object) 767 PLATFORM_EXPORT inline BasePage* pageFromObject(const void* object)
768 { 768 {
769 Address address = reinterpret_cast<Address>(const_cast<void*>(object)); 769 Address address = reinterpret_cast<Address>(const_cast<void*>(object));
770 BasePage* page = reinterpret_cast<BasePage*>(blinkPageAddress(address) + bli nkGuardPageSize); 770 BasePage* page = reinterpret_cast<BasePage*>(blinkPageAddress(address) + bli nkGuardPageSize);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 SET_MEMORY_ACCESSIBLE(result, allocationSize - sizeof(HeapObjectHeader)) ; 874 SET_MEMORY_ACCESSIBLE(result, allocationSize - sizeof(HeapObjectHeader)) ;
875 ASSERT(findPageFromAddress(headerAddress + allocationSize - 1)); 875 ASSERT(findPageFromAddress(headerAddress + allocationSize - 1));
876 return result; 876 return result;
877 } 877 }
878 return outOfLineAllocate(allocationSize, gcInfoIndex); 878 return outOfLineAllocate(allocationSize, gcInfoIndex);
879 } 879 }
880 880
881 } // namespace blink 881 } // namespace blink
882 882
883 #endif // HeapPage_h 883 #endif // HeapPage_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698