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

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

Issue 10545080: Optimize call sites that only ever have a single elements transition (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 6 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/ic.cc ('k') | test/mjsunit/elements-transition-hoisting.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 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 25 matching lines...) Expand all
36 36
37 support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); 37 support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8));
38 38
39 if (support_smi_only_arrays) { 39 if (support_smi_only_arrays) {
40 print("Tests include smi-only arrays."); 40 print("Tests include smi-only arrays.");
41 } else { 41 } else {
42 print("Tests do NOT include smi-only arrays."); 42 print("Tests do NOT include smi-only arrays.");
43 } 43 }
44 44
45 var elements_kind = { 45 var elements_kind = {
46 any : 'ignoreme',
46 fast_smi_only : 'fast smi only elements', 47 fast_smi_only : 'fast smi only elements',
47 fast : 'fast elements', 48 fast : 'fast elements',
48 fast_double : 'fast double elements', 49 fast_double : 'fast double elements',
49 dictionary : 'dictionary elements', 50 dictionary : 'dictionary elements',
50 external_byte : 'external byte elements', 51 external_byte : 'external byte elements',
51 external_unsigned_byte : 'external unsigned byte elements', 52 external_unsigned_byte : 'external unsigned byte elements',
52 external_short : 'external short elements', 53 external_short : 'external short elements',
53 external_unsigned_short : 'external unsigned short elements', 54 external_unsigned_short : 'external unsigned short elements',
54 external_int : 'external int elements', 55 external_int : 'external int elements',
55 external_unsigned_int : 'external unsigned int elements', 56 external_unsigned_int : 'external unsigned int elements',
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 89 }
89 if (%HasExternalDoubleElements(obj)) { 90 if (%HasExternalDoubleElements(obj)) {
90 return elements_kind.external_double; 91 return elements_kind.external_double;
91 } 92 }
92 if (%HasExternalPixelElements(obj)) { 93 if (%HasExternalPixelElements(obj)) {
93 return elements_kind.external_pixel; 94 return elements_kind.external_pixel;
94 } 95 }
95 } 96 }
96 97
97 function assertKind(expected, obj, name_opt) { 98 function assertKind(expected, obj, name_opt) {
99 if (expected == elements_kind.any)
100 return;
98 if (!support_smi_only_arrays && 101 if (!support_smi_only_arrays &&
99 expected == elements_kind.fast_smi_only) { 102 expected == elements_kind.fast_smi_only) {
100 expected = elements_kind.fast; 103 expected = elements_kind.fast;
101 } 104 }
102 assertEquals(expected, getKind(obj), name_opt); 105 assertEquals(expected, getKind(obj), name_opt);
103 } 106 }
104 107
105 var me = {}; 108 var me = {};
106 assertKind(elements_kind.fast, me); 109 assertKind(elements_kind.fast, me);
107 me.dance = 0xD15C0; 110 me.dance = 0xD15C0;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 187 }
185 188
186 // Test crankshafted transition SMI->DOUBLE. 189 // Test crankshafted transition SMI->DOUBLE.
187 function convert_to_double(array) { 190 function convert_to_double(array) {
188 array[1] = 2.5; 191 array[1] = 2.5;
189 assertKind(elements_kind.fast_double, array); 192 assertKind(elements_kind.fast_double, array);
190 assertEquals(2.5, array[1]); 193 assertEquals(2.5, array[1]);
191 } 194 }
192 var smis = construct_smis(); 195 var smis = construct_smis();
193 for (var i = 0; i < 3; i++) convert_to_double(smis); 196 for (var i = 0; i < 3; i++) convert_to_double(smis);
197 smis = construct_smis();
198 for (var i = 0; i < 3; i++) convert_to_double(smis);
194 %OptimizeFunctionOnNextCall(convert_to_double); 199 %OptimizeFunctionOnNextCall(convert_to_double);
195 smis = construct_smis(); 200 smis = construct_smis();
196 convert_to_double(smis); 201 convert_to_double(smis);
202 assertTrue(2 != %GetOptimizationStatus(convert_to_double));
197 // Test crankshafted transitions SMI->FAST and DOUBLE->FAST. 203 // Test crankshafted transitions SMI->FAST and DOUBLE->FAST.
198 function convert_to_fast(array) { 204 function convert_to_fast(array) {
199 array[1] = "two"; 205 array[1] = "two";
200 assertKind(elements_kind.fast, array); 206 assertKind(elements_kind.fast, array);
201 assertEquals("two", array[1]); 207 assertEquals("two", array[1]);
202 } 208 }
203 smis = construct_smis(); 209 smis = construct_smis();
204 for (var i = 0; i < 3; i++) convert_to_fast(smis); 210 for (var i = 0; i < 3; i++) convert_to_fast(smis);
205 var doubles = construct_doubles(); 211 var doubles = construct_doubles();
206 for (var i = 0; i < 3; i++) convert_to_fast(doubles); 212 for (var i = 0; i < 3; i++) convert_to_fast(doubles);
207 smis = construct_smis(); 213 smis = construct_smis();
214 for (var i = 0; i < 3; i++) convert_to_fast(smis);
215 smis = construct_smis();
208 doubles = construct_doubles(); 216 doubles = construct_doubles();
209 %OptimizeFunctionOnNextCall(convert_to_fast); 217 %OptimizeFunctionOnNextCall(convert_to_fast);
210 convert_to_fast(smis); 218 convert_to_fast(smis);
211 convert_to_fast(doubles); 219 convert_to_fast(doubles);
220 assertTrue(2 != %GetOptimizationStatus(convert_to_fast));
212 // Test transition chain SMI->DOUBLE->FAST (crankshafted function will 221 // Test transition chain SMI->DOUBLE->FAST (crankshafted function will
213 // transition to FAST directly). 222 // transition to FAST directly).
214 function convert_mixed(array, value, kind) { 223 function convert_mixed(array, value, kind) {
215 array[1] = value; 224 array[1] = value;
216 assertKind(kind, array); 225 assertKind(kind, array);
217 assertEquals(value, array[1]); 226 assertEquals(value, array[1]);
218 } 227 }
219 smis = construct_smis(); 228 smis = construct_smis();
220 for (var i = 0; i < 3; i++) { 229 for (var i = 0; i < 3; i++) {
221 convert_mixed(smis, 1.5, elements_kind.fast_double); 230 convert_mixed(smis, 1.5, elements_kind.fast_double);
222 } 231 }
223 doubles = construct_doubles(); 232 doubles = construct_doubles();
224 for (var i = 0; i < 3; i++) { 233 for (var i = 0; i < 3; i++) {
225 convert_mixed(doubles, "three", elements_kind.fast); 234 convert_mixed(doubles, "three", elements_kind.fast);
226 } 235 }
227 smis = construct_smis(); 236 smis = construct_smis();
237 for (var i = 0; i < 3; i++) {
238 convert_mixed(smis, 1.5, elements_kind.any);
239 }
240 smis = construct_smis();
228 doubles = construct_doubles(); 241 doubles = construct_doubles();
229 %OptimizeFunctionOnNextCall(convert_mixed); 242 %OptimizeFunctionOnNextCall(convert_mixed);
230 convert_mixed(smis, 1, elements_kind.fast); 243 convert_mixed(smis, 1, elements_kind.fast);
231 convert_mixed(doubles, 1, elements_kind.fast); 244 convert_mixed(doubles, 1, elements_kind.fast);
245 assertTrue(2 != %GetOptimizationStatus(convert_mixed));
232 assertTrue(%HaveSameMap(smis, doubles)); 246 assertTrue(%HaveSameMap(smis, doubles));
233 } 247 }
234 248
235 // Crankshaft support for smi-only elements in dynamic array literals. 249 // Crankshaft support for smi-only elements in dynamic array literals.
236 function get(foo) { return foo; } // Used to generate dynamic values. 250 function get(foo) { return foo; } // Used to generate dynamic values.
237 251
238 function crankshaft_test() { 252 function crankshaft_test() {
239 if (support_smi_only_arrays) { 253 if (support_smi_only_arrays) {
240 var a1 = [get(1), get(2), get(3)]; 254 var a1 = [get(1), get(2), get(3)];
241 assertKind(elements_kind.fast_smi_only, a1); 255 assertKind(elements_kind.fast_smi_only, a1);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 var a = ["foo", "bar"]; 351 var a = ["foo", "bar"];
338 assertKind(elements_kind.fast, a); 352 assertKind(elements_kind.fast, a);
339 var b = a.splice(0, 1); 353 var b = a.splice(0, 1);
340 assertKind(elements_kind.fast, b); 354 assertKind(elements_kind.fast, b);
341 var c = a.slice(0, 1); 355 var c = a.slice(0, 1);
342 assertKind(elements_kind.fast, c); 356 assertKind(elements_kind.fast, c);
343 } 357 }
344 358
345 // Throw away type information in the ICs for next stress run. 359 // Throw away type information in the ICs for next stress run.
346 gc(); 360 gc();
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | test/mjsunit/elements-transition-hoisting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698