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

Side by Side Diff: test/mjsunit/element-kind.js

Issue 8166017: Track elements_kind transitions in KeyedStoreICs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix nits Created 9 years, 2 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/x64/stub-cache-x64.cc ('k') | 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 %OptimizeFunctionOnNextCall(polymorphic); 176 %OptimizeFunctionOnNextCall(polymorphic);
177 polymorphic(smis, element_kind.fast_smi_only_elements); 177 polymorphic(smis, element_kind.fast_smi_only_elements);
178 polymorphic(strings, element_kind.fast_elements); 178 polymorphic(strings, element_kind.fast_elements);
179 polymorphic(doubles, support_smi_only_arrays 179 polymorphic(doubles, support_smi_only_arrays
180 ? element_kind.fast_double_elements 180 ? element_kind.fast_double_elements
181 : element_kind.fast_elements); 181 : element_kind.fast_elements);
182 182
183 // Crankshaft support for smi-only elements in dynamic array literals. 183 // Crankshaft support for smi-only elements in dynamic array literals.
184 function get(foo) { return foo; } // Used to generate dynamic values. 184 function get(foo) { return foo; } // Used to generate dynamic values.
185 185
186 //function crankshaft_test(expected_kind) {
187 function crankshaft_test() { 186 function crankshaft_test() {
188 var a = [get(1), get(2), get(3)]; 187 var a = [get(1), get(2), get(3)];
189 assertKind(element_kind.fast_smi_only_elements, a); 188 assertKind(element_kind.fast_smi_only_elements, a);
190 var b = [get(1), get(2), get("three")]; 189 var b = [get(1), get(2), get("three")];
191 assertKind(element_kind.fast_elements, b); 190 assertKind(element_kind.fast_elements, b);
192 var c = [get(1), get(2), get(3.5)]; 191 var c = [get(1), get(2), get(3.5)];
193 // The full code generator doesn't support conversion to fast_double_elements 192 // The full code generator doesn't support conversion to fast_double_elements
194 // yet. Crankshaft does, but only with --smi-only-arrays support. 193 // yet. Crankshaft does, but only with --smi-only-arrays support.
195 if ((%GetOptimizationStatus(crankshaft_test) & 1) && 194 if ((%GetOptimizationStatus(crankshaft_test) & 1) &&
196 support_smi_only_arrays) { 195 support_smi_only_arrays) {
197 assertKind(element_kind.fast_double_elements, c); 196 assertKind(element_kind.fast_double_elements, c);
198 } else { 197 } else {
199 assertKind(element_kind.fast_elements, c); 198 assertKind(element_kind.fast_elements, c);
200 } 199 }
201 } 200 }
202 for (var i = 0; i < 3; i++) { 201 for (var i = 0; i < 3; i++) {
203 crankshaft_test(); 202 crankshaft_test();
204 } 203 }
205 %OptimizeFunctionOnNextCall(crankshaft_test); 204 %OptimizeFunctionOnNextCall(crankshaft_test);
206 crankshaft_test(); 205 crankshaft_test();
206
207 // Elements_kind transitions for arrays.
208
209 // A map can have three different elements_kind transitions: SMI->DOUBLE,
210 // DOUBLE->OBJECT, and SMI->OBJECT. No matter in which order these three are
211 // created, they must always end up with the same FAST map.
212 // Preparation: create one pair of identical objects for each case.
213 var a = [1, 2, 3];
214 var b = [1, 2, 3];
215 assertTrue(%HaveSameMap(a, b));
216 assertKind(element_kind.fast_smi_only_elements, a);
217 var c = [1, 2, 3];
218 c["case2"] = true;
219 var d = [1, 2, 3];
220 d["case2"] = true;
221 assertTrue(%HaveSameMap(c, d));
222 assertFalse(%HaveSameMap(a, c));
223 assertKind(element_kind.fast_smi_only_elements, c);
224 var e = [1, 2, 3];
225 e["case3"] = true;
226 var f = [1, 2, 3];
227 f["case3"] = true;
228 assertTrue(%HaveSameMap(e, f));
229 assertFalse(%HaveSameMap(a, e));
230 assertFalse(%HaveSameMap(c, e));
231 assertKind(element_kind.fast_smi_only_elements, e);
232 // Case 1: SMI->DOUBLE, DOUBLE->OBJECT, SMI->OBJECT.
233 a[0] = 1.5;
234 assertKind(element_kind.fast_double_elements, a);
235 a[0] = "foo";
236 assertKind(element_kind.fast_elements, a);
237 b[0] = "bar";
238 assertTrue(%HaveSameMap(a, b));
239 // Case 2: SMI->DOUBLE, SMI->OBJECT, DOUBLE->OBJECT.
240 c[0] = 1.5;
241 assertKind(element_kind.fast_double_elements, c);
242 assertFalse(%HaveSameMap(c, d));
243 d[0] = "foo";
244 assertKind(element_kind.fast_elements, d);
245 assertFalse(%HaveSameMap(c, d));
246 c[0] = "bar";
247 assertTrue(%HaveSameMap(c, d));
248 // Case 3: SMI->OBJECT, SMI->DOUBLE, DOUBLE->OBJECT.
249 e[0] = "foo";
250 assertKind(element_kind.fast_elements, e);
251 assertFalse(%HaveSameMap(e, f));
252 f[0] = 1.5;
253 assertKind(element_kind.fast_double_elements, f);
254 assertFalse(%HaveSameMap(e, f));
255 f[0] = "bar";
256 assertKind(element_kind.fast_elements, f);
257 assertTrue(%HaveSameMap(e, f));
OLDNEW
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698