V8 Project
v8::internal::GlobalHandles Class Reference

#include <global-handles.h>

+ Collaboration diagram for v8::internal::GlobalHandles:

Classes

class  Node
 
class  NodeBlock
 
class  NodeIterator
 

Public Types

typedef WeakCallbackData< v8::Value, void >::Callback WeakCallback
 

Public Member Functions

 ~GlobalHandles ()
 
Handle< ObjectCreate (Object *value)
 
void RecordStats (HeapStats *stats)
 
int NumberOfWeakHandles ()
 
int NumberOfGlobalObjectWeakHandles ()
 
int global_handles_count () const
 
int PostGarbageCollectionProcessing (GarbageCollector collector)
 
void IterateStrongRoots (ObjectVisitor *v)
 
void IterateAllRoots (ObjectVisitor *v)
 
void IterateAllRootsWithClassIds (ObjectVisitor *v)
 
void IterateAllRootsInNewSpaceWithClassIds (ObjectVisitor *v)
 
void IterateWeakRoots (ObjectVisitor *v)
 
void IdentifyWeakHandles (WeakSlotCallback f)
 
void IterateNewSpaceStrongAndDependentRoots (ObjectVisitor *v)
 
void IdentifyNewSpaceWeakIndependentHandles (WeakSlotCallbackWithHeap f)
 
void IterateNewSpaceWeakIndependentRoots (ObjectVisitor *v)
 
bool IterateObjectGroups (ObjectVisitor *v, WeakSlotCallbackWithHeap can_skip)
 
void AddObjectGroup (Object ***handles, size_t length, v8::RetainedObjectInfo *info)
 
void SetObjectGroupId (Object **handle, UniqueId id)
 
void SetRetainedObjectInfo (UniqueId id, RetainedObjectInfo *info)
 
void SetReferenceFromGroup (UniqueId id, Object **child)
 
void SetReference (HeapObject **parent, Object **child)
 
List< ObjectGroup * > * object_groups ()
 
List< ImplicitRefGroup * > * implicit_ref_groups ()
 
void RemoveObjectGroups ()
 
void RemoveImplicitRefGroups ()
 
void TearDown ()
 
Isolateisolate ()
 

Static Public Member Functions

static Handle< ObjectCopyGlobal (Object **location)
 
static void Destroy (Object **location)
 
static void MakeWeak (Object **location, void *parameter, WeakCallback weak_callback)
 
static void * ClearWeakness (Object **location)
 
static void MarkIndependent (Object **location)
 
static void MarkPartiallyDependent (Object **location)
 
static bool IsIndependent (Object **location)
 
static bool IsNearDeath (Object **location)
 
static bool IsWeak (Object **location)
 

Private Member Functions

 GlobalHandles (Isolate *isolate)
 
void ComputeObjectGroupsAndImplicitReferences ()
 
 DISALLOW_COPY_AND_ASSIGN (GlobalHandles)
 

Private Attributes

Isolateisolate_
 
int number_of_global_handles_
 
NodeBlockfirst_block_
 
NodeBlockfirst_used_block_
 
Nodefirst_free_
 
List< Node * > new_space_nodes_
 
int post_gc_processing_count_
 
List< ObjectGroup * > object_groups_
 
List< ImplicitRefGroup * > implicit_ref_groups_
 
List< ObjectGroupConnectionobject_group_connections_
 
List< ObjectGroupRetainerInforetainer_infos_
 
List< ObjectGroupConnectionimplicit_ref_connections_
 

Static Private Attributes

static const int kObjectGroupConnectionsCapacity = 20
 

Friends

class Isolate
 

Detailed Description

Definition at line 100 of file global-handles.h.

Member Typedef Documentation

◆ WeakCallback

Definition at line 113 of file global-handles.h.

Constructor & Destructor Documentation

◆ ~GlobalHandles()

v8::internal::GlobalHandles::~GlobalHandles ( )

Definition at line 437 of file global-handles.cc.

437  {
438  NodeBlock* block = first_block_;
439  while (block != NULL) {
440  NodeBlock* tmp = block->next();
441  delete block;
442  block = tmp;
443  }
444  first_block_ = NULL;
445 }
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

References first_block_, v8::internal::GlobalHandles::NodeBlock::next(), and NULL.

+ Here is the call graph for this function:

◆ GlobalHandles()

v8::internal::GlobalHandles::GlobalHandles ( Isolate isolate)
explicitprivate

Member Function Documentation

◆ AddObjectGroup()

void v8::internal::GlobalHandles::AddObjectGroup ( Object ***  handles,
size_t  length,
v8::RetainedObjectInfo info 
)

Definition at line 816 of file global-handles.cc.

