Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/runtime.cc

Issue 3254010: Remove assertion that is no longer valid in InitializeStringSearch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2895 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 } 2906 }
2907 2907
2908 2908
2909 // Strategy for searching for a string in another string. 2909 // Strategy for searching for a string in another string.
2910 enum StringSearchStrategy { SEARCH_FAIL, SEARCH_SHORT, SEARCH_LONG }; 2910 enum StringSearchStrategy { SEARCH_FAIL, SEARCH_SHORT, SEARCH_LONG };
2911 2911
2912 2912
2913 template <typename pchar> 2913 template <typename pchar>
2914 static inline StringSearchStrategy InitializeStringSearch( 2914 static inline StringSearchStrategy InitializeStringSearch(
2915 Vector<const pchar> pat, bool ascii_subject) { 2915 Vector<const pchar> pat, bool ascii_subject) {
2916 ASSERT(pat.length() > 1);
2917 // We have an ASCII haystack and a non-ASCII needle. Check if there 2916 // We have an ASCII haystack and a non-ASCII needle. Check if there
2918 // really is a non-ASCII character in the needle and bail out if there 2917 // really is a non-ASCII character in the needle and bail out if there
2919 // is. 2918 // is.
2920 if (ascii_subject && sizeof(pchar) > 1) { 2919 if (ascii_subject && sizeof(pchar) > 1) {
2921 for (int i = 0; i < pat.length(); i++) { 2920 for (int i = 0; i < pat.length(); i++) {
2922 uc16 c = pat[i]; 2921 uc16 c = pat[i];
2923 if (c > String::kMaxAsciiCharCode) { 2922 if (c > String::kMaxAsciiCharCode) {
2924 return SEARCH_FAIL; 2923 return SEARCH_FAIL;
2925 } 2924 }
2926 } 2925 }
(...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after
5230 if (!subject->IsFlat()) FlattenString(subject); 5229 if (!subject->IsFlat()) FlattenString(subject);
5231 5230
5232 static const int kMaxInitialListCapacity = 16; 5231 static const int kMaxInitialListCapacity = 16;
5233 5232
5234 ZoneScope scope(DELETE_ON_EXIT); 5233 ZoneScope scope(DELETE_ON_EXIT);
5235 5234
5236 // Find (up to limit) indices of separator and end-of-string in subject 5235 // Find (up to limit) indices of separator and end-of-string in subject
5237 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit); 5236 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit);
5238 ZoneList<int> indices(initial_capacity); 5237 ZoneList<int> indices(initial_capacity);
5239 if (!pattern->IsFlat()) FlattenString(pattern); 5238 if (!pattern->IsFlat()) FlattenString(pattern);
5240 AssertNoAllocation nogc; 5239
5241 if (subject->IsAsciiRepresentation()) { 5240 // No allocation block.
5242 Vector<const char> subject_vector = subject->ToAsciiVector(); 5241 {
5243 if (pattern->IsAsciiRepresentation()) { 5242 AssertNoAllocation nogc;
5244 FindStringIndices(subject_vector, 5243 if (subject->IsAsciiRepresentation()) {
5245 pattern->ToAsciiVector(), 5244 Vector<const char> subject_vector = subject->ToAsciiVector();
5246 &indices, 5245 if (pattern->IsAsciiRepresentation()) {
5247 limit); 5246 FindStringIndices(subject_vector,
5247 pattern->ToAsciiVector(),
5248 &indices,
5249 limit);
5250 } else {
5251 FindStringIndices(subject_vector,
5252 pattern->ToUC16Vector(),
5253 &indices,
5254 limit);
5255 }
5248 } else { 5256 } else {
5249 FindStringIndices(subject_vector, 5257 Vector<const uc16> subject_vector = subject->ToUC16Vector();
5250 pattern->ToUC16Vector(), 5258 if (pattern->IsAsciiRepresentation()) {
5251 &indices, 5259 FindStringIndices(subject_vector,
5252 limit); 5260 pattern->ToAsciiVector(),
5253 } 5261 &indices,
5254 } else { 5262 limit);
5255 Vector<const uc16> subject_vector = subject->ToUC16Vector(); 5263 } else {
5256 if (pattern->IsAsciiRepresentation()) { 5264 FindStringIndices(subject_vector,
5257 FindStringIndices(subject_vector, 5265 pattern->ToUC16Vector(),
5258 pattern->ToAsciiVector(), 5266 &indices,
5259 &indices, 5267 limit);
5260 limit); 5268 }
5261 } else {
5262 FindStringIndices(subject_vector,
5263 pattern->ToUC16Vector(),
5264 &indices,
5265 limit);
5266 } 5269 }
5267 } 5270 }
5271
5268 if (static_cast<uint32_t>(indices.length()) < limit) { 5272 if (static_cast<uint32_t>(indices.length()) < limit) {
5269 indices.Add(subject_length); 5273 indices.Add(subject_length);
5270 } 5274 }
5275
5271 // The list indices now contains the end of each part to create. 5276 // The list indices now contains the end of each part to create.
5272 5277
5273
5274 // Create JSArray of substrings separated by separator. 5278 // Create JSArray of substrings separated by separator.
5275 int part_count = indices.length(); 5279 int part_count = indices.length();
5276 5280
5277 Handle<JSArray> result = Factory::NewJSArray(part_count); 5281 Handle<JSArray> result = Factory::NewJSArray(part_count);
5278 result->set_length(Smi::FromInt(part_count)); 5282 result->set_length(Smi::FromInt(part_count));
5279 5283
5280 ASSERT(result->HasFastElements()); 5284 ASSERT(result->HasFastElements());
5281 5285
5282 if (part_count == 1 && indices.at(0) == subject_length) { 5286 if (part_count == 1 && indices.at(0) == subject_length) {
5283 FixedArray::cast(result->elements())->set(0, *subject); 5287 FixedArray::cast(result->elements())->set(0, *subject);
(...skipping 5241 matching lines...) Expand 10 before | Expand all | Expand 10 after
10525 } else { 10529 } else {
10526 // Handle last resort GC and make sure to allow future allocations 10530 // Handle last resort GC and make sure to allow future allocations
10527 // to grow the heap without causing GCs (if possible). 10531 // to grow the heap without causing GCs (if possible).
10528 Counters::gc_last_resort_from_js.Increment(); 10532 Counters::gc_last_resort_from_js.Increment();
10529 Heap::CollectAllGarbage(false); 10533 Heap::CollectAllGarbage(false);
10530 } 10534 }
10531 } 10535 }
10532 10536
10533 10537
10534 } } // namespace v8::internal 10538 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698