V8 Project
v8::internal::PagedSpace Class Reference

#include <spaces.h>

+ Inheritance diagram for v8::internal::PagedSpace:
+ Collaboration diagram for v8::internal::PagedSpace:

Classes

struct  SizeStats
 

Public Member Functions

 PagedSpace (Heap *heap, intptr_t max_capacity, AllocationSpace id, Executability executable)
 
virtual ~PagedSpace ()
 
bool SetUp ()
 
bool HasBeenSetUp ()
 
void TearDown ()
 
bool Contains (Address a)
 
bool Contains (HeapObject *o)
 
ObjectFindObject (Address addr)
 
void RepairFreeListsAfterBoot ()
 
void PrepareForMarkCompact ()
 
intptr_t Capacity ()
 
intptr_t CommittedMemory ()
 
intptr_t MaximumCommittedMemory ()
 
size_t CommittedPhysicalMemory ()
 
void ObtainFreeListStatistics (Page *p, SizeStats *sizes)
 
void ResetFreeListStatistics ()
 
void ClearStats ()
 
void AddToAccountingStats (intptr_t bytes)
 
intptr_t Available ()
 
virtual intptr_t Size ()
 
virtual intptr_t SizeOfObjects ()
 
virtual intptr_t Waste ()
 
Address top ()
 
Address limit ()
 
Addressallocation_top_address ()
 
Addressallocation_limit_address ()
 
MUST_USE_RESULT AllocationResult AllocateRaw (int size_in_bytes)
 
int Free (Address start, int size_in_bytes)
 
void ResetFreeList ()
 
void SetTopAndLimit (Address top, Address limit)
 
void EmptyAllocationInfo ()
 
void Allocate (int bytes)
 
void IncreaseCapacity (int size)
 
void ReleasePage (Page *page)
 
Pageanchor ()
 
void IncrementUnsweptFreeBytes (intptr_t by)
 
void IncreaseUnsweptFreeBytes (Page *p)
 
void DecrementUnsweptFreeBytes (intptr_t by)
 
void DecreaseUnsweptFreeBytes (Page *p)
 
void ResetUnsweptFreeBytes ()
 
bool EnsureSweeperProgress (intptr_t size_in_bytes)
 
void set_end_of_unswept_pages (Page *page)
 
Pageend_of_unswept_pages ()
 
PageFirstPage ()
 
PageLastPage ()
 
void EvictEvacuationCandidatesFromFreeLists ()
 
bool CanExpand ()
 
int CountTotalPages ()
 
int AreaSize ()
 
void CreateEmergencyMemory ()
 
void FreeEmergencyMemory ()
 
void UseEmergencyMemory ()
 
bool HasEmergencyMemory ()
 
- Public Member Functions inherited from v8::internal::Space
 Space (Heap *heap, AllocationSpace id, Executability executable)
 
virtual ~Space ()
 
Heapheap () const
 
Executability executable ()
 
AllocationSpace identity ()
 
virtual int RoundSizeDownToObjectAlignment (int size)
 
- Public Member Functions inherited from v8::internal::Malloced
void * operator new (size_t size)
 
void operator delete (void *p)
 

Static Public Member Functions

static bool ShouldBeSweptBySweeperThreads (Page *p)
 
- Static Public Member Functions inherited from v8::internal::Malloced
static void FatalProcessOutOfMemory ()
 
static void * New (size_t size)
 
static void Delete (void *p)
 

Protected Member Functions

FreeListfree_list ()
 
intptr_t SizeOfFirstPage ()
 
bool Expand ()
 
HeapObjectAllocateLinearly (int size_in_bytes)
 
MUST_USE_RESULT HeapObjectWaitForSweeperThreadsAndRetryAllocation (int size_in_bytes)
 
MUST_USE_RESULT HeapObjectSlowAllocateRaw (int size_in_bytes)
 

Protected Attributes

int area_size_
 
intptr_t max_capacity_
 
AllocationStats accounting_stats_
 
Page anchor_
 
FreeList free_list_
 
AllocationInfo allocation_info_
 
intptr_t unswept_free_bytes_
 
Pageend_of_unswept_pages_
 
MemoryChunkemergency_memory_
 

Friends

class PageIterator
 
class MarkCompactCollector
 

Detailed Description

Definition at line 1648 of file spaces.h.

Constructor & Destructor Documentation

◆ PagedSpace()

v8::internal::PagedSpace::PagedSpace ( Heap heap,
intptr_t  max_capacity,
AllocationSpace  id,
Executability  executable 
)

Definition at line 880 of file spaces.cc.

882  : Space(heap, id, executable),
883  free_list_(this),
887  if (id == CODE_SPACE) {
889  } else {
891  }
892  max_capacity_ =
893  (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize) * AreaSize();
894  accounting_stats_.Clear();
895 
896  allocation_info_.set_top(NULL);
897  allocation_info_.set_limit(NULL);
898 
900 }
Isolate * isolate()
Definition: heap-inl.h:589
MemoryAllocator * memory_allocator()
Definition: isolate.h:883
static int CodePageAreaSize()
Definition: spaces.h:1103
static const int kObjectStartOffset
Definition: spaces.h:550
static const int kPageSize
Definition: spaces.h:748
void InitializeAsAnchor(PagedSpace *owner)
Definition: spaces.cc:391
AllocationInfo allocation_info_
Definition: spaces.h:1901
intptr_t unswept_free_bytes_
Definition: spaces.h:1905
AllocationStats accounting_stats_
Definition: spaces.h:1892
MemoryChunk * emergency_memory_
Definition: spaces.h:1916
Page * end_of_unswept_pages_
Definition: spaces.h:1910
Space(Heap *heap, AllocationSpace id, Executability executable)
Definition: spaces.h:818
Executability executable()
Definition: spaces.h:826
Heap * heap() const
Definition: spaces.h:823
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
T RoundDown(T x, intptr_t m)
Definition: macros.h:399

