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

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

Issue 2531973002: Simple BlinkGC heap compaction. (Closed)
Patch Set: add pointer alignment handling to SparseHeapBitmap Created 4 years 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 NO_SANITIZE_ADDRESS 301 NO_SANITIZE_ADDRESS
302 void link(FreeListEntry** prevNext) { 302 void link(FreeListEntry** prevNext) {
303 m_next = *prevNext; 303 m_next = *prevNext;
304 *prevNext = this; 304 *prevNext = this;
305 } 305 }
306 306
307 NO_SANITIZE_ADDRESS 307 NO_SANITIZE_ADDRESS
308 FreeListEntry* next() const { return m_next; } 308 FreeListEntry* next() const { return m_next; }
309 309
310 NO_SANITIZE_ADDRESS 310 NO_SANITIZE_ADDRESS
311 FreeListEntry** prevNext() { return &m_next; }
haraken 2016/12/09 07:25:56 This is unused.
sof 2016/12/09 21:44:04 Thanks, removed the leftover.
312
313 NO_SANITIZE_ADDRESS
311 void append(FreeListEntry* next) { 314 void append(FreeListEntry* next) {
312 ASSERT(!m_next); 315 ASSERT(!m_next);
313 m_next = next; 316 m_next = next;
314 } 317 }
315 318
316 private: 319 private:
317 FreeListEntry* m_next; 320 FreeListEntry* m_next;
318 }; 321 };
319 322
320 // Blink heap pages are set up with a guard page before and after the payload. 323 // Blink heap pages are set up with a guard page before and after the payload.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 // Compute the amount of padding we have to add to a header to make 508 // Compute the amount of padding we have to add to a header to make
506 // the size of the header plus the padding a multiple of 8 bytes. 509 // the size of the header plus the padding a multiple of 8 bytes.
507 size_t paddingSize = (sizeof(NormalPage) + allocationGranularity - 510 size_t paddingSize = (sizeof(NormalPage) + allocationGranularity -
508 (sizeof(HeapObjectHeader) % allocationGranularity)) % 511 (sizeof(HeapObjectHeader) % allocationGranularity)) %
509 allocationGranularity; 512 allocationGranularity;
510 return sizeof(NormalPage) + paddingSize; 513 return sizeof(NormalPage) + paddingSize;
511 } 514 }
512 515
513 inline NormalPageArena* arenaForNormalPage() const; 516 inline NormalPageArena* arenaForNormalPage() const;
514 517
518 // Context object holding the state of the arena page compaction pass,
519 // passed in when compacting individual pages.
520 class CompactionContext {
haraken 2016/12/09 07:25:56 Thanks, this is much more readable :)
521 STACK_ALLOCATED();
522
523 public:
524 // Page compacting into.
525 NormalPage* m_currentPage = nullptr;
526 // Offset into |m_currentPage| to the next free address.
527 size_t m_allocationPoint = 0;
528 // Chain of available pages to use for compaction. Page compaction
529 // picks the next one when the current one is exhausted.
530 BasePage* m_availablePages = nullptr;
531 // Chain of pages that have been compacted. Page compaction will
532 // add compacted pages once the current one becomes exhausted.
533 BasePage** m_compactedPages = nullptr;
534 };
535
536 void sweepAndCompact(CompactionContext&);
537
515 private: 538 private:
516 HeapObjectHeader* findHeaderFromAddress(Address); 539 HeapObjectHeader* findHeaderFromAddress(Address);
517 void populateObjectStartBitMap(); 540 void populateObjectStartBitMap();
518 541
519 bool m_objectStartBitMapComputed; 542 bool m_objectStartBitMapComputed;
520 uint8_t m_objectStartBitMap[reservedForObjectBitMap]; 543 uint8_t m_objectStartBitMap[reservedForObjectBitMap];
521 }; 544 };
522 545
523 // Large allocations are allocated as separate objects and linked in a list. 546 // Large allocations are allocated as separate objects and linked in a list.
524 // 547 //
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 static void zapFreedMemory(Address, size_t); 681 static void zapFreedMemory(Address, size_t);
659 static void checkFreedMemoryIsZapped(Address, size_t); 682 static void checkFreedMemoryIsZapped(Address, size_t);
660 #endif 683 #endif
661 684
662 private: 685 private:
663 int m_biggestFreeListIndex; 686 int m_biggestFreeListIndex;
664 687
665 // All FreeListEntries in the nth list have size >= 2^n. 688 // All FreeListEntries in the nth list have size >= 2^n.
666 FreeListEntry* m_freeLists[blinkPageSizeLog2]; 689 FreeListEntry* m_freeLists[blinkPageSizeLog2];
667 690
691 size_t freeListSize() const;
692
668 friend class NormalPageArena; 693 friend class NormalPageArena;
669 }; 694 };
670 695
671 // Each thread has a number of thread arenas (e.g., Generic arenas, 696 // Each thread has a number of thread arenas (e.g., Generic arenas,
672 // typed arenas for Node, arenas for collection backings etc) 697 // typed arenas for Node, arenas for collection backings etc)
673 // and BaseArena represents each thread arena. 698 // and BaseArena represents each thread arena.
674 // 699 //
675 // BaseArena is a parent class of NormalPageArena and LargeObjectArena. 700 // BaseArena is a parent class of NormalPageArena and LargeObjectArena.
676 // NormalPageArena represents a part of a heap that contains NormalPages 701 // NormalPageArena represents a part of a heap that contains NormalPages
677 // and LargeObjectArena represents a part of a heap that contains 702 // and LargeObjectArena represents a part of a heap that contains
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 bool shrinkObject(HeapObjectHeader*, size_t); 779 bool shrinkObject(HeapObjectHeader*, size_t);
755 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; } 780 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; }
756 781
757 bool isObjectAllocatedAtAllocationPoint(HeapObjectHeader* header) { 782 bool isObjectAllocatedAtAllocationPoint(HeapObjectHeader* header) {
758 return header->payloadEnd() == m_currentAllocationPoint; 783 return header->payloadEnd() == m_currentAllocationPoint;
759 } 784 }
760 785
761 bool isLazySweeping() const { return m_isLazySweeping; } 786 bool isLazySweeping() const { return m_isLazySweeping; }
762 void setIsLazySweeping(bool flag) { m_isLazySweeping = flag; } 787 void setIsLazySweeping(bool flag) { m_isLazySweeping = flag; }
763 788
789 size_t arenaSize();
790 size_t freeListSize();
791
792 void sweepAndCompact();
793
764 private: 794 private:
765 void allocatePage(); 795 NormalPage* allocatePage();
796 void allocateAndAddPage();
haraken 2016/12/09 07:25:56 What's the point of splitting the method into the
sof 2016/12/09 21:44:04 Thanks for catching that, that's a remnant of supp
797
766 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex); 798 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex);
767 Address allocateFromFreeList(size_t, size_t gcInfoIndex); 799 Address allocateFromFreeList(size_t, size_t gcInfoIndex);
768 800
769 Address lazySweepPages(size_t, size_t gcInfoIndex) override; 801 Address lazySweepPages(size_t, size_t gcInfoIndex) override;
770 802
771 Address currentAllocationPoint() const { return m_currentAllocationPoint; } 803 Address currentAllocationPoint() const { return m_currentAllocationPoint; }
772 bool hasCurrentAllocationArea() const { 804 bool hasCurrentAllocationArea() const {
773 return currentAllocationPoint() && remainingAllocationSize(); 805 return currentAllocationPoint() && remainingAllocationSize();
774 } 806 }
775 void setAllocationPoint(Address, size_t); 807 void setAllocationPoint(Address, size_t);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 return outOfLineAllocate(allocationSize, gcInfoIndex); 952 return outOfLineAllocate(allocationSize, gcInfoIndex);
921 } 953 }
922 954
923 inline NormalPageArena* NormalPage::arenaForNormalPage() const { 955 inline NormalPageArena* NormalPage::arenaForNormalPage() const {
924 return static_cast<NormalPageArena*>(arena()); 956 return static_cast<NormalPageArena*>(arena());
925 } 957 }
926 958
927 } // namespace blink 959 } // namespace blink
928 960
929 #endif // HeapPage_h 961 #endif // HeapPage_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698