| Index: src/objects.h
|
| diff --git a/src/objects.h b/src/objects.h
|
| index 59d735d80260006b45bdb9977903924b51c1a0f5..ed59fb5ee48dbd2e7085481265cf82d022d8b320 100644
|
| --- a/src/objects.h
|
| +++ b/src/objects.h
|
| @@ -241,7 +241,9 @@ static const int kVariableSizeSentinel = 0;
|
| V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \
|
| V(EXTERNAL_ASCII_STRING_TYPE) \
|
| V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \
|
| - \
|
| + V(EXTERNAL_BUFFERED_STRING_TYPE) \
|
| + V(EXTERNAL_BUFFERED_STRING_WITH_ASCII_DATA_TYPE) \
|
| + V(EXTERNAL_BUFFERED_ASCII_STRING_TYPE) \
|
| V(MAP_TYPE) \
|
| V(CODE_TYPE) \
|
| V(ODDBALL_TYPE) \
|
| @@ -375,7 +377,31 @@ static const int kVariableSizeSentinel = 0;
|
| V(EXTERNAL_ASCII_STRING_TYPE, \
|
| ExternalAsciiString::kSize, \
|
| external_ascii_string, \
|
| - ExternalAsciiString)
|
| + ExternalAsciiString) \
|
| + V(EXTERNAL_BUFFERED_SYMBOL_TYPE, \
|
| + ExternalTwoByteString::kExtendedSize, \
|
| + external_buffered_symbol, \
|
| + ExternalBufferedSymbol) \
|
| + V(EXTERNAL_BUFFERED_SYMBOL_WITH_ASCII_DATA_TYPE, \
|
| + ExternalTwoByteString::kExtendedSize, \
|
| + external_buffered_symbol_with_ascii_data, \
|
| + ExternalBufferedSymbolWithAsciiData) \
|
| + V(EXTERNAL_BUFFERED_ASCII_SYMBOL_TYPE, \
|
| + ExternalAsciiString::kExtendedSize, \
|
| + external_buffered_ascii_symbol, \
|
| + ExternalBufferedAsciiSymbol) \
|
| + V(EXTERNAL_BUFFERED_STRING_TYPE, \
|
| + ExternalTwoByteString::kExtendedSize, \
|
| + external_buffered_string, \
|
| + ExternalBufferedString) \
|
| + V(EXTERNAL_BUFFERED_STRING_WITH_ASCII_DATA_TYPE, \
|
| + ExternalTwoByteString::kExtendedSize, \
|
| + external_buffered_string_with_ascii_data, \
|
| + ExternalBufferedStringWithAsciiData) \
|
| + V(EXTERNAL_BUFFERED_ASCII_STRING_TYPE, \
|
| + ExternalAsciiString::kExtendedSize, \
|
| + external_buffered_ascii_string, \
|
| + ExternalBufferedAsciiString)
|
|
|
| // A struct is a simple object a set of object-valued fields. Including an
|
| // object type in this causes the compiler to generate most of the boilerplate
|
| @@ -459,6 +485,9 @@ STATIC_ASSERT(IS_POWER_OF_TWO(kSlicedNotConsMask) && kSlicedNotConsMask != 0);
|
| const uint32_t kAsciiDataHintMask = 0x08;
|
| const uint32_t kAsciiDataHintTag = 0x08;
|
|
|
| +// In the case of external string, bit 4 indicates whether it has a buffer.
|
| +const uint32_t kBufferedStringMask = 0x10;
|
| +const uint32_t kBufferedStringTag = 0x10;
|
|
|
| // A ConsString with an empty string as the right side is a candidate
|
| // for being shortcut by the garbage collector unless it is a
|
| @@ -492,9 +521,27 @@ enum InstanceType {
|
| EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag,
|
| EXTERNAL_STRING_WITH_ASCII_DATA_TYPE =
|
| kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag,
|
| - // LAST_STRING_TYPE
|
| EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag,
|
| PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE,
|
| + EXTERNAL_BUFFERED_SYMBOL_TYPE =
|
| + kTwoByteStringTag | kExternalStringTag |
|
| + kBufferedStringTag | kSymbolTag,
|
| + EXTERNAL_BUFFERED_SYMBOL_WITH_ASCII_DATA_TYPE =
|
| + kTwoByteStringTag | kExternalStringTag |
|
| + kAsciiDataHintTag | kBufferedStringTag | kSymbolTag,
|
| + // LAST_STRING_TYPE
|
| + EXTERNAL_BUFFERED_ASCII_SYMBOL_TYPE =
|
| + kAsciiStringTag | kExternalStringTag |
|
| + kBufferedStringTag | kSymbolTag,
|
| + EXTERNAL_BUFFERED_STRING_TYPE =
|
| + kTwoByteStringTag | kExternalStringTag | kBufferedStringTag,
|
| + EXTERNAL_BUFFERED_STRING_WITH_ASCII_DATA_TYPE =
|
| + kTwoByteStringTag | kExternalStringTag |
|
| + kAsciiDataHintTag | kBufferedStringTag,
|
| + // LAST_STRING_TYPE
|
| + EXTERNAL_BUFFERED_ASCII_STRING_TYPE =
|
| + kAsciiStringTag | kExternalStringTag | kBufferedStringTag,
|
| +
|
|
|
| // Objects allocated in their own spaces (never in new space).
|
| MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE
|
| @@ -6215,11 +6262,17 @@ class String: public HeapObject {
|
| // possible.
|
| inline bool HasOnlyAsciiChars();
|
|
|
| + enum ExternalStringBufferFlag {
|
| + IGNORE_EXTERNAL_STRING_BUFFER,
|
| + UPDATE_EXTERNAL_STRING_BUFFER
|
| + };
|
| +
|
| // Get and set individual two byte chars in the string.
|
| inline void Set(int index, uint16_t value);
|
| // Get individual two byte char in the string. Repeated calls
|
| // to this method are not efficient unless the string is flat.
|
| - inline uint16_t Get(int index);
|
| + inline uint16_t Get(
|
| + int index, ExternalStringBufferFlag flag = IGNORE_EXTERNAL_STRING_BUFFER);
|
|
|
| // Try to flatten the string. Checks first inline to see if it is
|
| // necessary. Does nothing if the string is not a cons string.
|
| @@ -6654,7 +6707,8 @@ class ConsString: public String {
|
| WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
|
|
| // Dispatched behavior.
|
| - uint16_t ConsStringGet(int index);
|
| + uint16_t ConsStringGet(
|
| + int index, ExternalStringBufferFlag flag = IGNORE_EXTERNAL_STRING_BUFFER);
|
|
|
| // Casting.
|
| static inline ConsString* cast(Object* obj);
|
| @@ -6707,7 +6761,8 @@ class SlicedString: public String {
|
| inline void set_offset(int offset);
|
|
|
| // Dispatched behavior.
|
| - uint16_t SlicedStringGet(int index);
|
| + uint16_t SlicedStringGet(
|
| + int index, ExternalStringBufferFlag flag = IGNORE_EXTERNAL_STRING_BUFFER);
|
|
|
| // Casting.
|
| static inline SlicedString* cast(Object* obj);
|
| @@ -6754,12 +6809,31 @@ class ExternalString: public String {
|
| // Casting
|
| static inline ExternalString* cast(Object* obj);
|
|
|
| + // Read-ahead buffer.
|
| + inline Address buffer();
|
| + inline int buffer_index();
|
| + inline void set_buffer_index(int index);
|
| + inline bool IsBuffered();
|
| +
|
| // Layout description.
|
| static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize);
|
| static const int kSize = kResourceOffset + kPointerSize;
|
|
|
| + // Long external strings have a read-ahead buffer attached.
|
| + static const int kBufferIndexOffset = kSize;
|
| + static const int kBufferContentOffset = kBufferIndexOffset + kPointerSize;
|
| +
|
| + static const int kBufferSize = 11 * kPointerSize;
|
| + static const int kExtendedSize = kBufferContentOffset + kBufferSize;
|
| + static const int kMinBufferedStringLength = 256;
|
| + static const int kInvalidBufferIndex = String::kMaxLength;
|
| +
|
| STATIC_CHECK(kResourceOffset == Internals::kStringResourceOffset);
|
|
|
| +#ifdef DEBUG
|
| + void ExternalStringVerify();
|
| +#endif
|
| +
|
| private:
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString);
|
| };
|
| @@ -6771,6 +6845,11 @@ class ExternalAsciiString: public ExternalString {
|
| public:
|
| static const bool kHasAsciiEncoding = true;
|
|
|
| + static const int kBufferedChars = kBufferSize / kASCIISize;
|
| + static const int kBackwardBufferedChars = kBufferedChars >> 2;
|
| + static const int kForwardBufferedChars =
|
| + kBufferedChars - kBackwardBufferedChars;
|
| +
|
| typedef v8::String::ExternalAsciiStringResource Resource;
|
|
|
| // The underlying resource.
|
| @@ -6778,7 +6857,8 @@ class ExternalAsciiString: public ExternalString {
|
| inline void set_resource(const Resource* buffer);
|
|
|
| // Dispatched behavior.
|
| - uint16_t ExternalAsciiStringGet(int index);
|
| + uint16_t ExternalAsciiStringGet(
|
| + int index, ExternalStringBufferFlag flag = IGNORE_EXTERNAL_STRING_BUFFER);
|
|
|
| // Casting.
|
| static inline ExternalAsciiString* cast(Object* obj);
|
| @@ -6808,6 +6888,11 @@ class ExternalTwoByteString: public ExternalString {
|
| public:
|
| static const bool kHasAsciiEncoding = false;
|
|
|
| + static const int kBufferedChars = kBufferSize / kUC16Size;
|
| + static const int kBackwardBufferedChars = kBufferedChars >> 2;
|
| + static const int kForwardBufferedChars =
|
| + kBufferedChars - kBackwardBufferedChars;
|
| +
|
| typedef v8::String::ExternalStringResource Resource;
|
|
|
| // The underlying string resource.
|
| @@ -6815,7 +6900,8 @@ class ExternalTwoByteString: public ExternalString {
|
| inline void set_resource(const Resource* buffer);
|
|
|
| // Dispatched behavior.
|
| - uint16_t ExternalTwoByteStringGet(int index);
|
| + uint16_t ExternalTwoByteStringGet(
|
| + int index, ExternalStringBufferFlag flag = IGNORE_EXTERNAL_STRING_BUFFER);
|
|
|
| // For regexp code.
|
| const uint16_t* ExternalTwoByteStringGetData(unsigned start);
|
|
|