v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8::internal::Sweeper Class Reference

#include <sweeper.h>

Collaboration diagram for v8::internal::Sweeper:

Classes

class  ConcurrentMajorSweeper
 
class  ConcurrentMinorSweeper
 
class  LocalSweeper
 
class  MajorSweeperJob
 
class  MinorSweeperJob
 
class  PauseMajorSweepingScope
 
class  SweepingState
 

Public Types

enum class  SweepingMode { kEagerDuringGC , kLazyOrConcurrent }
 
using SweepingList = std::vector<PageMetadata*>
 
using SweptList = std::vector<PageMetadata*>
 

Public Member Functions

 Sweeper (Heap *heap)
 
 ~Sweeper ()
 
bool major_sweeping_in_progress () const
 
bool minor_sweeping_in_progress () const
 
bool sweeping_in_progress () const
 
bool sweeping_in_progress_for_space (AllocationSpace space) const
 
void TearDown ()
 
void AddPage (AllocationSpace space, PageMetadata *page)
 
void AddNewSpacePage (PageMetadata *page)
 
void AddPromotedPage (MutablePageMetadata *chunk)
 
bool ParallelSweepSpace (AllocationSpace identity, SweepingMode sweeping_mode, uint32_t max_pages=std::numeric_limits< uint32_t >::max())
 
void EnsurePageIsSwept (PageMetadata *page)
 
void WaitForPageToBeSwept (PageMetadata *page)
 
void StartMajorSweeping ()
 
void StartMinorSweeping ()
 
void InitializeMajorSweeping ()
 
void InitializeMinorSweeping ()
 
V8_EXPORT_PRIVATE void StartMajorSweeperTasks ()
 
V8_EXPORT_PRIVATE void StartMinorSweeperTasks ()
 
void FinishMajorJobs ()
 
void EnsureMajorCompleted ()
 
void FinishMinorJobs ()
 
void EnsureMinorCompleted ()
 
bool AreMinorSweeperTasksRunning () const
 
bool AreMajorSweeperTasksRunning () const
 
bool UsingMajorSweeperTasks () const
 
PageMetadataGetSweptPageSafe (PagedSpaceBase *space)
 
SweptList GetAllSweptPagesSafe (PagedSpaceBase *space)
 
bool IsSweepingDoneForSpace (AllocationSpace space) const
 
GCTracer::Scope::ScopeId GetTracingScope (AllocationSpace space, bool is_joining_thread)
 
bool IsIteratingPromotedPages () const
 
void ContributeAndWaitForPromotedPagesIteration ()
 
bool ShouldRefillFreelistForSpace (AllocationSpace space) const
 
void SweepEmptyNewSpacePage (PageMetadata *page)
 
uint64_t GetTraceIdForFlowEvent (GCTracer::Scope::ScopeId scope_id) const
 

Static Public Member Functions

static V8_EXPORT_PRIVATE std::optional< base::AddressRegionComputeDiscardMemoryArea (Address start, Address end)
 

Private Types

enum class  SweepingScope { kMinor , kMajor }
 

Private Member Functions

NonAtomicMarkingStatemarking_state () const
 
void RawSweep (PageMetadata *p, FreeSpaceTreatmentMode free_space_treatment_mode, SweepingMode sweeping_mode, bool should_reduce_memory)
 
void ZeroOrDiscardUnusedMemory (PageMetadata *page, Address addr, size_t size)
 
void AddPageImpl (AllocationSpace space, PageMetadata *page)
 
template<typename Callback >
void ForAllSweepingSpaces (Callback callback) const
 
size_t FreeAndProcessFreedMemory (Address free_start, Address free_end, PageMetadata *page, Space *space, FreeSpaceTreatmentMode free_space_treatment_mode, bool should_reduce_memory)
 
void CleanupRememberedSetEntriesForFreedMemory (Address free_start, Address free_end, PageMetadata *page, bool record_free_ranges, TypedSlotSet::FreeRangesMap *free_ranges_map, SweepingMode sweeping_mode)
 
void CleanupTypedSlotsInFreeMemory (PageMetadata *page, const TypedSlotSet::FreeRangesMap &free_ranges_map, SweepingMode sweeping_mode)
 
void ClearMarkBitsAndHandleLivenessStatistics (PageMetadata *page, size_t live_bytes)
 
