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

Side by Side Diff: src/elements-kind.cc

Issue 213783004: Harden IsMoreGeneralElementsKindTransition. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return TERMINAL_FAST_ELEMENTS_KIND; 171 return TERMINAL_FAST_ELEMENTS_KIND;
172 } 172 }
173 173
174 174
175 static bool IsTypedArrayElementsKind(ElementsKind elements_kind) { 175 static bool IsTypedArrayElementsKind(ElementsKind elements_kind) {
176 return IsFixedTypedArrayElementsKind(elements_kind) || 176 return IsFixedTypedArrayElementsKind(elements_kind) ||
177 IsExternalArrayElementsKind(elements_kind); 177 IsExternalArrayElementsKind(elements_kind);
178 } 178 }
179 179
180 180
181 static inline bool IsFastTransitionTarget(ElementsKind elements_kind) {
182 return IsFastElementsKind(elements_kind) ||
183 elements_kind == DICTIONARY_ELEMENTS;
184 }
185
181 bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, 186 bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind,
182 ElementsKind to_kind) { 187 ElementsKind to_kind) {
183 if (IsTypedArrayElementsKind(from_kind) || 188 if (IsTypedArrayElementsKind(from_kind) ||
184 IsTypedArrayElementsKind(to_kind)) { 189 IsTypedArrayElementsKind(to_kind)) {
185 switch (from_kind) { 190 switch (from_kind) {
186 #define FIXED_TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 191 #define FIXED_TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
187 case TYPE##_ELEMENTS: \ 192 case TYPE##_ELEMENTS: \
188 return to_kind == EXTERNAL_##TYPE##_ELEMENTS; 193 return to_kind == EXTERNAL_##TYPE##_ELEMENTS;
189 194
190 TYPED_ARRAYS(FIXED_TYPED_ARRAY_CASE); 195 TYPED_ARRAYS(FIXED_TYPED_ARRAY_CASE);
191 #undef FIXED_TYPED_ARRAY_CASE 196 #undef FIXED_TYPED_ARRAY_CASE
192 default: 197 default:
193 return false; 198 return false;
194 } 199 }
195 } 200 }
196 switch (from_kind) { 201 if (IsFastElementsKind(from_kind) && IsFastTransitionTarget(to_kind)) {
197 case FAST_SMI_ELEMENTS: 202 switch (from_kind) {
198 return to_kind != FAST_SMI_ELEMENTS; 203 case FAST_SMI_ELEMENTS:
199 case FAST_HOLEY_SMI_ELEMENTS: 204 return to_kind != FAST_SMI_ELEMENTS;
200 return to_kind != FAST_SMI_ELEMENTS && 205 case FAST_HOLEY_SMI_ELEMENTS:
201 to_kind != FAST_HOLEY_SMI_ELEMENTS; 206 return to_kind != FAST_SMI_ELEMENTS &&
202 case FAST_DOUBLE_ELEMENTS: 207 to_kind != FAST_HOLEY_SMI_ELEMENTS;
203 return to_kind != FAST_SMI_ELEMENTS && 208 case FAST_DOUBLE_ELEMENTS:
204 to_kind != FAST_HOLEY_SMI_ELEMENTS && 209 return to_kind != FAST_SMI_ELEMENTS &&
205 to_kind != FAST_DOUBLE_ELEMENTS; 210 to_kind != FAST_HOLEY_SMI_ELEMENTS &&
206 case FAST_HOLEY_DOUBLE_ELEMENTS: 211 to_kind != FAST_DOUBLE_ELEMENTS;
207 return to_kind == FAST_ELEMENTS || 212 case FAST_HOLEY_DOUBLE_ELEMENTS:
208 to_kind == FAST_HOLEY_ELEMENTS; 213 return to_kind == FAST_ELEMENTS ||
209 case FAST_ELEMENTS: 214 to_kind == FAST_HOLEY_ELEMENTS;
210 return to_kind == FAST_HOLEY_ELEMENTS; 215 case FAST_ELEMENTS:
211 case FAST_HOLEY_ELEMENTS: 216 return to_kind == FAST_HOLEY_ELEMENTS;
212 return false; 217 case FAST_HOLEY_ELEMENTS:
213 default: 218 return false;
214 return false; 219 default:
220 return false;
221 }
215 } 222 }
223 return false;
216 } 224 }
217 225
218 226
219 } } // namespace v8::internal 227 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698