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

Side by Side Diff: src/api.cc

Issue 11759008: Introduce ENABLE_LATIN_1 compile flag (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix FilterASCII Created 7 years, 11 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 | « build/common.gypi ('k') | src/arm/code-stubs-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 3106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3117 // Native implementation of Object.prototype.toString (v8natives.js): 3117 // Native implementation of Object.prototype.toString (v8natives.js):
3118 // var c = %ClassOf(this); 3118 // var c = %ClassOf(this);
3119 // if (c === 'Arguments') c = 'Object'; 3119 // if (c === 'Arguments') c = 'Object';
3120 // return "[object " + c + "]"; 3120 // return "[object " + c + "]";
3121 3121
3122 if (!name->IsString()) { 3122 if (!name->IsString()) {
3123 return v8::String::New("[object ]"); 3123 return v8::String::New("[object ]");
3124 3124
3125 } else { 3125 } else {
3126 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name); 3126 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name);
3127 if (class_name->IsEqualTo(i::CStrVector("Arguments"))) { 3127 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) {
3128 return v8::String::New("[object Object]"); 3128 return v8::String::New("[object Object]");
3129 3129
3130 } else { 3130 } else {
3131 const char* prefix = "[object "; 3131 const char* prefix = "[object ";
3132 Local<String> str = Utils::ToLocal(class_name); 3132 Local<String> str = Utils::ToLocal(class_name);
3133 const char* postfix = "]"; 3133 const char* postfix = "]";
3134 3134
3135 int prefix_len = i::StrLength(prefix); 3135 int prefix_len = i::StrLength(prefix);
3136 int str_len = str->Length(); 3136 int str_len = str->Length();
3137 int postfix_len = i::StrLength(postfix); 3137 int postfix_len = i::StrLength(postfix);
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
4138 if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0; 4138 if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0;
4139 LOG_API(isolate, "String::WriteAscii"); 4139 LOG_API(isolate, "String::WriteAscii");
4140 ENTER_V8(isolate); 4140 ENTER_V8(isolate);
4141 ASSERT(start >= 0 && length >= -1); 4141 ASSERT(start >= 0 && length >= -1);
4142 i::Handle<i::String> str = Utils::OpenHandle(this); 4142 i::Handle<i::String> str = Utils::OpenHandle(this);
4143 isolate->string_tracker()->RecordWrite(str); 4143 isolate->string_tracker()->RecordWrite(str);
4144 if (options & HINT_MANY_WRITES_EXPECTED) { 4144 if (options & HINT_MANY_WRITES_EXPECTED) {
4145 FlattenString(str); // Flatten the string for efficiency. 4145 FlattenString(str); // Flatten the string for efficiency.
4146 } 4146 }
4147 4147
4148 if (str->IsOneByteRepresentation()) { 4148 if (str->HasOnlyAsciiChars()) {
4149 // WriteToFlat is faster than using the StringCharacterStream. 4149 // WriteToFlat is faster than using the StringCharacterStream.
4150 if (length == -1) length = str->length() + 1; 4150 if (length == -1) length = str->length() + 1;
4151 int len = i::Min(length, str->length() - start); 4151 int len = i::Min(length, str->length() - start);
4152 i::String::WriteToFlat(*str, buffer, start, start + len); 4152 i::String::WriteToFlat(*str, buffer, start, start + len);
4153 if (!(options & PRESERVE_ASCII_NULL)) { 4153 if (!(options & PRESERVE_ASCII_NULL)) {
4154 for (int i = 0; i < len; i++) { 4154 for (int i = 0; i < len; i++) {
4155 if (buffer[i] == '\0') buffer[i] = ' '; 4155 if (buffer[i] == '\0') buffer[i] = ' ';
4156 } 4156 }
4157 } 4157 }
4158 if (!(options & NO_NULL_TERMINATION) && length > len) { 4158 if (!(options & NO_NULL_TERMINATION) && length > len) {
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
5176 i::Execution::TryCall(func, 5176 i::Execution::TryCall(func,
5177 isolate->js_builtins_object(), 5177 isolate->js_builtins_object(),
5178 0, 5178 0,
5179 NULL, 5179 NULL,
5180 &caught_exception); 5180 &caught_exception);
5181 } 5181 }
5182 } 5182 }
5183 5183
5184 5184
5185 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { 5185 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) {
5186 char flags_buf[3]; 5186 uint8_t flags_buf[3];
5187 int num_flags = 0; 5187 int num_flags = 0;
5188 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; 5188 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g';
5189 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; 5189 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
5190 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; 5190 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
5191 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); 5191 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
5192 return FACTORY->LookupOneByteSymbol( 5192 return FACTORY->LookupOneByteSymbol(
5193 i::Vector<const char>(flags_buf, num_flags)); 5193 i::Vector<const uint8_t>(flags_buf, num_flags));
5194 } 5194 }
5195 5195
5196 5196
5197 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern, 5197 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern,
5198 Flags flags) { 5198 Flags flags) {
5199 i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate(); 5199 i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate();
5200 EnsureInitializedForIsolate(isolate, "v8::RegExp::New()"); 5200 EnsureInitializedForIsolate(isolate, "v8::RegExp::New()");
5201 LOG_API(isolate, "RegExp::New"); 5201 LOG_API(isolate, "RegExp::New");
5202 ENTER_V8(isolate); 5202 ENTER_V8(isolate);
5203 EXCEPTION_PREAMBLE(isolate); 5203 EXCEPTION_PREAMBLE(isolate);
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
6733 6733
6734 v->VisitPointers(blocks_.first(), first_block_limit_); 6734 v->VisitPointers(blocks_.first(), first_block_limit_);
6735 6735
6736 for (int i = 1; i < blocks_.length(); i++) { 6736 for (int i = 1; i < blocks_.length(); i++) {
6737 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6737 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6738 } 6738 }
6739 } 6739 }
6740 6740
6741 6741
6742 } } // namespace v8::internal 6742 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | src/arm/code-stubs-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698