818  {
819 #ifdef DEBUG
820  for (size_t i = 0; i < length; ++i) {
821  DCHECK(!Node::FromLocation(handles[i])->is_independent());
822  }
823 #endif
824  if (length == 0) {
825  if (info != NULL) info->Dispose();
826  return;
827  }
828  ObjectGroup* group = new ObjectGroup(length);
829  for (size_t i = 0; i < length; ++i)
830  group->objects[i] = handles[i];
831  group->info = info;
832  object_groups_.Add(group);
833 }
virtual void Dispose()=0
Called by V8 when it no longer needs an instance.
static Node * FromLocation(Object **location)
List< ObjectGroup * > object_groups_
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, v8::RetainedObjectInfo::Dispose(), v8::internal::GlobalHandles::Node::FromLocation(), v8::internal::ObjectGroup::info, NULL, object_groups_, and v8::internal::ObjectGroup::objects.

+ Here is the call graph for this function:

◆ ClearWeakness()

void * v8::internal::GlobalHandles::ClearWeakness ( Object **  location)
static

Definition at line 485 of file global-handles.cc.

485  {
486  return Node::FromLocation(location)->ClearWeakness();
487 }

References v8::internal::GlobalHandles::Node::ClearWeakness(), and v8::internal::GlobalHandles::Node::FromLocation().

Referenced by v8::internal::ScriptCache::Clear(), and v8::V8::ClearWeak().

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

◆ ComputeObjectGroupsAndImplicitReferences()

void v8::internal::GlobalHandles::ComputeObjectGroupsAndImplicitReferences ( )
private

Definition at line 888 of file global-handles.cc.

888  {
889  if (object_group_connections_.length() == 0) {
890  for (int i = 0; i < retainer_infos_.length(); ++i)
891  retainer_infos_[i].info->Dispose();
892  retainer_infos_.Clear();
894  return;
895  }
896 
898  retainer_infos_.Sort();
900 
901  int info_index = 0; // For iterating retainer_infos_.
902  UniqueId current_group_id(0);
903  int current_group_start = 0;
904 
905  int current_implicit_refs_start = 0;
906  int current_implicit_refs_end = 0;
907  for (int i = 0; i <= object_group_connections_.length(); ++i) {
908  if (i == 0)
909  current_group_id = object_group_connections_[i].id;
910  if (i == object_group_connections_.length() ||
911  current_group_id != object_group_connections_[i].id) {
912  // Group detected: objects in indices [current_group_start, i[.
913 
914  // Find out which implicit references are related to this group. (We want
915  // to ignore object groups which only have 1 object, but that object is
916  // needed as a representative object for the implicit refrerence group.)
917  while (current_implicit_refs_start < implicit_ref_connections_.length() &&
918  implicit_ref_connections_[current_implicit_refs_start].id <
919  current_group_id)
920  ++current_implicit_refs_start;
921  current_implicit_refs_end = current_implicit_refs_start;
922  while (current_implicit_refs_end < implicit_ref_connections_.length() &&
923  implicit_ref_connections_[current_implicit_refs_end].id ==
924  current_group_id)
925  ++current_implicit_refs_end;
926 
927  if (current_implicit_refs_end > current_implicit_refs_start) {
928  // Find a representative object for the implicit references.
929  HeapObject** representative = NULL;
930  for (int j = current_group_start; j < i; ++j) {
931  Object** object = object_group_connections_[j].object;
932  if ((*object)->IsHeapObject()) {
933  representative = reinterpret_cast<HeapObject**>(object);
934  break;
935  }
936  }
937  if (representative) {
938  ImplicitRefGroup* group = new ImplicitRefGroup(
939  representative,
940  current_implicit_refs_end - current_implicit_refs_start);
941  for (int j = current_implicit_refs_start;
942  j < current_implicit_refs_end;
943  ++j) {
944  group->children[j - current_implicit_refs_start] =
945  implicit_ref_connections_[j].object;
946  }
947  implicit_ref_groups_.Add(group);
948  }
949  current_implicit_refs_start = current_implicit_refs_end;
950  }
951 
952  // Find a RetainedObjectInfo for the group.
953  RetainedObjectInfo* info = NULL;
954  while (info_index < retainer_infos_.length() &&
955  retainer_infos_[info_index].id < current_group_id) {
956  retainer_infos_[info_index].info->Dispose();
957  ++info_index;
958  }
959  if (info_index < retainer_infos_.length() &&
960  retainer_infos_[info_index].id == current_group_id) {
961  // This object group has an associated ObjectGroupRetainerInfo.
962  info = retainer_infos_[info_index].info;
963  ++info_index;
964  }
965 
966  // Ignore groups which only contain one object.
967  if (i > current_group_start + 1) {
968  ObjectGroup* group = new ObjectGroup(i - current_group_start);
969  for (int j = current_group_start; j < i; ++j) {
970  group->objects[j - current_group_start] =
971  object_group_connections_[j].object;
972  }
973  group->info = info;
974  object_groups_.Add(group);
975  } else if (info) {
976  info->Dispose();
977  }
978 
979  if (i < object_group_connections_.length()) {
980  current_group_id = object_group_connections_[i].id;
981  current_group_start = i;
982  }
983  }
984  }
987  retainer_infos_.Clear();
989 }
List< ImplicitRefGroup * > implicit_ref_groups_
List< ObjectGroupConnection > implicit_ref_connections_
List< ObjectGroupRetainerInfo > retainer_infos_
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References v8::internal::ImplicitRefGroup::children, v8::RetainedObjectInfo::Dispose(), implicit_ref_connections_, implicit_ref_groups_, v8::internal::ObjectGroup::info, kObjectGroupConnectionsCapacity, NULL, object_group_connections_, object_groups_, v8::internal::ObjectGroup::objects, and retainer_infos_.

