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

Side by Side Diff: src/factory.cc

Issue 258823011: Version 3.25.28.15 (merged r20882) (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.25
Patch Set: Created 6 years, 7 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 | « no previous file | src/version.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 473
474 474
475 Handle<String> Factory::NewProperSubString(Handle<String> str, 475 Handle<String> Factory::NewProperSubString(Handle<String> str,
476 int begin, 476 int begin,
477 int end) { 477 int end) {
478 #if VERIFY_HEAP 478 #if VERIFY_HEAP
479 if (FLAG_verify_heap) str->StringVerify(); 479 if (FLAG_verify_heap) str->StringVerify();
480 #endif 480 #endif
481 ASSERT(begin > 0 || end < str->length()); 481 ASSERT(begin > 0 || end < str->length());
482 482
483 str = FlattenGetString(str);
484
483 int length = end - begin; 485 int length = end - begin;
484 if (length <= 0) return empty_string(); 486 if (length <= 0) return empty_string();
485 if (length == 1) { 487 if (length == 1) {
486 return LookupSingleCharacterStringFromCode(isolate(), str->Get(begin)); 488 return LookupSingleCharacterStringFromCode(isolate(), str->Get(begin));
487 } 489 }
488 if (length == 2) { 490 if (length == 2) {
489 // Optimization for 2-byte strings often used as keys in a decompression 491 // Optimization for 2-byte strings often used as keys in a decompression
490 // dictionary. Check whether we already have the string in the string 492 // dictionary. Check whether we already have the string in the string
491 // table to prevent creation of many unnecessary strings. 493 // table to prevent creation of many unnecessary strings.
492 uint16_t c1 = str->Get(begin); 494 uint16_t c1 = str->Get(begin);
(...skipping 14 matching lines...) Expand all
507 ASSERT(!result.is_null()); 509 ASSERT(!result.is_null());
508 uc16* dest = result->GetChars(); 510 uc16* dest = result->GetChars();
509 DisallowHeapAllocation no_gc; 511 DisallowHeapAllocation no_gc;
510 String::WriteToFlat(*str, dest, begin, end); 512 String::WriteToFlat(*str, dest, begin, end);
511 return result; 513 return result;
512 } 514 }
513 } 515 }
514 516
515 int offset = begin; 517 int offset = begin;
516 518
517 while (str->IsConsString()) {
518 Handle<ConsString> cons = Handle<ConsString>::cast(str);
519 int split = cons->first()->length();
520 if (split <= offset) {
521 // Slice is fully contained in the second part.
522 str = Handle<String>(cons->second(), isolate());
523 offset -= split; // Adjust for offset.
524 continue;
525 } else if (offset + length <= split) {
526 // Slice is fully contained in the first part.
527 str = Handle<String>(cons->first(), isolate());
528 continue;
529 }
530 break;
531 }
532
533 if (str->IsSlicedString()) { 519 if (str->IsSlicedString()) {
534 Handle<SlicedString> slice = Handle<SlicedString>::cast(str); 520 Handle<SlicedString> slice = Handle<SlicedString>::cast(str);
535 str = Handle<String>(slice->parent(), isolate()); 521 str = Handle<String>(slice->parent(), isolate());
536 offset += slice->offset(); 522 offset += slice->offset();
537 } else {
538 str = FlattenGetString(str);
539 } 523 }
540 524
541 ASSERT(str->IsSeqString() || str->IsExternalString()); 525 ASSERT(str->IsSeqString() || str->IsExternalString());
542 Handle<SlicedString> slice = NewRawSlicedString( 526 Handle<SlicedString> slice = NewRawSlicedString(
543 str->IsOneByteRepresentation() ? String::ONE_BYTE_ENCODING 527 str->IsOneByteRepresentation() ? String::ONE_BYTE_ENCODING
544 : String::TWO_BYTE_ENCODING); 528 : String::TWO_BYTE_ENCODING);
545 529
546 slice->set_hash_field(String::kEmptyHashField); 530 slice->set_hash_field(String::kEmptyHashField);
547 slice->set_length(length); 531 slice->set_length(length);
548 slice->set_parent(*str); 532 slice->set_parent(*str);
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 return Handle<Object>::null(); 2001 return Handle<Object>::null();
2018 } 2002 }
2019 2003
2020 2004
2021 Handle<Object> Factory::ToBoolean(bool value) { 2005 Handle<Object> Factory::ToBoolean(bool value) {
2022 return value ? true_value() : false_value(); 2006 return value ? true_value() : false_value();
2023 } 2007 }
2024 2008
2025 2009
2026 } } // namespace v8::internal 2010 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698