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

Side by Side Diff: src/api.cc

Issue 9320: Semi-weekly merge from bleeding_edge to the toiger branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 12 years, 1 month 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 | « SConstruct ('k') | src/bootstrapper.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 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 } 2029 }
2030 2030
2031 2031
2032 int String::WriteAscii(char* buffer, int start, int length) { 2032 int String::WriteAscii(char* buffer, int start, int length) {
2033 if (IsDeadCheck("v8::String::WriteAscii()")) return 0; 2033 if (IsDeadCheck("v8::String::WriteAscii()")) return 0;
2034 LOG_API("String::WriteAscii"); 2034 LOG_API("String::WriteAscii");
2035 ASSERT(start >= 0 && length >= -1); 2035 ASSERT(start >= 0 && length >= -1);
2036 i::Handle<i::String> str = Utils::OpenHandle(this); 2036 i::Handle<i::String> str = Utils::OpenHandle(this);
2037 // Flatten the string for efficiency. This applies whether we are 2037 // Flatten the string for efficiency. This applies whether we are
2038 // using StringInputBuffer or Get(i) to access the characters. 2038 // using StringInputBuffer or Get(i) to access the characters.
2039 str->TryFlatten(); 2039 str->TryFlatten(i::StringShape(*str));
2040 int end = length; 2040 int end = length;
2041 if ( (length == -1) || (length > str->length() - start) ) 2041 if ( (length == -1) || (length > str->length() - start) )
2042 end = str->length() - start; 2042 end = str->length() - start;
2043 if (end < 0) return 0; 2043 if (end < 0) return 0;
2044 write_input_buffer.Reset(start, *str); 2044 write_input_buffer.Reset(start, *str);
2045 int i; 2045 int i;
2046 for (i = 0; i < end; i++) { 2046 for (i = 0; i < end; i++) {
2047 char c = static_cast<char>(write_input_buffer.GetNext()); 2047 char c = static_cast<char>(write_input_buffer.GetNext());
2048 if (c == '\0') c = ' '; 2048 if (c == '\0') c = ' ';
2049 buffer[i] = c; 2049 buffer[i] = c;
2050 } 2050 }
2051 if (length == -1 || i < length) 2051 if (length == -1 || i < length)
2052 buffer[i] = '\0'; 2052 buffer[i] = '\0';
2053 return i; 2053 return i;
2054 } 2054 }
2055 2055
2056 2056
2057 int String::Write(uint16_t* buffer, int start, int length) { 2057 int String::Write(uint16_t* buffer, int start, int length) {
2058 if (IsDeadCheck("v8::String::Write()")) return 0; 2058 if (IsDeadCheck("v8::String::Write()")) return 0;
2059 LOG_API("String::Write"); 2059 LOG_API("String::Write");
2060 ASSERT(start >= 0 && length >= -1); 2060 ASSERT(start >= 0 && length >= -1);
2061 i::Handle<i::String> str = Utils::OpenHandle(this); 2061 i::Handle<i::String> str = Utils::OpenHandle(this);
2062 // Flatten the string for efficiency. This applies whether we are 2062 // Flatten the string for efficiency. This applies whether we are
2063 // using StringInputBuffer or Get(i) to access the characters. 2063 // using StringInputBuffer or Get(i) to access the characters.
2064 str->TryFlatten(); 2064 str->TryFlatten(i::StringShape(*str));
2065 int end = length; 2065 int end = length;
2066 if ( (length == -1) || (length > str->length() - start) ) 2066 if ( (length == -1) || (length > str->length() - start) )
2067 end = str->length() - start; 2067 end = str->length() - start;
2068 if (end < 0) return 0; 2068 if (end < 0) return 0;
2069 write_input_buffer.Reset(start, *str); 2069 write_input_buffer.Reset(start, *str);
2070 int i; 2070 int i;
2071 for (i = 0; i < end; i++) 2071 for (i = 0; i < end; i++)
2072 buffer[i] = write_input_buffer.GetNext(); 2072 buffer[i] = write_input_buffer.GetNext();
2073 if (length == -1 || i < length) 2073 if (length == -1 || i < length)
2074 buffer[i] = '\0'; 2074 buffer[i] = '\0';
2075 return i; 2075 return i;
2076 } 2076 }
2077 2077
2078 2078
2079 bool v8::String::IsExternal() { 2079 bool v8::String::IsExternal() {
2080 EnsureInitialized("v8::String::IsExternal()"); 2080 EnsureInitialized("v8::String::IsExternal()");
2081 i::Handle<i::String> str = Utils::OpenHandle(this); 2081 i::Handle<i::String> str = Utils::OpenHandle(this);
2082 return str->IsExternalTwoByteString(); 2082 i::StringShape shape(*str);
2083 return shape.IsExternalTwoByte();
2083 } 2084 }
2084 2085
2085 2086
2086 bool v8::String::IsExternalAscii() { 2087 bool v8::String::IsExternalAscii() {
2087 EnsureInitialized("v8::String::IsExternalAscii()"); 2088 EnsureInitialized("v8::String::IsExternalAscii()");
2088 i::Handle<i::String> str = Utils::OpenHandle(this); 2089 i::Handle<i::String> str = Utils::OpenHandle(this);
2089 return str->IsExternalAsciiString(); 2090 i::StringShape shape(*str);
2091 return shape.IsExternalAscii();
2090 } 2092 }
2091 2093
2092 2094
2093 v8::String::ExternalStringResource* v8::String::GetExternalStringResource() { 2095 v8::String::ExternalStringResource* v8::String::GetExternalStringResource() {
2094 EnsureInitialized("v8::String::GetExternalStringResource()"); 2096 EnsureInitialized("v8::String::GetExternalStringResource()");
2095 i::Handle<i::String> str = Utils::OpenHandle(this); 2097 i::Handle<i::String> str = Utils::OpenHandle(this);
2096 ASSERT(str->IsExternalTwoByteString()); 2098 ASSERT(str->IsExternalTwoByteString());
2097 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); 2099 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
2098 return reinterpret_cast<ExternalStringResource*>(resource); 2100 return reinterpret_cast<ExternalStringResource*>(resource);
2099 } 2101 }
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 reinterpret_cast<HandleScopeImplementer*>(storage); 2969 reinterpret_cast<HandleScopeImplementer*>(storage);
2968 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); 2970 List<void**>* blocks_of_archived_thread = thread_local->Blocks();
2969 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = 2971 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread =
2970 &thread_local->handle_scope_data_; 2972 &thread_local->handle_scope_data_;
2971 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); 2973 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread);
2972 2974
2973 return storage + ArchiveSpacePerThread(); 2975 return storage + ArchiveSpacePerThread();
2974 } 2976 }
2975 2977
2976 } } // namespace v8::internal 2978 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « SConstruct ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698