diff options
Diffstat (limited to 'deps/v8/src/heap/new-spaces.h')
-rw-r--r-- | deps/v8/src/heap/new-spaces.h | 125 |
1 files changed, 65 insertions, 60 deletions
diff --git a/deps/v8/src/heap/new-spaces.h b/deps/v8/src/heap/new-spaces.h index 09d11bc90c..c569aceb21 100644 --- a/deps/v8/src/heap/new-spaces.h +++ b/deps/v8/src/heap/new-spaces.h @@ -13,6 +13,7 @@ #include "src/base/platform/mutex.h" #include "src/common/globals.h" #include "src/heap/allocation-observer.h" +#include "src/heap/heap-verifier.h" #include "src/heap/heap.h" #include "src/heap/paged-spaces.h" #include "src/heap/spaces.h" @@ -27,9 +28,6 @@ class SemiSpaceNewSpace; enum SemiSpaceId { kFromSpace = 0, kToSpace = 1 }; -using ParkedAllocationBuffer = std::pair<int, Address>; -using ParkedAllocationBuffersVector = std::vector<ParkedAllocationBuffer>; - // ----------------------------------------------------------------------------- // SemiSpace in young generation // @@ -109,6 +107,9 @@ class SemiSpace final : public Space { void PrependPage(Page* page); void MovePageToTheEnd(Page* page); + void PauseAllocationObservers() override { UNREACHABLE(); } + void ResumeAllocationObservers() override { UNREACHABLE(); } + Page* InitializePage(MemoryChunk* chunk) final; // Age mark accessors. @@ -175,7 +176,10 @@ class SemiSpace final : public Space { #endif #ifdef VERIFY_HEAP - virtual void Verify() const; + void Verify(Isolate* isolate, SpaceVerificationVisitor* visitor) const final { + UNREACHABLE(); + } + void VerifyPageMetadata() const; #endif void AddRangeToActiveSystemPages(Address start, Address end); @@ -242,8 +246,6 @@ class NewSpace : NON_EXPORTED_BASE(public SpaceWithLinearArea) { inline bool Contains(HeapObject o) const; virtual bool ContainsSlow(Address a) const = 0; - void ResetParkedAllocationBuffers(); - #if DEBUG void VerifyTop() const override; #endif // DEBUG @@ -278,29 +280,13 @@ class NewSpace : NON_EXPORTED_BASE(public SpaceWithLinearArea) { // Grow the capacity of the space. virtual void Grow() = 0; - // Shrink the capacity of the space. - virtual void Shrink() = 0; - virtual bool ShouldBePromoted(Address) const = 0; // Creates a filler object in the linear allocation area. virtual void MakeLinearAllocationAreaIterable() = 0; -#ifdef VERIFY_HEAP - virtual void Verify(Isolate* isolate) const = 0; - // VerifyImpl verifies objects on the space starting from |current_page| and - // |current_address|. |current_address| should be a valid limit on - // |current_page| (see BasicMemoryChunk::ContainsLimit). - void VerifyImpl(Isolate* isolate, const Page* current_page, - Address current_address) const; -#endif - virtual void MakeIterable() = 0; -#ifdef V8_ENABLE_INNER_POINTER_RESOLUTION_OSB - virtual void ClearUnusedObjectStartBitmaps() = 0; -#endif // V8_ENABLE_INNER_POINTER_RESOLUTION_OSB - virtual iterator begin() = 0; virtual iterator end() = 0; @@ -313,10 +299,7 @@ class NewSpace : NON_EXPORTED_BASE(public SpaceWithLinearArea) { virtual void Prologue() {} - virtual void EvacuatePrologue() = 0; - virtual void EvacuateEpilogue() = 0; - - virtual void ZapUnusedMemory() {} + virtual void GarbageCollectionEpilogue() = 0; virtual bool IsPromotionCandidate(const MemoryChunk* page) const = 0; @@ -330,8 +313,6 @@ class NewSpace : NON_EXPORTED_BASE(public SpaceWithLinearArea) { AllocationCounter allocation_counter_; LinearAreaOriginalData linear_area_original_data_; - ParkedAllocationBuffersVector parked_allocation_buffers_; - virtual void RemovePage(Page* page) = 0; bool SupportsAllocationObserver() const final { return true; } @@ -344,6 +325,9 @@ class NewSpace : NON_EXPORTED_BASE(public SpaceWithLinearArea) { // forwards most functions to the appropriate semispace. class V8_EXPORT_PRIVATE SemiSpaceNewSpace final : public NewSpace { + using ParkedAllocationBuffer = std::pair<int, Address>; + using ParkedAllocationBuffersVector = std::vector<ParkedAllocationBuffer>; + public: static SemiSpaceNewSpace* From(NewSpace* space) { DCHECK(!v8_flags.minor_mc); @@ -363,7 +347,7 @@ class V8_EXPORT_PRIVATE SemiSpaceNewSpace final : public NewSpace { void Grow() final; // Shrink the capacity of the semispaces. - void Shrink() final; + void Shrink(); // Return the allocated bytes in the active semispace. size_t Size() const final { @@ -454,7 +438,8 @@ class V8_EXPORT_PRIVATE SemiSpaceNewSpace final : public NewSpace { // inline allocation every once in a while. This is done by setting // allocation_info_.limit to be lower than the actual limit and and increasing // it in steps to guarantee that the observers are notified periodically. - void UpdateInlineAllocationLimit(size_t size_in_bytes) final; + void UpdateInlineAllocationLimit() final; + void UpdateInlineAllocationLimitForAllocation(size_t size_in_bytes); // Try to switch the active semispace to a new, empty, page. // Returns false if this isn't possible or reasonable (i.e., there @@ -465,12 +450,17 @@ class V8_EXPORT_PRIVATE SemiSpaceNewSpace final : public NewSpace { bool AddParkedAllocationBuffer(int size_in_bytes, AllocationAlignment alignment); + void ResetParkedAllocationBuffers(); + // Creates a filler object in the linear allocation area and closes it. void FreeLinearAllocationArea() final; #ifdef VERIFY_HEAP // Verify the active semispace. - void Verify(Isolate* isolate) const final; + void Verify(Isolate* isolate, SpaceVerificationVisitor* visitor) const final; + + // VerifyObjects verifies all objects in the active semi space. + void VerifyObjects(Isolate* isolate, SpaceVerificationVisitor* visitor) const; #endif #ifdef DEBUG @@ -483,10 +473,6 @@ class V8_EXPORT_PRIVATE SemiSpaceNewSpace final : public NewSpace { void MakeAllPagesInFromSpaceIterable(); void MakeUnusedPagesInToSpaceIterable(); -#ifdef V8_ENABLE_INNER_POINTER_RESOLUTION_OSB - void ClearUnusedObjectStartBitmaps() override; -#endif // V8_ENABLE_INNER_POINTER_RESOLUTION_OSB - Page* first_page() final { return to_space_.first_page(); } Page* last_page() final { return to_space_.last_page(); } @@ -510,10 +496,11 @@ class V8_EXPORT_PRIVATE SemiSpaceNewSpace final : public NewSpace { void Prologue() final; - void EvacuatePrologue() final; - void EvacuateEpilogue() final; + void EvacuatePrologue(); - void ZapUnusedMemory() final; + void GarbageCollectionEpilogue() final; + + void ZapUnusedMemory(); bool IsPromotionCandidate(const MemoryChunk* page) const final; @@ -539,6 +526,8 @@ class V8_EXPORT_PRIVATE SemiSpaceNewSpace final : public NewSpace { SemiSpace from_space_; VirtualMemory reservation_; + ParkedAllocationBuffersVector parked_allocation_buffers_; + bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment, AllocationOrigin origin, int* out_max_aligned_size) final; @@ -565,7 +554,6 @@ class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase { void Grow(); // Shrink the capacity of the space. - void Shrink() { UNREACHABLE(); } bool StartShrinking(); void FinishShrinking(); @@ -587,15 +575,17 @@ class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase { } // Reset the allocation pointer. - void EvacuatePrologue() {} - void EvacuateEpilogue() { allocated_linear_areas_ = 0; } + void GarbageCollectionEpilogue() { + allocated_linear_areas_ = 0; + force_allocation_success_ = false; + } // When inline allocation stepping is active, either because of incremental // marking, idle scavenge, or allocation statistics gathering, we 'interrupt' // inline allocation every once in a while. This is done by setting // allocation_info_.limit to be lower than the actual limit and and increasing // it in steps to guarantee that the observers are notified periodically. - void UpdateInlineAllocationLimit(size_t size_in_bytes) final; + void UpdateInlineAllocationLimit() final; // Try to switch the active semispace to a new, empty, page. // Returns false if this isn't possible or reasonable (i.e., there @@ -624,18 +614,29 @@ class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase { } #ifdef VERIFY_HEAP - void Verify(Isolate* isolate, ObjectVisitor* visitor) const final; + void Verify(Isolate* isolate, SpaceVerificationVisitor* visitor) const final { + PagedSpaceBase::Verify(isolate, visitor); + + DCHECK_EQ(current_capacity_, Page::kPageSize * CountTotalPages()); + } #endif void MakeIterable() { free_list()->RepairLists(heap()); } -#ifdef V8_ENABLE_INNER_POINTER_RESOLUTION_OSB - void ClearUnusedObjectStartBitmaps() {} -#endif // V8_ENABLE_INNER_POINTER_RESOLUTION_OSB + bool ShouldReleaseEmptyPage() const; + + void RefillFreeList() final; - bool ShouldReleasePage() const; + bool AddPageBeyondCapacity(int size_in_bytes, AllocationOrigin origin); + + void ForceAllocationSuccessUntilNextGC() { force_allocation_success_ = true; } private: + size_t UsableCapacity() const { + DCHECK_LE(free_list_->wasted_bytes(), current_capacity_); + return current_capacity_ - free_list_->wasted_bytes(); + } + bool PreallocatePages(); const size_t initial_capacity_; @@ -644,6 +645,8 @@ class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase { size_t current_capacity_ = 0; size_t allocated_linear_areas_ = 0; + + bool force_allocation_success_ = false; }; // TODO(v8:12612): PagedNewSpace is a bridge between the NewSpace interface and @@ -669,7 +672,6 @@ class V8_EXPORT_PRIVATE PagedNewSpace final : public NewSpace { void Grow() final { paged_space_.Grow(); } // Shrink the capacity of the space. - void Shrink() final { paged_space_.Shrink(); } bool StartShrinking() { return paged_space_.StartShrinking(); } void FinishShrinking() { paged_space_.FinishShrinking(); } @@ -732,8 +734,8 @@ class V8_EXPORT_PRIVATE PagedNewSpace final : public NewSpace { // inline allocation every once in a while. This is done by setting // allocation_info_.limit to be lower than the actual limit and and increasing // it in steps to guarantee that the observers are notified periodically. - void UpdateInlineAllocationLimit(size_t size_in_bytes) final { - paged_space_.UpdateInlineAllocationLimit(size_in_bytes); + void UpdateInlineAllocationLimit() final { + paged_space_.UpdateInlineAllocationLimit(); } // Try to switch the active semispace to a new, empty, page. @@ -748,7 +750,9 @@ class V8_EXPORT_PRIVATE PagedNewSpace final : public NewSpace { #ifdef VERIFY_HEAP // Verify the active semispace. - void Verify(Isolate* isolate) const final; + void Verify(Isolate* isolate, SpaceVerificationVisitor* visitor) const final { + paged_space_.Verify(isolate, visitor); + } #endif #ifdef DEBUG @@ -774,8 +778,9 @@ class V8_EXPORT_PRIVATE PagedNewSpace final : public NewSpace { bool ShouldBePromoted(Address address) const final { return true; } - void EvacuatePrologue() final { paged_space_.EvacuatePrologue(); } - void EvacuateEpilogue() final { paged_space_.EvacuateEpilogue(); } + void GarbageCollectionEpilogue() final { + paged_space_.GarbageCollectionEpilogue(); + } bool IsPromotionCandidate(const MemoryChunk* page) const final { return true; @@ -793,18 +798,18 @@ class V8_EXPORT_PRIVATE PagedNewSpace final : public NewSpace { void MakeIterable() override { paged_space_.MakeIterable(); } -#ifdef V8_ENABLE_INNER_POINTER_RESOLUTION_OSB - void ClearUnusedObjectStartBitmaps() override { - paged_space_.ClearUnusedObjectStartBitmaps(); - } -#endif // V8_ENABLE_INNER_POINTER_RESOLUTION_OSB - // All operations on `memory_chunk_list_` should go through `paged_space_`. heap::List<MemoryChunk>& memory_chunk_list() final { UNREACHABLE(); } - bool ShouldReleasePage() const { return paged_space_.ShouldReleasePage(); } + bool ShouldReleaseEmptyPage() { + return paged_space_.ShouldReleaseEmptyPage(); + } void ReleasePage(Page* page) { paged_space_.ReleasePage(page); } + void ForceAllocationSuccessUntilNextGC() { + paged_space_.ForceAllocationSuccessUntilNextGC(); + } + private: bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment, AllocationOrigin origin, |