static_cast<StringRepresentationTag>(type & kStringRepresentationMask);
if (rep != kConsStringTag) return object;
- Object* second = reinterpret_cast<ConsString*>(object)->second();
+ Object* second = reinterpret_cast<ConsString*>(object)->unchecked_second();
if (reinterpret_cast<String*>(second) != Heap::empty_string()) return object;
// Since we don't have the object's start, it is impossible to update the
// remembered set. Therefore, we only replace the string with its left
// substring when the remembered set does not change.
- Object* first = reinterpret_cast<ConsString*>(object)->first();
+ Object* first = reinterpret_cast<ConsString*>(object)->unchecked_first();
if (!Heap::InNewSpace(object) && Heap::InNewSpace(first)) return object;
*p = first;
String* ConsString::first() {
+ ASSERT(String::cast(READ_FIELD(this, kSecondOffset))->length() != 0 ||
+ StringShape(
+ String::cast(
+ READ_FIELD(this, kFirstOffset))).IsAsciiRepresentation()
+ == StringShape(this).IsAsciiRepresentation());
return String::cast(READ_FIELD(this, kFirstOffset));
}
String* SlicedString::buffer() {
+ ASSERT(
+ StringShape(
+ String::cast(READ_FIELD(this, kBufferOffset))).IsAsciiRepresentation()
+ == StringShape(this).IsAsciiRepresentation());
return String::cast(READ_FIELD(this, kBufferOffset));
}
if (StringShape(String::cast(ok)).IsCons()) {
ss->set_buffer(ConsString::cast(ok)->first());
}
+ ASSERT(StringShape(this).IsAsciiRepresentation() ==
+ StringShape(ss->buffer()).IsAsciiRepresentation());
return this;
}
case kConsStringTag: {
int start_offset = previous_index;
int end_offset = subject_ptr->length();
+ bool is_ascii = StringShape(*subject).IsAsciiRepresentation();
+
if (StringShape(subject_ptr).IsCons()) {
subject_ptr = ConsString::cast(subject_ptr)->first();
} else if (StringShape(subject_ptr).IsSliced()) {
end_offset += slice->start();
subject_ptr = slice->buffer();
}
-
+ // Ensure that an underlying string has the same ascii-ness.
+ ASSERT(StringShape(subject_ptr).IsAsciiRepresentation() == is_ascii);
+ ASSERT(subject_ptr->IsExternalString() || subject_ptr->IsSeqString());
// String is now either Sequential or External
- bool is_ascii = StringShape(*subject).IsAsciiRepresentation();
int char_size_shift = is_ascii ? 0 : 1;
int char_length = end_offset - start_offset;