Referenced by implicit_ref_groups(), IterateObjectGroups(), and object_groups().

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

◆ CopyGlobal()

Handle< Object > v8::internal::GlobalHandles::CopyGlobal ( Object **  location)
static

Definition at line 467 of file global-handles.cc.

467  {
468  DCHECK(location != NULL);
469  return Node::FromLocation(location)->GetGlobalHandles()->Create(*location);
470 }
Handle< Object > Create(Object *value)

References Create(), DCHECK, v8::internal::GlobalHandles::Node::FromLocation(), v8::internal::GlobalHandles::Node::GetGlobalHandles(), and NULL.

Referenced by v8::V8::CopyPersistent().

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

◆ Create()

Handle< Object > v8::internal::GlobalHandles::Create ( Object value)

Definition at line 448 of file global-handles.cc.

448  {
449  if (first_free_ == NULL) {
450  first_block_ = new NodeBlock(this, first_block_);
452  }
453  DCHECK(first_free_ != NULL);
454  // Take the first node in the free list.
455  Node* result = first_free_;
456  first_free_ = result->next_free();
457  result->Acquire(value);
458  if (isolate_->heap()->InNewSpace(value) &&
459  !result->is_in_new_space_list()) {
460  new_space_nodes_.Add(result);
461  result->set_in_new_space_list(true);
462  }
463  return result->handle();
464 }
void PutNodesOnFreeList(Node **first_free)
bool InNewSpace(Object *object)
Definition: heap-inl.h:322

References v8::internal::GlobalHandles::Node::Acquire(), DCHECK, first_block_, first_free_, v8::internal::GlobalHandles::Node::handle(), v8::internal::Isolate::heap(), v8::internal::Heap::InNewSpace(), v8::internal::GlobalHandles::Node::is_in_new_space_list(), isolate_, new_space_nodes_, v8::internal::GlobalHandles::Node::next_free, NULL, v8::internal::GlobalHandles::NodeBlock::PutNodesOnFreeList(), and v8::internal::GlobalHandles::Node::set_in_new_space_list().

Referenced by v8::internal::ScriptCache::Add(), CopyGlobal(), v8::internal::DebugInfoListNode::DebugInfoListNode(), v8::V8::GlobalizeReference(), v8::internal::Debug::Load(), v8::internal::ArrayConcatVisitor::set_storage(), v8::internal::Debug::SetEventListener(), and v8::internal::AllocationTracker::UnresolvedLocation::UnresolvedLocation().

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

◆ Destroy()

void v8::internal::GlobalHandles::Destroy ( Object **  location)
static

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::GlobalHandles::DISALLOW_COPY_AND_ASSIGN ( GlobalHandles  )
private

◆ global_handles_count()

int v8::internal::GlobalHandles::global_handles_count ( ) const
inline

Definition at line 135 of file global-handles.h.

135  {
137  }

References number_of_global_handles_.

◆ IdentifyNewSpaceWeakIndependentHandles()

void v8::internal::GlobalHandles::IdentifyNewSpaceWeakIndependentHandles ( WeakSlotCallbackWithHeap  f)

Definition at line 543 of file global-handles.cc.

544  {
545  for (int i = 0; i < new_space_nodes_.length(); ++i) {
546  Node* node = new_space_nodes_[i];
547  DCHECK(node->is_in_new_space_list());
548  if ((node->is_independent() || node->is_partially_dependent()) &&
549  node->IsWeak() && f(isolate_->heap(), node->location())) {
550  node->MarkPending();
551  }
552  }
553 }

References DCHECK, v8::internal::Isolate::heap(), v8::internal::GlobalHandles::Node::is_in_new_space_list(), v8::internal::GlobalHandles::Node::is_independent(), v8::internal::GlobalHandles::Node::is_partially_dependent(), isolate_, v8::internal::GlobalHandles::Node::IsWeak(), v8::internal::GlobalHandles::Node::location(), v8::internal::GlobalHandles::Node::MarkPending(), and new_space_nodes_.

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

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

