V8 Project
v8::internal::SmallPointerList< T > Class Template Reference

#include <small-pointer-list.h>

+ Inheritance diagram for v8::internal::SmallPointerList< T >:
+ Collaboration diagram for v8::internal::SmallPointerList< T >:

Public Member Functions

 SmallPointerList ()
 
 SmallPointerList (int capacity, Zone *zone)
 
void Reserve (int capacity, Zone *zone)
 
void Clear ()
 
void Sort ()
 
bool is_empty () const
 
int length () const
 
void Add (T *pointer, Zone *zone)
 
Tat (int i) const
 
Toperator[] (int i) const
 
void RemoveElement (T *pointer)
 
TRemoveLast ()
 
void Rewind (int pos)
 
int CountOccurrences (T *pointer, int start, int end) const
 

Private Types

typedef ZoneList< T * > PointerList
 

Private Member Functions

 STATIC_ASSERT (kTagMask+1<=kPointerAlignment)
 
Tsingle_value () const
 
PointerListlist () const
 
 DISALLOW_COPY_AND_ASSIGN (SmallPointerList)
 

Static Private Member Functions

static int compare_value (T *const *a, T *const *b)
 

Private Attributes

intptr_t data_
 

Static Private Attributes

static const intptr_t kEmptyTag = 1
 
static const intptr_t kSingletonTag = 0
 
static const intptr_t kListTag = 2
 
static const intptr_t kTagMask = 3
 
static const intptr_t kValueMask = ~kTagMask
 

Detailed Description

template<typename T>
class v8::internal::SmallPointerList< T >

Definition at line 20 of file small-pointer-list.h.

Member Typedef Documentation

◆ PointerList

template<typename T >
typedef ZoneList<T*> v8::internal::SmallPointerList< T >::PointerList
private

Definition at line 143 of file small-pointer-list.h.

Constructor & Destructor Documentation

◆ SmallPointerList() [1/2]

template<typename T >
v8::internal::SmallPointerList< T >::SmallPointerList ( )
inline

Definition at line 22 of file small-pointer-list.h.

◆ SmallPointerList() [2/2]

template<typename T >
v8::internal::SmallPointerList< T >::SmallPointerList ( int  capacity,
Zone zone 
)
inline

Definition at line 24 of file small-pointer-list.h.

24  : data_(kEmptyTag) {
25  Reserve(capacity, zone);
26  }
void Reserve(int capacity, Zone *zone)

References v8::internal::SmallPointerList< T >::Reserve().

+ Here is the call graph for this function:

Member Function Documentation

◆ Add()

template<typename T >
void v8::internal::SmallPointerList< T >::Add ( T pointer,
Zone zone 
)
inline

Definition at line 63 of file small-pointer-list.h.

63  {
64  DCHECK(IsAligned(reinterpret_cast<intptr_t>(pointer), kPointerAlignment));
65  if ((data_ & kTagMask) == kEmptyTag) {
66  data_ = reinterpret_cast<intptr_t>(pointer) | kSingletonTag;
67  return;
68  }
69  if ((data_ & kTagMask) == kSingletonTag) {
70  PointerList* list = new(zone) PointerList(2, zone);
71  list->Add(single_value(), zone);
72  list->Add(pointer, zone);
73  DCHECK(IsAligned(reinterpret_cast<intptr_t>(list), kPointerAlignment));
74  data_ = reinterpret_cast<intptr_t>(list) | kListTag;
75  return;
76  }
77  list()->Add(pointer, zone);
78  }
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:17
static const intptr_t kSingletonTag
#define DCHECK(condition)
Definition: logging.h:205
bool IsAligned(T value, U alignment)
Definition: utils.h:123
const intptr_t kPointerAlignment
Definition: globals.h:230

References v8::internal::List< T, AllocationPolicy >::Add(), v8::internal::SmallPointerList< T >::data_, DCHECK, v8::internal::IsAligned(), v8::internal::SmallPointerList< T >::kEmptyTag, v8::internal::SmallPointerList< T >::kListTag, v8::internal::kPointerAlignment, v8::internal::SmallPointerList< T >::kSingletonTag, v8::internal::SmallPointerList< T >::kTagMask, v8::internal::SmallPointerList< T >::list(), and v8::internal::SmallPointerList< T >::single_value().

+ Here is the call graph for this function:

◆ at()

template<typename T >
T* v8::internal::SmallPointerList< T >::at ( int  i) const
inline

Definition at line 82 of file small-pointer-list.h.

82  {
84  if ((data_ & kTagMask) == kSingletonTag) {
85  DCHECK(i == 0);
86  return single_value();
87  }
88  return list()->at(i);
89  }
T & at(int i) const
Definition: list.h:69

References v8::internal::List< T, AllocationPolicy >::at(), v8::internal::SmallPointerList< T >::data_, DCHECK, v8::internal::SmallPointerList< T >::kEmptyTag, v8::internal::SmallPointerList< T >::kSingletonTag, v8::internal::SmallPointerList< T >::kTagMask, v8::internal::SmallPointerList< T >::list(), and v8::internal::SmallPointerList< T >::single_value().

