V8 Project
v8::internal::HandleScopeImplementer Class Reference

#include <api.h>

+ Collaboration diagram for v8::internal::HandleScopeImplementer:

Public Member Functions

 HandleScopeImplementer (Isolate *isolate)
 
 ~HandleScopeImplementer ()
 
char * RestoreThread (char *from)
 
char * ArchiveThread (char *to)
 
void FreeThreadResources ()
 
void Iterate (v8::internal::ObjectVisitor *v)
 
internal::Object ** GetSpareOrNewBlock ()
 
void DeleteExtensions (internal::Object **prev_limit)
 
void IncrementCallDepth ()
 
void DecrementCallDepth ()
 
bool CallDepthIsZero ()
 
void EnterContext (Handle< Context > context)
 
void LeaveContext ()
 
bool LastEnteredContextWas (Handle< Context > context)
 
Handle< ContextLastEnteredContext ()
 
void SaveContext (Context *context)
 
ContextRestoreContext ()
 
bool HasSavedContexts ()
 
List< internal::Object ** > * blocks ()
 
Isolateisolate () const
 
void ReturnBlock (Object **block)
 

Static Public Member Functions

static int ArchiveSpacePerThread ()
 
static char * Iterate (v8::internal::ObjectVisitor *v, char *data)
 

Private Member Functions

void ResetAfterArchive ()
 
void Free ()
 
void BeginDeferredScope ()
 
DeferredHandlesDetach (Object **prev_limit)
 
void IterateThis (ObjectVisitor *v)
 
char * RestoreThreadHelper (char *from)
 
char * ArchiveThreadHelper (char *to)
 
 DISALLOW_COPY_AND_ASSIGN (HandleScopeImplementer)
 

Private Attributes

Isolateisolate_
 
List< internal::Object ** > blocks_
 
List< Context * > entered_contexts_
 
List< Context * > saved_contexts_
 
Object ** spare_
 
int call_depth_
 
Object ** last_handle_before_deferred_block_
 
HandleScopeData handle_scope_data_
 

Friends

class DeferredHandles
 
class DeferredHandleScope
 

Detailed Description

Definition at line 492 of file api.h.

Constructor & Destructor Documentation

◆ HandleScopeImplementer()

v8::internal::HandleScopeImplementer::HandleScopeImplementer ( Isolate isolate)
inlineexplicit

Definition at line 494 of file api.h.

495  : isolate_(isolate),
496  blocks_(0),
498  saved_contexts_(0),
499  spare_(NULL),
500  call_depth_(0),
List< internal::Object ** > blocks_
Definition: api.h:574
List< Context * > entered_contexts_
Definition: api.h:576
List< Context * > saved_contexts_
Definition: api.h:578
Isolate * isolate() const
Definition: api.h:538
Object ** last_handle_before_deferred_block_
Definition: api.h:581
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

◆ ~HandleScopeImplementer()

v8::internal::HandleScopeImplementer::~HandleScopeImplementer ( )
inline

Definition at line 503 of file api.h.

503  {
505  }
void DeleteArray(T *array)
Definition: allocation.h:68

References v8::internal::DeleteArray(), and spare_.

+ Here is the call graph for this function:

Member Function Documentation

◆ ArchiveSpacePerThread()

int v8::internal::HandleScopeImplementer::ArchiveSpacePerThread ( )
static

Definition at line 7541 of file api.cc.

7541  {
7542  return sizeof(HandleScopeImplementer);
7543 }
HandleScopeImplementer(Isolate *isolate)
Definition: api.h:494

Referenced by v8::internal::ArchiveSpacePerThread(), and v8::internal::ThreadManager::IterateArchivedThreads().

+ Here is the caller graph for this function:

◆ ArchiveThread()

char * v8::internal::HandleScopeImplementer::ArchiveThread ( char *  to)

Definition at line 7529 of file api.cc.