◆ IdentifyWeakHandles()

void v8::internal::GlobalHandles::IdentifyWeakHandles ( WeakSlotCallback  f)

Definition at line 522 of file global-handles.cc.

522  {
523  for (NodeIterator it(this); !it.done(); it.Advance()) {
524  if (it.node()->IsWeak() && f(it.node()->location())) {
525  it.node()->MarkPending();
526  }
527  }
528 }

References v8::internal::GlobalHandles::NodeIterator::done().

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

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

◆ implicit_ref_groups()

List<ImplicitRefGroup*>* v8::internal::GlobalHandles::implicit_ref_groups ( )
inline

Definition at line 233 of file global-handles.h.

233  {
235  return &implicit_ref_groups_;
236  }

References ComputeObjectGroupsAndImplicitReferences(), and implicit_ref_groups_.

Referenced by v8::internal::NativeObjectsExplorer::FillImplicitReferences(), and v8::internal::MarkCompactCollector::MarkImplicitRefGroups().

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

◆ IsIndependent()

bool v8::internal::GlobalHandles::IsIndependent ( Object **  location)
static

Definition at line 500 of file global-handles.cc.

500  {
501  return Node::FromLocation(location)->is_independent();
502 }

References v8::internal::GlobalHandles::Node::FromLocation(), and v8::internal::GlobalHandles::Node::is_independent().

+ Here is the call graph for this function:

◆ IsNearDeath()

bool v8::internal::GlobalHandles::IsNearDeath ( Object **  location)
static

Definition at line 505 of file global-handles.cc.

505  {
506  return Node::FromLocation(location)->IsNearDeath();
507 }

References v8::internal::GlobalHandles::Node::FromLocation(), and v8::internal::GlobalHandles::Node::IsNearDeath().

+ Here is the call graph for this function:

◆ isolate()

Isolate* v8::internal::GlobalHandles::isolate ( )
inline

Definition at line 245 of file global-handles.h.

245 { return isolate_; }

References isolate_.

Referenced by v8::internal::GlobalHandles::Node::DecreaseBlockUses(), v8::internal::GlobalHandles::Node::IncreaseBlockUses(), v8::internal::GlobalHandles::Node::MarkPartiallyDependent(), and v8::internal::GlobalHandles::Node::PostGarbageCollectionProcessing().

+ Here is the caller graph for this function:

◆ IsWeak()

bool v8::internal::GlobalHandles::IsWeak ( Object **  location)
static

Definition at line 510 of file global-handles.cc.

510  {
511  return Node::FromLocation(location)->IsWeak();
512 }

References v8::internal::GlobalHandles::Node::FromLocation(), and v8::internal::GlobalHandles::Node::IsWeak().

+ Here is the call graph for this function:

◆ IterateAllRoots()

void v8::internal::GlobalHandles::IterateAllRoots ( ObjectVisitor v)

Definition at line 702 of file global-handles.cc.

702  {
703  for (NodeIterator it(this); !it.done(); it.Advance()) {
704  if (it.node()->IsRetainer()) {
705  v->VisitPointer(it.node()->location());
706  }
707  }
708 }

References v8::internal::GlobalHandles::NodeIterator::done().

Referenced by v8::internal::Heap::IterateStrongRoots(), and v8::internal::V8HeapExplorer::TagGlobalObjects().

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

◆ IterateAllRootsInNewSpaceWithClassIds()

void v8::internal::GlobalHandles::IterateAllRootsInNewSpaceWithClassIds ( ObjectVisitor v)

Definition at line 721 of file global-handles.cc.

721  {
722  for (int i = 0; i < new_space_nodes_.length(); ++i) {
723  Node* node = new_space_nodes_[i];
724  if (node->IsRetainer() && node->has_wrapper_class_id()) {
725  v->VisitEmbedderReference(node->location(),
726  node->wrapper_class_id());
727  }
728  }
729 }

References v8::internal::GlobalHandles::Node::has_wrapper_class_id(), v8::internal::GlobalHandles::Node::IsRetainer(), v8::internal::GlobalHandles::Node::location(), new_space_nodes_, and v8::internal::GlobalHandles::Node::wrapper_class_id().

Referenced by v8::V8::VisitHandlesForPartialDependence().

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

◆ IterateAllRootsWithClassIds()

void v8::internal::GlobalHandles::IterateAllRootsWithClassIds ( ObjectVisitor v)

Definition at line 711 of file global-handles.cc.

711  {
712  for (NodeIterator it(this); !it.done(); it.Advance()) {
713  if (it.node()->IsRetainer() && it.node()->has_wrapper_class_id()) {
714  v->VisitEmbedderReference(it.node()->location(),
715  it.node()->wrapper_class_id());
716  }
717  }
718 }

