Test a few assertions that should hold.
authorlrn@chromium.org <lrn@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 24 Mar 2009 10:16:30 +0000 (10:16 +0000)
committerlrn@chromium.org <lrn@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 24 Mar 2009 10:16:30 +0000 (10:16 +0000)
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/mark-compact.cc
src/objects-inl.h
src/objects.cc
src/regexp-macro-assembler-ia32.cc

index a747ca3..b369cac 100644 (file)
@@ -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;
index 831a248..762bb63 100644 (file)
@@ -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));
 }
 
index 72fc5e5..9f50d62 100644 (file)
@@ -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: {
index fa529a5..2a7bf3e 100644 (file)
@@ -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;