7529  {
7530  HandleScopeData* current = isolate_->handle_scope_data();
7531  handle_scope_data_ = *current;
7532  MemCopy(storage, this, sizeof(*this));
7533 
7535  current->Initialize();
7536 
7537  return storage + ArchiveSpacePerThread();
7538 }
HandleScopeData handle_scope_data_
Definition: api.h:583
HandleScopeData * handle_scope_data()
Definition: isolate.h:899
void MemCopy(void *dest, const void *src, size_t size)
Definition: utils.h:350

References v8::internal::ArchiveSpacePerThread(), v8::internal::HandleScopeData::Initialize(), and v8::internal::MemCopy().

Referenced by v8::internal::ThreadManager::EagerlyArchiveThread().

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

◆ ArchiveThreadHelper()

char* v8::internal::HandleScopeImplementer::ArchiveThreadHelper ( char *  to)
private

◆ BeginDeferredScope()

void v8::internal::HandleScopeImplementer::BeginDeferredScope ( )
private

Definition at line 7633 of file api.cc.

7633  {
7636 }
#define DCHECK(condition)
Definition: logging.h:205
internal::Object ** next
Definition: handles.h:285

References DCHECK, v8::internal::Isolate::handle_scope_data(), v8::internal::HandleScopeData::next, and NULL.

Referenced by v8::internal::DeferredHandleScope::DeferredHandleScope().

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

◆ blocks()

List<internal::Object**>* v8::internal::HandleScopeImplementer::blocks ( )
inline

Definition at line 537 of file api.h.

537 { return &blocks_; }

References blocks_.

Referenced by v8::internal::DeferredHandleScope::DeferredHandleScope(), v8::internal::Deserializer::Deserialize(), v8::internal::HandleScope::Extend(), v8::internal::HandleScope::NumberOfHandles(), and v8::internal::StartupSerializer::SerializeStrongReferences().

+ Here is the caller graph for this function:

◆ CallDepthIsZero()

bool v8::internal::HandleScopeImplementer::CallDepthIsZero ( )
inline

Definition at line 523 of file api.h.

523 { return call_depth_ == 0; }

References call_depth_.

◆ DecrementCallDepth()

void v8::internal::HandleScopeImplementer::DecrementCallDepth ( )
inline

Definition at line 522 of file api.h.

522 {call_depth_--;}

References call_depth_.

◆ DeleteExtensions()

void v8::internal::HandleScopeImplementer::DeleteExtensions ( internal::Object **  prev_limit)
inline

Definition at line 645 of file api.h.

645  {
646  while (!blocks_.is_empty()) {
647  internal::Object** block_start = blocks_.last();
648  internal::Object** block_limit = block_start + kHandleBlockSize;
649 #ifdef DEBUG
650  // SealHandleScope may make the prev_limit to point inside the block.
651  if (block_start <= prev_limit && prev_limit <= block_limit) {
652 #ifdef ENABLE_HANDLE_ZAPPING
653  internal::HandleScope::ZapRange(prev_limit, block_limit);
654 #endif
655  break;
656  }
657 #else
658  if (prev_limit == block_limit) break;
659 #endif
660 
661  blocks_.RemoveLast();
662 #ifdef ENABLE_HANDLE_ZAPPING
663  internal::HandleScope::ZapRange(block_start, block_limit);
664 #endif
665  if (spare_ != NULL) {
667  }
668  spare_ = block_start;
669  }
670  DCHECK((blocks_.is_empty() && prev_limit == NULL) ||
671  (!blocks_.is_empty() && prev_limit != NULL));
672 }
kSerializedDataOffset Object
Definition: objects-inl.h:5322
const int kHandleBlockSize
Definition: api.h:596

References blocks_, DCHECK, v8::internal::DeleteArray(), v8::internal::kHandleBlockSize, NULL, and spare_.

Referenced by v8::internal::HandleScope::DeleteExtensions().

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

◆ Detach()

DeferredHandles * v8::internal::HandleScopeImplementer::Detach ( Object **  prev_limit)
private

Definition at line 7605 of file api.cc.

