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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 } | 378 } |
379 BasePage* next() const { return m_next; } | 379 BasePage* next() const { return m_next; } |
380 | 380 |
381 // virtual methods are slow. So performance-sensitive methods | 381 // virtual methods are slow. So performance-sensitive methods |
382 // should be defined as non-virtual methods on NormalPage and LargeObjectPag
e. | 382 // should be defined as non-virtual methods on NormalPage and LargeObjectPag
e. |
383 // The following methods are not performance-sensitive. | 383 // The following methods are not performance-sensitive. |
384 virtual size_t objectPayloadSizeForTesting() = 0; | 384 virtual size_t objectPayloadSizeForTesting() = 0; |
385 virtual bool isEmpty() = 0; | 385 virtual bool isEmpty() = 0; |
386 virtual void removeFromHeap() = 0; | 386 virtual void removeFromHeap() = 0; |
387 virtual void sweep() = 0; | 387 virtual void sweep() = 0; |
388 virtual void markUnmarkedObjectsDead() = 0; | 388 virtual void makeConsistentForGC() = 0; |
389 #if defined(ADDRESS_SANITIZER) | 389 #if defined(ADDRESS_SANITIZER) |
390 virtual void poisonUnmarkedObjects() = 0; | 390 virtual void poisonUnmarkedObjects() = 0; |
391 #endif | 391 #endif |
392 // Check if the given address points to an object in this | 392 // Check if the given address points to an object in this |
393 // heap page. If so, find the start of that object and mark it | 393 // heap page. If so, find the start of that object and mark it |
394 // using the given Visitor. Otherwise do nothing. The pointer must | 394 // using the given Visitor. Otherwise do nothing. The pointer must |
395 // be within the same aligned blinkPageSize as the this-pointer. | 395 // be within the same aligned blinkPageSize as the this-pointer. |
396 // | 396 // |
397 // This is used during conservative stack scanning to | 397 // This is used during conservative stack scanning to |
398 // conservatively mark all objects that could be referenced from | 398 // conservatively mark all objects that could be referenced from |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 Address payloadEnd() { return payload() + payloadSize(); } | 465 Address payloadEnd() { return payload() + payloadSize(); } |
466 bool containedInObjectPayload(Address address) | 466 bool containedInObjectPayload(Address address) |
467 { | 467 { |
468 return payload() <= address && address < payloadEnd(); | 468 return payload() <= address && address < payloadEnd(); |
469 } | 469 } |
470 | 470 |
471 virtual size_t objectPayloadSizeForTesting() override; | 471 virtual size_t objectPayloadSizeForTesting() override; |
472 virtual bool isEmpty() override; | 472 virtual bool isEmpty() override; |
473 virtual void removeFromHeap() override; | 473 virtual void removeFromHeap() override; |
474 virtual void sweep() override; | 474 virtual void sweep() override; |
475 virtual void markUnmarkedObjectsDead() override; | 475 virtual void makeConsistentForGC() override; |
476 #if defined(ADDRESS_SANITIZER) | 476 #if defined(ADDRESS_SANITIZER) |
477 virtual void poisonUnmarkedObjects() override; | 477 virtual void poisonUnmarkedObjects() override; |
478 #endif | 478 #endif |
479 virtual void checkAndMarkPointer(Visitor*, Address) override; | 479 virtual void checkAndMarkPointer(Visitor*, Address) override; |
480 virtual void markOrphaned() override; | 480 virtual void markOrphaned() override; |
481 #if ENABLE(GC_PROFILING) | 481 #if ENABLE(GC_PROFILING) |
482 const GCInfo* findGCInfo(Address) override; | 482 const GCInfo* findGCInfo(Address) override; |
483 void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override; | 483 void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override; |
484 void incrementMarkedObjectsAge() override; | 484 void incrementMarkedObjectsAge() override; |
485 void countMarkedObjects(ClassAgeCountsMap&) override; | 485 void countMarkedObjects(ClassAgeCountsMap&) override; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 Address payloadEnd() { return payload() + payloadSize(); } | 527 Address payloadEnd() { return payload() + payloadSize(); } |
528 bool containedInObjectPayload(Address address) | 528 bool containedInObjectPayload(Address address) |
529 { | 529 { |
530 return payload() <= address && address < payloadEnd(); | 530 return payload() <= address && address < payloadEnd(); |
531 } | 531 } |
532 | 532 |
533 virtual size_t objectPayloadSizeForTesting() override; | 533 virtual size_t objectPayloadSizeForTesting() override; |
534 virtual bool isEmpty() override; | 534 virtual bool isEmpty() override; |
535 virtual void removeFromHeap() override; | 535 virtual void removeFromHeap() override; |
536 virtual void sweep() override; | 536 virtual void sweep() override; |
537 virtual void markUnmarkedObjectsDead() override; | 537 virtual void makeConsistentForGC() override; |
538 #if defined(ADDRESS_SANITIZER) | 538 #if defined(ADDRESS_SANITIZER) |
539 virtual void poisonUnmarkedObjects() override; | 539 virtual void poisonUnmarkedObjects() override; |
540 #endif | 540 #endif |
541 virtual void checkAndMarkPointer(Visitor*, Address) override; | 541 virtual void checkAndMarkPointer(Visitor*, Address) override; |
542 virtual void markOrphaned() override; | 542 virtual void markOrphaned() override; |
543 | 543 |
544 #if ENABLE(GC_PROFILING) | 544 #if ENABLE(GC_PROFILING) |
545 const GCInfo* findGCInfo(Address) override; | 545 const GCInfo* findGCInfo(Address) override; |
546 void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override; | 546 void snapshot(TracedValue*, ThreadState::SnapshotInfo*) override; |
547 void incrementMarkedObjectsAge() override; | 547 void incrementMarkedObjectsAge() override; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 #if ENABLE(GC_PROFILING) | 685 #if ENABLE(GC_PROFILING) |
686 void snapshot(TracedValue*, ThreadState::SnapshotInfo*); | 686 void snapshot(TracedValue*, ThreadState::SnapshotInfo*); |
687 virtual void snapshotFreeList(TracedValue&) { }; | 687 virtual void snapshotFreeList(TracedValue&) { }; |
688 | 688 |
689 void countMarkedObjects(ClassAgeCountsMap&) const; | 689 void countMarkedObjects(ClassAgeCountsMap&) const; |
690 void countObjectsToSweep(ClassAgeCountsMap&) const; | 690 void countObjectsToSweep(ClassAgeCountsMap&) const; |
691 void incrementMarkedObjectsAge(); | 691 void incrementMarkedObjectsAge(); |
692 #endif | 692 #endif |
693 | 693 |
694 virtual void clearFreeLists() { } | 694 virtual void clearFreeLists() { } |
695 void makeConsistentForSweeping(); | 695 void makeConsistentForGC(); |
696 #if ENABLE(ASSERT) | 696 #if ENABLE(ASSERT) |
697 virtual bool isConsistentForSweeping() = 0; | 697 virtual bool isConsistentForGC() = 0; |
698 #endif | 698 #endif |
699 size_t objectPayloadSizeForTesting(); | 699 size_t objectPayloadSizeForTesting(); |
700 void prepareHeapForTermination(); | 700 void prepareHeapForTermination(); |
701 void prepareForSweep(); | 701 void prepareForSweep(); |
702 #if defined(ADDRESS_SANITIZER) | 702 #if defined(ADDRESS_SANITIZER) |
703 void poisonUnmarkedObjects(); | 703 void poisonUnmarkedObjects(); |
704 #endif | 704 #endif |
705 Address lazySweep(size_t, size_t gcInfoIndex); | 705 Address lazySweep(size_t, size_t gcInfoIndex); |
706 void sweepUnsweptPage(); | 706 void sweepUnsweptPage(); |
707 // Returns true if we have swept all pages within the deadline. | 707 // Returns true if we have swept all pages within the deadline. |
(...skipping 22 matching lines...) Expand all Loading... |
730 public: | 730 public: |
731 NormalPageHeap(ThreadState*, int); | 731 NormalPageHeap(ThreadState*, int); |
732 void addToFreeList(Address address, size_t size) | 732 void addToFreeList(Address address, size_t size) |
733 { | 733 { |
734 ASSERT(findPageFromAddress(address)); | 734 ASSERT(findPageFromAddress(address)); |
735 ASSERT(findPageFromAddress(address + size - 1)); | 735 ASSERT(findPageFromAddress(address + size - 1)); |
736 m_freeList.addToFreeList(address, size); | 736 m_freeList.addToFreeList(address, size); |
737 } | 737 } |
738 virtual void clearFreeLists() override; | 738 virtual void clearFreeLists() override; |
739 #if ENABLE(ASSERT) | 739 #if ENABLE(ASSERT) |
740 virtual bool isConsistentForSweeping() override; | 740 virtual bool isConsistentForGC() override; |
741 bool pagesToBeSweptContains(Address); | 741 bool pagesToBeSweptContains(Address); |
742 #endif | 742 #endif |
743 #if ENABLE(GC_PROFILING) | 743 #if ENABLE(GC_PROFILING) |
744 void snapshotFreeList(TracedValue&) override; | 744 void snapshotFreeList(TracedValue&) override; |
745 #endif | 745 #endif |
746 | 746 |
747 Address allocateObject(size_t allocationSize, size_t gcInfoIndex); | 747 Address allocateObject(size_t allocationSize, size_t gcInfoIndex); |
748 | 748 |
749 void freePage(NormalPage*); | 749 void freePage(NormalPage*); |
750 | 750 |
(...skipping 28 matching lines...) Expand all Loading... |
779 size_t m_inlineAllocationCount; | 779 size_t m_inlineAllocationCount; |
780 #endif | 780 #endif |
781 }; | 781 }; |
782 | 782 |
783 class LargeObjectHeap final : public BaseHeap { | 783 class LargeObjectHeap final : public BaseHeap { |
784 public: | 784 public: |
785 LargeObjectHeap(ThreadState*, int); | 785 LargeObjectHeap(ThreadState*, int); |
786 Address allocateLargeObjectPage(size_t, size_t gcInfoIndex); | 786 Address allocateLargeObjectPage(size_t, size_t gcInfoIndex); |
787 void freeLargeObjectPage(LargeObjectPage*); | 787 void freeLargeObjectPage(LargeObjectPage*); |
788 #if ENABLE(ASSERT) | 788 #if ENABLE(ASSERT) |
789 virtual bool isConsistentForSweeping() override { return true; } | 789 virtual bool isConsistentForGC() override { return true; } |
790 #endif | 790 #endif |
791 private: | 791 private: |
792 Address doAllocateLargeObjectPage(size_t, size_t gcInfoIndex); | 792 Address doAllocateLargeObjectPage(size_t, size_t gcInfoIndex); |
793 virtual Address lazySweepPages(size_t, size_t gcInfoIndex) override; | 793 virtual Address lazySweepPages(size_t, size_t gcInfoIndex) override; |
794 }; | 794 }; |
795 | 795 |
796 // Mask an address down to the enclosing oilpan heap base page. All oilpan heap | 796 // Mask an address down to the enclosing oilpan heap base page. All oilpan heap |
797 // pages are aligned at blinkPageBase plus an OS page size. | 797 // pages are aligned at blinkPageBase plus an OS page size. |
798 // FIXME: Remove PLATFORM_EXPORT once we get a proper public interface to our | 798 // FIXME: Remove PLATFORM_EXPORT once we get a proper public interface to our |
799 // typed heaps. This is only exported to enable tests in HeapTest.cpp. | 799 // typed heaps. This is only exported to enable tests in HeapTest.cpp. |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 size_t copySize = previousHeader->payloadSize(); | 1296 size_t copySize = previousHeader->payloadSize(); |
1297 if (copySize > size) | 1297 if (copySize > size) |
1298 copySize = size; | 1298 copySize = size; |
1299 memcpy(address, previous, copySize); | 1299 memcpy(address, previous, copySize); |
1300 return address; | 1300 return address; |
1301 } | 1301 } |
1302 | 1302 |
1303 } // namespace blink | 1303 } // namespace blink |
1304 | 1304 |
1305 #endif // Heap_h | 1305 #endif // Heap_h |
OLD | NEW |