References accounting_stats_, allocation_info_, anchor_, area_size_, AreaSize(), v8::internal::CODE_SPACE, v8::internal::MemoryAllocator::CodePageAreaSize(), v8::internal::Space::heap(), v8::internal::Page::InitializeAsAnchor(), v8::internal::Heap::isolate(), v8::internal::MemoryChunk::kObjectStartOffset, v8::internal::Page::kPageSize, max_capacity_, v8::internal::Isolate::memory_allocator(), NULL, and RoundDown().

+ Here is the call graph for this function:

◆ ~PagedSpace()

virtual v8::internal::PagedSpace::~PagedSpace ( )
inlinevirtual

Definition at line 1654 of file spaces.h.

1654 {}

Member Function Documentation

◆ AddToAccountingStats()

void v8::internal::PagedSpace::AddToAccountingStats ( intptr_t  bytes)
inline

Definition at line 1725 of file spaces.h.

1725  {
1726  accounting_stats_.DeallocateBytes(bytes);
1727  }

References accounting_stats_.

◆ Allocate()

void v8::internal::PagedSpace::Allocate ( int  bytes)
inline

Definition at line 1797 of file spaces.h.

1797 { accounting_stats_.AllocateBytes(bytes); }

References accounting_stats_.

Referenced by v8::internal::FreeList::Allocate().

+ Here is the caller graph for this function:

◆ AllocateLinearly()

HeapObject * v8::internal::PagedSpace::AllocateLinearly ( int  size_in_bytes)
inlineprotected

Definition at line 237 of file spaces-inl.h.

237  {
238  Address current_top = allocation_info_.top();
239  Address new_top = current_top + size_in_bytes;
240  if (new_top > allocation_info_.limit()) return NULL;
241 
242  allocation_info_.set_top(new_top);
243  return HeapObject::FromAddress(current_top);
244 }
static HeapObject * FromAddress(Address address)
Definition: objects-inl.h:1464
byte * Address
Definition: globals.h:101

References allocation_info_, v8::internal::HeapObject::FromAddress(), and NULL.

Referenced by AllocateRaw().

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

◆ AllocateRaw()

AllocationResult v8::internal::PagedSpace::AllocateRaw ( int  size_in_bytes)
inline

Definition at line 248 of file spaces-inl.h.

248  {
249  HeapObject* object = AllocateLinearly(size_in_bytes);
250 
251  if (object == NULL) {
252  object = free_list_.Allocate(size_in_bytes);
253  if (object == NULL) {
254  object = SlowAllocateRaw(size_in_bytes);
255  }
256  }
257 
258  if (object != NULL) {
259  if (identity() == CODE_SPACE) {
260  SkipList::Update(object->address(), size_in_bytes);
261  }
262  MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), size_in_bytes);
263  return object;
264  }
265 
267 }
static AllocationResult Retry(AllocationSpace space=NEW_SPACE)
Definition: spaces.h:1616
MUST_USE_RESULT HeapObject * Allocate(int size_in_bytes)
Definition: spaces.cc:2326
HeapObject * AllocateLinearly(int size_in_bytes)
Definition: spaces-inl.h:237
MUST_USE_RESULT HeapObject * SlowAllocateRaw(int size_in_bytes)
Definition: spaces.cc:2547
static void Update(Address addr, int size)
Definition: spaces.h:972
AllocationSpace identity()
Definition: spaces.h:829
#define MSAN_ALLOCATED_UNINITIALIZED_MEMORY(p, s)
Definition: msan.h:29

References v8::internal::HeapObject::address(), v8::internal::FreeList::Allocate(), AllocateLinearly(), v8::internal::CODE_SPACE, free_list_, v8::internal::Space::identity(), MSAN_ALLOCATED_UNINITIALIZED_MEMORY, NULL, v8::internal::AllocationResult::Retry(), SlowAllocateRaw(), and v8::internal::SkipList::Update().

Referenced by v8::internal::Heap::AllocateRaw(), v8::internal::ScavengingVisitor< marks_handling, logging_and_profiling_mode >::PromoteObject(), v8::internal::Heap::ReserveSpace(), and v8::internal::MarkCompactCollector::TryPromoteObject().

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

◆ allocation_limit_address()

Address* v8::internal::PagedSpace::allocation_limit_address ( )
inline

Definition at line 1758 of file spaces.h.

1758  {
1760  }

References allocation_info_, and v8::internal::AllocationInfo::limit_address().

Referenced by v8::internal::Heap::OldDataSpaceAllocationLimitAddress(), and v8::internal::Heap::OldPointerSpaceAllocationLimitAddress().

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

◆ allocation_top_address()

Address* v8::internal::PagedSpace::allocation_top_address ( )
inline

Definition at line 1755 of file spaces.h.

1755 { return allocation_info_.top_address(); }

References allocation_info_, and v8::internal::AllocationInfo::top_address().

Referenced by v8::internal::Heap::OldDataSpaceAllocationTopAddress(), and v8::internal::Heap::OldPointerSpaceAllocationTopAddress().

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

◆ anchor()

Page* v8::internal::PagedSpace::anchor ( )
inline

Definition at line 1805 of file spaces.h.

1805 { return &anchor_; }

References anchor_.

Referenced by v8::internal::HeapObjectIterator::AdvanceToNextPage().

+ Here is the caller graph for this function:

◆ AreaSize()

int v8::internal::PagedSpace::AreaSize ( )
inline

Definition at line 1873 of file spaces.h.

1873 { return area_size_; }

References area_size_.

Referenced by CanExpand(), CreateEmergencyMemory(), Expand(), FreeEmergencyMemory(), PagedSpace(), ReleasePage(), and SizeOfFirstPage().

+ Here is the caller graph for this function:

◆ Available()

intptr_t v8::internal::PagedSpace::Available ( )
inline

Definition at line 1733 of file spaces.h.

1733 { return free_list_.available(); }
intptr_t available()
Definition: spaces.h:1525

References v8::internal::FreeList::available(), and free_list_.

