| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 #else | 88 #else |
| 89 #define FILL_ZERO_IF_PRODUCTION(address, size) memset((address), 0, (size)) | 89 #define FILL_ZERO_IF_PRODUCTION(address, size) memset((address), 0, (size)) |
| 90 #define FILL_ZERO_IF_NOT_PRODUCTION(address, size) do { } while (false) | 90 #define FILL_ZERO_IF_NOT_PRODUCTION(address, size) do { } while (false) |
| 91 #endif | 91 #endif |
| 92 | 92 |
| 93 class CallbackStack; | 93 class CallbackStack; |
| 94 class FreePagePool; | 94 class FreePagePool; |
| 95 class NormalPageHeap; | 95 class NormalPageHeap; |
| 96 class OrphanedPagePool; | 96 class OrphanedPagePool; |
| 97 class PageMemory; | 97 class PageMemory; |
| 98 class WebProcessMemoryDump; |
| 98 | 99 |
| 99 #if ENABLE(GC_PROFILING) | 100 #if ENABLE(GC_PROFILING) |
| 100 class TracedValue; | 101 class TracedValue; |
| 101 #endif | 102 #endif |
| 102 | 103 |
| 103 // HeapObjectHeader is 4 byte (32 bit) that has the following layout: | 104 // HeapObjectHeader is 4 byte (32 bit) that has the following layout: |
| 104 // | 105 // |
| 105 // | gcInfoIndex (14 bit) | DOM mark bit (1 bit) | size (14 bit) | dead bit (1 b
it) | freed bit (1 bit) | mark bit (1 bit) | | 106 // | gcInfoIndex (14 bit) | DOM mark bit (1 bit) | size (14 bit) | dead bit (1 b
it) | freed bit (1 bit) | mark bit (1 bit) | |
| 106 // | 107 // |
| 107 // - For non-large objects, 14 bit is enough for |size| because the blink | 108 // - For non-large objects, 14 bit is enough for |size| because the blink |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 // Check if the given address points to an object in this | 395 // Check if the given address points to an object in this |
| 395 // heap page. If so, find the start of that object and mark it | 396 // heap page. If so, find the start of that object and mark it |
| 396 // using the given Visitor. Otherwise do nothing. The pointer must | 397 // using the given Visitor. Otherwise do nothing. The pointer must |
| 397 // be within the same aligned blinkPageSize as the this-pointer. | 398 // be within the same aligned blinkPageSize as the this-pointer. |
| 398 // | 399 // |
| 399 // This is used during conservative stack scanning to | 400 // This is used during conservative stack scanning to |
| 400 // conservatively mark all objects that could be referenced from | 401 // conservatively mark all objects that could be referenced from |
| 401 // the stack. | 402 // the stack. |
| 402 virtual void checkAndMarkPointer(Visitor*, Address) = 0; | 403 virtual void checkAndMarkPointer(Visitor*, Address) = 0; |
| 403 virtual void markOrphaned(); | 404 virtual void markOrphaned(); |
| 405 |
| 406 virtual void takeSnapshot(String dumpName, size_t pageIndex, ThreadState::GC
SnapshotInfo&) = 0; |
| 404 #if ENABLE(GC_PROFILING) | 407 #if ENABLE(GC_PROFILING) |
| 405 virtual const GCInfo* findGCInfo(Address) = 0; | 408 virtual const GCInfo* findGCInfo(Address) = 0; |
| 406 virtual void snapshot(TracedValue*, ThreadState::SnapshotInfo*) = 0; | 409 virtual void snapshot(TracedValue*, ThreadState::SnapshotInfo*) = 0; |
| 407 virtual void incrementMarkedObjectsAge() = 0; | 410 virtual void incrementMarkedObjectsAge() = 0; |
| 408 virtual void countMarkedObjects(ClassAgeCountsMap&) = 0; | 411 virtual void countMarkedObjects(ClassAgeCountsMap&) = 0; |
| 409 virtual void countObjectsToSweep(ClassAgeCountsMap&) = 0; | 412 virtual void countObjectsToSweep(ClassAgeCountsMap&) = 0; |
| 410 #endif | 413 #endif |
| 411 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) | 414 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
| 412 virtual bool contains(Address) = 0; | 415 virtual bool contains(Address) = 0; |
| 413 #endif | 416 #endif |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 virtual bool isEmpty() override; | 477 virtual bool isEmpty() override; |
| 475 virtual void removeFromHeap() override; | 478 virtual void removeFromHeap() override; |
| 476 virtual void sweep() override; | 479 virtual void sweep() override; |
| 477 virtual void makeConsistentForGC() override; | 480 virtual void makeConsistentForGC() override; |
| 478 virtual void makeConsistentForMutator() override; | 481 virtual void makeConsistentForMutator() override; |
| 479 #if defined(ADDRESS_SANITIZER) | 482 #if defined(ADDRESS_SANITIZER) |
| 480 virtual void poisonObjects(ObjectsToPoison, Poisoning) override; | 483 virtual void poisonObjects(ObjectsToPoison, Poisoning) override; |
| 481 #endif | 484 #endif |
| 482 virtual void checkAndMarkPointer(Visitor*, Address) override; | 485 virtual void checkAndMarkPointer(Visitor*, Address) override; |
| 483 virtual void markOrphaned() override; | 486 virtual void markOrphaned() override; |
| 487 |
| 488 void takeSnapshot(String dumpBaseName, size_t pageIndex, ThreadState::GCSnap
shotInfo&) override; |
| 484 #if ENABLE(GC_PROFILING) | 489 #if ENABLE(GC_PROFILING) |
| 485 const GCInfo* findGCInfo(Address) override; | 490 const GCInfo* findGCInfo(Address) override; |
| 486 void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override; | 491 void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override; |
| 487 void incrementMarkedObjectsAge() override; | 492 void incrementMarkedObjectsAge() override; |
| 488 void countMarkedObjects(ClassAgeCountsMap&) override; | 493 void countMarkedObjects(ClassAgeCountsMap&) override; |
| 489 void countObjectsToSweep(ClassAgeCountsMap&) override; | 494 void countObjectsToSweep(ClassAgeCountsMap&) override; |
| 490 #endif | 495 #endif |
| 491 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) | 496 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
| 492 // Returns true for the whole blinkPageSize page that the page is on, even | 497 // Returns true for the whole blinkPageSize page that the page is on, even |
| 493 // for the header, and the unmapped guard page at the start. That ensures | 498 // for the header, and the unmapped guard page at the start. That ensures |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 virtual void removeFromHeap() override; | 543 virtual void removeFromHeap() override; |
| 539 virtual void sweep() override; | 544 virtual void sweep() override; |
| 540 virtual void makeConsistentForGC() override; | 545 virtual void makeConsistentForGC() override; |
| 541 virtual void makeConsistentForMutator() override; | 546 virtual void makeConsistentForMutator() override; |
| 542 #if defined(ADDRESS_SANITIZER) | 547 #if defined(ADDRESS_SANITIZER) |
| 543 virtual void poisonObjects(ObjectsToPoison, Poisoning) override; | 548 virtual void poisonObjects(ObjectsToPoison, Poisoning) override; |
| 544 #endif | 549 #endif |
| 545 virtual void checkAndMarkPointer(Visitor*, Address) override; | 550 virtual void checkAndMarkPointer(Visitor*, Address) override; |
| 546 virtual void markOrphaned() override; | 551 virtual void markOrphaned() override; |
| 547 | 552 |
| 553 void takeSnapshot(String dumpBaseName, size_t pageIndex, ThreadState::GCSnap
shotInfo&) override; |
| 548 #if ENABLE(GC_PROFILING) | 554 #if ENABLE(GC_PROFILING) |
| 549 const GCInfo* findGCInfo(Address) override; | 555 const GCInfo* findGCInfo(Address) override; |
| 550 void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override; | 556 void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override; |
| 551 void incrementMarkedObjectsAge() override; | 557 void incrementMarkedObjectsAge() override; |
| 552 void countMarkedObjects(ClassAgeCountsMap&) override; | 558 void countMarkedObjects(ClassAgeCountsMap&) override; |
| 553 void countObjectsToSweep(ClassAgeCountsMap&) override; | 559 void countObjectsToSweep(ClassAgeCountsMap&) override; |
| 554 #endif | 560 #endif |
| 555 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) | 561 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
| 556 // Returns true for any address that is on one of the pages that this | 562 // Returns true for any address that is on one of the pages that this |
| 557 // large object uses. That ensures that we can use a negative result to | 563 // large object uses. That ensures that we can use a negative result to |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 public: | 649 public: |
| 644 FreeList(); | 650 FreeList(); |
| 645 | 651 |
| 646 void addToFreeList(Address, size_t); | 652 void addToFreeList(Address, size_t); |
| 647 void clear(); | 653 void clear(); |
| 648 | 654 |
| 649 // Returns a bucket number for inserting a FreeListEntry of a given size. | 655 // Returns a bucket number for inserting a FreeListEntry of a given size. |
| 650 // All FreeListEntries in the given bucket, n, have size >= 2^n. | 656 // All FreeListEntries in the given bucket, n, have size >= 2^n. |
| 651 static int bucketIndexForSize(size_t); | 657 static int bucketIndexForSize(size_t); |
| 652 | 658 |
| 659 void takeSnapshot(const String& dumpBaseName); |
| 653 #if ENABLE(GC_PROFILING) | 660 #if ENABLE(GC_PROFILING) |
| 654 struct PerBucketFreeListStats { | 661 struct PerBucketFreeListStats { |
| 655 size_t entryCount; | 662 size_t entryCount; |
| 656 size_t freeSize; | 663 size_t freeSize; |
| 657 | 664 |
| 658 PerBucketFreeListStats() : entryCount(0), freeSize(0) { } | 665 PerBucketFreeListStats() : entryCount(0), freeSize(0) { } |
| 659 }; | 666 }; |
| 660 | 667 |
| 661 void getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& totalSiz
e) const; | 668 void getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& totalSiz
e) const; |
| 662 #endif | 669 #endif |
| (...skipping 13 matching lines...) Expand all Loading... |
| 676 // | 683 // |
| 677 // BaseHeap is a parent class of NormalPageHeap and LargeObjectHeap. | 684 // BaseHeap is a parent class of NormalPageHeap and LargeObjectHeap. |
| 678 // NormalPageHeap represents a heap that contains NormalPages | 685 // NormalPageHeap represents a heap that contains NormalPages |
| 679 // and LargeObjectHeap represents a heap that contains LargeObjectPages. | 686 // and LargeObjectHeap represents a heap that contains LargeObjectPages. |
| 680 class PLATFORM_EXPORT BaseHeap { | 687 class PLATFORM_EXPORT BaseHeap { |
| 681 public: | 688 public: |
| 682 BaseHeap(ThreadState*, int); | 689 BaseHeap(ThreadState*, int); |
| 683 virtual ~BaseHeap(); | 690 virtual ~BaseHeap(); |
| 684 void cleanupPages(); | 691 void cleanupPages(); |
| 685 | 692 |
| 686 void takeSnapshot(const String& dumpBaseName); | 693 void takeSnapshot(const String& dumpBaseName, ThreadState::GCSnapshotInfo&); |
| 687 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) | 694 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
| 688 BasePage* findPageFromAddress(Address); | 695 BasePage* findPageFromAddress(Address); |
| 689 #endif | 696 #endif |
| 697 virtual void takeFreelistSnapshot(const String& dumpBaseName) { }; |
| 690 #if ENABLE(GC_PROFILING) | 698 #if ENABLE(GC_PROFILING) |
| 691 void snapshot(TracedValue*, ThreadState::SnapshotInfo*); | 699 void snapshot(TracedValue*, ThreadState::SnapshotInfo*); |
| 692 virtual void snapshotFreeList(TracedValue&) { }; | 700 virtual void snapshotFreeList(TracedValue&) { }; |
| 693 | 701 |
| 694 void countMarkedObjects(ClassAgeCountsMap&) const; | 702 void countMarkedObjects(ClassAgeCountsMap&) const; |
| 695 void countObjectsToSweep(ClassAgeCountsMap&) const; | 703 void countObjectsToSweep(ClassAgeCountsMap&) const; |
| 696 void incrementMarkedObjectsAge(); | 704 void incrementMarkedObjectsAge(); |
| 697 #endif | 705 #endif |
| 698 | 706 |
| 699 virtual void clearFreeLists() { } | 707 virtual void clearFreeLists() { } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 { | 747 { |
| 740 ASSERT(findPageFromAddress(address)); | 748 ASSERT(findPageFromAddress(address)); |
| 741 ASSERT(findPageFromAddress(address + size - 1)); | 749 ASSERT(findPageFromAddress(address + size - 1)); |
| 742 m_freeList.addToFreeList(address, size); | 750 m_freeList.addToFreeList(address, size); |
| 743 } | 751 } |
| 744 virtual void clearFreeLists() override; | 752 virtual void clearFreeLists() override; |
| 745 #if ENABLE(ASSERT) | 753 #if ENABLE(ASSERT) |
| 746 virtual bool isConsistentForGC() override; | 754 virtual bool isConsistentForGC() override; |
| 747 bool pagesToBeSweptContains(Address); | 755 bool pagesToBeSweptContains(Address); |
| 748 #endif | 756 #endif |
| 757 void takeFreelistSnapshot(const String& dumpBaseName) override; |
| 749 #if ENABLE(GC_PROFILING) | 758 #if ENABLE(GC_PROFILING) |
| 750 void snapshotFreeList(TracedValue&) override; | 759 void snapshotFreeList(TracedValue&) override; |
| 751 #endif | 760 #endif |
| 752 | 761 |
| 753 Address allocateObject(size_t allocationSize, size_t gcInfoIndex); | 762 Address allocateObject(size_t allocationSize, size_t gcInfoIndex); |
| 754 | 763 |
| 755 void freePage(NormalPage*); | 764 void freePage(NormalPage*); |
| 756 | 765 |
| 757 bool coalesce(); | 766 bool coalesce(); |
| 758 void promptlyFreeObject(HeapObjectHeader*); | 767 void promptlyFreeObject(HeapObjectHeader*); |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 size_t copySize = previousHeader->payloadSize(); | 1398 size_t copySize = previousHeader->payloadSize(); |
| 1390 if (copySize > size) | 1399 if (copySize > size) |
| 1391 copySize = size; | 1400 copySize = size; |
| 1392 memcpy(address, previous, copySize); | 1401 memcpy(address, previous, copySize); |
| 1393 return address; | 1402 return address; |
| 1394 } | 1403 } |
| 1395 | 1404 |
| 1396 } // namespace blink | 1405 } // namespace blink |
| 1397 | 1406 |
| 1398 #endif // Heap_h | 1407 #endif // Heap_h |
| OLD | NEW |