7605  {
7606  DeferredHandles* deferred =
7607  new DeferredHandles(isolate()->handle_scope_data()->next, isolate());
7608 
7609  while (!blocks_.is_empty()) {
7610  Object** block_start = blocks_.last();
7611  Object** block_limit = &block_start[kHandleBlockSize];
7612  // We should not need to check for SealHandleScope here. Assert this.
7613  DCHECK(prev_limit == block_limit ||
7614  !(block_start <= prev_limit && prev_limit <= block_limit));
7615  if (prev_limit == block_limit) break;
7616  deferred->blocks_.Add(blocks_.last());
7617  blocks_.RemoveLast();
7618  }
7619 
7620  // deferred->blocks_ now contains the blocks installed on the
7621  // HandleScope stack since BeginDeferredScope was called, but in
7622  // reverse order.
7623 
7624  DCHECK(prev_limit == NULL || !blocks_.is_empty());
7625 
7626  DCHECK(!blocks_.is_empty() && prev_limit != NULL);
7629  return deferred;
7630 }

References v8::internal::DeferredHandles::blocks_, DCHECK, v8::internal::kHandleBlockSize, and NULL.

Referenced by v8::internal::DeferredHandleScope::Detach().

+ Here is the caller graph for this function:

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::HandleScopeImplementer::DISALLOW_COPY_AND_ASSIGN ( HandleScopeImplementer  )
private

◆ EnterContext()

void v8::internal::HandleScopeImplementer::EnterContext ( Handle< Context context)
inline

Definition at line 614 of file api.h.

614  {
615  entered_contexts_.Add(*context);
616 }

References entered_contexts_.

Referenced by v8::Context::Enter().

+ Here is the caller graph for this function:

◆ Free()

void v8::internal::HandleScopeImplementer::Free ( )
inlineprivate

Definition at line 556 of file api.h.

556  {
557  DCHECK(blocks_.length() == 0);
558  DCHECK(entered_contexts_.length() == 0);
559  DCHECK(saved_contexts_.length() == 0);
560  blocks_.Free();
561  entered_contexts_.Free();
562  saved_contexts_.Free();
563  if (spare_ != NULL) {
565  spare_ = NULL;
566  }
567  DCHECK(call_depth_ == 0);
568  }

References blocks_, call_depth_, DCHECK, v8::internal::DeleteArray(), entered_contexts_, NULL, saved_contexts_, and spare_.

+ Here is the call graph for this function:

◆ FreeThreadResources()

void v8::internal::HandleScopeImplementer::FreeThreadResources ( )

Definition at line 7524 of file api.cc.

7524  {
7525  Free();
7526 }

References v8::internal::Free().

Referenced by v8::internal::ThreadManager::FreeThreadResources().

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

◆ GetSpareOrNewBlock()

internal::Object ** v8::internal::HandleScopeImplementer::GetSpareOrNewBlock ( )
inline

Definition at line 636 of file api.h.

636  {
637  internal::Object** block = (spare_ != NULL) ?
638  spare_ :
639  NewArray<internal::Object*>(kHandleBlockSize);
640  spare_ = NULL;
641  return block;
642 }

References v8::internal::kHandleBlockSize, NULL, and spare_.

Referenced by v8::internal::DeferredHandleScope::DeferredHandleScope(), and v8::internal::HandleScope::Extend().

+ Here is the caller graph for this function:

◆ HasSavedContexts()

bool v8::internal::HandleScopeImplementer::HasSavedContexts ( )
inline

Definition at line 609 of file api.h.

609  {
610  return !saved_contexts_.is_empty();
611 }

References saved_contexts_.

◆ IncrementCallDepth()

void v8::internal::HandleScopeImplementer::IncrementCallDepth ( )
inline

Definition at line 521 of file api.h.

521 {call_depth_++;}

References call_depth_.

Referenced by v8::Isolate::SuppressMicrotaskExecutionScope::SuppressMicrotaskExecutionScope().

+ Here is the caller graph for this function:

◆ isolate()

Isolate* v8::internal::HandleScopeImplementer::isolate ( ) const
inline

Definition at line 538 of file api.h.

538 { return isolate_; }

References isolate_.

