Commit c8c5d982 authored by lrn@chromium.org's avatar lrn@chromium.org

Test a few assertions that should hold.


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cf8c7cc3
......@@ -228,13 +228,13 @@ static inline HeapObject* ShortCircuitConsString(Object** p) {
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;
......
......@@ -1578,6 +1578,11 @@ int SeqAsciiString::SeqAsciiStringSize(InstanceType instance_type) {
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));
}
......@@ -1610,6 +1615,10 @@ void ConsString::set_second(String* value, WriteBarrierMode mode) {
String* SlicedString::buffer() {
ASSERT(
StringShape(
String::cast(READ_FIELD(this, kBufferOffset))).IsAsciiRepresentation()
== StringShape(this).IsAsciiRepresentation());
return String::cast(READ_FIELD(this, kBufferOffset));
}
......
......@@ -618,6 +618,8 @@ Object* String::TryFlatten() {
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: {
......
......@@ -972,6 +972,8 @@ RegExpMacroAssemblerIA32::Result RegExpMacroAssemblerIA32::Match(
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()) {
......@@ -980,9 +982,10 @@ RegExpMacroAssemblerIA32::Result RegExpMacroAssemblerIA32::Match(
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment