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

Side by Side Diff: src/objects.cc

Issue 368223002: Turn old space cons strings into regular external strings (not short). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix assertion Created 6 years, 4 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 | « src/heap/heap-inl.h ('k') | test/mjsunit/regress/regress-sliced-external-cons-regexp.js » ('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 // 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/v8.h" 5 #include "src/v8.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/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 } 1022 }
1023 #endif // DEBUG 1023 #endif // DEBUG
1024 int size = this->Size(); // Byte size of the original string. 1024 int size = this->Size(); // Byte size of the original string.
1025 // Abort if size does not allow in-place conversion. 1025 // Abort if size does not allow in-place conversion.
1026 if (size < ExternalString::kShortSize) return false; 1026 if (size < ExternalString::kShortSize) return false;
1027 Heap* heap = GetHeap(); 1027 Heap* heap = GetHeap();
1028 bool is_ascii = this->IsOneByteRepresentation(); 1028 bool is_ascii = this->IsOneByteRepresentation();
1029 bool is_internalized = this->IsInternalizedString(); 1029 bool is_internalized = this->IsInternalizedString();
1030 1030
1031 // Morph the string to an external string by replacing the map and 1031 // Morph the string to an external string by replacing the map and
1032 // reinitializing the fields. This won't work if 1032 // reinitializing the fields. This won't work if the space the existing
1033 // - the space the existing string occupies is too small for a regular 1033 // string occupies is too small for a regular external string.
1034 // external string. 1034 // Instead, we resort to a short external string instead, omitting
1035 // - the existing string is in old pointer space and the backing store of
1036 // the external string is not aligned. The GC cannot deal with a field
1037 // containing a possibly unaligned address to outside of V8's heap.
1038 // In either case we resort to a short external string instead, omitting
1039 // the field caching the address of the backing store. When we encounter 1035 // the field caching the address of the backing store. When we encounter
1040 // short external strings in generated code, we need to bailout to runtime. 1036 // short external strings in generated code, we need to bailout to runtime.
1041 Map* new_map; 1037 Map* new_map;
1042 if (size < ExternalString::kSize || 1038 if (size < ExternalString::kSize) {
1043 heap->old_pointer_space()->Contains(this)) {
1044 new_map = is_internalized 1039 new_map = is_internalized
1045 ? (is_ascii 1040 ? (is_ascii
1046 ? heap-> 1041 ? heap->
1047 short_external_internalized_string_with_one_byte_data_map() 1042 short_external_internalized_string_with_one_byte_data_map()
1048 : heap->short_external_internalized_string_map()) 1043 : heap->short_external_internalized_string_map())
1049 : (is_ascii 1044 : (is_ascii
1050 ? heap->short_external_string_with_one_byte_data_map() 1045 ? heap->short_external_string_with_one_byte_data_map()
1051 : heap->short_external_string_map()); 1046 : heap->short_external_string_map());
1052 } else { 1047 } else {
1053 new_map = is_internalized 1048 new_map = is_internalized
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 resource->length() * sizeof(smart_chars[0])) == 0); 1091 resource->length() * sizeof(smart_chars[0])) == 0);
1097 } 1092 }
1098 #endif // DEBUG 1093 #endif // DEBUG
1099 int size = this->Size(); // Byte size of the original string. 1094 int size = this->Size(); // Byte size of the original string.
1100 // Abort if size does not allow in-place conversion. 1095 // Abort if size does not allow in-place conversion.
1101 if (size < ExternalString::kShortSize) return false; 1096 if (size < ExternalString::kShortSize) return false;
1102 Heap* heap = GetHeap(); 1097 Heap* heap = GetHeap();
1103 bool is_internalized = this->IsInternalizedString(); 1098 bool is_internalized = this->IsInternalizedString();
1104 1099
1105 // Morph the string to an external string by replacing the map and 1100 // Morph the string to an external string by replacing the map and
1106 // reinitializing the fields. This won't work if 1101 // reinitializing the fields. This won't work if the space the existing
1107 // - the space the existing string occupies is too small for a regular 1102 // string occupies is too small for a regular external string.
1108 // external string. 1103 // Instead, we resort to a short external string instead, omitting
1109 // - the existing string is in old pointer space and the backing store of
1110 // the external string is not aligned. The GC cannot deal with a field
1111 // containing a possibly unaligned address to outside of V8's heap.
1112 // In either case we resort to a short external string instead, omitting
1113 // the field caching the address of the backing store. When we encounter 1104 // the field caching the address of the backing store. When we encounter
1114 // short external strings in generated code, we need to bailout to runtime. 1105 // short external strings in generated code, we need to bailout to runtime.
1115 Map* new_map; 1106 Map* new_map;
1116 if (size < ExternalString::kSize || 1107 if (size < ExternalString::kSize) {
1117 heap->old_pointer_space()->Contains(this)) {
1118 new_map = is_internalized 1108 new_map = is_internalized
1119 ? heap->short_external_ascii_internalized_string_map() 1109 ? heap->short_external_ascii_internalized_string_map()
1120 : heap->short_external_ascii_string_map(); 1110 : heap->short_external_ascii_string_map();
1121 } else { 1111 } else {
1122 new_map = is_internalized 1112 new_map = is_internalized
1123 ? heap->external_ascii_internalized_string_map() 1113 ? heap->external_ascii_internalized_string_map()
1124 : heap->external_ascii_string_map(); 1114 : heap->external_ascii_string_map();
1125 } 1115 }
1126 1116
1127 // Byte size of the external String object. 1117 // Byte size of the external String object.
(...skipping 15477 matching lines...) Expand 10 before | Expand all | Expand 10 after
16605 #define ERROR_MESSAGES_TEXTS(C, T) T, 16595 #define ERROR_MESSAGES_TEXTS(C, T) T,
16606 static const char* error_messages_[] = { 16596 static const char* error_messages_[] = {
16607 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16597 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16608 }; 16598 };
16609 #undef ERROR_MESSAGES_TEXTS 16599 #undef ERROR_MESSAGES_TEXTS
16610 return error_messages_[reason]; 16600 return error_messages_[reason];
16611 } 16601 }
16612 16602
16613 16603
16614 } } // namespace v8::internal 16604 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap-inl.h ('k') | test/mjsunit/regress/regress-sliced-external-cons-regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698