Referenced by v8::internal::Heap::Available(), v8::internal::StatisticsExtension::GetCounters(), and v8::internal::Heap::PrintShortHeapStatistics().

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

◆ CanExpand()

bool v8::internal::PagedSpace::CanExpand ( )

Definition at line 951 of file spaces.cc.

951  {
952  DCHECK(max_capacity_ % AreaSize() == 0);
953 
954  if (Capacity() == max_capacity_) return false;
955 
957 
958  // Are we going to exceed capacity for this space?
959  if ((Capacity() + Page::kPageSize) > max_capacity_) return false;
960 
961  return true;
962 }
#define DCHECK(condition)
Definition: logging.h:205

References AreaSize(), Capacity(), DCHECK, v8::internal::Page::kPageSize, and max_capacity_.

Referenced by Expand().

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

◆ Capacity()

intptr_t v8::internal::PagedSpace::Capacity ( )
inline

Definition at line 1688 of file spaces.h.

1688 { return accounting_stats_.Capacity(); }

References accounting_stats_.

Referenced by CanExpand(), v8::internal::Heap::Capacity(), CommittedMemory(), Expand(), v8::internal::Heap::RecordStats(), and ReleasePage().

+ Here is the caller graph for this function:

◆ ClearStats()

void v8::internal::PagedSpace::ClearStats ( )
inline

Definition at line 1719 of file spaces.h.

1719  {
1720  accounting_stats_.ClearSizeWaste();
1722  }
void ResetFreeListStatistics()
Definition: spaces.cc:1047

References accounting_stats_, and ResetFreeListStatistics().

+ Here is the call graph for this function:

◆ CommittedMemory()

intptr_t v8::internal::PagedSpace::CommittedMemory ( )
inline

Definition at line 1692 of file spaces.h.

1692 { return Capacity(); }

References Capacity().

Referenced by v8::internal::Heap::CommittedMemory(), CommittedPhysicalMemory(), v8::internal::StatisticsExtension::GetCounters(), and v8::internal::Heap::PrintShortHeapStatistics().

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

◆ CommittedPhysicalMemory()

size_t v8::internal::PagedSpace::CommittedPhysicalMemory ( )

Definition at line 920 of file spaces.cc.

920  {
923  size_t size = 0;
924  PageIterator it(this);
925  while (it.has_next()) {
926  size += it.next()->CommittedPhysicalMemory();
927  }
928  return size;
929 }
static void UpdateHighWaterMark(Address mark)
Definition: spaces-inl.h:189
intptr_t CommittedMemory()
Definition: spaces.h:1692
friend class PageIterator
Definition: spaces.h:1936
enable harmony numeric enable harmony object literal extensions Optimize object size

References allocation_info_, CommittedMemory(), v8::base::VirtualMemory::HasLazyCommits(), PageIterator, size, and v8::internal::MemoryChunk::UpdateHighWaterMark().

Referenced by v8::internal::Heap::CommittedPhysicalMemory().

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

◆ Contains() [1/2]

bool v8::internal::PagedSpace::Contains ( Address  a)
inline

Definition at line 150 of file spaces-inl.h.

150  {
151  Page* p = Page::FromAddress(addr);
152  if (!p->is_valid()) return false;
153  return p->owner() == this;
154 }
static MemoryChunk * FromAddress(Address a)
Definition: spaces.h:276

References v8::internal::MemoryChunk::FromAddress(), v8::internal::MemoryChunk::is_valid(), and v8::internal::MemoryChunk::owner().

Referenced by v8::internal::StoreBuffer::ClearDeadObject(), v8::internal::StoreBuffer::Compact(), v8::internal::Heap::Contains(), v8::internal::StoreBuffer::EnterDirectlyIntoStoreBuffer(), FindObject(), v8::internal::Heap::InOldDataSpace(), v8::internal::Heap::InOldPointerSpace(), v8::internal::Heap::InSpace(), and v8::internal::StoreBuffer::Mark().

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

◆ Contains() [2/2]

bool v8::internal::PagedSpace::Contains ( HeapObject o)
inline

Definition at line 1672 of file spaces.h.

1672 { return Contains(o->address()); }
bool Contains(Address a)
Definition: spaces-inl.h:150

References v8::internal::HeapObject::address(), and Contains().

Referenced by Contains().

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

◆ CountTotalPages()

int v8::internal::PagedSpace::CountTotalPages ( )

Definition at line 1028 of file spaces.cc.

1028  {
1029  PageIterator it(this);
1030  int count = 0;
1031  while (it.has_next()) {
1032  it.next();
1033  count++;
1034  }
1035  return count;
1036 }

References PageIterator.

Referenced by SlowAllocateRaw().

+ Here is the caller graph for this function:

◆ CreateEmergencyMemory()

void v8::internal::PagedSpace::CreateEmergencyMemory ( )

Definition at line 1097 of file spaces.cc.

1097  {
1099  AreaSize(), AreaSize(), executable(), this);
1100 }
MemoryChunk * AllocateChunk(intptr_t reserve_area_size, intptr_t commit_area_size, Executability executable, Space *space)
Definition: spaces.cc:548

References v8::internal::MemoryAllocator::AllocateChunk(), AreaSize(), emergency_memory_, v8::internal::Space::executable(), v8::internal::Space::heap(), v8::internal::Heap::isolate(), and v8::internal::Isolate::memory_allocator().

+ Here is the call graph for this function:

◆ DecreaseUnsweptFreeBytes()

void v8::internal::PagedSpace::DecreaseUnsweptFreeBytes ( Page p)
inline

Definition at line 1845 of file spaces.h.

1845  {
1847  unswept_free_bytes_ -= (p->area_size() - p->LiveBytes());
1848  }
static bool ShouldBeSweptBySweeperThreads(Page *p)
Definition: spaces.h:1831

References v8::internal::MemoryChunk::area_size(), DCHECK, v8::internal::MemoryChunk::LiveBytes(), ShouldBeSweptBySweeperThreads(), and unswept_free_bytes_.

