v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
String Class Reference

#include <objects.h>

Inheritance diagram for String:
Collaboration diagram for String:

Data Structures

class  FlatContent
 

Public Types

enum  Encoding { ONE_BYTE_ENCODING, TWO_BYTE_ENCODING }
 
- Public Types inherited from Object
enum  ValueType { OPTIMAL_REPRESENTATION, FORCE_TAGGED }
 

Public Member Functions

int length ()
 
void set_length (int value)
 
bool IsOneByteRepresentation ()
 
bool IsTwoByteRepresentation ()
 
bool IsOneByteRepresentationUnderneath ()
 
bool IsTwoByteRepresentationUnderneath ()
 
bool HasOnlyOneByteChars ()
 
void Set (int index, uint16_t value)
 
 INLINE (uint16_t Get(int index))
 
MaybeObject * TryFlatten (PretenureFlag pretenure=NOT_TENURED)
 
StringTryFlattenGetString (PretenureFlag pretenure=NOT_TENURED)
 
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::ExternalAsciiStringResource *resource)
 
bool AsArrayIndex (uint32_t *index)
 
void PrintOn (FILE *out)
 
bool LooksValid ()
 
void StringShortPrint (StringStream *accumulator)
 
bool IsFlat ()
 
 STATIC_CHECK (kMaxArrayIndexSize< (1<< kArrayIndexLengthBits))
 
const uc16GetTwoByteData (unsigned start)
 
- Public Member Functions inherited from 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 IsCacheable (Isolate *isolate)
 
 STATIC_CHECK ((kArrayIndexLengthBits > 0))
 
 STATIC_CHECK (IS_POWER_OF_TWO(kMaxCachedArrayIndexLength+1))
 
- Public Member Functions inherited from HeapObject
Mapmap ()
 
void set_map (Map *value)
 
void set_map_no_write_barrier (Map *value)
 
MapWord map_word ()
 
void set_map_word (MapWord map_word)
 
HeapGetHeap ()
 
IsolateGetIsolate ()
 
Address address ()
 
void Iterate (ObjectVisitor *v)
 
void IterateBody (InstanceType type, int object_size, ObjectVisitor *v)
 
int Size ()
 
int SizeFromMap (Map *map)
 
WriteBarrierMode GetWriteBarrierMode (const DisallowHeapAllocation &promise)
 
void HeapObjectShortPrint (StringStream *accumulator)
 
 STATIC_CHECK (kMapOffset==Internals::kHeapObjectMapOffset)
 
- Public Member Functions inherited from Object
bool IsObject ()
 
bool IsFixedArrayBase ()
 
bool IsExternal ()
 
bool IsAccessorInfo ()
 
bool IsStruct ()
 
 INLINE (bool IsSpecObject())
 
 INLINE (bool IsSpecFunction())
 
bool IsCallable ()
 
 INLINE (bool IsUndefined())
 
 INLINE (bool IsNull())
 
 INLINE (bool IsTheHole())
 
 INLINE (bool IsUninitialized())
 
 INLINE (bool IsTrue())
 
 INLINE (bool IsFalse())
 
bool IsArgumentsMarker ()
 
bool NonFailureIsHeapObject ()
 
bool IsFiller ()
 
double Number ()
 
bool IsNaN ()
 
bool ToInt32 (int32_t *value)
 
bool ToUint32 (uint32_t *value)
 
Representation OptimalRepresentation (ValueType type=OPTIMAL_REPRESENTATION)
 
bool FitsRepresentation (Representation representation)
 
MaybeObject * AllocateNewStorageFor (Heap *heap, Representation representation)
 
bool HasValidElements ()
 
bool HasSpecificClassOf (String *name)
 
MUST_USE_RESULT MaybeObject * ToObject (Isolate *isolate)
 
bool BooleanValue ()
 
MUST_USE_RESULT MaybeObject * ToObject (Context *native_context)
 
MUST_USE_RESULT MaybeObject * ToSmi ()
 
void Lookup (Name *name, LookupResult *result)
 
MUST_USE_RESULT MaybeObject * GetProperty (Name *key)
 
MUST_USE_RESULT MaybeObject * GetProperty (Name *key, PropertyAttributes *attributes)
 
MUST_USE_RESULT MaybeObject * GetPropertyWithReceiver (Object *receiver, Name *key, PropertyAttributes *attributes)
 
MUST_USE_RESULT MaybeObject * GetProperty (Object *receiver, LookupResult *result, Name *key, PropertyAttributes *attributes)
 
MUST_USE_RESULT MaybeObject * GetPropertyWithDefinedGetter (Object *receiver, JSReceiver *getter)
 
ObjectGetPrototype (Isolate *isolate)
 
MapGetMarkerMap (Isolate *isolate)
 
ObjectGetHash ()
 