size_t ConcurrentMinorSweepingPageCount ()
 
size_t ConcurrentMajorSweepingPageCount ()
 
PageMetadataGetSweepingPageSafe (AllocationSpace space)
 
MutablePageMetadataGetPromotedPageSafe ()
 
bool TryRemoveSweepingPageSafe (AllocationSpace space, PageMetadata *page)
 
bool TryRemovePromotedPageSafe (MutablePageMetadata *chunk)
 
void PrepareToBeSweptPage (AllocationSpace space, PageMetadata *page)
 
void PrepareToBeIteratedPromotedPage (PageMetadata *page)
 
void NotifyPromotedPageIterationFinished (MutablePageMetadata *chunk)
 
void NotifyPromotedPagesIterationFinished ()
 
void AddSweptPage (PageMetadata *page, AllocationSpace identity)
 

Static Private Member Functions

static bool IsValidSweepingSpace (AllocationSpace space)
 
static int GetSweepSpaceIndex (AllocationSpace space)
 

Private Attributes

Heap *const heap_
 
NonAtomicMarkingState *const marking_state_
 
base::Mutex mutex_
 
base::ConditionVariable cv_page_swept_
 
SweptList swept_list_ [kNumberOfSweepingSpaces]
 
SweepingList sweeping_list_ [kNumberOfSweepingSpaces]
 
std::atomic< boolhas_sweeping_work_ [kNumberOfSweepingSpaces] {false}
 
std::atomic< boolhas_swept_pages_ [kNumberOfSweepingSpaces] {false}
 
std::vector< MutablePageMetadata * > sweeping_list_for_promoted_page_iteration_
 
LocalSweeper main_thread_local_sweeper_
 
SweepingState< SweepingScope::kMajormajor_sweeping_state_ {this}
 
SweepingState< SweepingScope::kMinorminor_sweeping_state_ {this}
 
size_t promoted_pages_for_iteration_count_ = 0
 
std::atomic< size_titerated_promoted_pages_count_ {0}
 
base::Mutex promoted_pages_iteration_notification_mutex_
 
base::ConditionVariable promoted_pages_iteration_notification_variable_
 
std::atomic< boolpromoted_page_iteration_in_progress_ {false}
 

Static Private Attributes

static constexpr int kNumberOfSweepingSpaces
 

Detailed Description

Definition at line 37 of file sweeper.h.

Member Typedef Documentation

◆ SweepingList

Definition at line 52 of file sweeper.h.

◆ SweptList

Definition at line 53 of file sweeper.h.

Member Enumeration Documentation

◆ SweepingMode

Enumerator
kEagerDuringGC 
kLazyOrConcurrent 

Definition at line 55 of file sweeper.h.

◆ SweepingScope

enum class v8::internal::Sweeper::SweepingScope
strongprivate
Enumerator
kMinor 
kMajor 

Definition at line 273 of file sweeper.h.

Constructor & Destructor Documentation

◆ Sweeper()

v8::internal::Sweeper::Sweeper ( Heap * heap)
explicit

Definition at line 653 of file sweeper.cc.

◆ ~Sweeper()

v8::internal::Sweeper::~Sweeper ( )
default

Member Function Documentation

◆ AddNewSpacePage()

void v8::internal::Sweeper::AddNewSpacePage ( PageMetadata * page)

Definition at line 1316 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddPage()

void v8::internal::Sweeper::AddPage ( AllocationSpace space,
PageMetadata * page )

Definition at line 1311 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddPageImpl()

void v8::internal::Sweeper::AddPageImpl ( AllocationSpace space,
PageMetadata * page )
private

Definition at line 1326 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddPromotedPage()

void v8::internal::Sweeper::AddPromotedPage ( MutablePageMetadata * chunk)

Definition at line 1343 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddSweptPage()

void v8::internal::Sweeper::AddSweptPage ( PageMetadata * page,
AllocationSpace identity )
private

Definition at line 1460 of file sweeper.cc.

Here is the call graph for this function:

◆ AreMajorSweeperTasksRunning()

bool v8::internal::Sweeper::AreMajorSweeperTasksRunning ( ) const

Definition at line 903 of file sweeper.cc.

Here is the call graph for this function:

◆ AreMinorSweeperTasksRunning()

bool v8::internal::Sweeper::AreMinorSweeperTasksRunning ( ) const