Referenced by ReleasePage().

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

◆ DecrementUnsweptFreeBytes()

void v8::internal::PagedSpace::DecrementUnsweptFreeBytes ( intptr_t  by)
inline

Definition at line 1843 of file spaces.h.

1843 { unswept_free_bytes_ -= by; }

References unswept_free_bytes_.

◆ EmptyAllocationInfo()

void v8::internal::PagedSpace::EmptyAllocationInfo ( )
inline

Definition at line 1789 of file spaces.h.

1789  {
1790  // Mark the old linear allocation area with a free space map so it can be
1791  // skipped when scanning the heap.
1792  int old_linear_size = static_cast<int>(limit() - top());
1793  Free(top(), old_linear_size);
1795  }
void SetTopAndLimit(Address top, Address limit)
Definition: spaces.h:1780
int Free(Address start, int size_in_bytes)
Definition: spaces.h:1770

References Free(), limit(), NULL, SetTopAndLimit(), and top().

Referenced by PrepareForMarkCompact().

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

◆ end_of_unswept_pages()

Page* v8::internal::PagedSpace::end_of_unswept_pages ( )
inline

Definition at line 1860 of file spaces.h.

1860 { return end_of_unswept_pages_; }

References end_of_unswept_pages_.

◆ EnsureSweeperProgress()

bool v8::internal::PagedSpace::EnsureSweeperProgress ( intptr_t  size_in_bytes)

◆ EvictEvacuationCandidatesFromFreeLists()

void v8::internal::PagedSpace::EvictEvacuationCandidatesFromFreeLists ( )

Definition at line 2516 of file spaces.cc.

2516  {
2517  if (allocation_info_.top() >= allocation_info_.limit()) return;
2518 
2519  if (Page::FromAllocationTop(allocation_info_.top())
2520  ->IsEvacuationCandidate()) {
2521  // Create filler object to keep page iterable if it was iterable.
2522  int remaining =
2523  static_cast<int>(allocation_info_.limit() - allocation_info_.top());
2524  heap()->CreateFillerObjectAt(allocation_info_.top(), remaining);
2525 
2526  allocation_info_.set_top(NULL);
2527  allocation_info_.set_limit(NULL);
2528  }
2529 }
void CreateFillerObjectAt(Address addr, int size)
Definition: heap.cc:3221

References allocation_info_, v8::internal::Heap::CreateFillerObjectAt(), v8::internal::Space::heap(), and NULL.

Referenced by v8::internal::MarkCompactCollector::StartCompaction().

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

◆ Expand()

bool v8::internal::PagedSpace::Expand ( )
protected

Definition at line 965 of file spaces.cc.

965  {
966  if (!CanExpand()) return false;
967 
968  intptr_t size = AreaSize();
969 
970  if (anchor_.next_page() == &anchor_) {
971  size = SizeOfFirstPage();
972  }
973 
974  Page* p = heap()->isolate()->memory_allocator()->AllocatePage(size, this,
975  executable());
976  if (p == NULL) return false;
977 
979 
980  p->InsertAfter(anchor_.prev_page());
981 
982  return true;
983 }
Page * AllocatePage(intptr_t size, PagedSpace *owner, Executability executable)
Definition: spaces.cc:680
Page * next_page()
Definition: spaces-inl.h:209
Page * prev_page()
Definition: spaces-inl.h:215
intptr_t SizeOfFirstPage()
Definition: spaces.cc:986

References v8::internal::MemoryAllocator::AllocatePage(), anchor_, AreaSize(), CanExpand(), Capacity(), DCHECK, v8::internal::Space::executable(), v8::internal::Space::heap(), v8::internal::MemoryChunk::InsertAfter(), v8::internal::Heap::isolate(), max_capacity_, v8::internal::Isolate::memory_allocator(), v8::internal::Page::next_page(), NULL, v8::internal::Page::prev_page(), size, and SizeOfFirstPage().

Referenced by SlowAllocateRaw().

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

◆ FindObject()

Object * v8::internal::PagedSpace::FindObject ( Address  addr)

Definition at line 932 of file spaces.cc.

932  {
933  // Note: this function can only be called on iterable spaces.
934  DCHECK(!heap()->mark_compact_collector()->in_use());
935 
936  if (!Contains(addr)) return Smi::FromInt(0); // Signaling not found.
937 
938  Page* p = Page::FromAddress(addr);
939  HeapObjectIterator it(p, NULL);
940  for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
941  Address cur = obj->address();
942  Address next = cur + obj->Size();
943  if ((cur <= addr) && (addr < next)) return obj;
944  }
945 
946  UNREACHABLE();
947  return Smi::FromInt(0);
948 }
static Smi * FromInt(int value)
Definition: objects-inl.h:1321
#define UNREACHABLE()
Definition: logging.h:30

References Contains(), DCHECK, v8::internal::MemoryChunk::FromAddress(), v8::internal::Smi::FromInt(), v8::internal::Space::heap(), v8::internal::HeapObjectIterator::Next(), NULL, and UNREACHABLE.

+ Here is the call graph for this function:

◆ FirstPage()

Page* v8::internal::PagedSpace::FirstPage ( )
inline

Definition at line 1862 of file spaces.h.

1862 { return anchor_.next_page(); }

References anchor_, and v8::internal::Page::next_page().

Referenced by v8::internal::Heap::AllocateCode().

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

◆ Free()

int v8::internal::PagedSpace::Free ( Address  start,
int  size_in_bytes 
)
inline

Definition at line 1770 of file spaces.h.

1770  {
1771  int wasted = free_list_.Free(start, size_in_bytes);
1772  accounting_stats_.DeallocateBytes(size_in_bytes);
1773  accounting_stats_.WasteBytes(wasted);
1774  return size_in_bytes - wasted;
1775  }
int Free(Address start, int size_in_bytes)
Definition: spaces.cc:2177