References v8::internal::GlobalHandles::NodeIterator::done().

Referenced by v8::internal::NativeObjectsExplorer::FillRetainedObjects(), and v8::V8::VisitHandlesWithClassIds().

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

◆ IterateNewSpaceStrongAndDependentRoots()

void v8::internal::GlobalHandles::IterateNewSpaceStrongAndDependentRoots ( ObjectVisitor v)

Definition at line 531 of file global-handles.cc.

531  {
532  for (int i = 0; i < new_space_nodes_.length(); ++i) {
533  Node* node = new_space_nodes_[i];
534  if (node->IsStrongRetainer() ||
535  (node->IsWeakRetainer() && !node->is_independent() &&
536  !node->is_partially_dependent())) {
537  v->VisitPointer(node->location());
538  }
539  }
540 }

References v8::internal::GlobalHandles::Node::is_independent(), v8::internal::GlobalHandles::Node::is_partially_dependent(), v8::internal::GlobalHandles::Node::IsStrongRetainer(), v8::internal::GlobalHandles::Node::IsWeakRetainer(), v8::internal::GlobalHandles::Node::location(), and new_space_nodes_.

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

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

◆ IterateNewSpaceWeakIndependentRoots()

void v8::internal::GlobalHandles::IterateNewSpaceWeakIndependentRoots ( ObjectVisitor v)

Definition at line 556 of file global-handles.cc.

556  {
557  for (int i = 0; i < new_space_nodes_.length(); ++i) {
558  Node* node = new_space_nodes_[i];
559  DCHECK(node->is_in_new_space_list());
560  if ((node->is_independent() || node->is_partially_dependent()) &&
561  node->IsWeakRetainer()) {
562  v->VisitPointer(node->location());
563  }
564  }
565 }

References DCHECK, v8::internal::GlobalHandles::Node::is_in_new_space_list(), v8::internal::GlobalHandles::Node::is_independent(), v8::internal::GlobalHandles::Node::is_partially_dependent(), v8::internal::GlobalHandles::Node::IsWeakRetainer(), v8::internal::GlobalHandles::Node::location(), and new_space_nodes_.

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

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

◆ IterateObjectGroups()

bool v8::internal::GlobalHandles::IterateObjectGroups ( ObjectVisitor v,
WeakSlotCallbackWithHeap  can_skip 
)

Definition at line 568 of file global-handles.cc.

569  {
571  int last = 0;
572  bool any_group_was_visited = false;
573  for (int i = 0; i < object_groups_.length(); i++) {
574  ObjectGroup* entry = object_groups_.at(i);
575  DCHECK(entry != NULL);
576 
577  Object*** objects = entry->objects;
578  bool group_should_be_visited = false;
579  for (size_t j = 0; j < entry->length; j++) {
580  Object* object = *objects[j];
581  if (object->IsHeapObject()) {
582  if (!can_skip(isolate_->heap(), &object)) {
583  group_should_be_visited = true;
584  break;
585  }
586  }
587  }
588 
589  if (!group_should_be_visited) {
590  object_groups_[last++] = entry;
591  continue;
592  }
593 
594  // An object in the group requires visiting, so iterate over all
595  // objects in the group.
596  for (size_t j = 0; j < entry->length; ++j) {
597  Object* object = *objects[j];
598  if (object->IsHeapObject()) {
599  v->VisitPointer(&object);
600  any_group_was_visited = true;
601  }
602  }
603 
604  // Once the entire group has been iterated over, set the object
605  // group to NULL so it won't be processed again.
606  delete entry;
607  object_groups_.at(i) = NULL;
608  }
609  object_groups_.Rewind(last);
610  return any_group_was_visited;
611 }

References ComputeObjectGroupsAndImplicitReferences(), DCHECK, v8::internal::Isolate::heap(), isolate_, v8::internal::ObjectGroup::length, NULL, object_groups_, and v8::internal::ObjectGroup::objects.

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

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

◆ IterateStrongRoots()

void v8::internal::GlobalHandles::IterateStrongRoots ( ObjectVisitor v)

Definition at line 693 of file global-handles.cc.

693  {
694  for (NodeIterator it(this); !it.done(); it.Advance()) {
695  if (it.node()->IsStrongRetainer()) {
696  v->VisitPointer(it.node()->location());
697  }
698  }
699 }

References v8::internal::GlobalHandles::NodeIterator::done().

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

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

◆ IterateWeakRoots()

void v8::internal::GlobalHandles::IterateWeakRoots ( ObjectVisitor v)

Definition at line 515 of file global-handles.cc.

