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

Side by Side Diff: src/factory.cc

Issue 2736383003: [regexp] Properly flatten string during initialization (Closed)
Patch Set: Better DCHECKs Created 3 years, 9 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') | src/objects.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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 return result; 704 return result;
705 } 705 }
706 706
707 return (is_one_byte_data_in_two_byte_string) 707 return (is_one_byte_data_in_two_byte_string)
708 ? ConcatStringContent<uint8_t>( 708 ? ConcatStringContent<uint8_t>(
709 NewRawOneByteString(length).ToHandleChecked(), left, right) 709 NewRawOneByteString(length).ToHandleChecked(), left, right)
710 : ConcatStringContent<uc16>( 710 : ConcatStringContent<uc16>(
711 NewRawTwoByteString(length).ToHandleChecked(), left, right); 711 NewRawTwoByteString(length).ToHandleChecked(), left, right);
712 } 712 }
713 713
714 bool one_byte = (is_one_byte || is_one_byte_data_in_two_byte_string);
715 return NewConsString(left, right, length, one_byte);
716 }
717
718 Handle<String> Factory::NewConsString(Handle<String> left, Handle<String> right,
719 int length, bool one_byte) {
720 DCHECK(!left->IsThinString());
721 DCHECK(!right->IsThinString());
722 DCHECK_GE(length, ConsString::kMinLength);
723 DCHECK_LE(length, String::kMaxLength);
724
714 Handle<ConsString> result = 725 Handle<ConsString> result =
715 (is_one_byte || is_one_byte_data_in_two_byte_string) 726 one_byte ? New<ConsString>(cons_one_byte_string_map(), NEW_SPACE)
716 ? New<ConsString>(cons_one_byte_string_map(), NEW_SPACE) 727 : New<ConsString>(cons_string_map(), NEW_SPACE);
717 : New<ConsString>(cons_string_map(), NEW_SPACE);
718 728
719 DisallowHeapAllocation no_gc; 729 DisallowHeapAllocation no_gc;
720 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); 730 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
721 731
722 result->set_hash_field(String::kEmptyHashField); 732 result->set_hash_field(String::kEmptyHashField);
723 result->set_length(length); 733 result->set_length(length);
724 result->set_first(*left, mode); 734 result->set_first(*left, mode);
725 result->set_second(*right, mode); 735 result->set_second(*right, mode);
726 return result; 736 return result;
727 } 737 }
(...skipping 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2864 Handle<AccessorInfo> prototype = 2874 Handle<AccessorInfo> prototype =
2865 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); 2875 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs);
2866 Descriptor d = Descriptor::AccessorConstant( 2876 Descriptor d = Descriptor::AccessorConstant(
2867 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); 2877 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs);
2868 map->AppendDescriptor(&d); 2878 map->AppendDescriptor(&d);
2869 } 2879 }
2870 } 2880 }
2871 2881
2872 } // namespace internal 2882 } // namespace internal
2873 } // namespace v8 2883 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698