From: ricow@chromium.org Date: Tue, 31 Aug 2010 10:39:02 +0000 (+0000) Subject: Remove assertion that is no longer valid in InitializeStringSearch. X-Git-Tag: upstream/4.7.83~21263 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a9641176fdf98f1c39d111ad17b3adab34d6c435;p=platform%2Fupstream%2Fv8.git Remove assertion that is no longer valid in InitializeStringSearch. This assertion is no longer valid because r5380 changes the assumption about the pat parameter. In addition, we embed the no allocation part of StringSplit in a block to reenable allocation later in that method. Review URL: http://codereview.chromium.org/3254010 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5381 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/runtime.cc b/src/runtime.cc index 6b40a9b..c7ec6bf 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -2913,7 +2913,6 @@ enum StringSearchStrategy { SEARCH_FAIL, SEARCH_SHORT, SEARCH_LONG }; template static inline StringSearchStrategy InitializeStringSearch( Vector pat, bool ascii_subject) { - ASSERT(pat.length() > 1); // We have an ASCII haystack and a non-ASCII needle. Check if there // really is a non-ASCII character in the needle and bail out if there // is. @@ -5237,39 +5236,44 @@ static Object* Runtime_StringSplit(Arguments args) { int initial_capacity = Min(kMaxInitialListCapacity, limit); ZoneList indices(initial_capacity); if (!pattern->IsFlat()) FlattenString(pattern); - AssertNoAllocation nogc; - if (subject->IsAsciiRepresentation()) { - Vector subject_vector = subject->ToAsciiVector(); - if (pattern->IsAsciiRepresentation()) { - FindStringIndices(subject_vector, - pattern->ToAsciiVector(), - &indices, - limit); - } else { - FindStringIndices(subject_vector, - pattern->ToUC16Vector(), - &indices, - limit); - } - } else { - Vector subject_vector = subject->ToUC16Vector(); - if (pattern->IsAsciiRepresentation()) { - FindStringIndices(subject_vector, - pattern->ToAsciiVector(), - &indices, - limit); + + // No allocation block. + { + AssertNoAllocation nogc; + if (subject->IsAsciiRepresentation()) { + Vector subject_vector = subject->ToAsciiVector(); + if (pattern->IsAsciiRepresentation()) { + FindStringIndices(subject_vector, + pattern->ToAsciiVector(), + &indices, + limit); + } else { + FindStringIndices(subject_vector, + pattern->ToUC16Vector(), + &indices, + limit); + } } else { - FindStringIndices(subject_vector, - pattern->ToUC16Vector(), - &indices, - limit); + Vector subject_vector = subject->ToUC16Vector(); + if (pattern->IsAsciiRepresentation()) { + FindStringIndices(subject_vector, + pattern->ToAsciiVector(), + &indices, + limit); + } else { + FindStringIndices(subject_vector, + pattern->ToUC16Vector(), + &indices, + limit); + } } } + if (static_cast(indices.length()) < limit) { indices.Add(subject_length); } - // The list indices now contains the end of each part to create. + // The list indices now contains the end of each part to create. // Create JSArray of substrings separated by separator. int part_count = indices.length();