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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 #if defined(ADDRESS_SANITIZER) | 465 #if defined(ADDRESS_SANITIZER) |
466 // This needs to zap poisoned memory as well. | 466 // This needs to zap poisoned memory as well. |
467 // Force unpoison memory before memset. | 467 // Force unpoison memory before memset. |
468 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); | 468 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); |
469 #endif | 469 #endif |
470 memset(payload(), orphanedZapValue, payloadSize()); | 470 memset(payload(), orphanedZapValue, payloadSize()); |
471 BaseHeapPage::markOrphaned(); | 471 BaseHeapPage::markOrphaned(); |
472 } | 472 } |
473 #if ENABLE(GC_PROFILING) | 473 #if ENABLE(GC_PROFILING) |
474 const GCInfo* findGCInfo(Address) override; | 474 const GCInfo* findGCInfo(Address) override; |
475 #endif | |
476 #if ENABLE(GC_PROFILING) | |
477 virtual void snapshot(TracedValue*, ThreadState::SnapshotInfo*); | 475 virtual void snapshot(TracedValue*, ThreadState::SnapshotInfo*); |
| 476 void incrementMarkedObjectsAge(); |
| 477 void countMarkedObjects(ClassAgeCountsMap&); |
| 478 void countObjectsToSweep(ClassAgeCountsMap&); |
478 #endif | 479 #endif |
479 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) | 480 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
480 // Returns true for the whole blinkPageSize page that the page is on, even | 481 // Returns true for the whole blinkPageSize page that the page is on, even |
481 // for the header, and the unmapped guard page at the start. That ensures | 482 // for the header, and the unmapped guard page at the start. That ensures |
482 // the result can be used to populate the negative page cache. | 483 // the result can be used to populate the negative page cache. |
483 virtual bool contains(Address addr) override | 484 virtual bool contains(Address addr) override |
484 { | 485 { |
485 Address blinkPageStart = roundToBlinkPageStart(address()); | 486 Address blinkPageStart = roundToBlinkPageStart(address()); |
486 ASSERT(blinkPageStart == address() - WTF::kSystemPageSize); // Page is a
t aligned address plus guard page size. | 487 ASSERT(blinkPageStart == address() - WTF::kSystemPageSize); // Page is a
t aligned address plus guard page size. |
487 return blinkPageStart <= addr && addr < blinkPageStart + blinkPageSize; | 488 return blinkPageStart <= addr && addr < blinkPageStart + blinkPageSize; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 virtual void sweep() override; | 538 virtual void sweep() override; |
538 virtual void markUnmarkedObjectsDead() override; | 539 virtual void markUnmarkedObjectsDead() override; |
539 virtual void checkAndMarkPointer(Visitor*, Address) override; | 540 virtual void checkAndMarkPointer(Visitor*, Address) override; |
540 virtual void markOrphaned() override | 541 virtual void markOrphaned() override |
541 { | 542 { |
542 // Zap the payload with a recognizable value to detect any incorrect | 543 // Zap the payload with a recognizable value to detect any incorrect |
543 // cross thread pointer usage. | 544 // cross thread pointer usage. |
544 memset(payload(), orphanedZapValue, payloadSize()); | 545 memset(payload(), orphanedZapValue, payloadSize()); |
545 BaseHeapPage::markOrphaned(); | 546 BaseHeapPage::markOrphaned(); |
546 } | 547 } |
| 548 |
547 #if ENABLE(GC_PROFILING) | 549 #if ENABLE(GC_PROFILING) |
548 virtual const GCInfo* findGCInfo(Address) override; | 550 virtual const GCInfo* findGCInfo(Address) override; |
549 virtual void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override; | 551 virtual void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override; |
| 552 void incrementMarkedObjectsAge(); |
| 553 void countMarkedObjects(ClassAgeCountsMap&); |
| 554 void countObjectsToSweep(ClassAgeCountsMap&); |
550 #endif | 555 #endif |
| 556 |
551 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) | 557 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
552 // Returns true for any address that is on one of the pages that this | 558 // Returns true for any address that is on one of the pages that this |
553 // large object uses. That ensures that we can use a negative result to | 559 // large object uses. That ensures that we can use a negative result to |
554 // populate the negative page cache. | 560 // populate the negative page cache. |
555 virtual bool contains(Address object) override | 561 virtual bool contains(Address object) override |
556 { | 562 { |
557 return roundToBlinkPageStart(address()) <= object && object < roundToBli
nkPageEnd(address() + size()); | 563 return roundToBlinkPageStart(address()) <= object && object < roundToBli
nkPageEnd(address() + size()); |
558 } | 564 } |
559 #endif | 565 #endif |
560 virtual size_t size() | 566 virtual size_t size() |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 void clear(); | 708 void clear(); |
703 | 709 |
704 // Returns a bucket number for inserting a FreeListEntry of a given size. | 710 // Returns a bucket number for inserting a FreeListEntry of a given size. |
705 // All FreeListEntries in the given bucket, n, have size >= 2^n. | 711 // All FreeListEntries in the given bucket, n, have size >= 2^n. |
706 static int bucketIndexForSize(size_t); | 712 static int bucketIndexForSize(size_t); |
707 | 713 |
708 #if ENABLE(GC_PROFILING) | 714 #if ENABLE(GC_PROFILING) |
709 struct PerBucketFreeListStats { | 715 struct PerBucketFreeListStats { |
710 size_t entryCount; | 716 size_t entryCount; |
711 size_t freeSize; | 717 size_t freeSize; |
| 718 |
| 719 PerBucketFreeListStats() : entryCount(0), freeSize(0) { } |
712 }; | 720 }; |
713 | 721 |
714 void getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& totalSiz
e) const; | 722 void getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& totalSiz
e) const; |
715 #endif | 723 #endif |
716 | 724 |
717 private: | 725 private: |
718 int m_biggestFreeListIndex; | 726 int m_biggestFreeListIndex; |
719 | 727 |
720 // All FreeListEntries in the nth list have size >= 2^n. | 728 // All FreeListEntries in the nth list have size >= 2^n. |
721 FreeListEntry* m_freeLists[blinkPageSizeLog2]; | 729 FreeListEntry* m_freeLists[blinkPageSizeLog2]; |
(...skipping 15 matching lines...) Expand all Loading... |
737 public: | 745 public: |
738 ThreadHeap(ThreadState*, int); | 746 ThreadHeap(ThreadState*, int); |
739 ~ThreadHeap(); | 747 ~ThreadHeap(); |
740 void cleanupPages(); | 748 void cleanupPages(); |
741 | 749 |
742 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) | 750 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
743 BaseHeapPage* findPageFromAddress(Address); | 751 BaseHeapPage* findPageFromAddress(Address); |
744 #endif | 752 #endif |
745 #if ENABLE(GC_PROFILING) | 753 #if ENABLE(GC_PROFILING) |
746 void snapshot(TracedValue*, ThreadState::SnapshotInfo*); | 754 void snapshot(TracedValue*, ThreadState::SnapshotInfo*); |
| 755 void incrementMarkedObjectsAge(); |
747 #endif | 756 #endif |
748 | 757 |
749 void clearFreeLists(); | 758 void clearFreeLists(); |
750 void makeConsistentForSweeping(); | 759 void makeConsistentForSweeping(); |
751 #if ENABLE(ASSERT) | 760 #if ENABLE(ASSERT) |
752 bool isConsistentForSweeping(); | 761 bool isConsistentForSweeping(); |
753 #endif | 762 #endif |
754 size_t objectPayloadSizeForTesting(); | 763 size_t objectPayloadSizeForTesting(); |
755 | 764 |
756 ThreadState* threadState() { return m_threadState; } | 765 ThreadState* threadState() { return m_threadState; } |
(...skipping 19 matching lines...) Expand all Loading... |
776 void freePage(HeapPage*); | 785 void freePage(HeapPage*); |
777 void freeLargeObject(LargeObject*); | 786 void freeLargeObject(LargeObject*); |
778 | 787 |
779 void promptlyFreeObject(HeapObjectHeader*); | 788 void promptlyFreeObject(HeapObjectHeader*); |
780 bool expandObject(HeapObjectHeader*, size_t); | 789 bool expandObject(HeapObjectHeader*, size_t); |
781 void shrinkObject(HeapObjectHeader*, size_t); | 790 void shrinkObject(HeapObjectHeader*, size_t); |
782 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; } | 791 void decreasePromptlyFreedSize(size_t size) { m_promptlyFreedSize -= size; } |
783 | 792 |
784 #if ENABLE(GC_PROFILING) | 793 #if ENABLE(GC_PROFILING) |
785 void snapshotFreeList(TracedValue&); | 794 void snapshotFreeList(TracedValue&); |
| 795 |
| 796 void countMarkedObjects(ClassAgeCountsMap&) const; |
| 797 void countObjectsToSweep(ClassAgeCountsMap&) const; |
786 #endif | 798 #endif |
787 | 799 |
788 private: | 800 private: |
789 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex); | 801 Address outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex); |
790 Address currentAllocationPoint() const { return m_currentAllocationPoint; } | 802 Address currentAllocationPoint() const { return m_currentAllocationPoint; } |
791 size_t remainingAllocationSize() const { return m_remainingAllocationSize; } | 803 size_t remainingAllocationSize() const { return m_remainingAllocationSize; } |
792 bool hasCurrentAllocationArea() const { return currentAllocationPoint() && r
emainingAllocationSize(); } | 804 bool hasCurrentAllocationArea() const { return currentAllocationPoint() && r
emainingAllocationSize(); } |
793 inline void setAllocationPoint(Address, size_t); | 805 inline void setAllocationPoint(Address, size_t); |
794 void updateRemainingAllocationSize(); | 806 void updateRemainingAllocationSize(); |
795 Address allocateFromFreeList(size_t, size_t gcInfoIndex); | 807 Address allocateFromFreeList(size_t, size_t gcInfoIndex); |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2450 template<typename T, size_t inlineCapacity> | 2462 template<typename T, size_t inlineCapacity> |
2451 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T,
inlineCapacity, HeapAllocator>> { }; | 2463 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T,
inlineCapacity, HeapAllocator>> { }; |
2452 template<typename T, size_t inlineCapacity> | 2464 template<typename T, size_t inlineCapacity> |
2453 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i
nlineCapacity, HeapAllocator>> { }; | 2465 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i
nlineCapacity, HeapAllocator>> { }; |
2454 template<typename T, typename U, typename V> | 2466 template<typename T, typename U, typename V> |
2455 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted
Set<T, U, V, HeapAllocator>> { }; | 2467 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted
Set<T, U, V, HeapAllocator>> { }; |
2456 | 2468 |
2457 } // namespace blink | 2469 } // namespace blink |
2458 | 2470 |
2459 #endif // Heap_h | 2471 #endif // Heap_h |
OLD | NEW |