515  {
516  for (NodeIterator it(this); !it.done(); it.Advance()) {
517  if (it.node()->IsWeakRetainer()) v->VisitPointer(it.node()->location());
518  }
519 }

References v8::internal::GlobalHandles::NodeIterator::done().

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

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

◆ MakeWeak()

void v8::internal::GlobalHandles::MakeWeak ( Object **  location,
void *  parameter,
WeakCallback  weak_callback 
)
static

Definition at line 478 of file global-handles.cc.

480  {
481  Node::FromLocation(location)->MakeWeak(parameter, weak_callback);
482 }
void MakeWeak(void *parameter, WeakCallback weak_callback)

References v8::internal::GlobalHandles::Node::FromLocation(), and v8::internal::GlobalHandles::Node::MakeWeak().

Referenced by v8::internal::ScriptCache::Add(), v8::internal::DebugInfoListNode::DebugInfoListNode(), v8::V8::MakeWeak(), and v8::internal::AllocationTracker::UnresolvedLocation::UnresolvedLocation().

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

◆ MarkIndependent()

void v8::internal::GlobalHandles::MarkIndependent ( Object **  location)
static

Definition at line 490 of file global-handles.cc.

490  {
491  Node::FromLocation(location)->MarkIndependent();
492 }

References v8::internal::GlobalHandles::Node::FromLocation(), and v8::internal::GlobalHandles::Node::MarkIndependent().

+ Here is the call graph for this function:

◆ MarkPartiallyDependent()

void v8::internal::GlobalHandles::MarkPartiallyDependent ( Object **  location)
static

Definition at line 495 of file global-handles.cc.

495  {
497 }

References v8::internal::GlobalHandles::Node::FromLocation(), and v8::internal::GlobalHandles::Node::MarkPartiallyDependent().

+ Here is the call graph for this function:

◆ NumberOfGlobalObjectWeakHandles()

int v8::internal::GlobalHandles::NumberOfGlobalObjectWeakHandles ( )

Definition at line 743 of file global-handles.cc.

743  {
744  int count = 0;
745  for (NodeIterator it(this); !it.done(); it.Advance()) {
746  if (it.node()->IsWeakRetainer() &&
747  it.node()->object()->IsJSGlobalObject()) {
748  count++;
749  }
750  }
751  return count;
752 }

References v8::internal::GlobalHandles::NodeIterator::done().

+ Here is the call graph for this function:

◆ NumberOfWeakHandles()

int v8::internal::GlobalHandles::NumberOfWeakHandles ( )

Definition at line 732 of file global-handles.cc.

732  {
733  int count = 0;
734  for (NodeIterator it(this); !it.done(); it.Advance()) {
735  if (it.node()->IsWeakRetainer()) {
736  count++;
737  }
738  }
739  return count;
740 }

References v8::internal::GlobalHandles::NodeIterator::done().

Referenced by v8::internal::StartupSerializer::SerializeStrongReferences().

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

◆ object_groups()

List<ObjectGroup*>* v8::internal::GlobalHandles::object_groups ( )
inline

Definition at line 228 of file global-handles.h.

228  {
230  return &object_groups_;
231  }

References ComputeObjectGroupsAndImplicitReferences(), and object_groups_.

Referenced by v8::internal::NativeObjectsExplorer::FillRetainedObjects().

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

◆ PostGarbageCollectionProcessing()

int v8::internal::GlobalHandles::PostGarbageCollectionProcessing ( GarbageCollector  collector)

Definition at line 614 of file global-handles.cc.