Referenced by v8::internal::DeferredHandleScope::DeferredHandleScope(), v8::internal::DeferredHandleScope::Detach(), and v8::internal::DeferredHandleScope::~DeferredHandleScope().

+ Here is the caller graph for this function:

◆ Iterate() [1/2]

void v8::internal::HandleScopeImplementer::Iterate ( v8::internal::ObjectVisitor v)

Definition at line 7590 of file api.cc.

7590  {
7591  HandleScopeData* current = isolate_->handle_scope_data();
7592  handle_scope_data_ = *current;
7593  IterateThis(v);
7594 }
void IterateThis(ObjectVisitor *v)
Definition: api.cc:7553

Referenced by v8::internal::ThreadManager::Iterate(), v8::internal::Heap::IterateStrongRoots(), and v8::internal::MarkCompactCollector::PrepareForCodeFlushing().

+ Here is the caller graph for this function:

◆ Iterate() [2/2]

char * v8::internal::HandleScopeImplementer::Iterate ( v8::internal::ObjectVisitor v,
char *  data 
)
static

Definition at line 7597 of file api.cc.

7597  {
7598  HandleScopeImplementer* scope_implementer =
7599  reinterpret_cast<HandleScopeImplementer*>(storage);
7600  scope_implementer->IterateThis(v);
7601  return storage + ArchiveSpacePerThread();
7602 }

References v8::internal::ArchiveSpacePerThread(), and IterateThis().

+ Here is the call graph for this function:

◆ IterateThis()

void v8::internal::HandleScopeImplementer::IterateThis ( ObjectVisitor v)
private

Definition at line 7553 of file api.cc.

7553  {
7554 #ifdef DEBUG
7555  bool found_block_before_deferred = false;
7556 #endif
7557  // Iterate over all handles in the blocks except for the last.
7558  for (int i = blocks()->length() - 2; i >= 0; --i) {
7559  Object** block = blocks()->at(i);
7563  v->VisitPointers(block, last_handle_before_deferred_block_);
7564  DCHECK(!found_block_before_deferred);
7565 #ifdef DEBUG
7566  found_block_before_deferred = true;
7567 #endif
7568  } else {
7569  v->VisitPointers(block, &block[kHandleBlockSize]);
7570  }
7571  }
7572 
7574  found_block_before_deferred);
7575 
7576  // Iterate over live handles in the last block (if any).
7577  if (!blocks()->is_empty()) {
7578  v->VisitPointers(blocks()->last(), handle_scope_data_.next);
7579  }
7580 
7581  List<Context*>* context_lists[2] = { &saved_contexts_, &entered_contexts_};
7582  for (unsigned i = 0; i < arraysize(context_lists); i++) {
7583  if (context_lists[i]->is_empty()) continue;
7584  Object** start = reinterpret_cast<Object**>(&context_lists[i]->first());
7585  v->VisitPointers(start, start + context_lists[i]->length());
7586  }
7587 }
List< internal::Object ** > * blocks()
Definition: api.h:537
#define arraysize(array)
Definition: macros.h:86

References arraysize, DCHECK, v8::internal::List< T, AllocationPolicy >::first(), v8::internal::kHandleBlockSize, and NULL.

Referenced by Iterate().

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

◆ LastEnteredContext()

Handle< Context > v8::internal::HandleScopeImplementer::LastEnteredContext ( )
inline

Definition at line 629 of file api.h.

629  {
630  if (entered_contexts_.is_empty()) return Handle<Context>::null();
631  return Handle<Context>(entered_contexts_.last());
632 }
static Handle< T > null()
Definition: handles.h:123

References entered_contexts_, and v8::internal::Handle< T >::null().

Referenced by v8::Isolate::GetEnteredContext().

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

◆ LastEnteredContextWas()

bool v8::internal::HandleScopeImplementer::LastEnteredContextWas ( Handle< Context context)
inline

Definition at line 624 of file api.h.

624  {
625  return !entered_contexts_.is_empty() && entered_contexts_.last() == *context;
626 }

References entered_contexts_.