References accounting_stats_, v8::internal::FreeList::Free(), and free_list_.

Referenced by v8::internal::FreeList::Allocate(), and EmptyAllocationInfo().

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

◆ free_list()

FreeList* v8::internal::PagedSpace::free_list ( )
inlineprotected

Definition at line 1882 of file spaces.h.

1882 { return &free_list_; }

References free_list_.

◆ FreeEmergencyMemory()

void v8::internal::PagedSpace::FreeEmergencyMemory ( )

Definition at line 1103 of file spaces.cc.

1103  {
1104  Page* page = static_cast<Page*>(emergency_memory_);
1105  DCHECK(page->LiveBytes() == 0);
1106  DCHECK(AreaSize() == page->area_size());
1108  heap()->isolate()->memory_allocator()->Free(page);
1110 }
bool ContainsPageFreeListItems(Page *p)
Definition: spaces.cc:2418
void Free(MemoryChunk *chunk)
Definition: spaces.cc:700

References v8::internal::MemoryChunk::area_size(), AreaSize(), v8::internal::FreeList::ContainsPageFreeListItems(), DCHECK, emergency_memory_, v8::internal::MemoryAllocator::Free(), free_list_, v8::internal::Space::heap(), v8::internal::Heap::isolate(), v8::internal::MemoryChunk::LiveBytes(), v8::internal::Isolate::memory_allocator(), and NULL.

+ Here is the call graph for this function:

◆ HasBeenSetUp()

bool v8::internal::PagedSpace::HasBeenSetUp ( )

Definition at line 906 of file spaces.cc.

906 { return true; }

◆ HasEmergencyMemory()

bool v8::internal::PagedSpace::HasEmergencyMemory ( )
inline

Definition at line 1879 of file spaces.h.

1879 { return emergency_memory_ != NULL; }

References emergency_memory_, and NULL.

◆ IncreaseCapacity()

void v8::internal::PagedSpace::IncreaseCapacity ( int  size)

Definition at line 1056 of file spaces.cc.

1056  {
1057  accounting_stats_.ExpandSpace(size);
1058 }

References accounting_stats_, and size.

◆ IncreaseUnsweptFreeBytes()

void v8::internal::PagedSpace::IncreaseUnsweptFreeBytes ( Page p)
inline

Definition at line 1838 of file spaces.h.

1838  {
1840  unswept_free_bytes_ += (p->area_size() - p->LiveBytes());
1841  }

References v8::internal::MemoryChunk::area_size(), DCHECK, v8::internal::MemoryChunk::LiveBytes(), ShouldBeSweptBySweeperThreads(), and unswept_free_bytes_.

+ Here is the call graph for this function:

◆ IncrementUnsweptFreeBytes()

void v8::internal::PagedSpace::IncrementUnsweptFreeBytes ( intptr_t  by)
inline

Definition at line 1836 of file spaces.h.

1836 { unswept_free_bytes_ += by; }

References unswept_free_bytes_.

◆ LastPage()

Page* v8::internal::PagedSpace::LastPage ( )
inline

Definition at line 1863 of file spaces.h.

1863 { return anchor_.prev_page(); }

References anchor_, and v8::internal::Page::prev_page().

+ Here is the call graph for this function:

◆ limit()

Address v8::internal::PagedSpace::limit ( )
inline

Definition at line 1752 of file spaces.h.

1752 { return allocation_info_.limit(); }

References allocation_info_.

Referenced by v8::internal::FreeList::Allocate(), EmptyAllocationInfo(), v8::internal::HeapObjectIterator::FromCurrentPage(), v8::internal::InnerPointerToCodeCache::GcSafeFindCodeForInnerPointer(), SetTopAndLimit(), and SizeOfObjects().

+ Here is the caller graph for this function:

◆ MaximumCommittedMemory()

intptr_t v8::internal::PagedSpace::MaximumCommittedMemory ( )
inline

Definition at line 1695 of file spaces.h.

1695 { return accounting_stats_.MaxCapacity(); }

References accounting_stats_.

Referenced by v8::internal::Heap::TearDown().

+ Here is the caller graph for this function:

◆ ObtainFreeListStatistics()

void v8::internal::PagedSpace::ObtainFreeListStatistics ( Page p,
SizeStats sizes 
)

Definition at line 1039 of file spaces.cc.

1039  {
1040  sizes->huge_size_ = page->available_in_huge_free_list();
1041  sizes->small_size_ = page->available_in_small_free_list();
1042  sizes->medium_size_ = page->available_in_medium_free_list();
1043  sizes->large_size_ = page->available_in_large_free_list();
1044 }

References v8::internal::PagedSpace::SizeStats::huge_size_, v8::internal::PagedSpace::SizeStats::large_size_, v8::internal::PagedSpace::SizeStats::medium_size_, and v8::internal::PagedSpace::SizeStats::small_size_.

◆ PrepareForMarkCompact()

void v8::internal::PagedSpace::PrepareForMarkCompact ( )

Definition at line 2488 of file spaces.cc.

2488  {
2489  // We don't have a linear allocation area while sweeping. It will be restored
2490  // on the first allocation after the sweep.
2492 
2493  // This counter will be increased for pages which will be swept by the
2494  // sweeper threads.
2495  unswept_free_bytes_ = 0;
2496 
2497  // Clear the free list before a full GC---it will be rebuilt afterward.
2498  free_list_.Reset();
2499 }

References EmptyAllocationInfo(), free_list_, v8::internal::FreeList::Reset(), and unswept_free_bytes_.

+ Here is the call graph for this function:

◆ ReleasePage()

void v8::internal::PagedSpace::ReleasePage ( Page page)

Definition at line 1061 of file spaces.cc.

