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

Side by Side Diff: src/runtime.cc

Issue 7685005: Inserted a missing string encoding check in lastIndexOf. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Included a test case. Created 9 years, 4 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 | src/string.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3156 return Smi::FromInt(start_index); 3156 return Smi::FromInt(start_index);
3157 } 3157 }
3158 3158
3159 if (!sub->IsFlat()) FlattenString(sub); 3159 if (!sub->IsFlat()) FlattenString(sub);
3160 if (!pat->IsFlat()) FlattenString(pat); 3160 if (!pat->IsFlat()) FlattenString(pat);
3161 3161
3162 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid 3162 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid
3163 3163
3164 int position = -1; 3164 int position = -1;
3165 3165
3166 if (pat->IsAsciiRepresentation()) { 3166 String* seq_sub = *sub;
3167 Vector<const char> pat_vector = pat->ToAsciiVector(); 3167 // Extract flattened substrings of cons strings before determining asciiness.
Vitaly Repeshko 2011/08/22 13:37:46 nit: Move the comment one line above.
3168 if (sub->IsAsciiRepresentation()) { 3168 if (seq_sub->IsConsString()) seq_sub = ConsString::cast(seq_sub)->first();
3169 position = StringMatchBackwards(sub->ToAsciiVector(), 3169 String* seq_pat = *pat;
3170 if (seq_pat->IsConsString()) seq_pat = ConsString::cast(seq_pat)->first();
3171
3172 if (seq_pat->IsAsciiRepresentation()) {
3173 Vector<const char> pat_vector = seq_pat->ToAsciiVector();
3174 if (seq_sub->IsAsciiRepresentation()) {
3175 position = StringMatchBackwards(seq_sub->ToAsciiVector(),
3170 pat_vector, 3176 pat_vector,
3171 start_index); 3177 start_index);
3172 } else { 3178 } else {
3173 position = StringMatchBackwards(sub->ToUC16Vector(), 3179 position = StringMatchBackwards(seq_sub->ToUC16Vector(),
3174 pat_vector, 3180 pat_vector,
3175 start_index); 3181 start_index);
3176 } 3182 }
3177 } else { 3183 } else {
3178 Vector<const uc16> pat_vector = pat->ToUC16Vector(); 3184 Vector<const uc16> pat_vector = seq_pat->ToUC16Vector();
3179 if (sub->IsAsciiRepresentation()) { 3185 if (seq_sub->IsAsciiRepresentation()) {
3180 position = StringMatchBackwards(sub->ToAsciiVector(), 3186 position = StringMatchBackwards(seq_sub->ToAsciiVector(),
3181 pat_vector, 3187 pat_vector,
3182 start_index); 3188 start_index);
3183 } else { 3189 } else {
3184 position = StringMatchBackwards(sub->ToUC16Vector(), 3190 position = StringMatchBackwards(seq_sub->ToUC16Vector(),
3185 pat_vector, 3191 pat_vector,
3186 start_index); 3192 start_index);
3187 } 3193 }
3188 } 3194 }
3189 3195
3190 return Smi::FromInt(position); 3196 return Smi::FromInt(position);
3191 } 3197 }
3192 3198
3193 3199
3194 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { 3200 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) {
(...skipping 9715 matching lines...) Expand 10 before | Expand all | Expand 10 after
12910 } else { 12916 } else {
12911 // Handle last resort GC and make sure to allow future allocations 12917 // Handle last resort GC and make sure to allow future allocations
12912 // to grow the heap without causing GCs (if possible). 12918 // to grow the heap without causing GCs (if possible).
12913 isolate->counters()->gc_last_resort_from_js()->Increment(); 12919 isolate->counters()->gc_last_resort_from_js()->Increment();
12914 isolate->heap()->CollectAllGarbage(false); 12920 isolate->heap()->CollectAllGarbage(false);
12915 } 12921 }
12916 } 12922 }
12917 12923
12918 12924
12919 } } // namespace v8::internal 12925 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698