V8 Project
v8::internal::ReplacementStringBuilder Class Reference

#include <string-builder.h>

+ Collaboration diagram for v8::internal::ReplacementStringBuilder:

Public Member Functions

 ReplacementStringBuilder (Heap *heap, Handle< String > subject, int estimated_part_count)
 
void EnsureCapacity (int elements)
 
void AddSubjectSlice (int from, int to)
 
void AddString (Handle< String > string)
 
MaybeHandle< StringToString ()
 
void IncrementCharacterCount (int by)
 

Static Public Member Functions

static void AddSubjectSlice (FixedArrayBuilder *builder, int from, int to)
 

Private Member Functions

void AddElement (Object *element)
 

Private Attributes

Heapheap_
 
FixedArrayBuilder array_builder_
 
Handle< Stringsubject_
 
int character_count_
 
bool is_one_byte_
 

Detailed Description

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

Constructor & Destructor Documentation

◆ ReplacementStringBuilder()

v8::internal::ReplacementStringBuilder::ReplacementStringBuilder ( Heap heap,
Handle< String subject,
int  estimated_part_count 
)
inline

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

188  : heap_(heap),
189  array_builder_(heap->isolate(), estimated_part_count),
190  subject_(subject),
191  character_count_(0),
192  is_one_byte_(subject->IsOneByteRepresentation()) {
193  // Require a non-zero initial size. Ensures that doubling the size to
194  // extend the array will work.
195  DCHECK(estimated_part_count > 0);
196  }
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK.

Member Function Documentation

◆ AddElement()

void v8::internal::ReplacementStringBuilder::AddElement ( Object element)
inlineprivate

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

281  {
282  DCHECK(element->IsSmi() || element->IsString());
284  array_builder_.Add(element);
285  }

References v8::internal::FixedArrayBuilder::Add(), array_builder_, v8::internal::FixedArrayBuilder::capacity(), DCHECK, and v8::internal::FixedArrayBuilder::length().

Referenced by AddString().

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

◆ AddString()

void v8::internal::ReplacementStringBuilder::AddString ( Handle< String string)
inline

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

225  {
226  int length = string->length();
227  DCHECK(length > 0);
228  AddElement(*string);
229  if (!string->IsOneByteRepresentation()) {
230  is_one_byte_ = false;
231  }
232  IncrementCharacterCount(length);
233  }

References AddElement(), DCHECK, IncrementCharacterCount(), and is_one_byte_.

Referenced by v8::internal::CompiledReplacement::Apply(), and v8::internal::StringReplaceGlobalRegExpWithString().

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

◆ AddSubjectSlice() [1/2]

static void v8::internal::ReplacementStringBuilder::AddSubjectSlice ( FixedArrayBuilder builder,
int  from,
int  to 
)
inlinestatic

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

199  {
200  DCHECK(from >= 0);
201  int length = to - from;
202  DCHECK(length > 0);
205  int encoded_slice = StringBuilderSubstringLength::encode(length) |
207  builder->Add(Smi::FromInt(encoded_slice));
208  } else {
209  // Otherwise encode as two smis.
210  builder->Add(Smi::FromInt(-length));
211  builder->Add(Smi::FromInt(from));
212  }
213  }
static Smi * FromInt(int value)
Definition: objects-inl.h:1321
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 expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes to(mksnapshot only)") DEFINE_STRING(raw_context_file

References v8::internal::FixedArrayBuilder::Add(), DCHECK, v8::internal::BitFieldBase< T, shift, size, uint32_t >::encode(), v8::internal::Smi::FromInt(), v8::internal::BitFieldBase< T, shift, size, uint32_t >::is_valid(), and to().

Referenced by AddSubjectSlice(), v8::internal::CompiledReplacement::Apply(), v8::internal::SearchRegExpMultiple(), and v8::internal::StringReplaceGlobalRegExpWithString().

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

◆ AddSubjectSlice() [2/2]

void v8::internal::ReplacementStringBuilder::AddSubjectSlice ( int  from,
int  to 
)
inline

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

219  {
221  IncrementCharacterCount(to - from);
222  }
static void AddSubjectSlice(FixedArrayBuilder *builder, int from, int to)

References AddSubjectSlice(), array_builder_, IncrementCharacterCount(), and to().

+ Here is the call graph for this function:

◆ EnsureCapacity()

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

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

216 { array_builder_.EnsureCapacity(elements); }
void EnsureCapacity(int elements)

References array_builder_, and v8::internal::FixedArrayBuilder::EnsureCapacity().

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

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

◆ IncrementCharacterCount()

void v8::internal::ReplacementStringBuilder::IncrementCharacterCount ( int  by)
inline

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

271  {
275  } else {
276  character_count_ += by;
277  }
278  }
static const int kMaxLength
Definition: objects.h:8820
const int kMaxInt
Definition: globals.h:109
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))

References character_count_, v8::internal::kMaxInt, v8::internal::String::kMaxLength, and v8::internal::STATIC_ASSERT().

Referenced by AddString(), and AddSubjectSlice().

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

◆ ToString()

MaybeHandle<String> v8::internal::ReplacementStringBuilder::ToString ( )
inline

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

236  {
237  Isolate* isolate = heap_->isolate();
238  if (array_builder_.length() == 0) {
239  return isolate->factory()->empty_string();
240  }
241 
242  Handle<String> joined_string;
243  if (is_one_byte_) {
244  Handle<SeqOneByteString> seq;
246  isolate, seq,
247  isolate->factory()->NewRawOneByteString(character_count_), String);
248 
250  uint8_t* char_buffer = seq->GetChars();
253  joined_string = Handle<String>::cast(seq);
254  } else {
255  // Two-byte.
256  Handle<SeqTwoByteString> seq;
258  isolate, seq,
259  isolate->factory()->NewRawTwoByteString(character_count_), String);
260 
262  uc16* char_buffer = seq->GetChars();
265  joined_string = Handle<String>::cast(seq);
266  }
267  return joined_string;
268  }
Handle< FixedArray > array()
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
Isolate * isolate()
Definition: heap-inl.h:589
Factory * factory()
Definition: isolate.h:982
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T)
Definition: isolate.h:135
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110
static void StringBuilderConcatHelper(String *special, sinkchar *sink, FixedArray *fixed_array, int array_length)
uint16_t uc16
Definition: globals.h:184

References v8::internal::FixedArrayBuilder::array(), array_builder_, ASSIGN_RETURN_ON_EXCEPTION, v8::internal::Handle< T >::cast(), character_count_, v8::internal::Isolate::factory(), heap_, is_one_byte_, v8::internal::Heap::isolate(), v8::internal::FixedArrayBuilder::length(), v8::internal::StringBuilderConcatHelper(), and subject_.

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

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

Member Data Documentation

◆ array_builder_

FixedArrayBuilder v8::internal::ReplacementStringBuilder::array_builder_
private

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

Referenced by AddElement(), AddSubjectSlice(), EnsureCapacity(), and ToString().

◆ character_count_

int v8::internal::ReplacementStringBuilder::character_count_
private

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

Referenced by IncrementCharacterCount(), and ToString().

◆ heap_

Heap* v8::internal::ReplacementStringBuilder::heap_
private

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

Referenced by ToString().

◆ is_one_byte_

bool v8::internal::ReplacementStringBuilder::is_one_byte_
private

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

Referenced by AddString(), and ToString().

◆ subject_

Handle<String> v8::internal::ReplacementStringBuilder::subject_
private

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

Referenced by ToString().


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