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

#include <region-allocator.h>

Collaboration diagram for v8::base::RegionAllocator:

Classes

struct  AddressEndOrder
 
class  Region
 
struct  SizeAddressOrder
 

Public Types

enum class  RegionState { kFree , kExcluded , kAllocated }
 
using Address = uintptr_t
 
using SplitMergeCallback = std::function<void(Address start, size_t size)>
 

Public Member Functions

 RegionAllocator (Address address, size_t size, size_t page_size)
 
 RegionAllocator (const RegionAllocator &)=delete
 
RegionAllocatoroperator= (const RegionAllocator &)=delete
 
 ~RegionAllocator ()
 
void set_on_split_callback (SplitMergeCallback callback)
 
void set_on_merge_callback (SplitMergeCallback callback)
 
Address AllocateRegion (size_t size)
 
Address AllocateRegion (RandomNumberGenerator *rng, size_t size)
 
bool AllocateRegionAt (Address requested_address, size_t size, RegionState region_state=RegionState::kAllocated)
 
Address AllocateAlignedRegion (size_t size, size_t alignment)
 
Address AllocateRegion (Address hint, size_t size, size_t alignment)
 
size_t FreeRegion (Address address)
 
size_t TrimRegion (Address address, size_t new_size)
 
size_t CheckRegion (Address address)
 
bool IsFree (Address address, size_t size)
 
Address begin () const
 
Address end () const
 
size_t size () const
 
bool contains (Address address) const
 
bool contains (Address address, size_t size) const
 
size_t free_size () const
 
size_t page_size () const
 
void Print (std::ostream &os) const
 

Static Public Attributes

static constexpr Address kAllocationFailure = static_cast<Address>(-1)
 

Private Types

using AllRegionsSet = std::set<Region*, AddressEndOrder>
 

Private Member Functions

AllRegionsSet::iterator FindRegion (Address address)
 
void FreeListAddRegion (Region *region)
 
RegionFreeListFindRegion (size_t size)
 
void FreeListRemoveRegion (Region *region)
 
RegionSplit (Region *region, size_t new_size)
 
void Merge (AllRegionsSet::iterator prev_iter, AllRegionsSet::iterator next_iter)
 
 FRIEND_TEST (RegionAllocatorTest, AllocateExcluded)
 
 FRIEND_TEST (RegionAllocatorTest, AllocateRegionRandom)
 
 FRIEND_TEST (RegionAllocatorTest, Contains)
 
 FRIEND_TEST (RegionAllocatorTest, FindRegion)
 
 FRIEND_TEST (RegionAllocatorTest, Fragmentation)
 

Private Attributes

const Region whole_region_
 
const size_t region_size_in_pages_
 
const size_t max_load_for_randomization_
 
size_t free_size_
 
const size_t page_size_
 
AllRegionsSet all_regions_
 
std::set< Region *, SizeAddressOrderfree_regions_
 
SplitMergeCallback on_split_
 
SplitMergeCallback on_merge_
 

Detailed Description

Definition at line 26 of file region-allocator.h.

Member Typedef Documentation

◆ Address

Definition at line 28 of file region-allocator.h.

◆ AllRegionsSet

Definition at line 177 of file region-allocator.h.

◆ SplitMergeCallback

using v8::base::RegionAllocator::SplitMergeCallback = std::function<void(Address start, size_t size)>

Definition at line 30 of file region-allocator.h.

Member Enumeration Documentation

◆ RegionState

Enumerator
kFree 
kExcluded 
kAllocated 

Definition at line 34 of file region-allocator.h.

Constructor & Destructor Documentation

◆ RegionAllocator() [1/2]

v8::base::RegionAllocator::RegionAllocator ( Address address,
size_t size,
size_t page_size )

Definition at line 23 of file region-allocator.cc.

Here is the call graph for this function:

◆ RegionAllocator() [2/2]

v8::base::RegionAllocator::RegionAllocator ( const RegionAllocator & )
delete

◆ ~RegionAllocator()

v8::base::RegionAllocator::~RegionAllocator ( )

Definition at line 45 of file region-allocator.cc.

Member Function Documentation

◆ AllocateAlignedRegion()

RegionAllocator::Address v8::base::RegionAllocator::AllocateAlignedRegion ( size_t size,
size_t alignment )

Definition at line 212 of file region-allocator.cc.

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

◆ AllocateRegion() [1/3]

RegionAllocator::Address v8::base::RegionAllocator::AllocateRegion ( Address hint,
size_t size,
size_t alignment )

Definition at line 249 of file region-allocator.cc.

Here is the call graph for this function:

◆ AllocateRegion() [2/3]

RegionAllocator::Address v8::base::RegionAllocator::AllocateRegion ( RandomNumberGenerator * rng,
size_t size )

Definition at line 152 of file region-allocator.cc.

Here is the call graph for this function:

◆ AllocateRegion() [3/3]

RegionAllocator::Address v8::base::RegionAllocator::AllocateRegion ( size_t size)

Definition at line 133 of file region-allocator.cc.

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

◆ AllocateRegionAt()

bool v8::base::RegionAllocator::AllocateRegionAt ( Address requested_address,
size_t size,
RegionState region_state = RegionState::kAllocated )

Definition at line 171 of file region-allocator.cc.

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

◆ begin()

Address v8::base::RegionAllocator::begin ( ) const
inline

Definition at line 115 of file region-allocator.h.

Here is the caller graph for this function:

◆ CheckRegion()

size_t v8::base::RegionAllocator::CheckRegion ( Address address)

Definition at line 324 of file region-allocator.cc.

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

◆ contains() [1/2]

bool v8::base::RegionAllocator::contains ( Address address) const
inline

Definition at line 119 of file region-allocator.h.

