V8 Project
v8::internal::PromotionQueue Class Reference

#include <heap.h>

+ Collaboration diagram for v8::internal::PromotionQueue:

Classes

struct  Entry
 

Public Member Functions

 PromotionQueue (Heap *heap)
 
void Initialize ()
 
void Destroy ()
 
PageGetHeadPage ()
 
void SetNewLimit (Address limit)
 
bool IsBelowPromotionQueue (Address to_space_top)
 
bool is_empty ()
 
void insert (HeapObject *target, int size)
 
void remove (HeapObject **target, int *size)
 

Private Member Functions

void RelocateQueueHead ()
 
 DISALLOW_COPY_AND_ASSIGN (PromotionQueue)
 

Private Attributes

intptr_t * front_
 
intptr_t * rear_
 
intptr_t * limit_
 
List< Entry > * emergency_stack_
 
Heapheap_
 

Static Private Attributes

static const int kEntrySizeInWords = 2
 

Detailed Description

Definition at line 371 of file heap.h.

Constructor & Destructor Documentation

◆ PromotionQueue()

v8::internal::PromotionQueue::PromotionQueue ( Heap heap)
inlineexplicit

Definition at line 373 of file heap.h.

374  : front_(NULL),
375  rear_(NULL),
376  limit_(NULL),
377  emergency_stack_(0),
378  heap_(heap) {}
List< Entry > * emergency_stack_
Definition: heap.h:457
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

Member Function Documentation

◆ Destroy()

void v8::internal::PromotionQueue::Destroy ( )
inline

Definition at line 382 of file heap.h.

382  {
383  DCHECK(is_empty());
384  delete emergency_stack_;
386  }
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, emergency_stack_, is_empty(), and NULL.

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

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

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::PromotionQueue::DISALLOW_COPY_AND_ASSIGN ( PromotionQueue  )
private

◆ GetHeadPage()

Page* v8::internal::PromotionQueue::GetHeadPage ( )
inline

Definition at line 388 of file heap.h.

388  {
389  return Page::FromAllocationTop(reinterpret_cast<Address>(rear_));
390  }
byte * Address
Definition: globals.h:101

References rear_.

Referenced by IsBelowPromotionQueue().

+ Here is the caller graph for this function:

◆ Initialize()

void v8::internal::PromotionQueue::Initialize ( )

Definition at line 1365 of file heap.cc.

1365  {
1366  // Assumes that a NewSpacePage exactly fits a number of promotion queue
1367  // entries (where each is a pair of intptr_t). This allows us to simplify
1368  // the test fpr when to switch pages.
1370  0);
1371  limit_ = reinterpret_cast<intptr_t*>(heap_->new_space()->ToSpaceStart());
1372  front_ = rear_ =
1373  reinterpret_cast<intptr_t*>(heap_->new_space()->ToSpaceEnd());
1375 }
NewSpace * new_space()
Definition: heap.h:593
static const int kBodyOffset
Definition: spaces.h:543
Address ToSpaceEnd()
Definition: spaces.h:2489
Address ToSpaceStart()
Definition: spaces.h:2488
static const int kPageSize
Definition: spaces.h:748
const int kPointerSize
Definition: globals.h:129

References DCHECK, emergency_stack_, front_, heap_, v8::internal::MemoryChunk::kBodyOffset, v8::internal::Page::kPageSize, v8::internal::kPointerSize, limit_, v8::internal::Heap::new_space(), NULL, rear_, v8::internal::NewSpace::ToSpaceEnd(), and v8::internal::NewSpace::ToSpaceStart().

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

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

◆ insert()

void v8::internal::PromotionQueue::insert ( HeapObject target,
int  size 
)
inline

Definition at line 24 of file heap-inl.h.