Definition at line 899 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CleanupRememberedSetEntriesForFreedMemory()

V8_INLINE void v8::internal::Sweeper::CleanupRememberedSetEntriesForFreedMemory ( Address free_start,
Address free_end,
PageMetadata * page,
bool record_free_ranges,
TypedSlotSet::FreeRangesMap * free_ranges_map,
SweepingMode sweeping_mode )
private

Definition at line 1006 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CleanupTypedSlotsInFreeMemory()

void v8::internal::Sweeper::CleanupTypedSlotsInFreeMemory ( PageMetadata * page,
const TypedSlotSet::FreeRangesMap & free_ranges_map,
SweepingMode sweeping_mode )
private

Definition at line 1048 of file sweeper.cc.

Here is the caller graph for this function:

◆ ClearMarkBitsAndHandleLivenessStatistics()

void v8::internal::Sweeper::ClearMarkBitsAndHandleLivenessStatistics ( PageMetadata * page,
size_t live_bytes )
private

Definition at line 1074 of file sweeper.cc.

Here is the caller graph for this function:

◆ ComputeDiscardMemoryArea()

std::optional< base::AddressRegion > v8::internal::Sweeper::ComputeDiscardMemoryArea ( Address start,
Address end )
static

Definition at line 940 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConcurrentMajorSweepingPageCount()

size_t v8::internal::Sweeper::ConcurrentMajorSweepingPageCount ( )
private

Definition at line 1212 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConcurrentMinorSweepingPageCount()

size_t v8::internal::Sweeper::ConcurrentMinorSweepingPageCount ( )
private

Definition at line 1205 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ContributeAndWaitForPromotedPagesIteration()

void v8::internal::Sweeper::ContributeAndWaitForPromotedPagesIteration ( )

Definition at line 1183 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureMajorCompleted()

void v8::internal::Sweeper::EnsureMajorCompleted ( )

Definition at line 830 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureMinorCompleted()

void v8::internal::Sweeper::EnsureMinorCompleted ( )

Definition at line 888 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsurePageIsSwept()

void v8::internal::Sweeper::EnsurePageIsSwept ( PageMetadata * page)

Definition at line 1231 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FinishMajorJobs()

void v8::internal::Sweeper::FinishMajorJobs ( )

Definition at line 809 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FinishMinorJobs()

void v8::internal::Sweeper::FinishMinorJobs ( )

Definition at line 866 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ForAllSweepingSpaces()

template<typename Callback >
void v8::internal::Sweeper::ForAllSweepingSpaces ( Callback callback) const
inlineprivate

Definition at line 210 of file sweeper.h.

Here is the caller graph for this function:

◆ FreeAndProcessFreedMemory()

V8_INLINE size_t v8::internal::Sweeper::FreeAndProcessFreedMemory ( Address free_start,
Address free_end,
PageMetadata * page,
Space * space,
FreeSpaceTreatmentMode free_space_treatment_mode,
bool should_reduce_memory )
private

Definition at line 911 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAllSweptPagesSafe()

Sweeper::SweptList v8::internal::Sweeper::GetAllSweptPagesSafe ( PagedSpaceBase * space)

Definition at line 800 of file sweeper.cc.

Here is the call graph for this function:

◆ GetPromotedPageSafe()

MutablePageMetadata * v8::internal::Sweeper::GetPromotedPageSafe ( )
private

Definition at line 1435 of file sweeper.cc.

◆ GetSweepingPageSafe()

PageMetadata * v8::internal::Sweeper::GetSweepingPageSafe ( AllocationSpace space)
private

Definition at line 1418 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSweepSpaceIndex()

static int v8::internal::Sweeper::GetSweepSpaceIndex ( AllocationSpace space)
inlinestaticprivate

Definition at line 263 of file sweeper.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSweptPageSafe()

PageMetadata * v8::internal::Sweeper::GetSweptPageSafe ( PagedSpaceBase * space)

Definition at line 785 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTraceIdForFlowEvent()

uint64_t v8::internal::Sweeper::GetTraceIdForFlowEvent ( GCTracer::Scope::ScopeId scope_id) const

Definition at line 1541 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTracingScope()

GCTracer::Scope::ScopeId v8::internal::Sweeper::GetTracingScope ( AllocationSpace space,
bool is_joining_thread )

Definition at line 1445 of file sweeper.cc.

Here is the caller graph for this function:

◆ InitializeMajorSweeping()

void v8::internal::Sweeper::InitializeMajorSweeping ( )

Definition at line 665 of file sweeper.cc.

Here is the call graph for this function:

◆ InitializeMinorSweeping()

void v8::internal::Sweeper::InitializeMinorSweeping ( )

Definition at line 669 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsIteratingPromotedPages()

bool v8::internal::Sweeper::IsIteratingPromotedPages ( ) const

Definition at line 1179 of file sweeper.cc.

Here is the caller graph for this function:

◆ IsSweepingDoneForSpace()

bool v8::internal::Sweeper::IsSweepingDoneForSpace ( AllocationSpace space) const

Definition at line 1455 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsValidSweepingSpace()

static bool v8::internal::Sweeper::IsValidSweepingSpace ( AllocationSpace space)
inlinestaticprivate

Definition at line 259 of file sweeper.h.

Here is the caller graph for this function:

◆ major_sweeping_in_progress()

bool v8::internal::Sweeper::major_sweeping_in_progress ( ) const
inline

Definition at line 108 of file sweeper.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ marking_state()

NonAtomicMarkingState * v8::internal::Sweeper::marking_state ( ) const
inlineprivate

Definition at line 190 of file sweeper.h.

◆ minor_sweeping_in_progress()

bool v8::internal::Sweeper::minor_sweeping_in_progress ( ) const
inline

Definition at line 111 of file sweeper.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NotifyPromotedPageIterationFinished()

void v8::internal::Sweeper::NotifyPromotedPageIterationFinished ( MutablePageMetadata * chunk)
private

Definition at line 1187 of file sweeper.cc.

Here is the call graph for this function:

◆ NotifyPromotedPagesIterationFinished()

void v8::internal::Sweeper::NotifyPromotedPagesIterationFinished ( )
private

Definition at line 1197 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParallelSweepSpace()

bool v8::internal::Sweeper::ParallelSweepSpace ( AllocationSpace identity,
SweepingMode sweeping_mode,
uint32_t max_pages = std::numeric_limits<uint32_t>::max() )

Definition at line 1223 of file sweeper.cc.

Here is the call graph for this function:

◆ PrepareToBeIteratedPromotedPage()

void v8::internal::Sweeper::PrepareToBeIteratedPromotedPage ( PageMetadata * page)
private

Definition at line 1402 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrepareToBeSweptPage()

void v8::internal::Sweeper::PrepareToBeSweptPage ( AllocationSpace space,
PageMetadata * page )
private

Definition at line 1382 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RawSweep()

void v8::internal::Sweeper::RawSweep ( PageMetadata * p,
FreeSpaceTreatmentMode free_space_treatment_mode,
SweepingMode sweeping_mode,
bool should_reduce_memory )
private

Definition at line 1085 of file sweeper.cc.

Here is the call graph for this function:

◆ ShouldRefillFreelistForSpace()

bool v8::internal::Sweeper::ShouldRefillFreelistForSpace ( AllocationSpace space) const

Definition at line 1470 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartMajorSweeperTasks()

void v8::internal::Sweeper::StartMajorSweeperTasks ( )

Definition at line 738 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartMajorSweeping()

void v8::internal::Sweeper::StartMajorSweeping ( )

Definition at line 688 of file sweeper.cc.

Here is the call graph for this function:

◆ StartMinorSweeperTasks()

void v8::internal::Sweeper::StartMinorSweeperTasks ( )

Definition at line 764 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartMinorSweeping()

void v8::internal::Sweeper::StartMinorSweeping ( )

Definition at line 706 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SweepEmptyNewSpacePage()

void v8::internal::Sweeper::SweepEmptyNewSpacePage ( PageMetadata * page)

Definition at line 1476 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sweeping_in_progress()

bool v8::internal::Sweeper::sweeping_in_progress ( ) const
inline

Definition at line 114 of file sweeper.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sweeping_in_progress_for_space()

bool v8::internal::Sweeper::sweeping_in_progress_for_space ( AllocationSpace space) const
inline

Definition at line 117 of file sweeper.h.

Here is the call graph for this function:

◆ TearDown()

void v8::internal::Sweeper::TearDown ( )

Definition at line 660 of file sweeper.cc.

Here is the call graph for this function:

◆ TryRemovePromotedPageSafe()

