V8 Project
v8::internal::ConsString Class Reference

#include <objects.h>

+ Inheritance diagram for v8::internal::ConsString:
+ Collaboration diagram for v8::internal::ConsString:

Public Types

typedef FixedBodyDescriptor< kFirstOffset, kSecondOffset+kPointerSize, kSizeBodyDescriptor
 
- Public Types inherited from v8::internal::String
enum  Encoding { ONE_BYTE_ENCODING , TWO_BYTE_ENCODING }
 
- Public Types inherited from v8::internal::Object
enum  StoreFromKeyed { MAY_BE_STORE_FROM_KEYED , CERTAINLY_NOT_STORE_FROM_KEYED }
 
enum  StorePropertyMode { NORMAL_PROPERTY , SUPER_PROPERTY }
 

Public Member Functions

Stringfirst ()
 
Objectunchecked_first ()
 
void set_first (String *first, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
 
Stringsecond ()
 
Objectunchecked_second ()
 
void set_second (String *second, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
 
uint16_t ConsStringGet (int index)
 
- Public Member Functions inherited from v8::internal::String
 STATIC_ASSERT ((kArrayIndexLengthBits > 0))
 
 STATIC_ASSERT (IS_POWER_OF_TWO(kMaxCachedArrayIndexLength+1))
 
int length () const
 
void set_length (int value)
 
int synchronized_length () const
 
void synchronized_set_length (int value)
 
bool IsOneByteRepresentation () const
 
bool IsTwoByteRepresentation () const
 
bool IsOneByteRepresentationUnderneath ()
 
bool IsTwoByteRepresentationUnderneath ()
 
bool HasOnlyOneByteChars ()
 
void Set (int index, uint16_t value)
 
 INLINE (uint16_t Get(int index))
 
FlatContent GetFlatContent ()
 
StringGetUnderlying ()
 
bool MarkAsUndetectable ()
 
bool Equals (String *other)
 
bool IsUtf8EqualTo (Vector< const char > str, bool allow_prefix_match=false)
 
bool IsOneByteEqualTo (Vector< const uint8_t > str)
 
bool IsTwoByteEqualTo (Vector< const uc16 > str)
 
SmartArrayPointer< char > ToCString (AllowNullsFlag allow_nulls, RobustnessFlag robustness_flag, int offset, int length, int *length_output=0)
 
SmartArrayPointer< char > ToCString (AllowNullsFlag allow_nulls=DISALLOW_NULLS, RobustnessFlag robustness_flag=FAST_STRING_TRAVERSAL, int *length_output=0)
 
SmartArrayPointer< uc16ToWideCString (RobustnessFlag robustness_flag=FAST_STRING_TRAVERSAL)
 
bool ComputeArrayIndex (uint32_t *index)
 
bool MakeExternal (v8::String::ExternalStringResource *resource)
 
bool MakeExternal (v8::String::ExternalOneByteStringResource *resource)
 
bool AsArrayIndex (uint32_t *index)
 
void PrintOn (FILE *out)
 
bool LooksValid ()
 
void StringShortPrint (StringStream *accumulator)
 
void PrintUC16 (OStream &os, int start=0, int end=-1)
 
bool IsFlat ()
 
 STATIC_ASSERT (kMaxArrayIndexSize<(1<< kArrayIndexLengthBits))
 
const uc16GetTwoByteData (unsigned start)
 
void SetForwardedInternalizedString (String *string)
 
StringGetForwardedInternalizedString ()
 
- Public Member Functions inherited from v8::internal::Name
uint32_t hash_field ()
 
void set_hash_field (uint32_t value)
 
bool HasHashCode ()
 
uint32_t Hash ()
 
bool Equals (Name *other)
 
bool AsArrayIndex (uint32_t *index)
 
bool IsOwn ()
 
 STATIC_ASSERT ((kArrayIndexLengthBits > 0))
 
 STATIC_ASSERT (IS_POWER_OF_TWO(kMaxCachedArrayIndexLength+1))
 
- Public Member Functions inherited from v8::internal::HeapObject
Mapmap () const
 
void set_map (Map *value)
 
void set_map_no_write_barrier (Map *value)
 
Mapsynchronized_map ()
 
MapWord synchronized_map_word () const
 
void synchronized_set_map (Map *value)
 
void synchronized_set_map_no_write_barrier (Map *value)
 
void synchronized_set_map_word (MapWord map_word)
 
MapWord map_word () const
 
void set_map_word (MapWord map_word)
 
HeapGetHeap () const
 
IsolateGetIsolate () const
 
Address address ()
 
void Iterate (ObjectVisitor *v)
 
void IterateBody (InstanceType type, int object_size, ObjectVisitor *v)
 
int Size ()
 
bool MayContainRawValues ()
 
int SizeFromMap (Map *map)
 
WriteBarrierMode GetWriteBarrierMode (const DisallowHeapAllocation &promise)
 
void HeapObjectShortPrint (OStream &os)
 
 STATIC_ASSERT (kMapOffset==Internals::kHeapObjectMapOffset)
 
- Public Member Functions inherited from v8::internal::Object
bool IsObject () const
 
 INLINE (bool IsFixedArrayBase() const)
 
 INLINE (bool IsExternal() const)
 
 INLINE (bool IsAccessorInfo() const)
 
 INLINE (bool IsStruct() const)
 
 INLINE (bool IsSpecObject()) const
 
 INLINE (bool IsSpecFunction()) const
 
 INLINE (bool IsTemplateInfo()) const
 
 INLINE (bool IsNameDictionary() const)
 
 INLINE (bool IsSeededNumberDictionary() const)
 
 INLINE (bool IsUnseededNumberDictionary() const)
 
 INLINE (bool IsOrderedHashSet() const)
 
 INLINE (bool IsOrderedHashMap() const)
 
bool IsCallable () const
 
 INLINE (bool IsUndefined() const)
 
 INLINE (bool IsNull() const)
 
 INLINE (bool IsTheHole() const)
 
 INLINE (bool IsException() const)
 
 INLINE (bool IsUninitialized() const)
 
 INLINE (bool IsTrue() const)
 
 INLINE (bool IsFalse() const)
 
 INLINE (bool IsArgumentsMarker() const)
 
 INLINE (bool IsFiller() const)
 
double Number ()
 
 INLINE (bool IsNaN() const)
 
 INLINE (bool IsMinusZero() const)
 
bool ToInt32 (int32_t *value)
 
bool ToUint32 (uint32_t *value)
 
Representation OptimalRepresentation ()
 
bool FitsRepresentation (Representation representation)
 
Handle< HeapTypeOptimalType (Isolate *isolate, Representation representation)
 
bool HasValidElements ()
 
bool HasSpecificClassOf (String *name)
 
bool BooleanValue ()
 
ObjectGetHash ()
 
bool SameValue (Object *other)
 
bool SameValueZero (Object *other)
 
bool ToArrayIndex (uint32_t *index)
 
bool IsStringObjectWithCharacterAt (uint32_t index)
 
void VerifyApiCallResultType ()
 
void ShortPrint (FILE *out=stdout)
 
void ShortPrint (StringStream *accumulator)
 

Static Public Attributes

static const int kFirstOffset = POINTER_SIZE_ALIGN(String::kSize)
 
static const int kSecondOffset = kFirstOffset + kPointerSize
 
static const int kSize = kSecondOffset + kPointerSize
 
static const int kMinLength = 13
 
- Static Public Attributes inherited from v8::internal::String
static const int kMaxCachedArrayIndexLength = 7
 
static const int kArrayIndexValueBits = 24
 
static const int kArrayIndexLengthBits
 
static const unsigned int kContainsCachedArrayIndexMask
 
static const int kLengthOffset = Name::kSize
 
static const int kSize = kLengthOffset + kPointerSize
 
static const int kMaxArrayIndexSize = 10
 
static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar
 
static const uint32_t kMaxOneByteCharCodeU = unibrow::Latin1::kMaxChar
 
static const int kMaxUtf16CodeUnit = 0xffff
 
static const uint32_t kMaxUtf16CodeUnitU = kMaxUtf16CodeUnit
 
static const int kEmptyStringHash = kIsNotArrayIndexMask
 
static const int kMaxLength = (1 << 28) - 16
 
static const int kMaxHashCalcLength = 16383
 
static const int kMaxShortPrintLength = 1024
 
- Static Public Attributes inherited from v8::internal::Name
static const int kHashFieldOffset = HeapObject::kHeaderSize
 
static const int kSize = kHashFieldOffset + kPointerSize
 
static const int kHashNotComputedMask = 1
 
static const int kIsNotArrayIndexMask = 1 << 1
 
static const int kNofHashBitFields = 2
 
static const int kHashShift = kNofHashBitFields
 
static const uint32_t kHashBitMask = 0xffffffffu >> kHashShift
 
static const int kMaxCachedArrayIndexLength = 7
 
static const int kArrayIndexValueBits = 24
 
static const int kArrayIndexLengthBits
 
static const unsigned int kContainsCachedArrayIndexMask
 
static const int kEmptyHashField
 
- Static Public Attributes inherited from v8::internal::HeapObject
static const int kMapOffset = Object::kHeaderSize
 
static const int kHeaderSize = kMapOffset + kPointerSize
 
- Static Public Attributes inherited from v8::internal::Object
static const int kHeaderSize = 0
 

Private Member Functions

 DISALLOW_IMPLICIT_CONSTRUCTORS (ConsString)
 

Additional Inherited Members

- Static Public Member Functions inherited from v8::internal::String
static Handle< StringFlatten (Handle< String > string, PretenureFlag pretenure=NOT_TENURED)
 
static bool Equals (Handle< String > one, Handle< String > two)
 
template<typename sinkchar >
static void WriteToFlat (String *source, sinkchar *sink, int from, int to)
 
static int NonAsciiStart (const char *chars, int length)
 
static bool IsAscii (const char *chars, int length)
 
static bool IsAscii (const uint8_t *chars, int length)
 
static int NonOneByteStart (const uc16 *chars, int length)
 
static bool IsOneByte (const uc16 *chars, int length)
 
template<class Visitor >
static ConsStringVisitFlat (Visitor *visitor, String *string, int offset=0)
 
static Handle< FixedArrayCalculateLineEnds (Handle< String > string, bool include_ending_line)
 
- Static Public Member Functions inherited from v8::internal::Name
static bool Equals (Handle< Name > one, Handle< Name > two)
 
- Static Public Member Functions inherited from v8::internal::HeapObject
static HeapObjectFromAddress (Address address)
 
static Object ** RawField (HeapObject *obj, int offset)
 
static void UpdateMapCodeCache (Handle< HeapObject > object, Handle< Name > name, Handle< Code > code)
 
- Static Public Member Functions inherited from v8::internal::Object
static Handle< ObjectNewStorageFor (Isolate *isolate, Handle< Object > object, Representation representation)
 
static Handle< ObjectWrapForRead (Isolate *isolate, Handle< Object > object, Representation representation)
 
static MaybeHandle< JSReceiverToObject (Isolate *isolate, Handle< Object > object)
 
static MaybeHandle< JSReceiverToObject (Isolate *isolate, Handle< Object > object, Handle< Context > context)
 
static MUST_USE_RESULT MaybeHandle< SmiToSmi (Isolate *isolate, Handle< Object > object)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (LookupIterator *it)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetProperty (Handle< Object > object, Handle< Name > key, Handle< Object > value, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetProperty (LookupIterator *it, Handle< Object > value, StrictMode strict_mode, StoreFromKeyed store_mode, StorePropertyMode data_store_mode=NORMAL_PROPERTY)
 
static MUST_USE_RESULT MaybeHandle< ObjectWriteToReadOnlyProperty (LookupIterator *it, Handle< Object > value, StrictMode strict_mode)
 
static Handle< ObjectSetDataProperty (LookupIterator *it, Handle< Object > value)
 
static MUST_USE_RESULT MaybeHandle< ObjectAddDataProperty (LookupIterator *it, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyOrElement (Handle< Object > object, Handle< Name > key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (Isolate *isolate, Handle< Object > object, const char *key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (Handle< Object > object, Handle< Name > key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyWithAccessor (Handle< Object > receiver, Handle< Name > name, Handle< JSObject > holder, Handle< Object > structure)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetPropertyWithAccessor (Handle< Object > receiver, Handle< Name > name, Handle< Object > value, Handle< JSObject > holder, Handle< Object > structure, StrictMode strict_mode)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyWithDefinedGetter (Handle< Object > receiver, Handle< JSReceiver > getter)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetPropertyWithDefinedSetter (Handle< Object > receiver, Handle< JSReceiver > setter, Handle< Object > value)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetElement (Isolate *isolate, Handle< Object > object, uint32_t index)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetElementWithReceiver (Isolate *isolate, Handle< Object > object, Handle< Object > receiver, uint32_t index)
 
static Handle< SmiGetOrCreateHash (Isolate *isolate, Handle< Object > object)
 
- Protected Member Functions inherited from v8::internal::HeapObject
void IteratePointers (ObjectVisitor *v, int start, int end)
 
void IteratePointer (ObjectVisitor *v, int offset)
 
void IterateNextCodeLink (ObjectVisitor *v, int offset)
 
- Static Protected Member Functions inherited from v8::internal::Name
static bool IsHashFieldComputed (uint32_t field)
 

Detailed Description

Definition at line 9037 of file objects.h.

Member Typedef Documentation

◆ BodyDescriptor

Member Function Documentation

◆ ConsStringGet()

uint16_t v8::internal::ConsString::ConsStringGet ( int  index)

Definition at line 8333 of file objects.cc.

8333  {
8334  DCHECK(index >= 0 && index < this->length());
8335 
8336  // Check for a flattened cons string
8337  if (second()->length() == 0) {
8338  String* left = first();
8339  return left->Get(index);
8340  }
8341 
8342  String* string = String::cast(this);
8343 
8344  while (true) {
8345  if (StringShape(string).IsCons()) {
8346  ConsString* cons_string = ConsString::cast(string);
8347  String* left = cons_string->first();
8348  if (left->length() > index) {
8349  string = left;
8350  } else {
8351  index -= left->length();
8352  string = cons_string->second();
8353  }
8354  } else {
8355  return string->Get(index);
8356  }
8357  }
8358 
8359  UNREACHABLE();
8360  return 0;
8361 }
#define UNREACHABLE()
Definition: logging.h:30
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, first(), v8::internal::String::length(), second(), and UNREACHABLE.

+ Here is the call graph for this function:

◆ DISALLOW_IMPLICIT_CONSTRUCTORS()

v8::internal::ConsString::DISALLOW_IMPLICIT_CONSTRUCTORS ( ConsString  )
private

◆ first()

String * v8::internal::ConsString::first ( )
inline

Definition at line 3539 of file objects-inl.h.

3539  {
3540  return String::cast(READ_FIELD(this, kFirstOffset));
3541 }
static const int kFirstOffset
Definition: objects.h:9061
#define READ_FIELD(p, offset)
Definition: objects-inl.h:1179

References v8::internal::DescriptorArray::kFirstOffset, and READ_FIELD.

Referenced by v8::Utf8LengthHelper::Calculate(), v8::ContainsOnlyOneByteHelper::CheckCons(), ConsStringGet(), v8::internal::String::GetFlatContent(), v8::internal::ConsStringIteratorOp::NextLeaf(), v8::RecursivelySerializeToUtf8(), v8::internal::ConsStringIteratorOp::Search(), v8::internal::StringReplaceOneCharWithString(), and v8::internal::String::WriteToFlat().

+ Here is the caller graph for this function:

◆ second()

String * v8::internal::ConsString::second ( )
inline

Definition at line 3555 of file objects-inl.h.

3555  {
3556  return String::cast(READ_FIELD(this, kSecondOffset));
3557 }
static const int kSecondOffset
Definition: objects.h:9062

References READ_FIELD.

Referenced by v8::Utf8LengthHelper::Calculate(), v8::ContainsOnlyOneByteHelper::CheckCons(), ConsStringGet(), v8::internal::String::GetFlatContent(), v8::internal::ConsStringIteratorOp::NextLeaf(), v8::RecursivelySerializeToUtf8(), v8::internal::ConsStringIteratorOp::Search(), v8::internal::StringReplaceOneCharWithString(), and v8::internal::String::WriteToFlat().

+ Here is the caller graph for this function:

◆ set_first()

void v8::internal::ConsString::set_first ( String first,
WriteBarrierMode  mode = UPDATE_WRITE_BARRIER 
)
inline

Definition at line 3549 of file objects-inl.h.

3549  {
3550  WRITE_FIELD(this, kFirstOffset, value);
3552 }
Heap * GetHeap() const
Definition: objects-inl.h:1379
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 mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
#define WRITE_FIELD(p, offset, value)
Definition: objects-inl.h:1190
#define CONDITIONAL_WRITE_BARRIER(heap, object, offset, value, mode)
Definition: objects-inl.h:1210

References CONDITIONAL_WRITE_BARRIER, v8::internal::HeapObject::GetHeap(), v8::internal::DescriptorArray::kFirstOffset, mode(), and WRITE_FIELD.

+ Here is the call graph for this function:

◆ set_second()

void v8::internal::ConsString::set_second ( String second,
WriteBarrierMode  mode = UPDATE_WRITE_BARRIER 
)
inline

Definition at line 3565 of file objects-inl.h.

3565  {
3566  WRITE_FIELD(this, kSecondOffset, value);
3568 }

References CONDITIONAL_WRITE_BARRIER, v8::internal::HeapObject::GetHeap(), mode(), and WRITE_FIELD.

+ Here is the call graph for this function:

◆ unchecked_first()

Object * v8::internal::ConsString::unchecked_first ( )
inline

Definition at line 3544 of file objects-inl.h.

3544  {
3545  return READ_FIELD(this, kFirstOffset);
3546 }

References v8::internal::DescriptorArray::kFirstOffset, and READ_FIELD.

◆ unchecked_second()

Object * v8::internal::ConsString::unchecked_second ( )
inline

Definition at line 3560 of file objects-inl.h.

3560  {
3561  return READ_FIELD(this, kSecondOffset);
3562 }

References READ_FIELD.

Member Data Documentation

◆ kFirstOffset

◆ kMinLength

const int v8::internal::ConsString::kMinLength = 13
static

Definition at line 9066 of file objects.h.

Referenced by v8::internal::HGraphBuilder::BuildBinaryOperation().

◆ kSecondOffset

◆ kSize


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