Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index 93f7a1d119d0f7321df3c1f42fe16bb50df2c6bb..0e8b28d8d95b0946f59f0e429a2945bf01997a48 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -5789,6 +5789,7 @@ class StringShape BASE_EMBEDDED { |
| inline bool IsSequentialTwoByte(); |
| inline bool IsSymbol(); |
| inline StringRepresentationTag representation_tag(); |
| + inline uint32_t encoding_tag(); |
| inline uint32_t full_representation_tag(); |
| inline uint32_t size_tag(); |
| #ifdef DEBUG |
| @@ -5820,6 +5821,35 @@ class StringShape BASE_EMBEDDED { |
| // All string values have a length field. |
| class String: public HeapObject { |
| public: |
| + class FlatContent { |
| + public: |
| + explicit FlatContent(Vector<const char> chars) |
| + : buffer_(Vector<const byte>::cast(chars)), |
| + state_(ASCII) { } |
| + explicit FlatContent(Vector<const uc16> chars) |
| + : buffer_(Vector<const byte>::cast(chars)), |
| + state_(TWO_BYTE) { } |
| + FlatContent() : buffer_(), state_(NON_FLAT) { } |
| + |
| + bool IsFlat() { return state_ != NON_FLAT; } |
| + bool IsAscii() { return state_ == ASCII; } |
| + bool IsTwoByte() { return state_ == TWO_BYTE; } |
| + |
| + Vector<const char> ToAsciiVector() { |
| + ASSERT_EQ(ASCII, state_); |
| + return Vector<const char>::cast(buffer_); |
| + } |
| + Vector<const uc16> ToUC16Vector() { |
| + ASSERT_EQ(TWO_BYTE, state_); |
| + return Vector<const uc16>::cast(buffer_); |
| + } |
| + |
| + private: |
| + enum State { NON_FLAT, ASCII, TWO_BYTE }; |
| + Vector<const byte> buffer_; |
| + State state_; |
| + }; |
| + |
| // Get and set the length of the string. |
| inline int length(); |
| inline void set_length(int value); |
| @@ -5831,10 +5861,10 @@ class String: public HeapObject { |
| inline bool IsAsciiRepresentation(); |
| inline bool IsTwoByteRepresentation(); |
| - // Returns whether this string has ascii chars, i.e. all of them can |
| - // be ascii encoded. This might be the case even if the string is |
| + // Returns whether this string has only ASCII chars, i.e. all of them can |
| + // be ASCII encoded. This might be the case even if the string is |
| // two-byte. Such strings may appear when the embedder prefers |
| - // two-byte external representations even for ascii data. |
| + // two-byte external representations even for ASCII data. |
| // |
| // NOTE: this should be considered only a hint. False negatives are |
| // possible. |
| @@ -5868,8 +5898,7 @@ class String: public HeapObject { |
| // string. |
| inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED); |
| - Vector<const char> ToAsciiVector(); |
| - Vector<const uc16> ToUC16Vector(); |
| + FlatContent GetFlatContent(); |
|
Vitaly Repeshko
2011/08/23 10:28:28
This needs some documentation.
A couple of option
Lasse Reichstein
2011/08/23 12:01:55
Absolutely.
|
| // Mark the string as an undetectable object. It only applies to |
| // ascii and two byte string types. |