V8 Project
v8::internal::FixedArrayBuilder Class Reference

#include <string-builder.h>

+ Collaboration diagram for v8::internal::FixedArrayBuilder:

Public Member Functions

 FixedArrayBuilder (Isolate *isolate, int initial_capacity)
 
 FixedArrayBuilder (Handle< FixedArray > backing_store)
 
bool HasCapacity (int elements)
 
void EnsureCapacity (int elements)
 
void Add (Object *value)
 
void Add (Smi *value)
 
Handle< FixedArrayarray ()
 
int length ()
 
int capacity ()
 
Handle< JSArrayToJSArray (Handle< JSArray > target_array)
 

Private Attributes

Handle< FixedArrayarray_
 
int length_
 
bool has_non_smi_elements_
 

Detailed Description

Definition at line 110 of file string-builder.h.

Constructor & Destructor Documentation

◆ FixedArrayBuilder() [1/2]

v8::internal::FixedArrayBuilder::FixedArrayBuilder ( Isolate isolate,
int  initial_capacity 
)
inlineexplicit

Definition at line 112 of file string-builder.h.

113  : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)),
114  length_(0),
115  has_non_smi_elements_(false) {
116  // Require a non-zero initial size. Ensures that doubling the size to
117  // extend the array will work.
118  DCHECK(initial_capacity > 0);
119  }
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK.

◆ FixedArrayBuilder() [2/2]

v8::internal::FixedArrayBuilder::FixedArrayBuilder ( Handle< FixedArray backing_store)
inlineexplicit

Definition at line 121 of file string-builder.h.

122  : array_(backing_store), length_(0), has_non_smi_elements_(false) {
123  // Require a non-zero initial size. Ensures that doubling the size to
124  // extend the array will work.
125  DCHECK(backing_store->length() > 0);
126  }

References DCHECK.

Member Function Documentation

◆ Add() [1/2]

void v8::internal::FixedArrayBuilder::Add ( Object value)
inline

Definition at line 149 of file string-builder.h.

149  {
150  DCHECK(!value->IsSmi());
151  DCHECK(length_ < capacity());
152  array_->set(length_, value);
153  length_++;
154  has_non_smi_elements_ = true;
155  }

References array_, capacity(), DCHECK, has_non_smi_elements_, and length_.

Referenced by v8::internal::ReplacementStringBuilder::AddElement(), v8::internal::ReplacementStringBuilder::AddSubjectSlice(), and v8::internal::SearchRegExpMultiple().

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

◆ Add() [2/2]

void v8::internal::FixedArrayBuilder::Add ( Smi value)
inline

Definition at line 157 of file string-builder.h.

157  {
158  DCHECK(value->IsSmi());
159  DCHECK(length_ < capacity());
160  array_->set(length_, value);
161  length_++;
162  }

References array_, capacity(), DCHECK, and length_.

+ Here is the call graph for this function:

◆ array()

Handle<FixedArray> v8::internal::FixedArrayBuilder::array ( )
inline

Definition at line 164 of file string-builder.h.

164 { return array_; }

References array_.

Referenced by v8::internal::SearchRegExpMultiple(), and v8::internal::ReplacementStringBuilder::ToString().

+ Here is the caller graph for this function:

◆ capacity()

int v8::internal::FixedArrayBuilder::capacity ( )
inline

Definition at line 168 of file string-builder.h.

168 { return array_->length(); }

References array_.

Referenced by Add(), and v8::internal::ReplacementStringBuilder::AddElement().

+ Here is the caller graph for this function:

◆ EnsureCapacity()

void v8::internal::FixedArrayBuilder::EnsureCapacity ( int  elements)
inline

Definition at line 134 of file string-builder.h.

134  {
135  int length = array_->length();
136  int required_length = length_ + elements;
137  if (length < required_length) {
138  int new_length = length;
139  do {
140  new_length *= 2;
141  } while (new_length < required_length);
142  Handle<FixedArray> extended_array =
143  array_->GetIsolate()->factory()->NewFixedArrayWithHoles(new_length);
144  array_->CopyTo(0, *extended_array, 0, length_);
145  array_ = extended_array;
146  }
147  }

References array_, length(), and length_.

Referenced by v8::internal::ReplacementStringBuilder::EnsureCapacity(), and v8::internal::SearchRegExpMultiple().

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

◆ HasCapacity()

bool v8::internal::FixedArrayBuilder::HasCapacity ( int  elements)
inline

Definition at line 128 of file string-builder.h.

128  {
129  int length = array_->length();
130  int required_length = length_ + elements;
131  return (length >= required_length);
132  }

References array_, length(), and length_.

+ Here is the call graph for this function:

◆ length()

int v8::internal::FixedArrayBuilder::length ( )
inline

Definition at line 166 of file string-builder.h.

166 { return length_; }

References length_.

Referenced by v8::internal::ReplacementStringBuilder::AddElement(), EnsureCapacity(), HasCapacity(), v8::internal::SearchRegExpMultiple(), and v8::internal::ReplacementStringBuilder::ToString().

+ Here is the caller graph for this function:

◆ ToJSArray()

Handle<JSArray> v8::internal::FixedArrayBuilder::ToJSArray ( Handle< JSArray target_array)
inline

Definition at line 170 of file string-builder.h.

170  {
171  JSArray::SetContent(target_array, array_);
172  target_array->set_length(Smi::FromInt(length_));
173  return target_array;
174  }
static void SetContent(Handle< JSArray > array, Handle< FixedArrayBase > storage)
Definition: objects-inl.h:6986
static Smi * FromInt(int value)
Definition: objects-inl.h:1321

References array_, v8::internal::Smi::FromInt(), length_, and v8::internal::JSArray::SetContent().

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

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

Member Data Documentation

◆ array_

Handle<FixedArray> v8::internal::FixedArrayBuilder::array_
private

Definition at line 178 of file string-builder.h.

Referenced by Add(), array(), capacity(), EnsureCapacity(), HasCapacity(), and ToJSArray().

◆ has_non_smi_elements_

bool v8::internal::FixedArrayBuilder::has_non_smi_elements_
private

Definition at line 180 of file string-builder.h.

Referenced by Add().

◆ length_

int v8::internal::FixedArrayBuilder::length_
private

Definition at line 179 of file string-builder.h.

Referenced by Add(), EnsureCapacity(), HasCapacity(), length(), and ToJSArray().


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