Referenced by v8::internal::SmallPointerList< T >::operator[]().

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

◆ Clear()

template<typename T >
void v8::internal::SmallPointerList< T >::Clear ( )
inline

◆ compare_value()

template<typename T >
static int v8::internal::SmallPointerList< T >::compare_value ( T *const *  a,
T *const *  b 
)
inlinestaticprivate

Definition at line 145 of file small-pointer-list.h.

145  {
146  return Compare<T>(**a, **b);
147  }

Referenced by v8::internal::SmallPointerList< T >::Sort().

+ Here is the caller graph for this function:

◆ CountOccurrences()

template<typename T >
int v8::internal::SmallPointerList< T >::CountOccurrences ( T pointer,
int  start,
int  end 
) const
inline

Definition at line 131 of file small-pointer-list.h.

131  {
132  if ((data_ & kTagMask) == kEmptyTag) return 0;
133  if ((data_ & kTagMask) == kSingletonTag) {
134  if (start == 0 && end >= 0) {
135  return (single_value() == pointer) ? 1 : 0;
136  }
137  return 0;
138  }
139  return list()->CountOccurrences(pointer, start, end);
140  }
int CountOccurrences(const T &elm, int start, int end) const
Definition: list-inl.h:184

References v8::internal::List< T, AllocationPolicy >::CountOccurrences(), v8::internal::SmallPointerList< T >::data_, v8::internal::SmallPointerList< T >::kEmptyTag, v8::internal::SmallPointerList< T >::kSingletonTag, v8::internal::SmallPointerList< T >::kTagMask, v8::internal::SmallPointerList< T >::list(), and v8::internal::SmallPointerList< T >::single_value().

+ Here is the call graph for this function:

◆ DISALLOW_COPY_AND_ASSIGN()

template<typename T >
v8::internal::SmallPointerList< T >::DISALLOW_COPY_AND_ASSIGN ( SmallPointerList< T )
private

◆ is_empty()

template<typename T >
bool v8::internal::SmallPointerList< T >::is_empty ( ) const
inline

Definition at line 55 of file small-pointer-list.h.

55 { return length() == 0; }

References v8::internal::SmallPointerList< T >::length().

+ Here is the call graph for this function:

◆ length()

template<typename T >
int v8::internal::SmallPointerList< T >::length ( ) const
inline

Definition at line 57 of file small-pointer-list.h.

57  {
58  if ((data_ & kTagMask) == kEmptyTag) return 0;
59  if ((data_ & kTagMask) == kSingletonTag) return 1;
60  return list()->length();
61  }

References v8::internal::SmallPointerList< T >::data_, v8::internal::SmallPointerList< T >::kEmptyTag, v8::internal::SmallPointerList< T >::kSingletonTag, v8::internal::SmallPointerList< T >::kTagMask, and v8::internal::SmallPointerList< T >::list().

Referenced by v8::internal::SmallPointerList< T >::is_empty().

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

◆ list()

◆ operator[]()

template<typename T >
T* v8::internal::SmallPointerList< T >::operator[] ( int  i) const
inline

Definition at line 92 of file small-pointer-list.h.

92 { return at(i); }

References v8::internal::SmallPointerList< T >::at().

+ Here is the call graph for this function:

◆ RemoveElement()

template<typename T >
void v8::internal::SmallPointerList< T >::RemoveElement ( T pointer)
inline

Definition at line 95 of file small-pointer-list.h.

95  {
96  if ((data_ & kTagMask) == kEmptyTag) return;
97  if ((data_ & kTagMask) == kSingletonTag) {
98  if (pointer == single_value()) {
99  data_ = kEmptyTag;
100  }
101  return;
102  }
103  list()->RemoveElement(pointer);
104  }
bool RemoveElement(const T &elm)
Definition: list-inl.h:115

References v8::internal::SmallPointerList< T >::data_, v8::internal::SmallPointerList< T >::kEmptyTag, v8::internal::SmallPointerList< T >::kSingletonTag, v8::internal::SmallPointerList< T >::kTagMask, v8::internal::SmallPointerList< T >::list(), v8::internal::List< T, AllocationPolicy >::RemoveElement(), and v8::internal::SmallPointerList< T >::single_value().

+ Here is the call graph for this function:

◆ RemoveLast()

template<typename T >
T* v8::internal::SmallPointerList< T >::RemoveLast ( )
inline

Definition at line 106 of file small-pointer-list.h.

106  {
107  DCHECK((data_ & kTagMask) != kEmptyTag);
108  if ((data_ & kTagMask) == kSingletonTag) {
109  T* result = single_value();
110  data_ = kEmptyTag;
111  return result;
112  }
113  return list()->RemoveLast();
114  }
#define T(name, string, precedence)
Definition: token.cc:25

References v8::internal::SmallPointerList< T >::data_, DCHECK, v8::internal::SmallPointerList< T >::kEmptyTag, v8::internal::SmallPointerList< T >::kSingletonTag, v8::internal::SmallPointerList< T >::kTagMask, v8::internal::SmallPointerList< T >::list(), v8::internal::SmallPointerList< T >::single_value(), and T.

