V8 Project
v8::internal::ExternalStringTable Class Reference

#include <heap.h>

+ Collaboration diagram for v8::internal::ExternalStringTable:

Public Member Functions

void AddString (String *string)
 
void Iterate (ObjectVisitor *v)
 
void CleanUp ()
 
void TearDown ()
 

Private Member Functions

 ExternalStringTable (Heap *heap)
 
void Verify ()
 
void AddOldString (String *string)
 
void ShrinkNewStrings (int position)
 
 DISALLOW_COPY_AND_ASSIGN (ExternalStringTable)
 

Private Attributes

List< Object * > new_space_strings_
 
List< Object * > old_space_strings_
 
Heapheap_
 

Friends

class Heap
 

Detailed Description

Definition at line 474 of file heap.h.

Constructor & Destructor Documentation

◆ ExternalStringTable()

v8::internal::ExternalStringTable::ExternalStringTable ( Heap heap)
inlineexplicitprivate

Definition at line 489 of file heap.h.

489 : heap_(heap) {}

Member Function Documentation

◆ AddOldString()

void v8::internal::ExternalStringTable::AddOldString ( String string)
inlineprivate

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

684  {
685  DCHECK(string->IsExternalString());
686  DCHECK(!heap_->InNewSpace(string));
687  old_space_strings_.Add(string);
688 }
List< Object * > old_space_strings_
Definition: heap.h:503
bool InNewSpace(Object *object)
Definition: heap-inl.h:322
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, heap_, v8::internal::Heap::InNewSpace(), and old_space_strings_.

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

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

◆ AddString()

void v8::internal::ExternalStringTable::AddString ( String string)
inline

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

644  {
645  DCHECK(string->IsExternalString());
646  if (heap_->InNewSpace(string)) {
647  new_space_strings_.Add(string);
648  } else {
649  old_space_strings_.Add(string);
650  }
651 }
List< Object * > new_space_strings_
Definition: heap.h:502

References DCHECK, heap_, v8::internal::Heap::InNewSpace(), new_space_strings_, and old_space_strings_.

Referenced by v8::internal::ExternalizeStringExtension::Externalize(), v8::String::MakeExternal(), and v8::String::NewExternal().

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

◆ CleanUp()

void v8::internal::ExternalStringTable::CleanUp ( )

Definition at line 5972 of file heap.cc.

5972  {
5973  int last = 0;
5974  for (int i = 0; i < new_space_strings_.length(); ++i) {
5975  if (new_space_strings_[i] == heap_->the_hole_value()) {
5976  continue;
5977  }
5978  DCHECK(new_space_strings_[i]->IsExternalString());
5981  } else {
5983  }
5984  }
5985  new_space_strings_.Rewind(last);
5986  new_space_strings_.Trim();
5987 
5988  last = 0;
5989  for (int i = 0; i < old_space_strings_.length(); ++i) {
5990  if (old_space_strings_[i] == heap_->the_hole_value()) {
5991  continue;
5992  }
5993  DCHECK(old_space_strings_[i]->IsExternalString());
5996  }
5997  old_space_strings_.Rewind(last);
5998  old_space_strings_.Trim();
5999 #ifdef VERIFY_HEAP
6000  if (FLAG_verify_heap) {
6001  Verify();
6002  }
6003 #endif
6004 }

References DCHECK, heap_, v8::internal::Heap::InNewSpace(), new_space_strings_, old_space_strings_, and Verify().

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

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

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::ExternalStringTable::DISALLOW_COPY_AND_ASSIGN ( ExternalStringTable  )
private

◆ Iterate()

void v8::internal::ExternalStringTable::Iterate ( ObjectVisitor v)
inline

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

654  {
655  if (!new_space_strings_.is_empty()) {
656  Object** start = &new_space_strings_[0];
657  v->VisitPointers(start, start + new_space_strings_.length());
658  }
659  if (!old_space_strings_.is_empty()) {
660  Object** start = &old_space_strings_[0];
661  v->VisitPointers(start, start + old_space_strings_.length());
662  }
663 }
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References new_space_strings_, and old_space_strings_.

Referenced by v8::internal::MarkCompactCollector::AfterMarking(), v8::internal::Heap::IterateWeakRoots(), and v8::internal::Heap::VisitExternalResources().

+ Here is the caller graph for this function:

◆ ShrinkNewStrings()

void v8::internal::ExternalStringTable::ShrinkNewStrings ( int  position)
inlineprivate

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

691  {
692  new_space_strings_.Rewind(position);
693 #ifdef VERIFY_HEAP
694  if (FLAG_verify_heap) {
695  Verify();
696  }
697 #endif
698 }

References new_space_strings_, and Verify().

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

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

◆ TearDown()

void v8::internal::ExternalStringTable::TearDown ( )

Definition at line 6007 of file heap.cc.

6007  {
6008  for (int i = 0; i < new_space_strings_.length(); ++i) {
6009  heap_->FinalizeExternalString(ExternalString::cast(new_space_strings_[i]));
6010  }
6011  new_space_strings_.Free();
6012  for (int i = 0; i < old_space_strings_.length(); ++i) {
6013  heap_->FinalizeExternalString(ExternalString::cast(old_space_strings_[i]));
6014  }
6015  old_space_strings_.Free();
6016 }
void FinalizeExternalString(String *string)
Definition: heap-inl.h:307

References v8::internal::Heap::FinalizeExternalString(), heap_, new_space_strings_, and old_space_strings_.

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

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

◆ Verify()

void v8::internal::ExternalStringTable::Verify ( )
inlineprivate

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

668  {
669 #ifdef DEBUG
670  for (int i = 0; i < new_space_strings_.length(); ++i) {
671  Object* obj = Object::cast(new_space_strings_[i]);
672  DCHECK(heap_->InNewSpace(obj));
673  DCHECK(obj != heap_->the_hole_value());
674  }
675  for (int i = 0; i < old_space_strings_.length(); ++i) {
676  Object* obj = Object::cast(old_space_strings_[i]);
677  DCHECK(!heap_->InNewSpace(obj));
678  DCHECK(obj != heap_->the_hole_value());
679  }
680 #endif
681 }

References DCHECK, heap_, v8::internal::Heap::InNewSpace(), new_space_strings_, and old_space_strings_.

Referenced by CleanUp(), ShrinkNewStrings(), and v8::internal::Heap::UpdateNewSpaceReferencesInExternalStringTable().

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

Friends And Related Function Documentation

◆ Heap

friend class Heap
friend

Definition at line 491 of file heap.h.

Member Data Documentation

◆ heap_

Heap* v8::internal::ExternalStringTable::heap_
private

Definition at line 505 of file heap.h.

Referenced by AddOldString(), AddString(), CleanUp(), TearDown(), and Verify().

◆ new_space_strings_

List<Object*> v8::internal::ExternalStringTable::new_space_strings_
private

◆ old_space_strings_

List<Object*> v8::internal::ExternalStringTable::old_space_strings_
private

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