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

Side by Side Diff: test/mjsunit/array-literal-transitions.js

Issue 8747009: Optimize Crankshaft array literal initialization from boilerplate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: merge with latest Created 9 years 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 | « test/cctest/test-debug.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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 assertEquals(large, 115 assertEquals(large,
116 [0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 116 [0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5,
117 new Object(), new Object(), new Object(), new Object()]); 117 new Object(), new Object(), new Object(), new Object()]);
118 } 118 }
119 119
120 for (var i = 0; i < 3; i++) { 120 for (var i = 0; i < 3; i++) {
121 test_large_literal(); 121 test_large_literal();
122 } 122 }
123 %OptimizeFunctionOnNextCall(test_large_literal); 123 %OptimizeFunctionOnNextCall(test_large_literal);
124 test_large_literal(); 124 test_large_literal();
125
126 function deopt_array(use_literal) {
127 if (use_literal) {
128 return [.5, 3, 4];
129 } else {
130 return new Array();
131 }
132 }
133
134 deopt_array(false);
135 deopt_array(false);
136 deopt_array(false);
137 %OptimizeFunctionOnNextCall(deopt_array);
138 var array = deopt_array(false);
139 assertTrue(2 != %GetOptimizationStatus(deopt_array));
140 deopt_array(true);
141 assertTrue(1 != %GetOptimizationStatus(deopt_array));
142 array = deopt_array(false);
143 assertTrue(1 != %GetOptimizationStatus(deopt_array));
144
145 // Check that unexpected changes in the objects stored into the boilerplate
146 // also force a deopt.
147 function deopt_array_literal_all_smis(a) {
148 return [0, 1, a];
149 }
150
151 deopt_array_literal_all_smis(2);
152 deopt_array_literal_all_smis(3);
153 deopt_array_literal_all_smis(4);
154 array = deopt_array_literal_all_smis(4);
155 assertEquals(0, array[0]);
156 assertEquals(1, array[1]);
157 assertEquals(4, array[2]);
158 %OptimizeFunctionOnNextCall(deopt_array_literal_all_smis);
159 array = deopt_array_literal_all_smis(5);
160 array = deopt_array_literal_all_smis(6);
161 assertTrue(2 != %GetOptimizationStatus(deopt_array_literal_all_smis));
162 assertEquals(0, array[0]);
163 assertEquals(1, array[1]);
164 assertEquals(6, array[2]);
165
166 array = deopt_array_literal_all_smis(.5);
167 assertTrue(1 != %GetOptimizationStatus(deopt_array_literal_all_smis));
168 assertEquals(0, array[0]);
169 assertEquals(1, array[1]);
170 assertEquals(.5, array[2]);
171
172 function deopt_array_literal_all_doubles(a) {
173 return [0.5, 1, a];
174 }
175
176 deopt_array_literal_all_doubles(.5);
177 deopt_array_literal_all_doubles(.5);
178 deopt_array_literal_all_doubles(.5);
179 array = deopt_array_literal_all_doubles(0.5);
180 assertEquals(0.5, array[0]);
181 assertEquals(1, array[1]);
182 assertEquals(0.5, array[2]);
183 %OptimizeFunctionOnNextCall(deopt_array_literal_all_doubles);
184 array = deopt_array_literal_all_doubles(5);
185 array = deopt_array_literal_all_doubles(6);
186 assertTrue(2 != %GetOptimizationStatus(deopt_array_literal_all_doubles));
187 assertEquals(0.5, array[0]);
188 assertEquals(1, array[1]);
189 assertEquals(6, array[2]);
190
191 var foo = new Object();
192 array = deopt_array_literal_all_doubles(foo);
193 assertTrue(1 != %GetOptimizationStatus(deopt_array_literal_all_doubles));
194 assertEquals(0.5, array[0]);
195 assertEquals(1, array[1]);
196 assertEquals(foo, array[2]);
125 } 197 }
OLDNEW
« no previous file with comments | « test/cctest/test-debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698