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

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

Issue 2531973002: Simple BlinkGC heap compaction. (Closed)
Patch Set: synchronize on compaction finish 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; }
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 size_t sweepCompact(NormalPage*&, BasePage**, size_t);
haraken 2016/12/02 12:43:20 sweepAndCompact ?
519
515 private: 520 private:
516 HeapObjectHeader* findHeaderFromAddress(Address); 521 HeapObjectHeader* findHeaderFromAddress(Address);
517 void populateObjectStartBitMap(); 522 void populateObjectStartBitMap();
518 523
519 bool m_objectStartBitMapComputed; 524 bool m_objectStartBitMapComputed;
520 uint8_t m_objectStartBitMap[reservedForObjectBitMap]; 525 uint8_t m_objectStartBitMap[reservedForObjectBitMap];
521 }; 526 };
522 527
523 // Large allocations are allocated as separate objects and linked in a list. 528 // Large allocations are allocated as separate objects and linked in a list.
524 // 529 //
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 static void zapFreedMemory(Address, size_t); 663 static void zapFreedMemory(Address, size_t);
659 static void checkFreedMemoryIsZapped(Address, size_t); 664 static void checkFreedMemoryIsZapped(Address, size_t);
660 #endif 665 #endif
661 666
662 private: 667 private:
663 int m_biggestFreeListIndex; 668 int m_biggestFreeListIndex;
664 669
665 // All FreeListEntries in the nth list have size >= 2^n. 670 // All FreeListEntries in the nth list have size >= 2^n.
666 FreeListEntry* m_freeLists[blinkPageSizeLog2]; 671 FreeListEntry* m_freeLists[blinkPageSizeLog2];
667 672
673 size_t size() const;
haraken 2016/12/02 12:43:20 size => freeListSize ? (since size() is used in va
sof 2016/12/04 14:55:38 That's better, done.
674
668 friend class NormalPageArena; 675 friend class NormalPageArena;
669 }; 676 };
670 677
671 // Each thread has a number of thread arenas (e.g., Generic arenas, 678 // Each thread has a number of thread arenas (e.g., Generic arenas,
672 // typed arenas for Node, arenas for collection backings etc) 679 // typed arenas for Node, arenas for collection backings etc)
673 // and BaseArena represents each thread arena. 680 // and BaseArena represents each thread arena.
674 // 681 //
675 // BaseArena is a parent class of NormalPageArena and LargeObjectArena. 682 // BaseArena is a parent class of NormalPageArena and LargeObjectArena.
676 // NormalPageArena represents a part of a heap that contains NormalPages 683 // NormalPageArena represents a part of a heap that contains NormalPages
677 // and LargeObjectArena represents a part of a heap that contains 684 // 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); 761 bool shrinkObject(HeapObjectHeader*, size_t);
755 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; } 762 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; }
756 763
757 bool isObjectAllocatedAtAllocationPoint(HeapObjectHeader* header) { 764 bool isObjectAllocatedAtAllocationPoint(HeapObjectHeader* header) {
758 return header->payloadEnd() == m_currentAllocationPoint; 765 return header->payloadEnd() == m_currentAllocationPoint;
759 } 766 }
760 767
761 bool isLazySweeping() const { return m_isLazySweeping; } 768 bool isLazySweeping() const { return m_isLazySweeping; }
762 void setIsLazySweeping(bool flag) { m_isLazySweeping = flag; } 769 void setIsLazySweeping(bool flag) { m_isLazySweeping = flag; }
763 770
771 size_t arenaSize();
772 size_t freeListSize();
773
774 void sweepCompact();
haraken 2016/12/02 12:43:20 sweepAndCompact ?
sof 2016/12/04 14:55:38 Done.
775
764 private: 776 private:
765 void allocatePage(); 777 NormalPage* allocatePage();
778 void allocateAndAddPage();
779
766 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex); 780 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex);
767 Address allocateFromFreeList(size_t, size_t gcInfoIndex); 781 Address allocateFromFreeList(size_t, size_t gcInfoIndex);
768 782
769 Address lazySweepPages(size_t, size_t gcInfoIndex) override; 783 Address lazySweepPages(size_t, size_t gcInfoIndex) override;
770 784
771 Address currentAllocationPoint() const { return m_currentAllocationPoint; } 785 Address currentAllocationPoint() const { return m_currentAllocationPoint; }
772 bool hasCurrentAllocationArea() const { 786 bool hasCurrentAllocationArea() const {
773 return currentAllocationPoint() && remainingAllocationSize(); 787 return currentAllocationPoint() && remainingAllocationSize();
774 } 788 }
775 void setAllocationPoint(Address, size_t); 789 void setAllocationPoint(Address, size_t);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 return outOfLineAllocate(allocationSize, gcInfoIndex); 934 return outOfLineAllocate(allocationSize, gcInfoIndex);
921 } 935 }
922 936
923 inline NormalPageArena* NormalPage::arenaForNormalPage() const { 937 inline NormalPageArena* NormalPage::arenaForNormalPage() const {
924 return static_cast<NormalPageArena*>(arena()); 938 return static_cast<NormalPageArena*>(arena());
925 } 939 }
926 940
927 } // namespace blink 941 } // namespace blink
928 942
929 #endif // HeapPage_h 943 #endif // HeapPage_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698