| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef HeapPage_h | 31 #ifndef HeapPage_h |
| 32 #define HeapPage_h | 32 #define HeapPage_h |
| 33 | 33 |
| 34 #include <stdint.h> | 34 #include <stdint.h> |
| 35 #include "base/trace_event/memory_allocator_dump.h" | 35 #include "base/trace_event/memory_allocator_dump.h" |
| 36 #include "platform/PlatformExport.h" | 36 #include "platform/PlatformExport.h" |
| 37 #include "platform/heap/BlinkGC.h" | 37 #include "platform/heap/BlinkGC.h" |
| 38 #include "platform/heap/GCInfo.h" | 38 #include "platform/heap/GCInfo.h" |
| 39 #include "platform/heap/PagePool.h" |
| 39 #include "platform/heap/ThreadState.h" | 40 #include "platform/heap/ThreadState.h" |
| 40 #include "platform/heap/Visitor.h" | 41 #include "platform/heap/Visitor.h" |
| 41 #include "platform/wtf/AddressSanitizer.h" | 42 #include "platform/wtf/AddressSanitizer.h" |
| 42 #include "platform/wtf/Allocator.h" | 43 #include "platform/wtf/Allocator.h" |
| 43 #include "platform/wtf/Assertions.h" | 44 #include "platform/wtf/Assertions.h" |
| 44 #include "platform/wtf/ContainerAnnotations.h" | 45 #include "platform/wtf/ContainerAnnotations.h" |
| 45 #include "platform/wtf/Forward.h" | 46 #include "platform/wtf/Forward.h" |
| 46 #include "platform/wtf/allocator/Partitions.h" | 47 #include "platform/wtf/allocator/Partitions.h" |
| 47 | 48 |
| 48 namespace blink { | 49 namespace blink { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 *previous_next = next_; | 385 *previous_next = next_; |
| 385 next_ = nullptr; | 386 next_ = nullptr; |
| 386 } | 387 } |
| 387 BasePage* Next() const { return next_; } | 388 BasePage* Next() const { return next_; } |
| 388 | 389 |
| 389 // Virtual methods are slow. So performance-sensitive methods should be | 390 // Virtual methods are slow. So performance-sensitive methods should be |
| 390 // defined as non-virtual methods on |NormalPage| and |LargeObjectPage|. The | 391 // defined as non-virtual methods on |NormalPage| and |LargeObjectPage|. The |
| 391 // following methods are not performance-sensitive. | 392 // following methods are not performance-sensitive. |
| 392 virtual size_t ObjectPayloadSizeForTesting() = 0; | 393 virtual size_t ObjectPayloadSizeForTesting() = 0; |
| 393 virtual bool IsEmpty() = 0; | 394 virtual bool IsEmpty() = 0; |
| 394 virtual void RemoveFromHeap() = 0; | 395 virtual void RemoveFromHeap( |
| 396 DecommitMemoryTiming = DecommitMemoryTiming::DecommitAsAppropriate) = 0; |
| 395 virtual void Sweep() = 0; | 397 virtual void Sweep() = 0; |
| 396 virtual void MakeConsistentForMutator() = 0; | 398 virtual void MakeConsistentForMutator() = 0; |
| 397 virtual void InvalidateObjectStartBitmap() = 0; | 399 virtual void InvalidateObjectStartBitmap() = 0; |
| 398 | 400 |
| 399 #if defined(ADDRESS_SANITIZER) | 401 #if defined(ADDRESS_SANITIZER) |
| 400 virtual void PoisonUnmarkedObjects() = 0; | 402 virtual void PoisonUnmarkedObjects() = 0; |
| 401 #endif | 403 #endif |
| 402 | 404 |
| 403 // Check if the given address points to an object in this heap page. If so, | 405 // Check if the given address points to an object in this heap page. If so, |
| 404 // find the start of that object and mark it using the given |Visitor|. | 406 // find the start of that object and mark it using the given |Visitor|. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 size_t PayloadSize() { | 469 size_t PayloadSize() { |
| 468 return (BlinkPagePayloadSize() - PageHeaderSize()) & ~kAllocationMask; | 470 return (BlinkPagePayloadSize() - PageHeaderSize()) & ~kAllocationMask; |
| 469 } | 471 } |
| 470 Address PayloadEnd() { return Payload() + PayloadSize(); } | 472 Address PayloadEnd() { return Payload() + PayloadSize(); } |
| 471 bool ContainedInObjectPayload(Address address) { | 473 bool ContainedInObjectPayload(Address address) { |
| 472 return Payload() <= address && address < PayloadEnd(); | 474 return Payload() <= address && address < PayloadEnd(); |
| 473 } | 475 } |
| 474 | 476 |
| 475 size_t ObjectPayloadSizeForTesting() override; | 477 size_t ObjectPayloadSizeForTesting() override; |
| 476 bool IsEmpty() override; | 478 bool IsEmpty() override; |
| 477 void RemoveFromHeap() override; | 479 void RemoveFromHeap(DecommitMemoryTiming = |
| 480 DecommitMemoryTiming::DecommitAsAppropriate) override; |
| 478 void Sweep() override; | 481 void Sweep() override; |
| 479 void MakeConsistentForMutator() override; | 482 void MakeConsistentForMutator() override; |
| 480 void InvalidateObjectStartBitmap() override { | 483 void InvalidateObjectStartBitmap() override { |
| 481 object_start_bit_map_computed_ = false; | 484 object_start_bit_map_computed_ = false; |
| 482 } | 485 } |
| 483 #if defined(ADDRESS_SANITIZER) | 486 #if defined(ADDRESS_SANITIZER) |
| 484 void PoisonUnmarkedObjects() override; | 487 void PoisonUnmarkedObjects() override; |
| 485 #endif | 488 #endif |
| 486 void CheckAndMarkPointer(Visitor*, Address) override; | 489 void CheckAndMarkPointer(Visitor*, Address) override; |
| 487 #if DCHECK_IS_ON() | 490 #if DCHECK_IS_ON() |
| (...skipping 27 matching lines...) Expand all Loading... |
| 515 // Context object holding the state of the arena page compaction pass, passed | 518 // Context object holding the state of the arena page compaction pass, passed |
| 516 // in when compacting individual pages. | 519 // in when compacting individual pages. |
| 517 class CompactionContext { | 520 class CompactionContext { |
| 518 STACK_ALLOCATED(); | 521 STACK_ALLOCATED(); |
| 519 | 522 |
| 520 public: | 523 public: |
| 521 // Page compacting into. | 524 // Page compacting into. |
| 522 NormalPage* current_page_ = nullptr; | 525 NormalPage* current_page_ = nullptr; |
| 523 // Offset into |m_currentPage| to the next free address. | 526 // Offset into |m_currentPage| to the next free address. |
| 524 size_t allocation_point_ = 0; | 527 size_t allocation_point_ = 0; |
| 528 |
| 529 void AddAvailable(BasePage*); |
| 530 BasePage* TakeAvailable(); |
| 525 // Chain of available pages to use for compaction. Page compaction picks the | 531 // Chain of available pages to use for compaction. Page compaction picks the |
| 526 // next one when the current one is exhausted. | 532 // next one when the current one is exhausted. |
| 527 BasePage* available_pages_ = nullptr; | 533 BasePage* available_pages_ = nullptr; |
| 534 BasePage* last_available_ = nullptr; |
| 535 |
| 528 // Chain of pages that have been compacted. Page compaction will add | 536 // Chain of pages that have been compacted. Page compaction will add |
| 529 // compacted pages once the current one becomes exhausted. | 537 // compacted pages once the current one becomes exhausted. |
| 530 BasePage** compacted_pages_ = nullptr; | 538 BasePage** compacted_pages_ = nullptr; |
| 531 }; | 539 }; |
| 532 | 540 |
| 533 void SweepAndCompact(CompactionContext&); | 541 void SweepAndCompact(CompactionContext&); |
| 534 | 542 |
| 535 private: | 543 private: |
| 536 HeapObjectHeader* FindHeaderFromAddress(Address); | 544 HeapObjectHeader* FindHeaderFromAddress(Address); |
| 537 void PopulateObjectStartBitMap(); | 545 void PopulateObjectStartBitMap(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 558 // ObjectPayload. | 566 // ObjectPayload. |
| 559 Address Payload() { return GetHeapObjectHeader()->Payload(); } | 567 Address Payload() { return GetHeapObjectHeader()->Payload(); } |
| 560 size_t PayloadSize() { return payload_size_; } | 568 size_t PayloadSize() { return payload_size_; } |
| 561 Address PayloadEnd() { return Payload() + PayloadSize(); } | 569 Address PayloadEnd() { return Payload() + PayloadSize(); } |
| 562 bool ContainedInObjectPayload(Address address) { | 570 bool ContainedInObjectPayload(Address address) { |
| 563 return Payload() <= address && address < PayloadEnd(); | 571 return Payload() <= address && address < PayloadEnd(); |
| 564 } | 572 } |
| 565 | 573 |
| 566 size_t ObjectPayloadSizeForTesting() override; | 574 size_t ObjectPayloadSizeForTesting() override; |
| 567 bool IsEmpty() override; | 575 bool IsEmpty() override; |
| 568 void RemoveFromHeap() override; | 576 void RemoveFromHeap(DecommitMemoryTiming = |
| 577 DecommitMemoryTiming::DecommitAsAppropriate) override; |
| 569 void Sweep() override; | 578 void Sweep() override; |
| 570 void MakeConsistentForMutator() override; | 579 void MakeConsistentForMutator() override; |
| 571 void InvalidateObjectStartBitmap() override {} | 580 void InvalidateObjectStartBitmap() override {} |
| 572 #if defined(ADDRESS_SANITIZER) | 581 #if defined(ADDRESS_SANITIZER) |
| 573 void PoisonUnmarkedObjects() override; | 582 void PoisonUnmarkedObjects() override; |
| 574 #endif | 583 #endif |
| 575 void CheckAndMarkPointer(Visitor*, Address) override; | 584 void CheckAndMarkPointer(Visitor*, Address) override; |
| 576 #if DCHECK_IS_ON() | 585 #if DCHECK_IS_ON() |
| 577 void CheckAndMarkPointer(Visitor*, | 586 void CheckAndMarkPointer(Visitor*, |
| 578 Address, | 587 Address, |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 } | 782 } |
| 774 void ClearFreeLists() override; | 783 void ClearFreeLists() override; |
| 775 #if DCHECK_IS_ON() | 784 #if DCHECK_IS_ON() |
| 776 bool IsConsistentForGC() override; | 785 bool IsConsistentForGC() override; |
| 777 bool PagesToBeSweptContains(Address); | 786 bool PagesToBeSweptContains(Address); |
| 778 #endif | 787 #endif |
| 779 void TakeFreelistSnapshot(const String& dump_base_name) override; | 788 void TakeFreelistSnapshot(const String& dump_base_name) override; |
| 780 | 789 |
| 781 Address AllocateObject(size_t allocation_size, size_t gc_info_index); | 790 Address AllocateObject(size_t allocation_size, size_t gc_info_index); |
| 782 | 791 |
| 783 void FreePage(NormalPage*); | 792 void FreePage(NormalPage*, DecommitMemoryTiming); |
| 784 | 793 |
| 785 bool Coalesce(); | 794 bool Coalesce(); |
| 786 void PromptlyFreeObject(HeapObjectHeader*); | 795 void PromptlyFreeObject(HeapObjectHeader*); |
| 787 bool ExpandObject(HeapObjectHeader*, size_t); | 796 bool ExpandObject(HeapObjectHeader*, size_t); |
| 788 bool ShrinkObject(HeapObjectHeader*, size_t); | 797 bool ShrinkObject(HeapObjectHeader*, size_t); |
| 789 void DecreasePromptlyFreedSize(size_t size) { promptly_freed_size_ -= size; } | 798 void DecreasePromptlyFreedSize(size_t size) { promptly_freed_size_ -= size; } |
| 790 | 799 |
| 791 bool IsObjectAllocatedAtAllocationPoint(HeapObjectHeader* header) { | 800 bool IsObjectAllocatedAtAllocationPoint(HeapObjectHeader* header) { |
| 792 return header->PayloadEnd() == current_allocation_point_; | 801 return header->PayloadEnd() == current_allocation_point_; |
| 793 } | 802 } |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 return OutOfLineAllocate(allocation_size, gc_info_index); | 1031 return OutOfLineAllocate(allocation_size, gc_info_index); |
| 1023 } | 1032 } |
| 1024 | 1033 |
| 1025 inline NormalPageArena* NormalPage::ArenaForNormalPage() const { | 1034 inline NormalPageArena* NormalPage::ArenaForNormalPage() const { |
| 1026 return static_cast<NormalPageArena*>(Arena()); | 1035 return static_cast<NormalPageArena*>(Arena()); |
| 1027 } | 1036 } |
| 1028 | 1037 |
| 1029 } // namespace blink | 1038 } // namespace blink |
| 1030 | 1039 |
| 1031 #endif // HeapPage_h | 1040 #endif // HeapPage_h |
| OLD | NEW |