Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index 9ef14dbdab6868ed3f2e5461b02be1351dc8f597..692cd49cb7b4289550cb29857f875b0d48d6ae3d 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -86,6 +86,7 @@ |
| // - SeqString |
| // - SeqAsciiString |
| // - SeqTwoByteString |
| +// - SlicedString |
| // - ConsString |
| // - ExternalString |
| // - ExternalAsciiString |
| @@ -280,6 +281,7 @@ static const int kVariableSizeSentinel = 0; |
| V(ASCII_STRING_TYPE) \ |
| V(CONS_STRING_TYPE) \ |
| V(CONS_ASCII_STRING_TYPE) \ |
| + V(SLICED_STRING_TYPE) \ |
| V(EXTERNAL_STRING_TYPE) \ |
| V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \ |
| V(EXTERNAL_ASCII_STRING_TYPE) \ |
| @@ -368,6 +370,14 @@ static const int kVariableSizeSentinel = 0; |
| ConsString::kSize, \ |
| cons_ascii_symbol, \ |
| ConsAsciiSymbol) \ |
| + V(SLICED_SYMBOL_TYPE, \ |
| + SlicedString::kSize, \ |
| + sliced_symbol, \ |
| + SlicedSymbol) \ |
| + V(SLICED_ASCII_SYMBOL_TYPE, \ |
| + SlicedString::kSize, \ |
| + sliced_ascii_symbol, \ |
| + SlicedAsciiSymbol) \ |
| V(EXTERNAL_SYMBOL_TYPE, \ |
| ExternalTwoByteString::kSize, \ |
| external_symbol, \ |
| @@ -396,6 +406,14 @@ static const int kVariableSizeSentinel = 0; |
| ConsString::kSize, \ |
| cons_ascii_string, \ |
| ConsAsciiString) \ |
| + V(SLICED_STRING_TYPE, \ |
| + SlicedString::kSize, \ |
| + sliced_string, \ |
| + SlicedString) \ |
| + V(SLICED_ASCII_STRING_TYPE, \ |
| + SlicedString::kSize, \ |
| + sliced_ascii_string, \ |
| + SlicedAsciiString) \ |
| V(EXTERNAL_STRING_TYPE, \ |
| ExternalTwoByteString::kSize, \ |
| external_string, \ |
| @@ -469,9 +487,15 @@ const uint32_t kStringRepresentationMask = 0x03; |
| enum StringRepresentationTag { |
| kSeqStringTag = 0x0, |
| kConsStringTag = 0x1, |
| - kExternalStringTag = 0x2 |
| + kExternalStringTag = 0x2, |
| + kSlicedStringTag = 0x3 |
| }; |
| -const uint32_t kIsConsStringMask = 0x1; |
| +const uint32_t kIsIndirectStringMask = 0x1; |
| +const uint32_t kIsIndirectStringTag = 0x1; |
| +STATIC_ASSERT( |
| + (kConsStringTag & kIsIndirectStringMask) == kIsIndirectStringTag); |
| +STATIC_ASSERT( |
| + (kSlicedStringTag & kIsIndirectStringMask) == kIsIndirectStringTag); |
|
antonm
2011/07/27 14:04:49
sorry, up to you, but I would code it like:
bool
Yang
2011/07/28 15:43:06
There is only one place where this tag is actually
|
| // If bit 7 is clear, then bit 3 indicates whether this two-byte |
| // string actually contains ascii data. |
| @@ -497,6 +521,8 @@ enum InstanceType { |
| ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kSeqStringTag, |
| CONS_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kConsStringTag, |
| CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag, |
| + SLICED_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kSlicedStringTag, |
|
antonm
2011/07/27 14:04:49
Do we want sliced symbols?
Rico
2011/07/28 06:49:50
I am a little concerned about this as well, this c
|
| + SLICED_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kSlicedStringTag, |
| EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, |
| EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = |
| kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, |
| @@ -506,6 +532,8 @@ enum InstanceType { |
| ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag, |
| CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, |
| CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag, |
| + SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag, |
| + SLICED_ASCII_STRING_TYPE = kAsciiStringTag | kSlicedStringTag, |
| EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, |
| EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = |
| kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, |
| @@ -709,6 +737,7 @@ class MaybeObject BASE_EMBEDDED { |
| V(SeqString) \ |
| V(ExternalString) \ |
| V(ConsString) \ |
| + V(SlicedString) \ |
| V(ExternalTwoByteString) \ |
| V(ExternalAsciiString) \ |
| V(SeqTwoByteString) \ |
| @@ -5709,6 +5738,7 @@ class StringShape BASE_EMBEDDED { |
| inline bool IsSequential(); |
| inline bool IsExternal(); |
| inline bool IsCons(); |
| + inline bool IsSliced(); |
| inline bool IsExternalAscii(); |
| inline bool IsExternalTwoByte(); |
| inline bool IsSequentialAscii(); |
| @@ -5881,6 +5911,7 @@ class String: public HeapObject { |
| void StringVerify(); |
| #endif |
| inline bool IsFlat(); |
| + inline bool IsIndirect(); |
| // Layout description. |
| static const int kLengthOffset = HeapObject::kHeaderSize; |
| @@ -6228,6 +6259,44 @@ class ConsString: public String { |
| }; |
| +class SlicedString: public String { |
| + public: |
| + |
| + inline String* parent(); |
| + inline void set_parent(String* parent); |
| + inline int offset(); |
| + inline void set_offset(int offset); |
| + |
| + // Dispatched behavior. |
| + uint16_t SlicedStringGet(int index); |
| + |
| + // Casting. |
| + static inline SlicedString* cast(Object* obj); |
| + |
| + // Layout description. |
| + static const int kParentOffset = POINTER_SIZE_ALIGN(String::kSize); |
| + static const int kOffsetOffset = kParentOffset + kPointerSize; |
| + static const int kSize = kOffsetOffset + kPointerSize; |
| + |
| + // Support for StringInputBuffer |
| + inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer, |
| + unsigned* offset_ptr, |
| + unsigned chars); |
| + inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| + unsigned* offset_ptr, |
| + unsigned chars); |
| + // Minimum length for a sliced string. |
| + static const int kMinLength = 13; |
| + |
| + typedef FixedBodyDescriptor<kParentOffset, |
| + kOffsetOffset + kPointerSize, kSize> |
| + BodyDescriptor; |
| + |
| + private: |
| + DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString); |
| +}; |
| + |
| + |
| // The ExternalString class describes string values that are backed by |
| // a string resource that lies outside the V8 heap. ExternalStrings |
| // consist of the length field common to all strings, a pointer to the |