From c8c5d9820de6b3d0142be2b5909793ebcf76c28d Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Tue, 24 Mar 2009 10:16:30 +0000 Subject: [PATCH] Test a few assertions that should hold. git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mark-compact.cc | 4 ++-- src/objects-inl.h | 9 +++++++++ src/objects.cc | 2 ++ src/regexp-macro-assembler-ia32.cc | 7 +++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/mark-compact.cc b/src/mark-compact.cc index a747ca3..b369cac 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -228,13 +228,13 @@ static inline HeapObject* ShortCircuitConsString(Object** p) { static_cast(type & kStringRepresentationMask); if (rep != kConsStringTag) return object; - Object* second = reinterpret_cast(object)->second(); + Object* second = reinterpret_cast(object)->unchecked_second(); if (reinterpret_cast(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(object)->first(); + Object* first = reinterpret_cast(object)->unchecked_first(); if (!Heap::InNewSpace(object) && Heap::InNewSpace(first)) return object; *p = first; diff --git a/src/objects-inl.h b/src/objects-inl.h index 831a248..762bb63 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -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)); } diff --git a/src/objects.cc b/src/objects.cc index 72fc5e5..9f50d62 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -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: { diff --git a/src/regexp-macro-assembler-ia32.cc b/src/regexp-macro-assembler-ia32.cc index fa529a5..2a7bf3e 100644 --- a/src/regexp-macro-assembler-ia32.cc +++ b/src/regexp-macro-assembler-ia32.cc @@ -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; -- 2.7.4