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

Side by Side Diff: src/api.cc

Issue 45010: Remove all uses of StringShape variables, since that has proven... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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/codegen.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 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 } 2027 }
2028 2028
2029 2029
2030 int String::WriteAscii(char* buffer, int start, int length) const { 2030 int String::WriteAscii(char* buffer, int start, int length) const {
2031 if (IsDeadCheck("v8::String::WriteAscii()")) return 0; 2031 if (IsDeadCheck("v8::String::WriteAscii()")) return 0;
2032 LOG_API("String::WriteAscii"); 2032 LOG_API("String::WriteAscii");
2033 ASSERT(start >= 0 && length >= -1); 2033 ASSERT(start >= 0 && length >= -1);
2034 i::Handle<i::String> str = Utils::OpenHandle(this); 2034 i::Handle<i::String> str = Utils::OpenHandle(this);
2035 // Flatten the string for efficiency. This applies whether we are 2035 // Flatten the string for efficiency. This applies whether we are
2036 // using StringInputBuffer or Get(i) to access the characters. 2036 // using StringInputBuffer or Get(i) to access the characters.
2037 str->TryFlattenIfNotFlat(i::StringShape(*str)); 2037 str->TryFlattenIfNotFlat();
2038 int end = length; 2038 int end = length;
2039 if ( (length == -1) || (length > str->length() - start) ) 2039 if ( (length == -1) || (length > str->length() - start) )
2040 end = str->length() - start; 2040 end = str->length() - start;
2041 if (end < 0) return 0; 2041 if (end < 0) return 0;
2042 write_input_buffer.Reset(start, *str); 2042 write_input_buffer.Reset(start, *str);
2043 int i; 2043 int i;
2044 for (i = 0; i < end; i++) { 2044 for (i = 0; i < end; i++) {
2045 char c = static_cast<char>(write_input_buffer.GetNext()); 2045 char c = static_cast<char>(write_input_buffer.GetNext());
2046 if (c == '\0') c = ' '; 2046 if (c == '\0') c = ' ';
2047 buffer[i] = c; 2047 buffer[i] = c;
2048 } 2048 }
2049 if (length == -1 || i < length) 2049 if (length == -1 || i < length)
2050 buffer[i] = '\0'; 2050 buffer[i] = '\0';
2051 return i; 2051 return i;
2052 } 2052 }
2053 2053
2054 2054
2055 int String::Write(uint16_t* buffer, int start, int length) const { 2055 int String::Write(uint16_t* buffer, int start, int length) const {
2056 if (IsDeadCheck("v8::String::Write()")) return 0; 2056 if (IsDeadCheck("v8::String::Write()")) return 0;
2057 LOG_API("String::Write"); 2057 LOG_API("String::Write");
2058 ASSERT(start >= 0 && length >= -1); 2058 ASSERT(start >= 0 && length >= -1);
2059 i::Handle<i::String> str = Utils::OpenHandle(this); 2059 i::Handle<i::String> str = Utils::OpenHandle(this);
2060 // Flatten the string for efficiency. This applies whether we are 2060 // Flatten the string for efficiency. This applies whether we are
2061 // using StringInputBuffer or Get(i) to access the characters. 2061 // using StringInputBuffer or Get(i) to access the characters.
2062 str->TryFlattenIfNotFlat(i::StringShape(*str)); 2062 str->TryFlattenIfNotFlat();
2063 int end = length; 2063 int end = length;
2064 if ( (length == -1) || (length > str->length() - start) ) 2064 if ( (length == -1) || (length > str->length() - start) )
2065 end = str->length() - start; 2065 end = str->length() - start;
2066 if (end < 0) return 0; 2066 if (end < 0) return 0;
2067 write_input_buffer.Reset(start, *str); 2067 write_input_buffer.Reset(start, *str);
2068 int i; 2068 int i;
2069 for (i = 0; i < end; i++) 2069 for (i = 0; i < end; i++)
2070 buffer[i] = write_input_buffer.GetNext(); 2070 buffer[i] = write_input_buffer.GetNext();
2071 if (length == -1 || i < length) 2071 if (length == -1 || i < length)
2072 buffer[i] = '\0'; 2072 buffer[i] = '\0';
2073 return i; 2073 return i;
2074 } 2074 }
2075 2075
2076 2076
2077 bool v8::String::IsExternal() const { 2077 bool v8::String::IsExternal() const {
2078 EnsureInitialized("v8::String::IsExternal()"); 2078 EnsureInitialized("v8::String::IsExternal()");
2079 i::Handle<i::String> str = Utils::OpenHandle(this); 2079 i::Handle<i::String> str = Utils::OpenHandle(this);
2080 i::StringShape shape(*str); 2080 return i::StringShape(*str).IsExternalTwoByte();
2081 return shape.IsExternalTwoByte();
2082 } 2081 }
2083 2082
2084 2083
2085 bool v8::String::IsExternalAscii() const { 2084 bool v8::String::IsExternalAscii() const {
2086 EnsureInitialized("v8::String::IsExternalAscii()"); 2085 EnsureInitialized("v8::String::IsExternalAscii()");
2087 i::Handle<i::String> str = Utils::OpenHandle(this); 2086 i::Handle<i::String> str = Utils::OpenHandle(this);
2088 i::StringShape shape(*str); 2087 return i::StringShape(*str).IsExternalAscii();
2089 return shape.IsExternalAscii();
2090 } 2088 }
2091 2089
2092 2090
2093 v8::String::ExternalStringResource* 2091 v8::String::ExternalStringResource*
2094 v8::String::GetExternalStringResource() const { 2092 v8::String::GetExternalStringResource() const {
2095 EnsureInitialized("v8::String::GetExternalStringResource()"); 2093 EnsureInitialized("v8::String::GetExternalStringResource()");
2096 i::Handle<i::String> str = Utils::OpenHandle(this); 2094 i::Handle<i::String> str = Utils::OpenHandle(this);
2097 ASSERT(str->IsExternalTwoByteString()); 2095 ASSERT(str->IsExternalTwoByteString());
2098 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); 2096 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
2099 return reinterpret_cast<ExternalStringResource*>(resource); 2097 return reinterpret_cast<ExternalStringResource*>(resource);
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
3064 reinterpret_cast<HandleScopeImplementer*>(storage); 3062 reinterpret_cast<HandleScopeImplementer*>(storage);
3065 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); 3063 List<void**>* blocks_of_archived_thread = thread_local->Blocks();
3066 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = 3064 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread =
3067 &thread_local->handle_scope_data_; 3065 &thread_local->handle_scope_data_;
3068 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); 3066 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread);
3069 3067
3070 return storage + ArchiveSpacePerThread(); 3068 return storage + ArchiveSpacePerThread();
3071 } 3069 }
3072 3070
3073 } } // namespace v8::internal 3071 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698