| Index: src/objects-inl.h
|
| diff --git a/src/objects-inl.h b/src/objects-inl.h
|
| index e3d21cc658ea6d2445c22ebab33fedc3033bb969..2e3aaf4968c436b1f898c1c88ec44c7eaadf34a3 100644
|
| --- a/src/objects-inl.h
|
| +++ b/src/objects-inl.h
|
| @@ -178,6 +178,13 @@ bool Object::IsConsString() {
|
| }
|
|
|
|
|
| +bool Object::IsFlatString() {
|
| + if (!this->IsHeapObject()) return false;
|
| + uint32_t type = HeapObject::cast(this)->map()->instance_type();
|
| + return (type & (kIsNotStringMask | kStringRepresentationMask)) == kStringTag;
|
| +}
|
| +
|
| +
|
| bool Object::IsSeqString() {
|
| if (!IsString()) return false;
|
| return StringShape(String::cast(this)).IsSequential();
|
| @@ -1875,6 +1882,7 @@ CAST_ACCESSOR(CompilationCacheTable)
|
| CAST_ACCESSOR(CodeCacheHashTable)
|
| CAST_ACCESSOR(MapCache)
|
| CAST_ACCESSOR(String)
|
| +CAST_ACCESSOR(FlatString)
|
| CAST_ACCESSOR(SeqString)
|
| CAST_ACCESSOR(SeqAsciiString)
|
| CAST_ACCESSOR(SeqTwoByteString)
|
| @@ -1974,6 +1982,26 @@ String* String::TryFlattenGetString(PretenureFlag pretenure) {
|
| }
|
|
|
|
|
| +uint16_t FlatString::FlatStringGet(int index) {
|
| + ASSERT(index >= 0 && index < length());
|
| + switch (StringShape(this).full_representation_tag()) {
|
| + case kSeqStringTag | kAsciiStringTag:
|
| + return SeqAsciiString::cast(this)->SeqAsciiStringGet(index);
|
| + case kSeqStringTag | kTwoByteStringTag:
|
| + return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index);
|
| + case kExternalStringTag | kAsciiStringTag:
|
| + return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index);
|
| + case kExternalStringTag | kTwoByteStringTag:
|
| + return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index);
|
| + default:
|
| + break;
|
| + }
|
| +
|
| + UNREACHABLE();
|
| + return 0;
|
| +}
|
| +
|
| +
|
| uint16_t String::Get(int index) {
|
| ASSERT(index >= 0 && index < length());
|
| switch (StringShape(this).full_representation_tag()) {
|
| @@ -1991,12 +2019,19 @@ uint16_t String::Get(int index) {
|
| default:
|
| break;
|
| }
|
| -
|
| UNREACHABLE();
|
| return 0;
|
| }
|
|
|
|
|
| +MaybeObject* String::GetMayFlatten(int index) {
|
| + if (this->IsConsString()) {
|
| + return ConsString::cast(this)->ConsStringGetMayFlatten(index);
|
| + }
|
| + return Smi::FromInt(FlatString::cast(this)->FlatStringGet(index));
|
| +}
|
| +
|
| +
|
| void String::Set(int index, uint16_t value) {
|
| ASSERT(index >= 0 && index < length());
|
| ASSERT(StringShape(this).IsSequential());
|
|
|