OLD | NEW |
---|---|
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 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1060 #endif // DEBUG | 1060 #endif // DEBUG |
1061 Heap* heap = GetHeap(); | 1061 Heap* heap = GetHeap(); |
1062 int size = this->Size(); // Byte size of the original string. | 1062 int size = this->Size(); // Byte size of the original string. |
1063 if (size < ExternalString::kShortSize) { | 1063 if (size < ExternalString::kShortSize) { |
1064 return false; | 1064 return false; |
1065 } | 1065 } |
1066 bool is_ascii = this->IsOneByteRepresentation(); | 1066 bool is_ascii = this->IsOneByteRepresentation(); |
1067 bool is_internalized = this->IsInternalizedString(); | 1067 bool is_internalized = this->IsInternalizedString(); |
1068 | 1068 |
1069 // Morph the string to an external string by replacing the map and | 1069 // Morph the string to an external string by replacing the map and |
1070 // reinitializing the fields. This won't work if | 1070 // reinitializing the fields. This won't work if the space the existing |
1071 // - the space the existing string occupies is too small for a regular | 1071 // string occupies is too small for a regular external string. |
Hannes Payer (out of office)
2014/07/03 11:37:18
minus one blank before "external string"
| |
1072 // external string. | 1072 // Instead, we resort to a short external string instead, omitting |
Hannes Payer (out of office)
2014/07/03 11:37:18
drop the second instead
| |
1073 // - the existing string is in old pointer space and the backing store of | |
1074 // the external string is not aligned. The GC cannot deal with a field | |
1075 // containing a possibly unaligned address to outside of V8's heap. | |
1076 // In either case we resort to a short external string instead, omitting | |
1077 // the field caching the address of the backing store. When we encounter | 1073 // the field caching the address of the backing store. When we encounter |
1078 // short external strings in generated code, we need to bailout to runtime. | 1074 // short external strings in generated code, we need to bailout to runtime. |
1079 Map* new_map; | 1075 Map* new_map; |
1080 if (size < ExternalString::kSize || | 1076 if (size < ExternalString::kSize) { |
1081 heap->old_pointer_space()->Contains(this)) { | |
1082 new_map = is_internalized | 1077 new_map = is_internalized |
1083 ? (is_ascii | 1078 ? (is_ascii |
1084 ? heap-> | 1079 ? heap-> |
1085 short_external_internalized_string_with_one_byte_data_map() | 1080 short_external_internalized_string_with_one_byte_data_map() |
1086 : heap->short_external_internalized_string_map()) | 1081 : heap->short_external_internalized_string_map()) |
1087 : (is_ascii | 1082 : (is_ascii |
1088 ? heap->short_external_string_with_one_byte_data_map() | 1083 ? heap->short_external_string_with_one_byte_data_map() |
1089 : heap->short_external_string_map()); | 1084 : heap->short_external_string_map()); |
1090 } else { | 1085 } else { |
1091 new_map = is_internalized | 1086 new_map = is_internalized |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 } | 1127 } |
1133 #endif // DEBUG | 1128 #endif // DEBUG |
1134 Heap* heap = GetHeap(); | 1129 Heap* heap = GetHeap(); |
1135 int size = this->Size(); // Byte size of the original string. | 1130 int size = this->Size(); // Byte size of the original string. |
1136 if (size < ExternalString::kShortSize) { | 1131 if (size < ExternalString::kShortSize) { |
1137 return false; | 1132 return false; |
1138 } | 1133 } |
1139 bool is_internalized = this->IsInternalizedString(); | 1134 bool is_internalized = this->IsInternalizedString(); |
1140 | 1135 |
1141 // Morph the string to an external string by replacing the map and | 1136 // Morph the string to an external string by replacing the map and |
1142 // reinitializing the fields. This won't work if | 1137 // reinitializing the fields. This won't work if the space the existing |
1143 // - the space the existing string occupies is too small for a regular | 1138 // string occupies is too small for a regular external string. |
Hannes Payer (out of office)
2014/07/03 11:37:18
same as above
| |
1144 // external string. | 1139 // Instead, we resort to a short external string instead, omitting |
1145 // - the existing string is in old pointer space and the backing store of | |
1146 // the external string is not aligned. The GC cannot deal with a field | |
1147 // containing a possibly unaligned address to outside of V8's heap. | |
1148 // In either case we resort to a short external string instead, omitting | |
1149 // the field caching the address of the backing store. When we encounter | 1140 // the field caching the address of the backing store. When we encounter |
1150 // short external strings in generated code, we need to bailout to runtime. | 1141 // short external strings in generated code, we need to bailout to runtime. |
1151 Map* new_map; | 1142 Map* new_map; |
1152 if (size < ExternalString::kSize || | 1143 if (size < ExternalString::kSize) { |
1153 heap->old_pointer_space()->Contains(this)) { | |
1154 new_map = is_internalized | 1144 new_map = is_internalized |
1155 ? heap->short_external_ascii_internalized_string_map() | 1145 ? heap->short_external_ascii_internalized_string_map() |
1156 : heap->short_external_ascii_string_map(); | 1146 : heap->short_external_ascii_string_map(); |
1157 } else { | 1147 } else { |
1158 new_map = is_internalized | 1148 new_map = is_internalized |
1159 ? heap->external_ascii_internalized_string_map() | 1149 ? heap->external_ascii_internalized_string_map() |
1160 : heap->external_ascii_string_map(); | 1150 : heap->external_ascii_string_map(); |
1161 } | 1151 } |
1162 | 1152 |
1163 // Byte size of the external String object. | 1153 // Byte size of the external String object. |
(...skipping 15812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16976 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16966 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16977 static const char* error_messages_[] = { | 16967 static const char* error_messages_[] = { |
16978 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16968 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16979 }; | 16969 }; |
16980 #undef ERROR_MESSAGES_TEXTS | 16970 #undef ERROR_MESSAGES_TEXTS |
16981 return error_messages_[reason]; | 16971 return error_messages_[reason]; |
16982 } | 16972 } |
16983 | 16973 |
16984 | 16974 |
16985 } } // namespace v8::internal | 16975 } } // namespace v8::internal |
OLD | NEW |