24  {
25  if (emergency_stack_ != NULL) {
26  emergency_stack_->Add(Entry(target, size));
27  return;
28  }
29 
30  if (NewSpacePage::IsAtStart(reinterpret_cast<Address>(rear_))) {
31  NewSpacePage* rear_page =
32  NewSpacePage::FromAddress(reinterpret_cast<Address>(rear_));
33  DCHECK(!rear_page->prev_page()->is_anchor());
34  rear_ = reinterpret_cast<intptr_t*>(rear_page->prev_page()->area_end());
35  }
36 
37  if ((rear_ - 2) < limit_) {
39  emergency_stack_->Add(Entry(target, size));
40  return;
41  }
42 
43  *(--rear_) = reinterpret_cast<intptr_t>(target);
44  *(--rear_) = size;
45 // Assert no overflow into live objects.
46 #ifdef DEBUG
47  SemiSpace::AssertValidRange(target->GetIsolate()->heap()->new_space()->top(),
48  reinterpret_cast<Address>(rear_));
49 #endif
50 }
static bool IsAtStart(Address addr)
Definition: spaces.h:2009
static NewSpacePage * FromAddress(Address address_in_page)
Definition: spaces.h:2021
static void AssertValidRange(Address from, Address to)
Definition: spaces.h:2165
enable harmony numeric enable harmony object literal extensions Optimize object size

References v8::internal::MemoryChunk::area_end(), v8::internal::SemiSpace::AssertValidRange(), DCHECK, emergency_stack_, v8::internal::NewSpacePage::FromAddress(), v8::internal::HeapObject::GetIsolate(), v8::internal::Isolate::heap(), v8::internal::NewSpacePage::is_anchor(), v8::internal::NewSpacePage::IsAtStart(), limit_, v8::internal::Heap::new_space(), NULL, v8::internal::NewSpacePage::prev_page(), rear_, RelocateQueueHead(), size, and v8::internal::NewSpace::top().

Referenced by v8::internal::ScavengingVisitor< marks_handling, logging_and_profiling_mode >::PromoteObject().

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

◆ is_empty()

bool v8::internal::PromotionQueue::is_empty ( )
inline

Definition at line 414 of file heap.h.

414  {
415  return (front_ == rear_) &&
416  (emergency_stack_ == NULL || emergency_stack_->length() == 0);
417  }

References emergency_stack_, front_, NULL, and rear_.

Referenced by Destroy(), and remove().

+ Here is the caller graph for this function:

◆ IsBelowPromotionQueue()

bool v8::internal::PromotionQueue::IsBelowPromotionQueue ( Address  to_space_top)
inline

Definition at line 402 of file heap.h.

402  {
403  // If the given to-space top pointer and the head of the promotion queue
404  // are not on the same page, then the to-space objects are below the
405  // promotion queue.
406  if (GetHeadPage() != Page::FromAddress(to_space_top)) {
407  return true;
408  }
409  // If the to space top pointer is smaller or equal than the promotion
410  // queue head, then the to-space objects are below the promotion queue.
411  return reinterpret_cast<intptr_t*>(to_space_top) <= rear_;
412  }
static MemoryChunk * FromAddress(Address a)
Definition: spaces.h:276

References v8::internal::MemoryChunk::FromAddress(), GetHeadPage(), and rear_.

Referenced by v8::internal::ScavengingVisitor< marks_handling, logging_and_profiling_mode >::INLINE().

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

◆ RelocateQueueHead()

void v8::internal::PromotionQueue::RelocateQueueHead ( )
private

Definition at line 1378 of file heap.cc.

1378  {
1380 
1381  Page* p = Page::FromAllocationTop(reinterpret_cast<Address>(rear_));
1382  intptr_t* head_start = rear_;
1383  intptr_t* head_end = Min(front_, reinterpret_cast<intptr_t*>(p->area_end()));
1384 
1385  int entries_count =
1386  static_cast<int>(head_end - head_start) / kEntrySizeInWords;
1387 
1388  emergency_stack_ = new List<Entry>(2 * entries_count);
1389 
1390  while (head_start != head_end) {
1391  int size = static_cast<int>(*(head_start++));
1392  HeapObject* obj = reinterpret_cast<HeapObject*>(*(head_start++));
1393  emergency_stack_->Add(Entry(obj, size));
1394  }
1395  rear_ = head_end;
1396 }
static const int kEntrySizeInWords
Definition: heap.h:449
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)

