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

Side by Side Diff: src/factory.cc

Issue 864273005: Scanner / Unicode decoding: use size_t instead of unsigned. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: tentative Created 5 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
« no previous file with comments | « no previous file | src/heap-snapshot-generator.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/conversions.h" 9 #include "src/conversions.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // If the string is ASCII, we do not need to convert the characters 233 // If the string is ASCII, we do not need to convert the characters
234 // since UTF8 is backwards compatible with ASCII. 234 // since UTF8 is backwards compatible with ASCII.
235 return NewStringFromOneByte(Vector<const uint8_t>::cast(string), pretenure); 235 return NewStringFromOneByte(Vector<const uint8_t>::cast(string), pretenure);
236 } 236 }
237 237
238 // Non-ASCII and we need to decode. 238 // Non-ASCII and we need to decode.
239 Access<UnicodeCache::Utf8Decoder> 239 Access<UnicodeCache::Utf8Decoder>
240 decoder(isolate()->unicode_cache()->utf8_decoder()); 240 decoder(isolate()->unicode_cache()->utf8_decoder());
241 decoder->Reset(string.start() + non_ascii_start, 241 decoder->Reset(string.start() + non_ascii_start,
242 length - non_ascii_start); 242 length - non_ascii_start);
243 int utf16_length = decoder->Utf16Length(); 243 int utf16_length = static_cast<int>(decoder->Utf16Length());
244 DCHECK(utf16_length > 0); 244 DCHECK(utf16_length > 0);
245 // Allocate string. 245 // Allocate string.
246 Handle<SeqTwoByteString> result; 246 Handle<SeqTwoByteString> result;
247 ASSIGN_RETURN_ON_EXCEPTION( 247 ASSIGN_RETURN_ON_EXCEPTION(
248 isolate(), result, 248 isolate(), result,
249 NewRawTwoByteString(non_ascii_start + utf16_length, pretenure), 249 NewRawTwoByteString(non_ascii_start + utf16_length, pretenure),
250 String); 250 String);
251 // Copy ASCII portion. 251 // Copy ASCII portion.
252 uint16_t* data = result->GetChars(); 252 uint16_t* data = result->GetChars();
253 const char* ascii_data = string.start(); 253 const char* ascii_data = string.start();
(...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 return Handle<Object>::null(); 2515 return Handle<Object>::null();
2516 } 2516 }
2517 2517
2518 2518
2519 Handle<Object> Factory::ToBoolean(bool value) { 2519 Handle<Object> Factory::ToBoolean(bool value) {
2520 return value ? true_value() : false_value(); 2520 return value ? true_value() : false_value();
2521 } 2521 }
2522 2522
2523 2523
2524 } } // namespace v8::internal 2524 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698