V8 Project
v8::ContainsOnlyOneByteHelper Class Reference
+ Collaboration diagram for v8::ContainsOnlyOneByteHelper:

Public Member Functions

 ContainsOnlyOneByteHelper ()
 
bool Check (i::String *string)
 
void VisitOneByteString (const uint8_t *chars, int length)
 
void VisitTwoByteString (const uint16_t *chars, int length)
 

Private Member Functions

bool CheckCons (i::ConsString *cons_string)
 
 DISALLOW_COPY_AND_ASSIGN (ContainsOnlyOneByteHelper)
 

Private Attributes

bool is_one_byte_
 

Detailed Description

Definition at line 4271 of file api.cc.

Constructor & Destructor Documentation

◆ ContainsOnlyOneByteHelper()

v8::ContainsOnlyOneByteHelper::ContainsOnlyOneByteHelper ( )
inline

Definition at line 4273 of file api.cc.

4273 : is_one_byte_(true) {}

Member Function Documentation

◆ Check()

bool v8::ContainsOnlyOneByteHelper::Check ( i::String string)
inline

Definition at line 4274 of file api.cc.

4274  {
4275  i::ConsString* cons_string = i::String::VisitFlat(this, string, 0);
4276  if (cons_string == NULL) return is_one_byte_;
4277  return CheckCons(cons_string);
4278  }
bool CheckCons(i::ConsString *cons_string)
Definition: api.cc:4315
static ConsString * VisitFlat(Visitor *visitor, String *string, int offset=0)
Definition: objects-inl.h:3416
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 CheckCons(), is_one_byte_, NULL, and v8::internal::String::VisitFlat().

Referenced by v8::String::ContainsOnlyOneByte().

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

◆ CheckCons()

bool v8::ContainsOnlyOneByteHelper::CheckCons ( i::ConsString cons_string)
inlineprivate

Definition at line 4315 of file api.cc.

4315  {
4316  while (true) {
4317  // Check left side if flat.
4318  i::String* left = cons_string->first();
4319  i::ConsString* left_as_cons =
4320  i::String::VisitFlat(this, left, 0);
4321  if (!is_one_byte_) return false;
4322  // Check right side if flat.
4323  i::String* right = cons_string->second();
4324  i::ConsString* right_as_cons =
4325  i::String::VisitFlat(this, right, 0);
4326  if (!is_one_byte_) return false;
4327  // Standard recurse/iterate trick.
4328  if (left_as_cons != NULL && right_as_cons != NULL) {
4329  if (left->length() < right->length()) {
4330  CheckCons(left_as_cons);
4331  cons_string = right_as_cons;
4332  } else {
4333  CheckCons(right_as_cons);
4334  cons_string = left_as_cons;
4335  }
4336  // Check fast return.
4337  if (!is_one_byte_) return false;
4338  continue;
4339  }
4340  // Descend left in place.
4341  if (left_as_cons != NULL) {
4342  cons_string = left_as_cons;
4343  continue;
4344  }
4345  // Descend right in place.
4346  if (right_as_cons != NULL) {
4347  cons_string = right_as_cons;
4348  continue;
4349  }
4350  // Terminate.
4351  break;
4352  }
4353  return is_one_byte_;
4354  }

References v8::internal::ConsString::first(), is_one_byte_, v8::internal::String::length(), NULL, v8::internal::ConsString::second(), and v8::internal::String::VisitFlat().

Referenced by Check().

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

◆ DISALLOW_COPY_AND_ASSIGN()

v8::ContainsOnlyOneByteHelper::DISALLOW_COPY_AND_ASSIGN ( ContainsOnlyOneByteHelper  )
private

◆ VisitOneByteString()

void v8::ContainsOnlyOneByteHelper::VisitOneByteString ( const uint8_t *  chars,
int  length 
)
inline

Definition at line 4279 of file api.cc.

4279  {
4280  // Nothing to do.
4281  }

◆ VisitTwoByteString()

void v8::ContainsOnlyOneByteHelper::VisitTwoByteString ( const uint16_t *  chars,
int  length 
)
inline

Definition at line 4282 of file api.cc.

4282  {
4283  // Accumulated bits.
4284  uintptr_t acc = 0;
4285  // Align to uintptr_t.
4286  const uint16_t* end = chars + length;
4287  while (Unaligned(chars) && chars != end) {
4288  acc |= *chars++;
4289  }
4290  // Read word aligned in blocks,
4291  // checking the return value at the end of each block.
4292  const uint16_t* aligned_end = Align(end);
4293  const int increment = sizeof(uintptr_t)/sizeof(uint16_t);
4294  const int inner_loops = 16;
4295  while (chars + inner_loops*increment < aligned_end) {
4296  for (int i = 0; i < inner_loops; i++) {
4297  acc |= *reinterpret_cast<const uintptr_t*>(chars);
4298  chars += increment;
4299  }
4300  // Check for early return.
4301  if ((acc & kOneByteMask) != 0) {
4302  is_one_byte_ = false;
4303  return;
4304  }
4305  }
4306  // Read the rest.
4307  while (chars != end) {
4308  acc |= *chars++;
4309  }
4310  // Check result.
4311  if ((acc & kOneByteMask) != 0) is_one_byte_ = false;
4312  }
unsigned short uint16_t
Definition: unicode.cc:23
static const uint16_t * Align(const uint16_t *chars)
Definition: api.cc:4266
static const uintptr_t kOneByteMask
Definition: api.cc:4259
static bool Unaligned(const uint16_t *chars)
Definition: api.cc:4261

References v8::Align(), is_one_byte_, v8::kOneByteMask, and v8::Unaligned().

+ Here is the call graph for this function:

Member Data Documentation

◆ is_one_byte_

bool v8::ContainsOnlyOneByteHelper::is_one_byte_
private

Definition at line 4355 of file api.cc.

Referenced by Check(), CheckCons(), and VisitTwoByteString().


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