Index: src/objects.h |
diff --git a/src/objects.h b/src/objects.h |
index f1fa27accdef209ed0e0653f6bd20b331a3b24e9..ad921251fa2f224028a92d43eaf9d4e4e7bacce7 100644 |
--- a/src/objects.h |
+++ b/src/objects.h |
@@ -532,9 +532,11 @@ enum InstanceType { |
SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kSeqStringTag, |
ASCII_SYMBOL_TYPE = kOneByteStringTag | kAsciiDataHintTag | kSymbolTag | |
kSeqStringTag, |
+ ONE_BYTE_SYMBOL_TYPE = kOneByteStringTag | kSymbolTag | kSeqStringTag, |
CONS_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kConsStringTag, |
CONS_ASCII_SYMBOL_TYPE = kOneByteStringTag | kAsciiDataHintTag | kSymbolTag | |
kConsStringTag, |
+ CONS_ONE_BYTE_SYMBOL_TYPE = kOneByteStringTag | kSymbolTag | kConsStringTag, |
SHORT_EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | |
kExternalStringTag | kShortExternalStringTag, |
SHORT_EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = |
@@ -543,19 +545,27 @@ enum InstanceType { |
SHORT_EXTERNAL_ASCII_SYMBOL_TYPE = kOneByteStringTag | kAsciiDataHintTag | |
kExternalStringTag | kSymbolTag | |
kShortExternalStringTag, |
+ SHORT_EXTERNAL_ONE_BYTE_SYMBOL_TYPE = kOneByteStringTag | |
+ kExternalStringTag | kSymbolTag | |
+ kShortExternalStringTag, |
EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, |
EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = |
kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, |
EXTERNAL_ASCII_SYMBOL_TYPE = |
kOneByteStringTag | kAsciiDataHintTag | kSymbolTag | kExternalStringTag, |
+ EXTERNAL_ONE_BYTE_SYMBOL_TYPE = |
+ kOneByteStringTag | kSymbolTag | kExternalStringTag, |
STRING_TYPE = kTwoByteStringTag | kSeqStringTag, |
ASCII_STRING_TYPE = kOneByteStringTag | kAsciiDataHintTag | kSeqStringTag, |
+ ONE_BYTE_STRING_TYPE = kOneByteStringTag | kSeqStringTag, |
CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, |
CONS_ASCII_STRING_TYPE = |
kOneByteStringTag | kAsciiDataHintTag | kConsStringTag, |
+ CONS_ONE_BYTE_STRING_TYPE = kOneByteStringTag | kConsStringTag, |
SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag, |
SLICED_ASCII_STRING_TYPE = |
kOneByteStringTag | kAsciiDataHintTag | kSlicedStringTag, |
+ SLICED_ONE_BYTE_STRING_TYPE = kOneByteStringTag | kSlicedStringTag, |
SHORT_EXTERNAL_STRING_TYPE = |
kTwoByteStringTag | kExternalStringTag | kShortExternalStringTag, |
SHORT_EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = |
@@ -564,12 +574,15 @@ enum InstanceType { |
SHORT_EXTERNAL_ASCII_STRING_TYPE = |
kOneByteStringTag | kAsciiDataHintTag | |
kExternalStringTag | kShortExternalStringTag, |
+ SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE = |
+ kOneByteStringTag | kExternalStringTag | kShortExternalStringTag, |
EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, |
EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = |
kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, |
- // LAST_STRING_TYPE |
EXTERNAL_ASCII_STRING_TYPE = |
kOneByteStringTag | kAsciiDataHintTag | kExternalStringTag, |
+ // LAST_STRING_TYPE |
+ EXTERNAL_ONE_BYTE_STRING_TYPE = kOneByteStringTag | kExternalStringTag, |
PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE, |
// Objects allocated in their own spaces (never in new space). |
@@ -3028,7 +3041,7 @@ class SymbolTable: public HashTable<SymbolTableShape, HashTableKey*> { |
// pointer *s is set to the symbol found. |
MUST_USE_RESULT MaybeObject* LookupUtf8Symbol(Vector<const char> str, |
Object** s); |
- MUST_USE_RESULT MaybeObject* LookupOneByteSymbol(Vector<const char> str, |
+ MUST_USE_RESULT MaybeObject* LookupOneByteSymbol(Vector<const uint8_t> str, |
Object** s); |
MUST_USE_RESULT MaybeObject* LookupSubStringOneByteSymbol( |
Handle<SeqOneByteString> str, |
@@ -7057,12 +7070,19 @@ class String: public HeapObject { |
// Returns true if the structure contains two-byte content. |
bool IsTwoByte() { return state_ == TWO_BYTE; } |
+ // TODO(dcarney): Remove this function. |
// Return the ASCII content of the string. Only use if IsAscii() returns |
// true. |
Vector<const char> ToAsciiVector() { |
ASSERT_EQ(ASCII, state_); |
return Vector<const char>::cast(buffer_); |
} |
+ // Return the one byte content of the string. Only use if IsAscii() returns |
+ // true. |
+ Vector<const uint8_t> ToOneByteVector() { |
+ ASSERT_EQ(ASCII, state_); |
+ return buffer_; |
+ } |
// Return the two-byte content of the string. Only use if IsTwoByte() |
// returns true. |
Vector<const uc16> ToUC16Vector() { |
@@ -7113,6 +7133,8 @@ class String: public HeapObject { |
// possible. |
inline bool HasOnlyAsciiChars(); |
+ inline bool IsOneByteConvertible(); |
+ |
// 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 |
@@ -7163,8 +7185,8 @@ class String: public HeapObject { |
// String equality operations. |
inline bool Equals(String* other); |
- bool IsEqualTo(Vector<const char> str); |
- bool IsAsciiEqualTo(Vector<const char> str); |
+ bool IsUtf8EqualTo(Vector<const char> str); |
+ bool IsOneByteEqualTo(Vector<const uint8_t> str); |
bool IsTwoByteEqualTo(Vector<const uc16> str); |
// Return a UTF8 representation of the string. The string is null |
@@ -7240,9 +7262,9 @@ class String: public HeapObject { |
// value into an array index. |
static const int kMaxArrayIndexSize = 10; |
- // Max ASCII char code. |
- static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; |
- static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; |
+ // Max char codes. |
+ static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar; |
+ static const uint32_t kMaxOneByteCharCodeU = unibrow::Latin1::kMaxChar; |
static const int kMaxUtf16CodeUnit = 0xffff; |
// Mask constant for checking if a string has a computed hash code |
@@ -7327,7 +7349,7 @@ class String: public HeapObject { |
const char* start = chars; |
const char* limit = chars + length; |
#ifdef V8_HOST_CAN_READ_UNALIGNED |
- ASSERT(kMaxAsciiCharCode == 0x7F); |
+ ASSERT(unibrow::Utf8::kMaxOneByteChar == 0x7F); |
const uintptr_t non_ascii_mask = kUintptrAllBitsSet / 0xFF * 0x80; |
while (chars + sizeof(uintptr_t) <= limit) { |
if (*reinterpret_cast<const uintptr_t*>(chars) & non_ascii_mask) { |
@@ -7337,7 +7359,7 @@ class String: public HeapObject { |
} |
#endif |
while (chars < limit) { |
- if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) { |
+ if (static_cast<uint8_t>(*chars) > unibrow::Utf8::kMaxOneByteChar) { |
return static_cast<int>(chars - start); |
} |
++chars; |
@@ -7349,18 +7371,18 @@ class String: public HeapObject { |
return NonAsciiStart(chars, length) >= length; |
} |
- static inline int NonAsciiStart(const uc16* chars, int length) { |
+ static inline int NonOneByteStart(const uc16* chars, int length) { |
const uc16* limit = chars + length; |
const uc16* start = chars; |
while (chars < limit) { |
- if (*chars > kMaxAsciiCharCodeU) return static_cast<int>(chars - start); |
+ if (*chars > kMaxOneByteCharCodeU) return static_cast<int>(chars - start); |
++chars; |
} |
return static_cast<int>(chars - start); |
} |
- static inline bool IsAscii(const uc16* chars, int length) { |
- return NonAsciiStart(chars, length) >= length; |
+ static inline bool IsOneByte(const uc16* chars, int length) { |
+ return NonOneByteStart(chars, length) >= length; |
} |
template<class Visitor, class ConsOp> |
@@ -7425,7 +7447,9 @@ class SeqOneByteString: public SeqString { |
// Get the address of the characters in this string. |
inline Address GetCharsAddress(); |
+ // TODO(dcarney): remove GetChars and rename GetCharsU to GetChars. |
inline char* GetChars(); |
+ inline uint8_t* GetCharsU(); |
// Casting |
static inline SeqOneByteString* cast(Object* obj); |