I tried adding a test to first (if second is empty, this and first have same ascii-ness), but it fails, and in reporting the failure, it fails again, giving an infinite recursion.
But it does fail, which is not encouraging. /L On Mon, Mar 23, 2009 at 11:14 AM, Erik Corry <[email protected]> wrote: > LGTM > > Can we put an assert in SlicedString::buffer(), ConsString::first() > and ConsString::second()? > > 2009/3/23 <[email protected]>: > > Reviewers: Erik Corry, > > > > Message: > > Review, please. > > > > Description: > > Test a few assertions that should hold. > > > > Please review this at http://codereview.chromium.org/42499 > > > > Affected files: > > M src/objects.cc > > M src/regexp-macro-assembler-ia32.cc > > > > > > Index: src/objects.cc > > diff --git a/src/objects.cc b/src/objects.cc > > index > > > 72fc5e5088bc5446b00517181a5cdbe8ddf26142..9f50d62483324d0b76780df0c6d534d279a87d5b > > 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: { > > Index: src/regexp-macro-assembler-ia32.cc > > diff --git a/src/regexp-macro-assembler-ia32.cc > > b/src/regexp-macro-assembler-ia32.cc > > index > > > fa529a572b92de4b87adb865b4a937dc3a6ff0a3..2a7bf3e76b41442fd863405eebcb0bee6e2fb9c9 > > 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; > > > > > > > > > > > > -- > Erik Corry, Software Engineer > Google Denmark ApS. CVR nr. 28 86 69 84 > c/o Philip & Partners, 7 Vognmagergade, P.O. Box 2227, DK-1018 > Copenhagen K, Denmark. > -- Lasse R.H. Nielsen [email protected] 'Faith without judgement merely degrades the spirit divine' --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