1061  {
1062  DCHECK(page->LiveBytes() == 0);
1063  DCHECK(AreaSize() == page->area_size());
1064 
1065  if (page->WasSwept()) {
1066  intptr_t size = free_list_.EvictFreeListItems(page);
1067  accounting_stats_.AllocateBytes(size);
1068  DCHECK_EQ(AreaSize(), static_cast<int>(size));
1069  } else {
1071  }
1072 
1073  if (page->IsFlagSet(MemoryChunk::SCAN_ON_SCAVENGE)) {
1075  page->ClearFlag(MemoryChunk::SCAN_ON_SCAVENGE);
1076  }
1077 
1079 
1080  if (Page::FromAllocationTop(allocation_info_.top()) == page) {
1081  allocation_info_.set_top(NULL);
1082  allocation_info_.set_limit(NULL);
1083  }
1084 
1085  page->Unlink();
1086  if (page->IsFlagSet(MemoryChunk::CONTAINS_ONLY_DATA)) {
1087  heap()->isolate()->memory_allocator()->Free(page);
1088  } else {
1089  heap()->QueueMemoryChunkForFree(page);
1090  }
1091 
1092  DCHECK(Capacity() > 0);
1093  accounting_stats_.ShrinkSpace(AreaSize());
1094 }
intptr_t EvictFreeListItems(Page *p)
Definition: spaces.cc:2401
void QueueMemoryChunkForFree(MemoryChunk *chunk)
Definition: heap.cc:6019
void decrement_scan_on_scavenge_pages()
Definition: heap.h:746
void DecreaseUnsweptFreeBytes(Page *p)
Definition: spaces.h:1845
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206

References accounting_stats_, allocation_info_, v8::internal::MemoryChunk::area_size(), AreaSize(), Capacity(), v8::internal::MemoryChunk::ClearFlag(), v8::internal::MemoryChunk::CONTAINS_ONLY_DATA, v8::internal::FreeList::ContainsPageFreeListItems(), DCHECK, DCHECK_EQ, DecreaseUnsweptFreeBytes(), v8::internal::Heap::decrement_scan_on_scavenge_pages(), v8::internal::FreeList::EvictFreeListItems(), v8::internal::MemoryAllocator::Free(), free_list_, v8::internal::Space::heap(), v8::internal::MemoryChunk::IsFlagSet(), v8::internal::Heap::isolate(), v8::internal::MemoryChunk::LiveBytes(), v8::internal::Isolate::memory_allocator(), NULL, v8::internal::Heap::QueueMemoryChunkForFree(), v8::internal::MemoryChunk::SCAN_ON_SCAVENGE, size, v8::internal::MemoryChunk::Unlink(), and v8::internal::Page::WasSwept().

+ Here is the call graph for this function:

◆ RepairFreeListsAfterBoot()

void v8::internal::PagedSpace::RepairFreeListsAfterBoot ( )

Definition at line 2513 of file spaces.cc.

2513 { free_list_.RepairLists(heap()); }
void RepairLists(Heap *heap)
Definition: spaces.cc:2426

References free_list_, v8::internal::Space::heap(), and v8::internal::FreeList::RepairLists().

+ Here is the call graph for this function:

◆ ResetFreeList()

void v8::internal::PagedSpace::ResetFreeList ( )
inline

Definition at line 1777 of file spaces.h.

1777 { free_list_.Reset(); }

References free_list_, and v8::internal::FreeList::Reset().

+ Here is the call graph for this function:

◆ ResetFreeListStatistics()

void v8::internal::PagedSpace::ResetFreeListStatistics ( )

Definition at line 1047 of file spaces.cc.

1047  {
1048  PageIterator page_iterator(this);
1049  while (page_iterator.has_next()) {
1050  Page* page = page_iterator.next();
1051  page->ResetFreeListStatistics();
1052  }
1053 }

References PageIterator, and v8::internal::Page::ResetFreeListStatistics().

Referenced by ClearStats().

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

◆ ResetUnsweptFreeBytes()

void v8::internal::PagedSpace::ResetUnsweptFreeBytes ( )
inline

Definition at line 1850 of file spaces.h.

1850 { unswept_free_bytes_ = 0; }

References unswept_free_bytes_.

Referenced by v8::internal::MarkCompactCollector::EnsureSweepingCompleted().

+ Here is the caller graph for this function:

◆ set_end_of_unswept_pages()

void v8::internal::PagedSpace::set_end_of_unswept_pages ( Page page)
inline

Definition at line 1858 of file spaces.h.

1858 { end_of_unswept_pages_ = page; }

References end_of_unswept_pages_.

◆ SetTopAndLimit()

void v8::internal::PagedSpace::SetTopAndLimit ( Address  top,
Address  limit 
)
inline

Definition at line 1780 of file spaces.h.

1780  {
1781  DCHECK(top == limit ||
1784  allocation_info_.set_top(top);
1785  allocation_info_.set_limit(limit);
1786  }

References allocation_info_, DCHECK, v8::internal::MemoryChunk::FromAddress(), limit(), top(), and v8::internal::MemoryChunk::UpdateHighWaterMark().

Referenced by v8::internal::FreeList::Allocate(), and EmptyAllocationInfo().

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

◆ SetUp()

bool v8::internal::PagedSpace::SetUp ( )

Definition at line 903 of file spaces.cc.

903 { return true; }

Referenced by v8::internal::Heap::SetUp().

+ Here is the caller graph for this function:

◆ ShouldBeSweptBySweeperThreads()

static bool v8::internal::PagedSpace::ShouldBeSweptBySweeperThreads ( Page p)
inlinestatic

Definition at line 1831 of file spaces.h.

1831  {
1832  return !p->IsEvacuationCandidate() &&
1833  !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) && !p->WasSwept();
1834  }

References v8::internal::MemoryChunk::IsEvacuationCandidate(), v8::internal::MemoryChunk::IsFlagSet(), v8::internal::MemoryChunk::RESCAN_ON_EVACUATION, and v8::internal::Page::WasSwept().

Referenced by DecreaseUnsweptFreeBytes(), and IncreaseUnsweptFreeBytes().

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

◆ Size()

virtual intptr_t v8::internal::PagedSpace::Size ( )
inlinevirtual

