| Index: include/v8.h
|
| diff --git a/include/v8.h b/include/v8.h
|
| index a019c9d561f92a00ece1efd263e5d0a0c1deb987..26f09d5a3899ce62d48ea8fe8f0b979f24667447 100644
|
| --- a/include/v8.h
|
| +++ b/include/v8.h
|
| @@ -1897,6 +1897,7 @@ class V8_EXPORT String : public Primitive {
|
| void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
|
| Encoding encoding) const;
|
| void VerifyExternalStringResource(ExternalStringResource* val) const;
|
| + static internal::Object* GetRedirectedString(internal::Object* cons);
|
| static void CheckCast(v8::Value* obj);
|
| };
|
|
|
| @@ -5388,9 +5389,12 @@ class Internals {
|
| static const int kContextHeaderSize = 2 * kApiPointerSize;
|
| static const int kContextEmbedderDataIndex = 65;
|
| static const int kFullStringRepresentationMask = 0x07;
|
| + static const int kStringRepresentationMask = 0x03;
|
| static const int kStringEncodingMask = 0x4;
|
| + static const int kConsTwoByteRepresentationTag = 0x01;
|
| static const int kExternalTwoByteRepresentationTag = 0x02;
|
| - static const int kExternalAsciiRepresentationTag = 0x06;
|
| + static const int kConsRepresentationTag = 0x01;
|
| + static const int kExternalRepresentationTag = 0x02;
|
|
|
| static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize;
|
| static const int kIsolateRootsOffset = 5 * kApiPointerSize;
|
| @@ -5454,11 +5458,6 @@ class Internals {
|
| return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
|
| }
|
|
|
| - V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
|
| - int representation = (instance_type & kFullStringRepresentationMask);
|
| - return representation == kExternalTwoByteRepresentationTag;
|
| - }
|
| -
|
| V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) {
|
| uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
|
| return *addr & static_cast<uint8_t>(1U << shift);
|
| @@ -5991,12 +5990,16 @@ String::ExternalStringResource* String::GetExternalStringResource() const {
|
| typedef internal::Object O;
|
| typedef internal::Internals I;
|
| O* obj = *reinterpret_cast<O**>(const_cast<String*>(this));
|
| - String::ExternalStringResource* result;
|
| - if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
|
| + String::ExternalStringResource* result = NULL;
|
| + int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
|
| + // Resolve redirected string via cons string.
|
| + if (type == I::kConsTwoByteRepresentationTag) {
|
| + obj = GetRedirectedString(obj);
|
| + type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
|
| + }
|
| + if (type == I::kExternalTwoByteRepresentationTag) {
|
| void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
|
| result = reinterpret_cast<String::ExternalStringResource*>(value);
|
| - } else {
|
| - result = NULL;
|
| }
|
| #ifdef V8_ENABLE_CHECKS
|
| VerifyExternalStringResource(result);
|
| @@ -6010,11 +6013,16 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
|
| typedef internal::Object O;
|
| typedef internal::Internals I;
|
| O* obj = *reinterpret_cast<O**>(const_cast<String*>(this));
|
| - int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
|
| - *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
|
| + int instance_type = I::GetInstanceType(obj);
|
| + int string_type = instance_type & I::kStringRepresentationMask;
|
| + *encoding_out = static_cast<Encoding>(instance_type & I::kStringEncodingMask);
|
| ExternalStringResourceBase* resource = NULL;
|
| - if (type == I::kExternalAsciiRepresentationTag ||
|
| - type == I::kExternalTwoByteRepresentationTag) {
|
| + // Resolve redirected string via cons string.
|
| + if (string_type == I::kConsRepresentationTag) {
|
| + obj = GetRedirectedString(obj);
|
| + string_type = I::GetInstanceType(obj) & I::kStringRepresentationMask;
|
| + }
|
| + if (string_type == I::kExternalRepresentationTag) {
|
| void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
|
| resource = static_cast<ExternalStringResourceBase*>(value);
|
| }
|
|
|