bool v8::internal::Sweeper::TryRemovePromotedPageSafe ( MutablePageMetadata * chunk)
private

Definition at line 1300 of file sweeper.cc.

Here is the caller graph for this function:

◆ TryRemoveSweepingPageSafe()

bool v8::internal::Sweeper::TryRemoveSweepingPageSafe ( AllocationSpace space,
PageMetadata * page )
private

Definition at line 1283 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UsingMajorSweeperTasks()

bool v8::internal::Sweeper::UsingMajorSweeperTasks ( ) const

Definition at line 907 of file sweeper.cc.

Here is the call graph for this function:

◆ WaitForPageToBeSwept()

void v8::internal::Sweeper::WaitForPageToBeSwept ( PageMetadata * page)

Definition at line 1273 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZeroOrDiscardUnusedMemory()

void v8::internal::Sweeper::ZeroOrDiscardUnusedMemory ( PageMetadata * page,
Address addr,
size_t size )
private

Definition at line 953 of file sweeper.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ cv_page_swept_

base::ConditionVariable v8::internal::Sweeper::cv_page_swept_
private

Definition at line 326 of file sweeper.h.

◆ has_sweeping_work_

std::atomic<bool> v8::internal::Sweeper::has_sweeping_work_[kNumberOfSweepingSpaces] {false}
private

Definition at line 329 of file sweeper.h.

◆ has_swept_pages_

std::atomic<bool> v8::internal::Sweeper::has_swept_pages_[kNumberOfSweepingSpaces] {false}
private

Definition at line 330 of file sweeper.h.

◆ heap_

Heap* const v8::internal::Sweeper::heap_
private

Definition at line 323 of file sweeper.h.

◆ iterated_promoted_pages_count_

std::atomic<size_t> v8::internal::Sweeper::iterated_promoted_pages_count_ {0}
private

Definition at line 339 of file sweeper.h.

◆ kNumberOfSweepingSpaces

int v8::internal::Sweeper::kNumberOfSweepingSpaces
staticconstexprprivate
Initial value:

Definition at line 206 of file sweeper.h.

◆ main_thread_local_sweeper_

LocalSweeper v8::internal::Sweeper::main_thread_local_sweeper_
private

Definition at line 332 of file sweeper.h.

◆ major_sweeping_state_

SweepingState<SweepingScope::kMajor> v8::internal::Sweeper::major_sweeping_state_ {this}
private

Definition at line 333 of file sweeper.h.

◆ marking_state_

NonAtomicMarkingState* const v8::internal::Sweeper::marking_state_
private

Definition at line 324 of file sweeper.h.

◆ minor_sweeping_state_

SweepingState<SweepingScope::kMinor> v8::internal::Sweeper::minor_sweeping_state_ {this}
private

Definition at line 334 of file sweeper.h.

◆ mutex_

base::Mutex v8::internal::Sweeper::mutex_
private

Definition at line 325 of file sweeper.h.

◆ promoted_page_iteration_in_progress_

std::atomic<bool> v8::internal::Sweeper::promoted_page_iteration_in_progress_ {false}
private

Definition at line 342 of file sweeper.h.

◆ promoted_pages_for_iteration_count_

size_t v8::internal::Sweeper::promoted_pages_for_iteration_count_ = 0
private

Definition at line 338 of file sweeper.h.

◆ promoted_pages_iteration_notification_mutex_

base::Mutex v8::internal::Sweeper::promoted_pages_iteration_notification_mutex_
private

Definition at line 340 of file sweeper.h.

◆ promoted_pages_iteration_notification_variable_

base::ConditionVariable v8::internal::Sweeper::promoted_pages_iteration_notification_variable_
private

Definition at line 341 of file sweeper.h.

◆ sweeping_list_

SweepingList v8::internal::Sweeper::sweeping_list_[kNumberOfSweepingSpaces]
private

Definition at line 328 of file sweeper.h.

◆ sweeping_list_for_promoted_page_iteration_

std::vector<MutablePageMetadata*> v8::internal::Sweeper::sweeping_list_for_promoted_page_iteration_
private

Definition at line 331 of file sweeper.h.

◆ swept_list_

SweptList v8::internal::Sweeper::swept_list_[kNumberOfSweepingSpaces]
private

Definition at line 327 of file sweeper.h.


The documentation for this class was generated from the following files: