| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 // | 406 // |
| 407 // This is used during conservative stack scanning to | 407 // This is used during conservative stack scanning to |
| 408 // conservatively mark all objects that could be referenced from | 408 // conservatively mark all objects that could be referenced from |
| 409 // the stack. | 409 // the stack. |
| 410 virtual void checkAndMarkPointer(Visitor*, Address) = 0; | 410 virtual void checkAndMarkPointer(Visitor*, Address) = 0; |
| 411 #if DCHECK_IS_ON() | 411 #if DCHECK_IS_ON() |
| 412 virtual void checkAndMarkPointer(Visitor*, | 412 virtual void checkAndMarkPointer(Visitor*, |
| 413 Address, | 413 Address, |
| 414 MarkedPointerCallbackForTesting) = 0; | 414 MarkedPointerCallbackForTesting) = 0; |
| 415 #endif | 415 #endif |
| 416 virtual void markOrphaned(); | |
| 417 | 416 |
| 418 class HeapSnapshotInfo { | 417 class HeapSnapshotInfo { |
| 419 STACK_ALLOCATED(); | 418 STACK_ALLOCATED(); |
| 420 | 419 |
| 421 public: | 420 public: |
| 422 size_t freeCount = 0; | 421 size_t freeCount = 0; |
| 423 size_t freeSize = 0; | 422 size_t freeSize = 0; |
| 424 }; | 423 }; |
| 425 | 424 |
| 426 virtual void takeSnapshot(base::trace_event::MemoryAllocatorDump*, | 425 virtual void takeSnapshot(base::trace_event::MemoryAllocatorDump*, |
| 427 ThreadState::GCSnapshotInfo&, | 426 ThreadState::GCSnapshotInfo&, |
| 428 HeapSnapshotInfo&) = 0; | 427 HeapSnapshotInfo&) = 0; |
| 429 #if DCHECK_IS_ON() | 428 #if DCHECK_IS_ON() |
| 430 virtual bool contains(Address) = 0; | 429 virtual bool contains(Address) = 0; |
| 431 #endif | 430 #endif |
| 432 virtual size_t size() = 0; | 431 virtual size_t size() = 0; |
| 433 virtual bool isLargeObjectPage() { return false; } | 432 virtual bool isLargeObjectPage() { return false; } |
| 434 | 433 |
| 435 Address getAddress() { return reinterpret_cast<Address>(this); } | 434 Address getAddress() { return reinterpret_cast<Address>(this); } |
| 436 PageMemory* storage() const { return m_storage; } | 435 PageMemory* storage() const { return m_storage; } |
| 437 BaseArena* arena() const { return m_arena; } | 436 BaseArena* arena() const { return m_arena; } |
| 438 bool orphaned() { return !m_arena; } | |
| 439 bool terminating() { return m_terminating; } | 437 bool terminating() { return m_terminating; } |
| 440 void setTerminating() { m_terminating = true; } | 438 void setTerminating() { m_terminating = true; } |
| 441 | 439 |
| 442 // Returns true if this page has been swept by the ongoing lazy sweep. | 440 // Returns true if this page has been swept by the ongoing lazy sweep. |
| 443 bool hasBeenSwept() const { return m_swept; } | 441 bool hasBeenSwept() const { return m_swept; } |
| 444 | 442 |
| 445 void markAsSwept() { | 443 void markAsSwept() { |
| 446 ASSERT(!m_swept); | 444 ASSERT(!m_swept); |
| 447 m_swept = true; | 445 m_swept = true; |
| 448 } | 446 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 489 } |
| 492 #if defined(ADDRESS_SANITIZER) | 490 #if defined(ADDRESS_SANITIZER) |
| 493 void poisonUnmarkedObjects() override; | 491 void poisonUnmarkedObjects() override; |
| 494 #endif | 492 #endif |
| 495 void checkAndMarkPointer(Visitor*, Address) override; | 493 void checkAndMarkPointer(Visitor*, Address) override; |
| 496 #if DCHECK_IS_ON() | 494 #if DCHECK_IS_ON() |
| 497 void checkAndMarkPointer(Visitor*, | 495 void checkAndMarkPointer(Visitor*, |
| 498 Address, | 496 Address, |
| 499 MarkedPointerCallbackForTesting) override; | 497 MarkedPointerCallbackForTesting) override; |
| 500 #endif | 498 #endif |
| 501 void markOrphaned() override; | |
| 502 | 499 |
| 503 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, | 500 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, |
| 504 ThreadState::GCSnapshotInfo&, | 501 ThreadState::GCSnapshotInfo&, |
| 505 HeapSnapshotInfo&) override; | 502 HeapSnapshotInfo&) override; |
| 506 #if DCHECK_IS_ON() | 503 #if DCHECK_IS_ON() |
| 507 // Returns true for the whole blinkPageSize page that the page is on, even | 504 // Returns true for the whole blinkPageSize page that the page is on, even |
| 508 // for the header, and the unmapped guard page at the start. That ensures | 505 // for the header, and the unmapped guard page at the start. That ensures |
| 509 // the result can be used to populate the negative page cache. | 506 // the result can be used to populate the negative page cache. |
| 510 bool contains(Address) override; | 507 bool contains(Address) override; |
| 511 #endif | 508 #endif |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 void invalidateObjectStartBitmap() override {} | 570 void invalidateObjectStartBitmap() override {} |
| 574 #if defined(ADDRESS_SANITIZER) | 571 #if defined(ADDRESS_SANITIZER) |
| 575 void poisonUnmarkedObjects() override; | 572 void poisonUnmarkedObjects() override; |
| 576 #endif | 573 #endif |
| 577 void checkAndMarkPointer(Visitor*, Address) override; | 574 void checkAndMarkPointer(Visitor*, Address) override; |
| 578 #if DCHECK_IS_ON() | 575 #if DCHECK_IS_ON() |
| 579 void checkAndMarkPointer(Visitor*, | 576 void checkAndMarkPointer(Visitor*, |
| 580 Address, | 577 Address, |
| 581 MarkedPointerCallbackForTesting) override; | 578 MarkedPointerCallbackForTesting) override; |
| 582 #endif | 579 #endif |
| 583 void markOrphaned() override; | |
| 584 | 580 |
| 585 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, | 581 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, |
| 586 ThreadState::GCSnapshotInfo&, | 582 ThreadState::GCSnapshotInfo&, |
| 587 HeapSnapshotInfo&) override; | 583 HeapSnapshotInfo&) override; |
| 588 #if DCHECK_IS_ON() | 584 #if DCHECK_IS_ON() |
| 589 // Returns true for any address that is on one of the pages that this | 585 // Returns true for any address that is on one of the pages that this |
| 590 // large object uses. That ensures that we can use a negative result to | 586 // large object uses. That ensures that we can use a negative result to |
| 591 // populate the negative page cache. | 587 // populate the negative page cache. |
| 592 bool contains(Address) override; | 588 bool contains(Address) override; |
| 593 #endif | 589 #endif |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 // BaseArena is a parent class of NormalPageArena and LargeObjectArena. | 706 // BaseArena is a parent class of NormalPageArena and LargeObjectArena. |
| 711 // NormalPageArena represents a part of a heap that contains NormalPages | 707 // NormalPageArena represents a part of a heap that contains NormalPages |
| 712 // and LargeObjectArena represents a part of a heap that contains | 708 // and LargeObjectArena represents a part of a heap that contains |
| 713 // LargeObjectPages. | 709 // LargeObjectPages. |
| 714 class PLATFORM_EXPORT BaseArena { | 710 class PLATFORM_EXPORT BaseArena { |
| 715 USING_FAST_MALLOC(BaseArena); | 711 USING_FAST_MALLOC(BaseArena); |
| 716 | 712 |
| 717 public: | 713 public: |
| 718 BaseArena(ThreadState*, int); | 714 BaseArena(ThreadState*, int); |
| 719 virtual ~BaseArena(); | 715 virtual ~BaseArena(); |
| 720 void cleanupPages(); | 716 void removeAllPages(); |
| 721 | 717 |
| 722 void takeSnapshot(const String& dumpBaseName, ThreadState::GCSnapshotInfo&); | 718 void takeSnapshot(const String& dumpBaseName, ThreadState::GCSnapshotInfo&); |
| 723 #if DCHECK_IS_ON() | 719 #if DCHECK_IS_ON() |
| 724 BasePage* findPageFromAddress(Address); | 720 BasePage* findPageFromAddress(Address); |
| 725 #endif | 721 #endif |
| 726 virtual void takeFreelistSnapshot(const String& dumpBaseName) {} | 722 virtual void takeFreelistSnapshot(const String& dumpBaseName) {} |
| 727 virtual void clearFreeLists() {} | 723 virtual void clearFreeLists() {} |
| 728 void makeConsistentForGC(); | 724 void makeConsistentForGC(); |
| 729 void makeConsistentForMutator(); | 725 void makeConsistentForMutator(); |
| 730 #if DCHECK_IS_ON() | 726 #if DCHECK_IS_ON() |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 // Large objects should not refer to header->size(). | 856 // Large objects should not refer to header->size(). |
| 861 // The actual size of a large object is stored in | 857 // The actual size of a large object is stored in |
| 862 // LargeObjectPage::m_payloadSize. | 858 // LargeObjectPage::m_payloadSize. |
| 863 ASSERT(result != largeObjectSizeInHeader); | 859 ASSERT(result != largeObjectSizeInHeader); |
| 864 ASSERT(!pageFromObject(this)->isLargeObjectPage()); | 860 ASSERT(!pageFromObject(this)->isLargeObjectPage()); |
| 865 return result; | 861 return result; |
| 866 } | 862 } |
| 867 | 863 |
| 868 #if DCHECK_IS_ON() | 864 #if DCHECK_IS_ON() |
| 869 NO_SANITIZE_ADDRESS inline bool HeapObjectHeader::checkHeader() const { | 865 NO_SANITIZE_ADDRESS inline bool HeapObjectHeader::checkHeader() const { |
| 870 return !pageFromObject(this)->orphaned() && m_magic == magic; | 866 return m_magic == magic; |
| 871 } | 867 } |
| 872 #endif | 868 #endif |
| 873 | 869 |
| 874 inline Address HeapObjectHeader::payload() { | 870 inline Address HeapObjectHeader::payload() { |
| 875 return reinterpret_cast<Address>(this) + sizeof(HeapObjectHeader); | 871 return reinterpret_cast<Address>(this) + sizeof(HeapObjectHeader); |
| 876 } | 872 } |
| 877 | 873 |
| 878 inline Address HeapObjectHeader::payloadEnd() { | 874 inline Address HeapObjectHeader::payloadEnd() { |
| 879 return reinterpret_cast<Address>(this) + size(); | 875 return reinterpret_cast<Address>(this) + size(); |
| 880 } | 876 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 return outOfLineAllocate(allocationSize, gcInfoIndex); | 946 return outOfLineAllocate(allocationSize, gcInfoIndex); |
| 951 } | 947 } |
| 952 | 948 |
| 953 inline NormalPageArena* NormalPage::arenaForNormalPage() const { | 949 inline NormalPageArena* NormalPage::arenaForNormalPage() const { |
| 954 return static_cast<NormalPageArena*>(arena()); | 950 return static_cast<NormalPageArena*>(arena()); |
| 955 } | 951 } |
| 956 | 952 |
| 957 } // namespace blink | 953 } // namespace blink |
| 958 | 954 |
| 959 #endif // HeapPage_h | 955 #endif // HeapPage_h |
| OLD | NEW |