bool SameValue (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 Member Functions

static Stringcast (Object *obj)
 
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 , class ConsOp >
static void Visit (String *string, unsigned offset, Visitor &visitor, ConsOp &cons_op, int32_t type, unsigned length)
 
template<class Visitor >
static ConsStringVisitFlat (Visitor *visitor, String *string, int offset, int length, int32_t type)
 
template<class Visitor >
static ConsStringVisitFlat (Visitor *visitor, String *string, int offset=0)
 
- Static Public Member Functions inherited from Name
static Namecast (Object *obj)
 
- Static Public Member Functions inherited from 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 HeapObjectcast (Object *obj)
 
- Static Public Member Functions inherited from Object
static MUST_USE_RESULT Handle
< Object
ToSmi (Isolate *isolate, Handle< Object > object)
 
static Handle< ObjectGetPropertyWithReceiver (Handle< Object > object, Handle< Object > receiver, Handle< Name > name, PropertyAttributes *attributes)
 
static Handle< ObjectGetProperty (Handle< Object > object, Handle< Name > key)
 
static Handle< ObjectGetProperty (Handle< Object > object, Handle< Object > receiver, LookupResult *result, Handle< Name > key, PropertyAttributes *attributes)
 
static MUST_USE_RESULT
MaybeObject * 
GetPropertyOrFail (Handle< Object > object, Handle< Object > receiver, LookupResult *result, Handle< Name > key, PropertyAttributes *attributes)
 
static Handle< ObjectGetElement (Isolate *isolate, Handle< Object > object, uint32_t index)
 
static Handle< ObjectGetElementNoExceptionThrown (Isolate *isolate, Handle< Object > object, uint32_t index)
 
static Handle< ObjectGetElementWithReceiver (Isolate *isolate, Handle< Object > object, Handle< Object > receiver, uint32_t index)
 
static Handle< ObjectGetOrCreateHash (Handle< Object > object, Isolate *isolate)
 
static Objectcast (Object *value)
 

Static Public Attributes

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 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 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 int kArrayIndexHashLengthShift
 
static const int kArrayIndexHashMask = (1 << kArrayIndexHashLengthShift) - 1
 
static const int kArrayIndexValueMask
 
static const unsigned int kContainsCachedArrayIndexMask
 
static const int kEmptyHashField
 
- Static Public Attributes inherited from HeapObject
static const int kMapOffset = Object::kHeaderSize
 
static const int kHeaderSize = kMapOffset + kPointerSize
 
- Static Public Attributes inherited from Object
static const int kHeaderSize = 0
 

Friends

class Name
 

Additional Inherited Members

- Protected Member Functions inherited from 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 Name
static bool IsHashFieldComputed (uint32_t field)
 

Detailed Description

Definition at line 8731 of file objects.h.

Member Enumeration Documentation

enum Encoding
Enumerator
ONE_BYTE_ENCODING 
TWO_BYTE_ENCODING 

Definition at line 8733 of file objects.h.

Member Function Documentation

static String* cast ( Object obj)
inlinestatic

Referenced by Heap::AllocateInternalizedStringImpl(), Heap::AllocateOneByteInternalizedString(), Heap::AllocateRawOneByteString(), Heap::AllocateRawTwoByteString(), Heap::AllocateTwoByteInternalizedString(), Logger::ApiNamedPropertyAccess(), Logger::ApiNamedSecurityCheck(), CodeEventLogger::NameBuffer::AppendName(), Name::AsArrayIndex(), RegExpImpl::AtomExecRaw(), Object::BooleanValue(), JSReceiver::class_name(), Logger::CodeCreateEvent(), CodeEventLogger::CodeCreateEvent(), ConsString::ConsStringGet(), Map::constructor_name(), ScopeInfo::ContextLocalName(), ScopeInfo::CopyContextLocalsToScopeObject(), SharedFunctionInfo::DebugName(), JSObject::DefineAccessor(), Scope::DeserializeScopeChain(), Isolate::DoThrow(), RegExpResultsCache::Enter(), Name::Equals(), JSObject::ExpectedTransitionKey(), ConsString::first(), ScopeInfo::FunctionName(), V8HeapExplorer::GetConstructorName(), Function::GetDisplayName(), Runtime::GetElementOrCharAt(), JSObject::GetLocalElementKeys(), StringsStorage::GetName(), Heap::GetNumberStringCache(), v8::internal::GetScriptLineNumberSafe(), SharedFunctionInfo::GetSourceCode(), String::GetUnderlying(), Name::Hash(), SequentialStringKey< uc16 >::HashForObject(), SubStringKey< Char >::HashForObject(), Utf8StringKey::HashForObject(), StringKey::HashForObject(), StringSharedKey::HashForObject(), RegExpKey::HashForObject(), InternalizedStringKey::HashForObject(), TwoCharHashTableKey::HashForObject(), StringsKey::HashForObject(), Script::HasValidSource(), HeapObject::HeapObjectShortPrint(), Runtime::InitializeIntrinsicFunctionNames(), v8::internal::InitScriptLineEnds(), OneByteStringKey::IsMatch(), TwoByteStringKey::IsMatch(), Utf8StringKey::IsMatch(), StringKey::IsMatch(), StringSharedKey::IsMatch(), RegExpKey::IsMatch(), SubStringKey< Char >::IsMatch(), InternalizedStringKey::IsMatch(), TwoCharHashTableKey::IsMatch(), V8_FINAL< kOperandKind, kNumCachedOperands >::IsPropertyName(), Object::IsStringObjectWithCharacterAt(), JSObject::JSObjectShortPrint(), BASE_EMBEDDED< Visitor >::KeyToUniqueName(), ScopeInfo::LocalName(), Logger::LogExistingFunction(), Logger::LogRuntime(), Context::Lookup(), StringTable::LookupStringIfExists(), StringTable::LookupTwoCharsStringIfExists(), FullCodeGenerator::MakeCode(), ModuleInfo::name(), Heap::NumberToString(), ScopeInfo::ParameterName(), SlicedString::parent(), JSRegExp::Pattern(), Map::PrintGeneralization(), JSObject::PrintInstanceMigration(), StringStream::PrintName(), StringStream::PrintPrototype(), JavaScriptFrame::PrintTop(), StringStream::PrintUsingMap(), Compiler::RecordFunctionCompilation(), v8::internal::RUNTIME_FUNCTION(), Object::SameValue(), ConsString::second(), SharedFunctionInfo::SourceCodePrint(), ScopeInfo::StackLocalName(), Value::StrictEquals(), InternalizedStringKey::StringHash(), StringSharedKey::StringSharedHashHelper(), JSObjectWalkVisitor< ContextObject >::StructureWalk(), Logger::SuspectReadEvent(), TEST(), NameDictionary::TransformPropertiesToFastFor(), String::TryFlattenGetString(), KeyedLookupCache::Update(), ToBooleanStub::Types::UpdateStatus(), StringObject::ValueOf(), Heap::VisitExternalResources(), and StringTableCleaner< finalize_external_strings >::VisitPointers().

bool ComputeArrayIndex ( uint32_t *  index)
INLINE ( uint16_t   Getint index)
static bool IsAscii ( const char *  chars,
int  length 
)
inlinestatic

Definition at line 8966 of file objects.h.

Referenced by TEST().

static bool IsAscii ( const uint8_t *  chars,
int  length 
)
inlinestatic

Definition at line 8970 of file objects.h.

static bool IsOneByte ( const uc16 chars,
int  length 
)
inlinestatic
bool MarkAsUndetectable ( )

Definition at line 8955 of file objects.cc.

References HeapObject::GetHeap(), HeapObject::map(), and HeapObject::set_map().

static int NonAsciiStart ( const char *  chars,
int  length 
)
inlinestatic

Definition at line 8944 of file objects.h.

References ASSERT, Utf8::kMaxOneByteChar, and v8::internal::kUintptrAllBitsSet.

Referenced by Heap::AllocateStringFromUtf8().

static int NonOneByteStart ( const uc16 chars,
int  length 
)
inlinestatic

Definition at line 8975 of file objects.h.

void PrintOn ( FILE *  out)
STATIC_CHECK ( )
SmartArrayPointer< char > ToCString ( AllowNullsFlag  allow_nulls = DISALLOW_NULLS,
RobustnessFlag  robustness_flag = FAST_STRING_TRAVERSAL,
int *  length_output = 0 
)

Definition at line 8323 of file objects.cc.

References String::ToCString().

MaybeObject * TryFlatten ( PretenureFlag  pretenure = NOT_TENURED)
inline
String * TryFlattenGetString ( PretenureFlag  pretenure = NOT_TENURED)
inline

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

References String::cast().

ConsString * VisitFlat ( Visitor *  visitor,
String string,
int  offset,
int  length,
int32_t  type 
)
inlinestatic
static ConsString* VisitFlat ( Visitor *  visitor,
String string,
int  offset = 0 
)
inlinestatic

Definition at line 9006 of file objects.h.

References String::length().

Friends And Related Function Documentation

friend class Name
friend

Definition at line 9014 of file objects.h.

Field Documentation

const int kEmptyStringHash = kIsNotArrayIndexMask
static

Definition at line 8919 of file objects.h.

const int kMaxArrayIndexSize = 10
static
const int kMaxHashCalcLength = 16383
static
const uint32_t kMaxOneByteCharCodeU = unibrow::Latin1::kMaxChar
static

Definition at line 8915 of file objects.h.

const int kMaxShortPrintLength = 1024
static

Definition at line 8929 of file objects.h.

Referenced by String::StringShortPrint().

const int kSize = kLengthOffset + kPointerSize
static

Definition at line 8906 of file objects.h.


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