615  {
616  // Process weak global handle callbacks. This must be done after the
617  // GC is completely done, because the callbacks may invoke arbitrary
618  // API functions.
620  const int initial_post_gc_processing_count = ++post_gc_processing_count_;
621  int freed_nodes = 0;
622  if (collector == SCAVENGER) {
623  for (int i = 0; i < new_space_nodes_.length(); ++i) {
624  Node* node = new_space_nodes_[i];
625  DCHECK(node->is_in_new_space_list());
626  if (!node->IsRetainer()) {
627  // Free nodes do not have weak callbacks. Do not use them to compute
628  // the freed_nodes.
629  continue;
630  }
631  // Skip dependent handles. Their weak callbacks might expect to be
632  // called between two global garbage collection callbacks which
633  // are not called for minor collections.
634  if (!node->is_independent() && !node->is_partially_dependent()) {
635  continue;
636  }
637  node->clear_partially_dependent();
638  if (node->PostGarbageCollectionProcessing(isolate_)) {
639  if (initial_post_gc_processing_count != post_gc_processing_count_) {
640  // Weak callback triggered another GC and another round of
641  // PostGarbageCollection processing. The current node might
642  // have been deleted in that round, so we need to bail out (or
643  // restart the processing).
644  return freed_nodes;
645  }
646  }
647  if (!node->IsRetainer()) {
648  freed_nodes++;
649  }
650  }
651  } else {
652  for (NodeIterator it(this); !it.done(); it.Advance()) {
653  if (!it.node()->IsRetainer()) {
654  // Free nodes do not have weak callbacks. Do not use them to compute
655  // the freed_nodes.
656  continue;
657  }
658  it.node()->clear_partially_dependent();
659  if (it.node()->PostGarbageCollectionProcessing(isolate_)) {
660  if (initial_post_gc_processing_count != post_gc_processing_count_) {
661  // See the comment above.
662  return freed_nodes;
663  }
664  }
665  if (!it.node()->IsRetainer()) {
666  freed_nodes++;
667  }
668  }
669  }
670  // Update the list of new space nodes.
671  int last = 0;
672  for (int i = 0; i < new_space_nodes_.length(); ++i) {
673  Node* node = new_space_nodes_[i];
674  DCHECK(node->is_in_new_space_list());
675  if (node->IsRetainer()) {
676  if (isolate_->heap()->InNewSpace(node->object())) {
677  new_space_nodes_[last++] = node;
679  } else {
680  node->set_in_new_space_list(false);
682  }
683  } else {
684  node->set_in_new_space_list(false);
686  }
687  }
688  new_space_nodes_.Rewind(last);
689  return freed_nodes;
690 }
HeapState gc_state()
Definition: heap.h:955
void IncrementNodesCopiedInNewSpace()
Definition: heap.h:1126
void IncrementNodesPromoted()
Definition: heap.h:1128
void IncrementNodesDiedInNewSpace()
Definition: heap.h:1124

References v8::internal::GlobalHandles::Node::clear_partially_dependent(), DCHECK, v8::internal::GlobalHandles::NodeIterator::done(), v8::internal::Heap::gc_state(), v8::internal::Isolate::heap(), v8::internal::Heap::IncrementNodesCopiedInNewSpace(), v8::internal::Heap::IncrementNodesDiedInNewSpace(), v8::internal::Heap::IncrementNodesPromoted(), v8::internal::Heap::InNewSpace(), v8::internal::GlobalHandles::Node::is_in_new_space_list(), v8::internal::GlobalHandles::Node::is_independent(), v8::internal::GlobalHandles::Node::is_partially_dependent(), isolate_, v8::internal::GlobalHandles::Node::IsRetainer(), new_space_nodes_, v8::internal::Heap::NOT_IN_GC, v8::internal::GlobalHandles::Node::object(), post_gc_processing_count_, v8::internal::GlobalHandles::Node::PostGarbageCollectionProcessing(), v8::internal::SCAVENGER, and v8::internal::GlobalHandles::Node::set_in_new_space_list().

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

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

◆ RecordStats()

void v8::internal::GlobalHandles::RecordStats ( HeapStats stats)

Definition at line 755 of file global-handles.cc.

755  {
756  *stats->global_handle_count = 0;
757  *stats->weak_global_handle_count = 0;
758  *stats->pending_global_handle_count = 0;
759  *stats->near_death_global_handle_count = 0;
760  *stats->free_global_handle_count = 0;
761  for (NodeIterator it(this); !it.done(); it.Advance()) {
762  *stats->global_handle_count += 1;
763  if (it.node()->state() == Node::WEAK) {
764  *stats->weak_global_handle_count += 1;
765  } else if (it.node()->state() == Node::PENDING) {
766  *stats->pending_global_handle_count += 1;
767  } else if (it.node()->state() == Node::NEAR_DEATH) {
768  *stats->near_death_global_handle_count += 1;
769  } else if (it.node()->state() == Node::FREE) {
770  *stats->free_global_handle_count += 1;
771  }
772  }
773 }

References v8::internal::GlobalHandles::NodeIterator::done(), v8::internal::GlobalHandles::Node::FREE, v8::internal::HeapStats::free_global_handle_count, v8::internal::HeapStats::global_handle_count, v8::internal::GlobalHandles::Node::NEAR_DEATH, v8::internal::HeapStats::near_death_global_handle_count, v8::internal::GlobalHandles::Node::PENDING, v8::internal::HeapStats::pending_global_handle_count, v8::internal::GlobalHandles::Node::WEAK, and v8::internal::HeapStats::weak_global_handle_count.

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

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

◆ RemoveImplicitRefGroups()

void v8::internal::GlobalHandles::RemoveImplicitRefGroups ( )

Definition at line 874 of file global-handles.cc.

874  {
875  for (int i = 0; i < implicit_ref_groups_.length(); i++) {
876  delete implicit_ref_groups_.at(i);
877  }
878  implicit_ref_groups_.Clear();
880 }

References implicit_ref_connections_, and implicit_ref_groups_.

