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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 #endif | 487 #endif |
488 size_t size() override { return blinkPageSize; } | 488 size_t size() override { return blinkPageSize; } |
489 static size_t pageHeaderSize() | 489 static size_t pageHeaderSize() |
490 { | 490 { |
491 // Compute the amount of padding we have to add to a header to make | 491 // Compute the amount of padding we have to add to a header to make |
492 // the size of the header plus the padding a multiple of 8 bytes. | 492 // the size of the header plus the padding a multiple of 8 bytes. |
493 size_t paddingSize = (sizeof(NormalPage) + allocationGranularity - (size
of(HeapObjectHeader) % allocationGranularity)) % allocationGranularity; | 493 size_t paddingSize = (sizeof(NormalPage) + allocationGranularity - (size
of(HeapObjectHeader) % allocationGranularity)) % allocationGranularity; |
494 return sizeof(NormalPage) + paddingSize; | 494 return sizeof(NormalPage) + paddingSize; |
495 } | 495 } |
496 | 496 |
497 | |
498 NormalPageArena* arenaForNormalPage(); | 497 NormalPageArena* arenaForNormalPage(); |
499 | 498 |
500 private: | 499 private: |
501 HeapObjectHeader* findHeaderFromAddress(Address); | 500 HeapObjectHeader* findHeaderFromAddress(Address); |
502 void populateObjectStartBitMap(); | 501 void populateObjectStartBitMap(); |
503 | 502 |
504 bool m_objectStartBitMapComputed; | 503 bool m_objectStartBitMapComputed; |
505 uint8_t m_objectStartBitMap[reservedForObjectBitMap]; | 504 uint8_t m_objectStartBitMap[reservedForObjectBitMap]; |
506 }; | 505 }; |
507 | 506 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 // Returns true if we have swept all pages within the deadline. | 688 // Returns true if we have swept all pages within the deadline. |
690 // Returns false otherwise. | 689 // Returns false otherwise. |
691 bool lazySweepWithDeadline(double deadlineSeconds); | 690 bool lazySweepWithDeadline(double deadlineSeconds); |
692 void completeSweep(); | 691 void completeSweep(); |
693 | 692 |
694 ThreadState* getThreadState() { return m_threadState; } | 693 ThreadState* getThreadState() { return m_threadState; } |
695 int arenaIndex() const { return m_index; } | 694 int arenaIndex() const { return m_index; } |
696 | 695 |
697 Address allocateLargeObject(size_t allocationSize, size_t gcInfoIndex); | 696 Address allocateLargeObject(size_t allocationSize, size_t gcInfoIndex); |
698 | 697 |
| 698 bool willObjectBeLazilySwept(BasePage*, void*) const; |
| 699 |
699 protected: | 700 protected: |
700 BasePage* m_firstPage; | 701 BasePage* m_firstPage; |
701 BasePage* m_firstUnsweptPage; | 702 BasePage* m_firstUnsweptPage; |
702 | 703 |
703 private: | 704 private: |
704 virtual Address lazySweepPages(size_t, size_t gcInfoIndex) = 0; | 705 virtual Address lazySweepPages(size_t, size_t gcInfoIndex) = 0; |
705 | 706 |
706 ThreadState* m_threadState; | 707 ThreadState* m_threadState; |
707 | 708 |
708 // Index into the page pools. This is used to ensure that the pages of the | 709 // Index into the page pools. This is used to ensure that the pages of the |
(...skipping 25 matching lines...) Expand all Loading... |
734 void promptlyFreeObject(HeapObjectHeader*); | 735 void promptlyFreeObject(HeapObjectHeader*); |
735 bool expandObject(HeapObjectHeader*, size_t); | 736 bool expandObject(HeapObjectHeader*, size_t); |
736 bool shrinkObject(HeapObjectHeader*, size_t); | 737 bool shrinkObject(HeapObjectHeader*, size_t); |
737 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; } | 738 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; } |
738 | 739 |
739 bool isObjectAllocatedAtAllocationPoint(HeapObjectHeader* header) | 740 bool isObjectAllocatedAtAllocationPoint(HeapObjectHeader* header) |
740 { | 741 { |
741 return header->payloadEnd() == m_currentAllocationPoint; | 742 return header->payloadEnd() == m_currentAllocationPoint; |
742 } | 743 } |
743 | 744 |
| 745 bool isLazySweeping() const { return m_isLazySweeping; } |
| 746 void setIsLazySweeping(bool flag) { m_isLazySweeping = flag; } |
| 747 |
744 private: | 748 private: |
745 void allocatePage(); | 749 void allocatePage(); |
746 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex); | 750 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex); |
747 Address allocateFromFreeList(size_t, size_t gcInfoIndex); | 751 Address allocateFromFreeList(size_t, size_t gcInfoIndex); |
748 | 752 |
749 Address lazySweepPages(size_t, size_t gcInfoIndex) override; | 753 Address lazySweepPages(size_t, size_t gcInfoIndex) override; |
750 | 754 |
751 Address currentAllocationPoint() const { return m_currentAllocationPoint; } | 755 Address currentAllocationPoint() const { return m_currentAllocationPoint; } |
752 bool hasCurrentAllocationArea() const { return currentAllocationPoint() && r
emainingAllocationSize(); } | 756 bool hasCurrentAllocationArea() const { return currentAllocationPoint() && r
emainingAllocationSize(); } |
753 void setAllocationPoint(Address, size_t); | 757 void setAllocationPoint(Address, size_t); |
754 | 758 |
755 size_t remainingAllocationSize() const { return m_remainingAllocationSize; } | 759 size_t remainingAllocationSize() const { return m_remainingAllocationSize; } |
756 void setRemainingAllocationSize(size_t); | 760 void setRemainingAllocationSize(size_t); |
757 void updateRemainingAllocationSize(); | 761 void updateRemainingAllocationSize(); |
758 | 762 |
759 FreeList m_freeList; | 763 FreeList m_freeList; |
760 Address m_currentAllocationPoint; | 764 Address m_currentAllocationPoint; |
761 size_t m_remainingAllocationSize; | 765 size_t m_remainingAllocationSize; |
762 size_t m_lastRemainingAllocationSize; | 766 size_t m_lastRemainingAllocationSize; |
763 | 767 |
764 // The size of promptly freed objects in the heap. | 768 // The size of promptly freed objects in the heap. |
765 size_t m_promptlyFreedSize; | 769 size_t m_promptlyFreedSize; |
| 770 |
| 771 bool m_isLazySweeping; |
766 }; | 772 }; |
767 | 773 |
768 class LargeObjectArena final : public BaseArena { | 774 class LargeObjectArena final : public BaseArena { |
769 public: | 775 public: |
770 LargeObjectArena(ThreadState*, int); | 776 LargeObjectArena(ThreadState*, int); |
771 Address allocateLargeObjectPage(size_t, size_t gcInfoIndex); | 777 Address allocateLargeObjectPage(size_t, size_t gcInfoIndex); |
772 void freeLargeObjectPage(LargeObjectPage*); | 778 void freeLargeObjectPage(LargeObjectPage*); |
773 #if ENABLE(ASSERT) | 779 #if ENABLE(ASSERT) |
774 bool isConsistentForGC() override { return true; } | 780 bool isConsistentForGC() override { return true; } |
775 #endif | 781 #endif |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 SET_MEMORY_ACCESSIBLE(result, allocationSize - sizeof(HeapObjectHeader))
; | 921 SET_MEMORY_ACCESSIBLE(result, allocationSize - sizeof(HeapObjectHeader))
; |
916 ASSERT(findPageFromAddress(headerAddress + allocationSize - 1)); | 922 ASSERT(findPageFromAddress(headerAddress + allocationSize - 1)); |
917 return result; | 923 return result; |
918 } | 924 } |
919 return outOfLineAllocate(allocationSize, gcInfoIndex); | 925 return outOfLineAllocate(allocationSize, gcInfoIndex); |
920 } | 926 } |
921 | 927 |
922 } // namespace blink | 928 } // namespace blink |
923 | 929 |
924 #endif // HeapPage_h | 930 #endif // HeapPage_h |
OLD | NEW |