Here is the caller graph for this function:

◆ contains() [2/2]

bool v8::base::RegionAllocator::contains ( Address address,
size_t size ) const
inline

Definition at line 123 of file region-allocator.h.

◆ end()

Address v8::base::RegionAllocator::end ( ) const
inline

Definition at line 116 of file region-allocator.h.

Here is the caller graph for this function:

◆ FindRegion()

RegionAllocator::AllRegionsSet::iterator v8::base::RegionAllocator::FindRegion ( Address address)
private

Definition at line 53 of file region-allocator.cc.

Here is the caller graph for this function:

◆ free_size()

size_t v8::base::RegionAllocator::free_size ( ) const
inline

Definition at line 128 of file region-allocator.h.

Here is the caller graph for this function:

◆ FreeListAddRegion()

void v8::base::RegionAllocator::FreeListAddRegion ( Region * region)
private

Definition at line 67 of file region-allocator.cc.

Here is the caller graph for this function:

◆ FreeListFindRegion()

RegionAllocator::Region * v8::base::RegionAllocator::FreeListFindRegion ( size_t size)
private

Definition at line 72 of file region-allocator.cc.

Here is the caller graph for this function:

◆ FreeListRemoveRegion()

void v8::base::RegionAllocator::FreeListRemoveRegion ( Region * region)
private

Definition at line 78 of file region-allocator.cc.

Here is the caller graph for this function:

◆ FreeRegion()

size_t v8::base::RegionAllocator::FreeRegion ( Address address)
inline

Definition at line 100 of file region-allocator.h.

Here is the caller graph for this function:

◆ FRIEND_TEST() [1/5]

v8::base::RegionAllocator::FRIEND_TEST ( RegionAllocatorTest ,
AllocateExcluded  )
private

◆ FRIEND_TEST() [2/5]

v8::base::RegionAllocator::FRIEND_TEST ( RegionAllocatorTest ,
AllocateRegionRandom  )
private

◆ FRIEND_TEST() [3/5]

v8::base::RegionAllocator::FRIEND_TEST ( RegionAllocatorTest ,
Contains  )
private

◆ FRIEND_TEST() [4/5]

v8::base::RegionAllocator::FRIEND_TEST ( RegionAllocatorTest ,
FindRegion  )
private

◆ FRIEND_TEST() [5/5]

v8::base::RegionAllocator::FRIEND_TEST ( RegionAllocatorTest ,
Fragmentation  )
private

◆ IsFree()

bool v8::base::RegionAllocator::IsFree ( Address address,
size_t size )

Definition at line 336 of file region-allocator.cc.

Here is the call graph for this function:

◆ Merge()

void v8::base::RegionAllocator::Merge ( AllRegionsSet::iterator prev_iter,
AllRegionsSet::iterator next_iter )
private

Definition at line 116 of file region-allocator.cc.

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

◆ operator=()

RegionAllocator & v8::base::RegionAllocator::operator= ( const RegionAllocator & )
delete

◆ page_size()

size_t v8::base::RegionAllocator::page_size ( ) const
inline

Definition at line 132 of file region-allocator.h.

Here is the caller graph for this function:

◆ Print()

void v8::base::RegionAllocator::Print ( std::ostream & os) const

Definition at line 368 of file region-allocator.cc.

Here is the call graph for this function:

◆ set_on_merge_callback()

void v8::base::RegionAllocator::set_on_merge_callback ( SplitMergeCallback callback)
inline

Definition at line 65 of file region-allocator.h.

Here is the caller graph for this function:

◆ set_on_split_callback()

void v8::base::RegionAllocator::set_on_split_callback ( SplitMergeCallback callback)
inline

Definition at line 60 of file region-allocator.h.

Here is the caller graph for this function:

◆ size()

size_t v8::base::RegionAllocator::size ( ) const
inline

Definition at line 117 of file region-allocator.h.

Here is the caller graph for this function:

◆ Split()

RegionAllocator::Region * v8::base::RegionAllocator::Split ( Region * region,
size_t new_size )
private

Definition at line 88 of file region-allocator.cc.

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

◆ TrimRegion()

size_t v8::base::RegionAllocator::TrimRegion ( Address address,
size_t new_size )

Definition at line 272 of file region-allocator.cc.

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

Member Data Documentation

◆ all_regions_

AllRegionsSet v8::base::RegionAllocator::all_regions_
private

Definition at line 178 of file region-allocator.h.

◆ free_regions_

std::set<Region*, SizeAddressOrder> v8::base::RegionAllocator::free_regions_
private

Definition at line 187 of file region-allocator.h.

◆ free_size_

size_t v8::base::RegionAllocator::free_size_
private

Definition at line 166 of file region-allocator.h.

◆ kAllocationFailure

Address v8::base::RegionAllocator::kAllocationFailure = static_cast<Address>(-1)
staticconstexpr

Definition at line 32 of file region-allocator.h.

◆ max_load_for_randomization_

const size_t v8::base::RegionAllocator::max_load_for_randomization_
private

Definition at line 163 of file region-allocator.h.

◆ on_merge_

SplitMergeCallback v8::base::RegionAllocator::on_merge_
private

Definition at line 191 of file region-allocator.h.

◆ on_split_

SplitMergeCallback v8::base::RegionAllocator::on_split_
private

Definition at line 190 of file region-allocator.h.

◆ page_size_

const size_t v8::base::RegionAllocator::page_size_
private

Definition at line 169 of file region-allocator.h.

◆ region_size_in_pages_

const size_t v8::base::RegionAllocator::region_size_in_pages_
private

Definition at line 159 of file region-allocator.h.

◆ whole_region_

const Region v8::base::RegionAllocator::whole_region_
private

Definition at line 156 of file region-allocator.h.


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