Referenced by v8::internal::MarkCompactCollector::AfterMarking(), v8::internal::NativeObjectsExplorer::FillImplicitReferences(), and v8::internal::Heap::Scavenge().

+ Here is the caller graph for this function:

◆ RemoveObjectGroups()

void v8::internal::GlobalHandles::RemoveObjectGroups ( )

Definition at line 862 of file global-handles.cc.

862  {
863  for (int i = 0; i < object_groups_.length(); i++)
864  delete object_groups_.at(i);
865  object_groups_.Clear();
866  for (int i = 0; i < retainer_infos_.length(); ++i)
867  retainer_infos_[i].info->Dispose();
868  retainer_infos_.Clear();
871 }

References kObjectGroupConnectionsCapacity, object_group_connections_, object_groups_, and retainer_infos_.

Referenced by v8::internal::MarkCompactCollector::AfterMarking(), v8::internal::NativeObjectsExplorer::FillRetainedObjects(), and v8::internal::Heap::Scavenge().

+ Here is the caller graph for this function:

◆ SetObjectGroupId()

void v8::internal::GlobalHandles::SetObjectGroupId ( Object **  handle,
UniqueId  id 
)

Definition at line 836 of file global-handles.cc.

837  {
838  object_group_connections_.Add(ObjectGroupConnection(id, handle));
839 }
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146

References v8::internal::handle(), and object_group_connections_.

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

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

◆ SetReference()

void v8::internal::GlobalHandles::SetReference ( HeapObject **  parent,
Object **  child 
)

Definition at line 854 of file global-handles.cc.

854  {
855  DCHECK(!Node::FromLocation(child)->is_independent());
856  ImplicitRefGroup* group = new ImplicitRefGroup(parent, 1);
857  group->children[0] = child;
858  implicit_ref_groups_.Add(group);
859 }

References v8::internal::ImplicitRefGroup::children, DCHECK, v8::internal::GlobalHandles::Node::FromLocation(), and implicit_ref_groups_.

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

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

◆ SetReferenceFromGroup()

void v8::internal::GlobalHandles::SetReferenceFromGroup ( UniqueId  id,
Object **  child 
)

Definition at line 848 of file global-handles.cc.

848  {
849  DCHECK(!Node::FromLocation(child)->is_independent());
850  implicit_ref_connections_.Add(ObjectGroupConnection(id, child));
851 }

References DCHECK, v8::internal::GlobalHandles::Node::FromLocation(), and implicit_ref_connections_.

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

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

◆ SetRetainedObjectInfo()

void v8::internal::GlobalHandles::SetRetainedObjectInfo ( UniqueId  id,
RetainedObjectInfo info 
)

Definition at line 842 of file global-handles.cc.

843  {
844  retainer_infos_.Add(ObjectGroupRetainerInfo(id, info));
845 }

References retainer_infos_.

Referenced by v8::internal::HeapProfiler::SetRetainedObjectInfo().

+ Here is the caller graph for this function:

◆ TearDown()

void v8::internal::GlobalHandles::TearDown ( )

Definition at line 883 of file global-handles.cc.

883  {
884  // TODO(1428): invoke weak callbacks.
885 }

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

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Isolate

friend class Isolate
friend

Definition at line 300 of file global-handles.h.

Member Data Documentation

◆ first_block_

NodeBlock* v8::internal::GlobalHandles::first_block_
private

Definition at line 275 of file global-handles.h.

Referenced by Create(), and ~GlobalHandles().

◆ first_free_

Node* v8::internal::GlobalHandles::first_free_
private

◆ first_used_block_

NodeBlock* v8::internal::GlobalHandles::first_used_block_
private

◆ implicit_ref_connections_

List<ObjectGroupConnection> v8::internal::GlobalHandles::implicit_ref_connections_
private

◆ implicit_ref_groups_

List<ImplicitRefGroup*> v8::internal::GlobalHandles::implicit_ref_groups_
private

◆ isolate_

Isolate* v8::internal::GlobalHandles::isolate_
private

◆ kObjectGroupConnectionsCapacity

const int v8::internal::GlobalHandles::kObjectGroupConnectionsCapacity = 20
staticprivate

◆ new_space_nodes_

◆ number_of_global_handles_

int v8::internal::GlobalHandles::number_of_global_handles_
private

◆ object_group_connections_

List<ObjectGroupConnection> v8::internal::GlobalHandles::object_group_connections_
private

◆ object_groups_

List<ObjectGroup*> v8::internal::GlobalHandles::object_groups_
private

◆ post_gc_processing_count_

int v8::internal::GlobalHandles::post_gc_processing_count_
private

Definition at line 287 of file global-handles.h.

Referenced by PostGarbageCollectionProcessing().

◆ retainer_infos_

List<ObjectGroupRetainerInfo> v8::internal::GlobalHandles::retainer_infos_
private

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