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

Side by Side Diff: src/api.cc

Issue 18552: Fix bug where strings were not flattened before regexp. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 10 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/handles.cc » ('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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 } 2030 }
2031 2031
2032 2032
2033 int String::WriteAscii(char* buffer, int start, int length) const { 2033 int String::WriteAscii(char* buffer, int start, int length) const {
2034 if (IsDeadCheck("v8::String::WriteAscii()")) return 0; 2034 if (IsDeadCheck("v8::String::WriteAscii()")) return 0;
2035 LOG_API("String::WriteAscii"); 2035 LOG_API("String::WriteAscii");
2036 ASSERT(start >= 0 && length >= -1); 2036 ASSERT(start >= 0 && length >= -1);
2037 i::Handle<i::String> str = Utils::OpenHandle(this); 2037 i::Handle<i::String> str = Utils::OpenHandle(this);
2038 // Flatten the string for efficiency. This applies whether we are 2038 // Flatten the string for efficiency. This applies whether we are
2039 // using StringInputBuffer or Get(i) to access the characters. 2039 // using StringInputBuffer or Get(i) to access the characters.
2040 str->TryFlatten(i::StringShape(*str)); 2040 str->TryFlattenIfNotFlat(i::StringShape(*str));
2041 int end = length; 2041 int end = length;
2042 if ( (length == -1) || (length > str->length() - start) ) 2042 if ( (length == -1) || (length > str->length() - start) )
2043 end = str->length() - start; 2043 end = str->length() - start;
2044 if (end < 0) return 0; 2044 if (end < 0) return 0;
2045 write_input_buffer.Reset(start, *str); 2045 write_input_buffer.Reset(start, *str);
2046 int i; 2046 int i;
2047 for (i = 0; i < end; i++) { 2047 for (i = 0; i < end; i++) {
2048 char c = static_cast<char>(write_input_buffer.GetNext()); 2048 char c = static_cast<char>(write_input_buffer.GetNext());
2049 if (c == '\0') c = ' '; 2049 if (c == '\0') c = ' ';
2050 buffer[i] = c; 2050 buffer[i] = c;
2051 } 2051 }
2052 if (length == -1 || i < length) 2052 if (length == -1 || i < length)
2053 buffer[i] = '\0'; 2053 buffer[i] = '\0';
2054 return i; 2054 return i;
2055 } 2055 }
2056 2056
2057 2057
2058 int String::Write(uint16_t* buffer, int start, int length) const { 2058 int String::Write(uint16_t* buffer, int start, int length) const {
2059 if (IsDeadCheck("v8::String::Write()")) return 0; 2059 if (IsDeadCheck("v8::String::Write()")) return 0;
2060 LOG_API("String::Write"); 2060 LOG_API("String::Write");
2061 ASSERT(start >= 0 && length >= -1); 2061 ASSERT(start >= 0 && length >= -1);
2062 i::Handle<i::String> str = Utils::OpenHandle(this); 2062 i::Handle<i::String> str = Utils::OpenHandle(this);
2063 // Flatten the string for efficiency. This applies whether we are 2063 // Flatten the string for efficiency. This applies whether we are
2064 // using StringInputBuffer or Get(i) to access the characters. 2064 // using StringInputBuffer or Get(i) to access the characters.
2065 str->TryFlatten(i::StringShape(*str)); 2065 str->TryFlattenIfNotFlat(i::StringShape(*str));
2066 int end = length; 2066 int end = length;
2067 if ( (length == -1) || (length > str->length() - start) ) 2067 if ( (length == -1) || (length > str->length() - start) )
2068 end = str->length() - start; 2068 end = str->length() - start;
2069 if (end < 0) return 0; 2069 if (end < 0) return 0;
2070 write_input_buffer.Reset(start, *str); 2070 write_input_buffer.Reset(start, *str);
2071 int i; 2071 int i;
2072 for (i = 0; i < end; i++) 2072 for (i = 0; i < end; i++)
2073 buffer[i] = write_input_buffer.GetNext(); 2073 buffer[i] = write_input_buffer.GetNext();
2074 if (length == -1 || i < length) 2074 if (length == -1 || i < length)
2075 buffer[i] = '\0'; 2075 buffer[i] = '\0';
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 reinterpret_cast<HandleScopeImplementer*>(storage); 3011 reinterpret_cast<HandleScopeImplementer*>(storage);
3012 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); 3012 List<void**>* blocks_of_archived_thread = thread_local->Blocks();
3013 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = 3013 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread =
3014 &thread_local->handle_scope_data_; 3014 &thread_local->handle_scope_data_;
3015 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); 3015 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread);
3016 3016
3017 return storage + ArchiveSpacePerThread(); 3017 return storage + ArchiveSpacePerThread();
3018 } 3018 }
3019 3019
3020 } } // namespace v8::internal 3020 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698