References v8::internal::MemoryChunk::area_end(), DCHECK, emergency_stack_, front_, kEntrySizeInWords, v8::internal::Min(), NULL, rear_, and size.

Referenced by insert(), and SetNewLimit().

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

◆ remove()

void v8::internal::PromotionQueue::remove ( HeapObject **  target,
int size 
)
inline

Definition at line 421 of file heap.h.

421  {
422  DCHECK(!is_empty());
423  if (front_ == rear_) {
424  Entry e = emergency_stack_->RemoveLast();
425  *target = e.obj_;
426  *size = e.size_;
427  return;
428  }
429 
430  if (NewSpacePage::IsAtStart(reinterpret_cast<Address>(front_))) {
431  NewSpacePage* front_page =
432  NewSpacePage::FromAddress(reinterpret_cast<Address>(front_));
433  DCHECK(!front_page->prev_page()->is_anchor());
434  front_ = reinterpret_cast<intptr_t*>(front_page->prev_page()->area_end());
435  }
436  *target = reinterpret_cast<HeapObject*>(*(--front_));
437  *size = static_cast<int>(*(--front_));
438  // Assert no underflow.
439  SemiSpace::AssertValidRange(reinterpret_cast<Address>(rear_),
440  reinterpret_cast<Address>(front_));
441  }

References v8::internal::MemoryChunk::area_end(), v8::internal::SemiSpace::AssertValidRange(), DCHECK, emergency_stack_, v8::internal::NewSpacePage::FromAddress(), front_, v8::internal::NewSpacePage::is_anchor(), is_empty(), v8::internal::NewSpacePage::IsAtStart(), v8::internal::PromotionQueue::Entry::obj_, v8::internal::NewSpacePage::prev_page(), rear_, size, and v8::internal::PromotionQueue::Entry::size_.

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

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

◆ SetNewLimit()

void v8::internal::PromotionQueue::SetNewLimit ( Address  limit)
inline

Definition at line 392 of file heap.h.

392  {
393  limit_ = reinterpret_cast<intptr_t*>(limit);
394 
395  if (limit_ <= rear_) {
396  return;
397  }
398 
400  }

References limit_, rear_, and RelocateQueueHead().

Referenced by v8::internal::NewSpace::AddFreshPage(), and v8::internal::ScavengingVisitor< marks_handling, logging_and_profiling_mode >::SemiSpaceCopyObject().

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

Member Data Documentation

◆ emergency_stack_

List<Entry>* v8::internal::PromotionQueue::emergency_stack_
private

Definition at line 457 of file heap.h.

Referenced by Destroy(), Initialize(), insert(), is_empty(), RelocateQueueHead(), and remove().

◆ front_

intptr_t* v8::internal::PromotionQueue::front_
private

Definition at line 445 of file heap.h.

Referenced by Initialize(), is_empty(), RelocateQueueHead(), and remove().

◆ heap_

Heap* v8::internal::PromotionQueue::heap_
private

Definition at line 459 of file heap.h.

Referenced by Initialize().

◆ kEntrySizeInWords

const int v8::internal::PromotionQueue::kEntrySizeInWords = 2
staticprivate

Definition at line 449 of file heap.h.

Referenced by RelocateQueueHead().

◆ limit_

intptr_t* v8::internal::PromotionQueue::limit_
private

Definition at line 447 of file heap.h.

Referenced by Initialize(), insert(), and SetNewLimit().

◆ rear_

intptr_t* v8::internal::PromotionQueue::rear_
private

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