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

Side by Side Diff: src/api.cc

Issue 11308066: Rename IsAsciiRepresentation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | « no previous file | src/arm/regexp-macro-assembler-arm.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 3832 matching lines...) Expand 10 before | Expand all | Expand 10 after
3843 // Will fail with a negative answer if the recursion depth is too high. 3843 // Will fail with a negative answer if the recursion depth is too high.
3844 static int RecursivelySerializeToUtf8(i::String* string, 3844 static int RecursivelySerializeToUtf8(i::String* string,
3845 char* buffer, 3845 char* buffer,
3846 int start, 3846 int start,
3847 int end, 3847 int end,
3848 int recursion_budget, 3848 int recursion_budget,
3849 int32_t previous_character, 3849 int32_t previous_character,
3850 int32_t* last_character) { 3850 int32_t* last_character) {
3851 int utf8_bytes = 0; 3851 int utf8_bytes = 0;
3852 while (true) { 3852 while (true) {
3853 if (string->IsAsciiRepresentation()) { 3853 if (string->IsOneByteRepresentation()) {
3854 i::String::WriteToFlat(string, buffer, start, end); 3854 i::String::WriteToFlat(string, buffer, start, end);
3855 *last_character = unibrow::Utf16::kNoPreviousCharacter; 3855 *last_character = unibrow::Utf16::kNoPreviousCharacter;
3856 return utf8_bytes + end - start; 3856 return utf8_bytes + end - start;
3857 } 3857 }
3858 switch (i::StringShape(string).representation_tag()) { 3858 switch (i::StringShape(string).representation_tag()) {
3859 case i::kExternalStringTag: { 3859 case i::kExternalStringTag: {
3860 const uint16_t* data = i::ExternalTwoByteString::cast(string)-> 3860 const uint16_t* data = i::ExternalTwoByteString::cast(string)->
3861 ExternalTwoByteStringGetData(0); 3861 ExternalTwoByteStringGetData(0);
3862 char* current = buffer; 3862 char* current = buffer;
3863 for (int i = start; i < end; i++) { 3863 for (int i = start; i < end; i++) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3943 int options) const { 3943 int options) const {
3944 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3944 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3945 if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0; 3945 if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0;
3946 LOG_API(isolate, "String::WriteUtf8"); 3946 LOG_API(isolate, "String::WriteUtf8");
3947 ENTER_V8(isolate); 3947 ENTER_V8(isolate);
3948 i::Handle<i::String> str = Utils::OpenHandle(this); 3948 i::Handle<i::String> str = Utils::OpenHandle(this);
3949 if (options & HINT_MANY_WRITES_EXPECTED) { 3949 if (options & HINT_MANY_WRITES_EXPECTED) {
3950 FlattenString(str); // Flatten the string for efficiency. 3950 FlattenString(str); // Flatten the string for efficiency.
3951 } 3951 }
3952 int string_length = str->length(); 3952 int string_length = str->length();
3953 if (str->IsAsciiRepresentation()) { 3953 if (str->IsOneByteRepresentation()) {
3954 int len; 3954 int len;
3955 if (capacity == -1) { 3955 if (capacity == -1) {
3956 capacity = str->length() + 1; 3956 capacity = str->length() + 1;
3957 len = string_length; 3957 len = string_length;
3958 } else { 3958 } else {
3959 len = i::Min(capacity, str->length()); 3959 len = i::Min(capacity, str->length());
3960 } 3960 }
3961 i::String::WriteToFlat(*str, buffer, 0, len); 3961 i::String::WriteToFlat(*str, buffer, 0, len);
3962 if (nchars_ref != NULL) *nchars_ref = len; 3962 if (nchars_ref != NULL) *nchars_ref = len;
3963 if (!(options & NO_NULL_TERMINATION) && capacity > len) { 3963 if (!(options & NO_NULL_TERMINATION) && capacity > len) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
4077 if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0; 4077 if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0;
4078 LOG_API(isolate, "String::WriteAscii"); 4078 LOG_API(isolate, "String::WriteAscii");
4079 ENTER_V8(isolate); 4079 ENTER_V8(isolate);
4080 ASSERT(start >= 0 && length >= -1); 4080 ASSERT(start >= 0 && length >= -1);
4081 i::Handle<i::String> str = Utils::OpenHandle(this); 4081 i::Handle<i::String> str = Utils::OpenHandle(this);
4082 isolate->string_tracker()->RecordWrite(str); 4082 isolate->string_tracker()->RecordWrite(str);
4083 if (options & HINT_MANY_WRITES_EXPECTED) { 4083 if (options & HINT_MANY_WRITES_EXPECTED) {
4084 FlattenString(str); // Flatten the string for efficiency. 4084 FlattenString(str); // Flatten the string for efficiency.
4085 } 4085 }
4086 4086
4087 if (str->IsAsciiRepresentation()) { 4087 if (str->IsOneByteRepresentation()) {
4088 // WriteToFlat is faster than using the StringInputBuffer. 4088 // WriteToFlat is faster than using the StringInputBuffer.
4089 if (length == -1) length = str->length() + 1; 4089 if (length == -1) length = str->length() + 1;
4090 int len = i::Min(length, str->length() - start); 4090 int len = i::Min(length, str->length() - start);
4091 i::String::WriteToFlat(*str, buffer, start, start + len); 4091 i::String::WriteToFlat(*str, buffer, start, start + len);
4092 if (!(options & PRESERVE_ASCII_NULL)) { 4092 if (!(options & PRESERVE_ASCII_NULL)) {
4093 for (int i = 0; i < len; i++) { 4093 for (int i = 0; i < len; i++) {
4094 if (buffer[i] == '\0') buffer[i] = ' '; 4094 if (buffer[i] == '\0') buffer[i] = ' ';
4095 } 4095 }
4096 } 4096 }
4097 if (!(options & NO_NULL_TERMINATION) && length > len) { 4097 if (!(options & NO_NULL_TERMINATION) && length > len) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
4192 i::Handle<i::ExternalAsciiString>::cast(str)->resource(); 4192 i::Handle<i::ExternalAsciiString>::cast(str)->resource();
4193 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource); 4193 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4194 expectedEncoding = ASCII_ENCODING; 4194 expectedEncoding = ASCII_ENCODING;
4195 } else if (i::StringShape(*str).IsExternalTwoByte()) { 4195 } else if (i::StringShape(*str).IsExternalTwoByte()) {
4196 const void* resource = 4196 const void* resource =
4197 i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); 4197 i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
4198 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource); 4198 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4199 expectedEncoding = TWO_BYTE_ENCODING; 4199 expectedEncoding = TWO_BYTE_ENCODING;
4200 } else { 4200 } else {
4201 expected = NULL; 4201 expected = NULL;
4202 expectedEncoding = str->IsAsciiRepresentation() ? ASCII_ENCODING 4202 expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING
4203 : TWO_BYTE_ENCODING; 4203 : TWO_BYTE_ENCODING;
4204 } 4204 }
4205 CHECK_EQ(expected, value); 4205 CHECK_EQ(expected, value);
4206 CHECK_EQ(expectedEncoding, encoding); 4206 CHECK_EQ(expectedEncoding, encoding);
4207 } 4207 }
4208 4208
4209 const v8::String::ExternalAsciiStringResource* 4209 const v8::String::ExternalAsciiStringResource*
4210 v8::String::GetExternalAsciiStringResource() const { 4210 v8::String::GetExternalAsciiStringResource() const {
4211 i::Handle<i::String> str = Utils::OpenHandle(this); 4211 i::Handle<i::String> str = Utils::OpenHandle(this);
4212 if (IsDeadCheck(str->GetIsolate(), 4212 if (IsDeadCheck(str->GetIsolate(),
(...skipping 2452 matching lines...) Expand 10 before | Expand all | Expand 10 after
6665 6665
6666 v->VisitPointers(blocks_.first(), first_block_limit_); 6666 v->VisitPointers(blocks_.first(), first_block_limit_);
6667 6667
6668 for (int i = 1; i < blocks_.length(); i++) { 6668 for (int i = 1; i < blocks_.length(); i++) {
6669 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6669 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6670 } 6670 }
6671 } 6671 }
6672 6672
6673 6673
6674 } } // namespace v8::internal 6674 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/arm/regexp-macro-assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698