Implements v8::internal::Space.

Definition at line 1739 of file spaces.h.

1739 { return accounting_stats_.Size(); }

References accounting_stats_.

Referenced by v8::internal::StatisticsExtension::GetCounters(), and SizeOfObjects().

+ Here is the caller graph for this function:

◆ SizeOfFirstPage()

intptr_t v8::internal::PagedSpace::SizeOfFirstPage ( )
protected

Definition at line 986 of file spaces.cc.

986  {
987  // If using an ool constant pool then transfer the constant pool allowance
988  // from the code space to the old pointer space.
989  static const int constant_pool_delta = FLAG_enable_ool_constant_pool ? 48 : 0;
990  int size = 0;
991  switch (identity()) {
992  case OLD_POINTER_SPACE:
993  size = (112 + constant_pool_delta) * kPointerSize * KB;
994  break;
995  case OLD_DATA_SPACE:
996  size = 192 * KB;
997  break;
998  case MAP_SPACE:
999  size = 16 * kPointerSize * KB;
1000  break;
1001  case CELL_SPACE:
1002  size = 16 * kPointerSize * KB;
1003  break;
1004  case PROPERTY_CELL_SPACE:
1005  size = 8 * kPointerSize * KB;
1006  break;
1007  case CODE_SPACE: {
1008  CodeRange* code_range = heap()->isolate()->code_range();
1009  if (code_range != NULL && code_range->valid()) {
1010  // When code range exists, code pages are allocated in a special way
1011  // (from the reserved code range). That part of the code is not yet
1012  // upgraded to handle small pages.
1013  size = AreaSize();
1014  } else {
1015  size = RoundUp((480 - constant_pool_delta) * KB *
1016  FullCodeGenerator::kBootCodeSizeMultiplier / 100,
1017  kPointerSize);
1018  }
1019  break;
1020  }
1021  default:
1022  UNREACHABLE();
1023  }
1024  return Min(size, AreaSize());
1025 }
CodeRange * code_range()
Definition: isolate.h:863
const int kPointerSize
Definition: globals.h:129
const int KB
Definition: globals.h:106
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)
@ OLD_DATA_SPACE
Definition: globals.h:361
@ PROPERTY_CELL_SPACE
Definition: globals.h:365
@ OLD_POINTER_SPACE
Definition: globals.h:360
static void RoundUp(Vector< char > buffer, int *length, int *decimal_point)
Definition: fixed-dtoa.cc:171

References AreaSize(), v8::internal::CELL_SPACE, v8::internal::Isolate::code_range(), v8::internal::CODE_SPACE, v8::internal::Space::heap(), v8::internal::Space::identity(), v8::internal::Heap::isolate(), v8::internal::KB, v8::internal::kPointerSize, v8::internal::MAP_SPACE, v8::internal::Min(), NULL, v8::internal::OLD_DATA_SPACE, v8::internal::OLD_POINTER_SPACE, v8::internal::PROPERTY_CELL_SPACE, v8::internal::RoundUp(), size, UNREACHABLE, and v8::internal::CodeRange::valid().

Referenced by Expand().

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

◆ SizeOfObjects()

intptr_t v8::internal::PagedSpace::SizeOfObjects ( )
virtual

Reimplemented from v8::internal::Space.

Definition at line 2502 of file spaces.cc.

2502  {
2503  DCHECK(heap()->mark_compact_collector()->sweeping_in_progress() ||
2504  (unswept_free_bytes_ == 0));
2505  return Size() - unswept_free_bytes_ - (limit() - top());
2506 }
virtual intptr_t Size()
Definition: spaces.h:1739

References DCHECK, v8::internal::Space::heap(), limit(), Size(), top(), and unswept_free_bytes_.

Referenced by v8::internal::Heap::PrintShortHeapStatistics(), v8::internal::Heap::PromotedSpaceSizeOfObjects(), and v8::internal::Heap::RecordStats().

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

◆ SlowAllocateRaw()

HeapObject * v8::internal::PagedSpace::SlowAllocateRaw ( int  size_in_bytes)
protected

Definition at line 2547 of file spaces.cc.

2547  {
2548  // Allocation in this space has failed.
2549 
2551  // Sweeping is still in progress.
2552  if (collector->sweeping_in_progress()) {
2553  // First try to refill the free-list, concurrent sweeper threads
2554  // may have freed some objects in the meantime.
2555  collector->RefillFreeList(this);
2556 
2557  // Retry the free list allocation.
2558  HeapObject* object = free_list_.Allocate(size_in_bytes);
2559  if (object != NULL) return object;
2560 
2561  // If sweeping is still in progress try to sweep pages on the main thread.
2562  int free_chunk = collector->SweepInParallel(this, size_in_bytes);
2563  collector->RefillFreeList(this);
2564  if (free_chunk >= size_in_bytes) {
2565  HeapObject* object = free_list_.Allocate(size_in_bytes);
2566  // We should be able to allocate an object here since we just freed that
2567  // much memory.
2568  DCHECK(object != NULL);
2569  if (object != NULL) return object;
2570  }
2571  }
2572 
2573  // Free list allocation failed and there is no next page. Fail if we have
2574  // hit the old generation size limit that should cause a garbage
2575  // collection.
2576  if (!heap()->always_allocate() &&
2577  heap()->OldGenerationAllocationLimitReached()) {
2578  // If sweeper threads are active, wait for them at that point and steal
2579  // elements form their free-lists.
2580  HeapObject* object = WaitForSweeperThreadsAndRetryAllocation(size_in_bytes);
2581  if (object != NULL) return object;
2582  }
2583 
2584  // Try to expand the space and allocate in the new next page.
2585  if (Expand()) {
2586  DCHECK(CountTotalPages() > 1 || size_in_bytes <= free_list_.available());
2587  return free_list_.Allocate(size_in_bytes);
2588  }
2589 
2590  // If sweeper threads are active, wait for them at that point and steal
2591  // elements form their free-lists. Allocation may still fail their which
2592  // would indicate that there is not enough memory for the given allocation.
2593  return WaitForSweeperThreadsAndRetryAllocation(size_in_bytes);
2594 }
MarkCompactCollector * mark_compact_collector()
Definition: heap.h:1197
void RefillFreeList(PagedSpace *space)
MUST_USE_RESULT HeapObject * WaitForSweeperThreadsAndRetryAllocation(int size_in_bytes)
Definition: spaces.cc:2532
friend class MarkCompactCollector
Definition: spaces.h:1937

