Chromium Code Reviews| Index: src/objects-inl.h |
| diff --git a/src/objects-inl.h b/src/objects-inl.h |
| index 53a3183694cbfdfc87f16524888036e27d434d14..7014a6de93ca68266645093414e8992e671ff693 100644 |
| --- a/src/objects-inl.h |
| +++ b/src/objects-inl.h |
| @@ -184,6 +184,15 @@ bool Object::IsConsString() { |
| } |
| +bool Object::IsSlicedString() { |
| + if (!this->IsHeapObject()) return false; |
| + uint32_t type = HeapObject::cast(this)->map()->instance_type(); |
| + uint32_t representation = |
|
antonm
2011/07/27 14:04:49
if you don't want to introduce helper function whi
|
| + type & (kIsNotStringMask | kStringRepresentationMask); |
| + return representation == (kStringTag | kSlicedStringTag); |
| +} |
| + |
| + |
| bool Object::IsSeqString() { |
| if (!IsString()) return false; |
| return StringShape(String::cast(this)).IsSequential(); |
| @@ -280,6 +289,11 @@ bool StringShape::IsCons() { |
| } |
| +bool StringShape::IsSliced() { |
| + return (type_ & kStringRepresentationMask) == kSlicedStringTag; |
| +} |
| + |
| + |
| bool StringShape::IsExternal() { |
| return (type_ & kStringRepresentationMask) == kExternalStringTag; |
| } |
| @@ -2041,6 +2055,7 @@ CAST_ACCESSOR(String) |
| CAST_ACCESSOR(SeqString) |
| CAST_ACCESSOR(SeqAsciiString) |
| CAST_ACCESSOR(SeqTwoByteString) |
| +CAST_ACCESSOR(SlicedString) |
| CAST_ACCESSOR(ConsString) |
| CAST_ACCESSOR(ExternalString) |
| CAST_ACCESSOR(ExternalAsciiString) |
| @@ -2156,6 +2171,9 @@ uint16_t String::Get(int index) { |
| return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); |
| case kExternalStringTag | kTwoByteStringTag: |
| return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); |
| + case kSlicedStringTag | kAsciiStringTag: |
| + case kSlicedStringTag | kTwoByteStringTag: |
| + return SlicedString::cast(this)->SlicedStringGet(index); |
| default: |
| break; |
| } |
| @@ -2188,6 +2206,12 @@ bool String::IsFlat() { |
| } |
| +bool String::IsIndirect() { |
| + uint32_t representation = StringShape(this).representation_tag(); |
| + return (representation & kIsIndirectStringMask) == kIsIndirectStringTag; |
| +} |
| + |
| + |
| uint16_t SeqAsciiString::SeqAsciiStringGet(int index) { |
| ASSERT(index >= 0 && index < length()); |
| return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
| @@ -2243,6 +2267,20 @@ int SeqAsciiString::SeqAsciiStringSize(InstanceType instance_type) { |
| } |
| +String* SlicedString::parent() { |
| + return String::cast(READ_FIELD(this, kParentOffset)); |
| +} |
| + |
| + |
| +void SlicedString::set_parent(String* parent) { |
| + ASSERT(parent->IsSeqString()); |
| + WRITE_FIELD(this, kParentOffset, parent); |
| +} |
| + |
| + |
| +SMI_ACCESSORS(SlicedString, offset, kOffsetOffset) |
| + |
| + |
| String* ConsString::first() { |
| return String::cast(READ_FIELD(this, kFirstOffset)); |
| } |