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

Side by Side Diff: src/factory.cc

Issue 2065053002: ZoneVector overload of Factory::NewStringFromTwoByte (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: static_cast Created 4 years, 6 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 | « src/factory.h ('k') | no next file » | 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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 uint16_t* data = result->GetChars(); 285 uint16_t* data = result->GetChars();
286 const char* ascii_data = string.start(); 286 const char* ascii_data = string.start();
287 for (int i = 0; i < non_ascii_start; i++) { 287 for (int i = 0; i < non_ascii_start; i++) {
288 *data++ = *ascii_data++; 288 *data++ = *ascii_data++;
289 } 289 }
290 // Now write the remainder. 290 // Now write the remainder.
291 decoder->WriteUtf16(data, utf16_length); 291 decoder->WriteUtf16(data, utf16_length);
292 return result; 292 return result;
293 } 293 }
294 294
295 295 MaybeHandle<String> Factory::NewStringFromTwoByte(const uc16* string,
296 MaybeHandle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string, 296 int length,
297 PretenureFlag pretenure) { 297 PretenureFlag pretenure) {
298 int length = string.length(); 298 if (String::IsOneByte(string, length)) {
299 const uc16* start = string.start();
300 if (String::IsOneByte(start, length)) {
301 if (length == 1) return LookupSingleCharacterStringFromCode(string[0]); 299 if (length == 1) return LookupSingleCharacterStringFromCode(string[0]);
302 Handle<SeqOneByteString> result; 300 Handle<SeqOneByteString> result;
303 ASSIGN_RETURN_ON_EXCEPTION( 301 ASSIGN_RETURN_ON_EXCEPTION(
304 isolate(), 302 isolate(),
305 result, 303 result,
306 NewRawOneByteString(length, pretenure), 304 NewRawOneByteString(length, pretenure),
307 String); 305 String);
308 CopyChars(result->GetChars(), start, length); 306 CopyChars(result->GetChars(), string, length);
309 return result; 307 return result;
310 } else { 308 } else {
311 Handle<SeqTwoByteString> result; 309 Handle<SeqTwoByteString> result;
312 ASSIGN_RETURN_ON_EXCEPTION( 310 ASSIGN_RETURN_ON_EXCEPTION(
313 isolate(), 311 isolate(),
314 result, 312 result,
315 NewRawTwoByteString(length, pretenure), 313 NewRawTwoByteString(length, pretenure),
316 String); 314 String);
317 CopyChars(result->GetChars(), start, length); 315 CopyChars(result->GetChars(), string, length);
318 return result; 316 return result;
319 } 317 }
320 } 318 }
321 319
320 MaybeHandle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string,
321 PretenureFlag pretenure) {
322 return NewStringFromTwoByte(string.start(), string.length(), pretenure);
323 }
324
325 MaybeHandle<String> Factory::NewStringFromTwoByte(
326 const ZoneVector<uc16>* string, PretenureFlag pretenure) {
327 return NewStringFromTwoByte(string->data(), static_cast<int>(string->size()),
328 pretenure);
329 }
322 330
323 Handle<String> Factory::NewInternalizedStringFromUtf8(Vector<const char> str, 331 Handle<String> Factory::NewInternalizedStringFromUtf8(Vector<const char> str,
324 int chars, 332 int chars,
325 uint32_t hash_field) { 333 uint32_t hash_field) {
326 CALL_HEAP_FUNCTION( 334 CALL_HEAP_FUNCTION(
327 isolate(), 335 isolate(),
328 isolate()->heap()->AllocateInternalizedStringFromUtf8( 336 isolate()->heap()->AllocateInternalizedStringFromUtf8(
329 str, chars, hash_field), 337 str, chars, hash_field),
330 String); 338 String);
331 } 339 }
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 } 2403 }
2396 2404
2397 2405
2398 Handle<Object> Factory::ToBoolean(bool value) { 2406 Handle<Object> Factory::ToBoolean(bool value) {
2399 return value ? true_value() : false_value(); 2407 return value ? true_value() : false_value();
2400 } 2408 }
2401 2409
2402 2410
2403 } // namespace internal 2411 } // namespace internal
2404 } // namespace v8 2412 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698