| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef HeapPage_h | 31 #ifndef HeapPage_h |
| 32 #define HeapPage_h | 32 #define HeapPage_h |
| 33 | 33 |
| 34 #include "base/trace_event/memory_allocator_dump.h" |
| 34 #include "platform/PlatformExport.h" | 35 #include "platform/PlatformExport.h" |
| 35 #include "platform/heap/BlinkGC.h" | 36 #include "platform/heap/BlinkGC.h" |
| 36 #include "platform/heap/GCInfo.h" | 37 #include "platform/heap/GCInfo.h" |
| 37 #include "platform/heap/ThreadState.h" | 38 #include "platform/heap/ThreadState.h" |
| 38 #include "platform/heap/Visitor.h" | 39 #include "platform/heap/Visitor.h" |
| 39 #include "wtf/AddressSanitizer.h" | 40 #include "wtf/AddressSanitizer.h" |
| 40 #include "wtf/Allocator.h" | 41 #include "wtf/Allocator.h" |
| 41 #include "wtf/Assertions.h" | 42 #include "wtf/Assertions.h" |
| 42 #include "wtf/ContainerAnnotations.h" | 43 #include "wtf/ContainerAnnotations.h" |
| 43 #include "wtf/Forward.h" | 44 #include "wtf/Forward.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 virtual void checkAndMarkPointer(Visitor*, Address) = 0; | 395 virtual void checkAndMarkPointer(Visitor*, Address) = 0; |
| 395 virtual void markOrphaned(); | 396 virtual void markOrphaned(); |
| 396 | 397 |
| 397 class HeapSnapshotInfo { | 398 class HeapSnapshotInfo { |
| 398 STACK_ALLOCATED(); | 399 STACK_ALLOCATED(); |
| 399 public: | 400 public: |
| 400 size_t freeCount = 0; | 401 size_t freeCount = 0; |
| 401 size_t freeSize = 0; | 402 size_t freeSize = 0; |
| 402 }; | 403 }; |
| 403 | 404 |
| 404 virtual void takeSnapshot(WebMemoryAllocatorDump*, ThreadState::GCSnapshotIn
fo&, HeapSnapshotInfo&) = 0; | 405 virtual void takeSnapshot(base::trace_event::MemoryAllocatorDump*, ThreadSta
te::GCSnapshotInfo&, HeapSnapshotInfo&) = 0; |
| 405 #if ENABLE(ASSERT) | 406 #if ENABLE(ASSERT) |
| 406 virtual bool contains(Address) = 0; | 407 virtual bool contains(Address) = 0; |
| 407 #endif | 408 #endif |
| 408 virtual size_t size() = 0; | 409 virtual size_t size() = 0; |
| 409 virtual bool isLargeObjectPage() { return false; } | 410 virtual bool isLargeObjectPage() { return false; } |
| 410 | 411 |
| 411 Address getAddress() { return reinterpret_cast<Address>(this); } | 412 Address getAddress() { return reinterpret_cast<Address>(this); } |
| 412 PageMemory* storage() const { return m_storage; } | 413 PageMemory* storage() const { return m_storage; } |
| 413 BaseArena* arena() const { return m_arena; } | 414 BaseArena* arena() const { return m_arena; } |
| 414 bool orphaned() { return !m_arena; } | 415 bool orphaned() { return !m_arena; } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 void sweep() override; | 471 void sweep() override; |
| 471 void makeConsistentForGC() override; | 472 void makeConsistentForGC() override; |
| 472 void makeConsistentForMutator() override; | 473 void makeConsistentForMutator() override; |
| 473 void invalidateObjectStartBitmap() override { m_objectStartBitMapComputed =
false; } | 474 void invalidateObjectStartBitmap() override { m_objectStartBitMapComputed =
false; } |
| 474 #if defined(ADDRESS_SANITIZER) | 475 #if defined(ADDRESS_SANITIZER) |
| 475 void poisonUnmarkedObjects() override; | 476 void poisonUnmarkedObjects() override; |
| 476 #endif | 477 #endif |
| 477 void checkAndMarkPointer(Visitor*, Address) override; | 478 void checkAndMarkPointer(Visitor*, Address) override; |
| 478 void markOrphaned() override; | 479 void markOrphaned() override; |
| 479 | 480 |
| 480 void takeSnapshot(WebMemoryAllocatorDump*, ThreadState::GCSnapshotInfo&, Hea
pSnapshotInfo&) override; | 481 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, ThreadState::GCSn
apshotInfo&, HeapSnapshotInfo&) override; |
| 481 #if ENABLE(ASSERT) | 482 #if ENABLE(ASSERT) |
| 482 // Returns true for the whole blinkPageSize page that the page is on, even | 483 // Returns true for the whole blinkPageSize page that the page is on, even |
| 483 // for the header, and the unmapped guard page at the start. That ensures | 484 // for the header, and the unmapped guard page at the start. That ensures |
| 484 // the result can be used to populate the negative page cache. | 485 // the result can be used to populate the negative page cache. |
| 485 bool contains(Address) override; | 486 bool contains(Address) override; |
| 486 #endif | 487 #endif |
| 487 size_t size() override { return blinkPageSize; } | 488 size_t size() override { return blinkPageSize; } |
| 488 static size_t pageHeaderSize() | 489 static size_t pageHeaderSize() |
| 489 { | 490 { |
| 490 // 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 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 void sweep() override; | 528 void sweep() override; |
| 528 void makeConsistentForGC() override; | 529 void makeConsistentForGC() override; |
| 529 void makeConsistentForMutator() override; | 530 void makeConsistentForMutator() override; |
| 530 void invalidateObjectStartBitmap() override { } | 531 void invalidateObjectStartBitmap() override { } |
| 531 #if defined(ADDRESS_SANITIZER) | 532 #if defined(ADDRESS_SANITIZER) |
| 532 void poisonUnmarkedObjects() override; | 533 void poisonUnmarkedObjects() override; |
| 533 #endif | 534 #endif |
| 534 void checkAndMarkPointer(Visitor*, Address) override; | 535 void checkAndMarkPointer(Visitor*, Address) override; |
| 535 void markOrphaned() override; | 536 void markOrphaned() override; |
| 536 | 537 |
| 537 void takeSnapshot(WebMemoryAllocatorDump*, ThreadState::GCSnapshotInfo&, Hea
pSnapshotInfo&) override; | 538 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, ThreadState::GCSn
apshotInfo&, HeapSnapshotInfo&) override; |
| 538 #if ENABLE(ASSERT) | 539 #if ENABLE(ASSERT) |
| 539 // Returns true for any address that is on one of the pages that this | 540 // Returns true for any address that is on one of the pages that this |
| 540 // large object uses. That ensures that we can use a negative result to | 541 // large object uses. That ensures that we can use a negative result to |
| 541 // populate the negative page cache. | 542 // populate the negative page cache. |
| 542 bool contains(Address) override; | 543 bool contains(Address) override; |
| 543 #endif | 544 #endif |
| 544 virtual size_t size() | 545 virtual size_t size() |
| 545 { | 546 { |
| 546 return pageHeaderSize() + sizeof(HeapObjectHeader) + m_payloadSize; | 547 return pageHeaderSize() + sizeof(HeapObjectHeader) + m_payloadSize; |
| 547 } | 548 } |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 SET_MEMORY_ACCESSIBLE(result, allocationSize - sizeof(HeapObjectHeader))
; | 913 SET_MEMORY_ACCESSIBLE(result, allocationSize - sizeof(HeapObjectHeader))
; |
| 913 ASSERT(findPageFromAddress(headerAddress + allocationSize - 1)); | 914 ASSERT(findPageFromAddress(headerAddress + allocationSize - 1)); |
| 914 return result; | 915 return result; |
| 915 } | 916 } |
| 916 return outOfLineAllocate(allocationSize, gcInfoIndex); | 917 return outOfLineAllocate(allocationSize, gcInfoIndex); |
| 917 } | 918 } |
| 918 | 919 |
| 919 } // namespace blink | 920 } // namespace blink |
| 920 | 921 |
| 921 #endif // HeapPage_h | 922 #endif // HeapPage_h |
| OLD | NEW |