Referenced by v8::Context::Exit().

+ Here is the caller graph for this function:

◆ LeaveContext()

void v8::internal::HandleScopeImplementer::LeaveContext ( )
inline

Definition at line 619 of file api.h.

619  {
620  entered_contexts_.RemoveLast();
621 }

References entered_contexts_.

Referenced by v8::Context::Exit().

+ Here is the caller graph for this function:

◆ ResetAfterArchive()

void v8::internal::HandleScopeImplementer::ResetAfterArchive ( )
inlineprivate

Definition at line 547 of file api.h.

547  {
548  blocks_.Initialize(0);
549  entered_contexts_.Initialize(0);
550  saved_contexts_.Initialize(0);
551  spare_ = NULL;
553  call_depth_ = 0;
554  }

References blocks_, call_depth_, entered_contexts_, last_handle_before_deferred_block_, NULL, saved_contexts_, and spare_.

◆ RestoreContext()

Context * v8::internal::HandleScopeImplementer::RestoreContext ( )
inline

Definition at line 604 of file api.h.

604  {
605  return saved_contexts_.RemoveLast();
606 }

References saved_contexts_.

Referenced by v8::Context::Exit().

+ Here is the caller graph for this function:

◆ RestoreThread()

char * v8::internal::HandleScopeImplementer::RestoreThread ( char *  from)

Definition at line 7546 of file api.cc.

7546  {
7547  MemCopy(this, storage, sizeof(*this));
7549  return storage + ArchiveSpacePerThread();
7550 }

References v8::internal::ArchiveSpacePerThread(), and v8::internal::MemCopy().

Referenced by v8::internal::ThreadManager::RestoreThread().

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

◆ RestoreThreadHelper()

char* v8::internal::HandleScopeImplementer::RestoreThreadHelper ( char *  from)
private

◆ ReturnBlock()

void v8::internal::HandleScopeImplementer::ReturnBlock ( Object **  block)
inline

Definition at line 540 of file api.h.

540  {
541  DCHECK(block != NULL);
542  if (spare_ != NULL) DeleteArray(spare_);
543  spare_ = block;
544  }

References DCHECK, v8::internal::DeleteArray(), NULL, and spare_.

+ Here is the call graph for this function:

◆ SaveContext()

void v8::internal::HandleScopeImplementer::SaveContext ( Context context)
inline

Definition at line 599 of file api.h.

599  {
600  saved_contexts_.Add(context);
601 }

References saved_contexts_.

Referenced by v8::Context::Enter().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ DeferredHandles

friend class DeferredHandles
friend

Definition at line 589 of file api.h.

◆ DeferredHandleScope

friend class DeferredHandleScope
friend

Definition at line 590 of file api.h.

Member Data Documentation

◆ blocks_

List<internal::Object**> v8::internal::HandleScopeImplementer::blocks_
private

Definition at line 574 of file api.h.

Referenced by blocks(), DeleteExtensions(), Free(), and ResetAfterArchive().

◆ call_depth_

int v8::internal::HandleScopeImplementer::call_depth_
private

◆ entered_contexts_

List<Context*> v8::internal::HandleScopeImplementer::entered_contexts_
private

◆ handle_scope_data_

HandleScopeData v8::internal::HandleScopeImplementer::handle_scope_data_
private

Definition at line 583 of file api.h.

◆ isolate_

Isolate* v8::internal::HandleScopeImplementer::isolate_
private

Definition at line 573 of file api.h.

Referenced by isolate().

◆ last_handle_before_deferred_block_

Object** v8::internal::HandleScopeImplementer::last_handle_before_deferred_block_
private

Definition at line 581 of file api.h.

Referenced by ResetAfterArchive().

◆ saved_contexts_

List<Context*> v8::internal::HandleScopeImplementer::saved_contexts_
private

Definition at line 578 of file api.h.

Referenced by Free(), HasSavedContexts(), ResetAfterArchive(), RestoreContext(), and SaveContext().

◆ spare_

Object** v8::internal::HandleScopeImplementer::spare_
private

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