References v8::internal::FreeList::Allocate(), v8::internal::FreeList::available(), CountTotalPages(), DCHECK, Expand(), free_list_, v8::internal::Space::heap(), v8::internal::Heap::mark_compact_collector(), NULL, v8::internal::MarkCompactCollector::RefillFreeList(), v8::internal::MarkCompactCollector::sweeping_in_progress(), v8::internal::MarkCompactCollector::SweepInParallel(), and WaitForSweeperThreadsAndRetryAllocation().

Referenced by AllocateRaw().

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

◆ TearDown()

void v8::internal::PagedSpace::TearDown ( )

Definition at line 909 of file spaces.cc.

909  {
910  PageIterator iterator(this);
911  while (iterator.has_next()) {
912  heap()->isolate()->memory_allocator()->Free(iterator.next());
913  }
916  accounting_stats_.Clear();
917 }
void set_next_page(Page *page)
Definition: spaces-inl.h:221
void set_prev_page(Page *page)
Definition: spaces-inl.h:227

References accounting_stats_, anchor_, v8::internal::MemoryAllocator::Free(), v8::internal::Space::heap(), v8::internal::Heap::isolate(), v8::internal::Isolate::memory_allocator(), PageIterator, v8::internal::Page::set_next_page(), and v8::internal::Page::set_prev_page().

Referenced by v8::internal::Heap::TearDown().

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

◆ top()

Address v8::internal::PagedSpace::top ( )
inline

Definition at line 1751 of file spaces.h.

1751 { return allocation_info_.top(); }

References allocation_info_.

Referenced by v8::internal::FreeList::Allocate(), v8::internal::Deserializer::DeserializePartial(), EmptyAllocationInfo(), v8::internal::HeapObjectIterator::FromCurrentPage(), v8::internal::InnerPointerToCodeCache::GcSafeFindCodeForInnerPointer(), SetTopAndLimit(), and SizeOfObjects().

+ Here is the caller graph for this function:

◆ UseEmergencyMemory()

void v8::internal::PagedSpace::UseEmergencyMemory ( )

Definition at line 1113 of file spaces.cc.

1113  {
1114  Page* page = Page::Initialize(heap(), emergency_memory_, executable(), this);
1115  page->InsertAfter(anchor_.prev_page());
1117 }
static Page * Initialize(Heap *heap, MemoryChunk *chunk, Executability executable, PagedSpace *owner)
Definition: spaces-inl.h:136

References anchor_, emergency_memory_, v8::internal::Space::executable(), v8::internal::Space::heap(), v8::internal::Page::Initialize(), v8::internal::MemoryChunk::InsertAfter(), NULL, and v8::internal::Page::prev_page().

+ Here is the call graph for this function:

◆ WaitForSweeperThreadsAndRetryAllocation()

HeapObject * v8::internal::PagedSpace::WaitForSweeperThreadsAndRetryAllocation ( int  size_in_bytes)
protected

Definition at line 2532 of file spaces.cc.

2533  {
2535  if (collector->sweeping_in_progress()) {
2536  // Wait for the sweeper threads here and complete the sweeping phase.
2537  collector->EnsureSweepingCompleted();
2538 
2539  // After waiting for the sweeper threads, there may be new free-list
2540  // entries.
2541  return free_list_.Allocate(size_in_bytes);
2542  }
2543  return NULL;
2544 }

References v8::internal::FreeList::Allocate(), v8::internal::MarkCompactCollector::EnsureSweepingCompleted(), free_list_, v8::internal::Space::heap(), v8::internal::Heap::mark_compact_collector(), NULL, and v8::internal::MarkCompactCollector::sweeping_in_progress().

Referenced by SlowAllocateRaw().

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

◆ Waste()

virtual intptr_t v8::internal::PagedSpace::Waste ( )
inlinevirtual

Definition at line 1748 of file spaces.h.

1748 { return accounting_stats_.Waste(); }

References accounting_stats_.

Friends And Related Function Documentation

◆ MarkCompactCollector

friend class MarkCompactCollector
friend

Definition at line 1937 of file spaces.h.

◆ PageIterator

friend class PageIterator
friend

Member Data Documentation

◆ accounting_stats_

AllocationStats v8::internal::PagedSpace::accounting_stats_
protected

◆ allocation_info_

◆ anchor_

Page v8::internal::PagedSpace::anchor_
protected

Definition at line 1895 of file spaces.h.

Referenced by anchor(), Expand(), FirstPage(), LastPage(), PagedSpace(), TearDown(), and UseEmergencyMemory().

◆ area_size_

int v8::internal::PagedSpace::area_size_
protected

Definition at line 1884 of file spaces.h.

Referenced by AreaSize(), and PagedSpace().

◆ emergency_memory_

MemoryChunk* v8::internal::PagedSpace::emergency_memory_
protected

◆ end_of_unswept_pages_

Page* v8::internal::PagedSpace::end_of_unswept_pages_
protected

Definition at line 1910 of file spaces.h.

Referenced by end_of_unswept_pages(), and set_end_of_unswept_pages().

◆ free_list_

◆ max_capacity_

intptr_t v8::internal::PagedSpace::max_capacity_
protected

Definition at line 1887 of file spaces.h.

Referenced by CanExpand(), Expand(), and PagedSpace().

◆ unswept_free_bytes_

intptr_t v8::internal::PagedSpace::unswept_free_bytes_
protected

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