+ Here is the call graph for this function:

◆ Reserve()

template<typename T >
void v8::internal::SmallPointerList< T >::Reserve ( int  capacity,
Zone zone 
)
inline

Definition at line 28 of file small-pointer-list.h.

28  {
29  if (capacity < 2) return;
30  if ((data_ & kTagMask) == kListTag) {
31  if (list()->capacity() >= capacity) return;
32  int old_length = list()->length();
33  list()->AddBlock(NULL, capacity - list()->capacity(), zone);
34  list()->Rewind(old_length);
35  return;
36  }
37  PointerList* list = new(zone) PointerList(capacity, zone);
38  if ((data_ & kTagMask) == kSingletonTag) {
39  list->Add(single_value(), zone);
40  }
41  DCHECK(IsAligned(reinterpret_cast<intptr_t>(list), kPointerAlignment));
42  data_ = reinterpret_cast<intptr_t>(list) | kListTag;
43  }
Vector< T > AddBlock(T value, int count, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:77
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 v8::internal::List< T, AllocationPolicy >::Add(), v8::internal::List< T, AllocationPolicy >::AddBlock(), v8::internal::SmallPointerList< T >::data_, DCHECK, v8::internal::IsAligned(), v8::internal::SmallPointerList< T >::kListTag, v8::internal::kPointerAlignment, v8::internal::SmallPointerList< T >::kSingletonTag, v8::internal::SmallPointerList< T >::kTagMask, v8::internal::SmallPointerList< T >::list(), NULL, and v8::internal::SmallPointerList< T >::single_value().

Referenced by v8::internal::SmallPointerList< T >::SmallPointerList().

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

◆ Rewind()

template<typename T >
void v8::internal::SmallPointerList< T >::Rewind ( int  pos)
inline

Definition at line 116 of file small-pointer-list.h.

116  {
117  if ((data_ & kTagMask) == kEmptyTag) {
118  DCHECK(pos == 0);
119  return;
120  }
121  if ((data_ & kTagMask) == kSingletonTag) {
122  DCHECK(pos == 0 || pos == 1);
123  if (pos == 0) {
124  data_ = kEmptyTag;
125  }
126  return;
127  }
128  list()->Rewind(pos);
129  }

References v8::internal::SmallPointerList< T >::data_, DCHECK, v8::internal::SmallPointerList< T >::kEmptyTag, v8::internal::SmallPointerList< T >::kSingletonTag, v8::internal::SmallPointerList< T >::kTagMask, and v8::internal::SmallPointerList< T >::list().

+ Here is the call graph for this function:

◆ single_value()

template<typename T >
T* v8::internal::SmallPointerList< T >::single_value ( ) const
inlineprivate

Definition at line 157 of file small-pointer-list.h.

157  {
160  return reinterpret_cast<T*>(data_);
161  }
STATIC_ASSERT(kTagMask+1<=kPointerAlignment)

References v8::internal::SmallPointerList< T >::data_, DCHECK, v8::internal::SmallPointerList< T >::kSingletonTag, v8::internal::SmallPointerList< T >::kTagMask, v8::internal::SmallPointerList< T >::STATIC_ASSERT(), and T.

Referenced by v8::internal::SmallPointerList< T >::Add(), v8::internal::SmallPointerList< T >::at(), v8::internal::SmallPointerList< T >::CountOccurrences(), v8::internal::SmallPointerList< T >::RemoveElement(), v8::internal::SmallPointerList< T >::RemoveLast(), and v8::internal::SmallPointerList< T >::Reserve().

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

◆ Sort()

template<typename T >
void v8::internal::SmallPointerList< T >::Sort ( )
inline

Definition at line 49 of file small-pointer-list.h.

49  {
50  if ((data_ & kTagMask) == kListTag) {
52  }
53  }
void Sort(int(*cmp)(const T *x, const T *y))
Definition: list-inl.h:194
static int compare_value(T *const *a, T *const *b)

References v8::internal::SmallPointerList< T >::compare_value(), v8::internal::SmallPointerList< T >::data_, v8::internal::SmallPointerList< T >::kListTag, v8::internal::SmallPointerList< T >::kTagMask, v8::internal::SmallPointerList< T >::list(), and v8::internal::List< T, AllocationPolicy >::Sort().

+ Here is the call graph for this function:

◆ STATIC_ASSERT()

template<typename T >
v8::internal::SmallPointerList< T >::STATIC_ASSERT ( kTagMask+1<=  kPointerAlignment)
private

Referenced by v8::internal::SmallPointerList< T >::single_value().

+ Here is the caller graph for this function:

Member Data Documentation

◆ data_

◆ kEmptyTag

◆ kListTag

◆ kSingletonTag

◆ kTagMask

◆ kValueMask

template<typename T >
const intptr_t v8::internal::SmallPointerList< T >::kValueMask = ~kTagMask
staticprivate

Definition at line 153 of file small-pointer-list.h.

Referenced by v8::internal::SmallPointerList< T >::list().


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