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

Side by Side Diff: test/mjsunit/array-natives-elements.js

Issue 1315823004: Revert of Moving ArraySplice Builtin to ElementsAccessor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « src/elements.cc ('k') | test/mjsunit/array-splice.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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --allow-natives-syntax 28 // Flags: --allow-natives-syntax
29 29
30 // IC and Crankshaft support for smi-only elements in dynamic array literals. 30 // IC and Crankshaft support for smi-only elements in dynamic array literals.
31 function get(foo) { return foo; } // Used to generate dynamic values. 31 function get(foo) { return foo; } // Used to generate dynamic values.
32 32
33 function array_natives_test(optimized) { 33 function array_natives_test() {
34 34
35 // Ensure small array literals start in specific element kind mode. 35 // Ensure small array literals start in specific element kind mode.
36 assertTrue(%HasFastSmiElements([])); 36 assertTrue(%HasFastSmiElements([]));
37 assertTrue(%HasFastSmiElements([1])); 37 assertTrue(%HasFastSmiElements([1]));
38 assertTrue(%HasFastSmiElements([1,2])); 38 assertTrue(%HasFastSmiElements([1,2]));
39 assertTrue(%HasFastDoubleElements([1.1])); 39 assertTrue(%HasFastDoubleElements([1.1]));
40 assertTrue(%HasFastDoubleElements([1.1,2])); 40 assertTrue(%HasFastDoubleElements([1.1,2]));
41 41
42 // This code exists to eliminate the learning influence of AllocationSites 42 // This code exists to eliminate the learning influence of AllocationSites
43 // on the following tests. 43 // on the following tests.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 assertTrue(%HasFastSmiElements(a3r)); 144 assertTrue(%HasFastSmiElements(a3r));
145 assertTrue(%HasFastSmiElements(a3)); 145 assertTrue(%HasFastSmiElements(a3));
146 assertEquals([], a3r); 146 assertEquals([], a3r);
147 assertEquals([2, 1, 2, 3], a3); 147 assertEquals([2, 1, 2, 3], a3);
148 a3 = [1,2,3]; 148 a3 = [1,2,3];
149 a3r = a3.splice(0, 1, 2); 149 a3r = a3.splice(0, 1, 2);
150 assertTrue(%HasFastSmiElements(a3r)); 150 assertTrue(%HasFastSmiElements(a3r));
151 assertTrue(%HasFastSmiElements(a3)); 151 assertTrue(%HasFastSmiElements(a3));
152 assertEquals([1], a3r); 152 assertEquals([1], a3r);
153 assertEquals([2, 2, 3], a3); 153 assertEquals([2, 2, 3], a3);
154
154 a3 = [1.1,2,3]; 155 a3 = [1.1,2,3];
155 a3r = a3.splice(0, 0); 156 a3r = a3.splice(0, 0);
156 assertTrue(%HasFastDoubleElements(a3r)); 157 assertTrue(%HasFastDoubleElements(a3r));
157 assertTrue(%HasFastDoubleElements(a3)); 158 assertTrue(%HasFastDoubleElements(a3));
158 assertEquals([], a3r); 159 assertEquals([], a3r);
159 assertEquals([1.1, 2, 3], a3); 160 assertEquals([1.1, 2, 3], a3);
160 a3 = [1.1,2,3]; 161 a3 = [1.1,2,3];
161 a3r = a3.splice(0, 1); 162 a3r = a3.splice(0, 1);
162 assertTrue(%HasFastDoubleElements(a3r)); 163 assertTrue(%HasFastDoubleElements(a3r));
163 assertTrue(%HasFastDoubleElements(a3)); 164 assertTrue(%HasFastDoubleElements(a3));
164 assertEquals([1.1], a3r); 165 assertEquals([1.1], a3r);
165 assertEquals([2, 3], a3); 166 assertEquals([2, 3], a3);
166 a3 = [1.1,2,3]; 167 a3 = [1.1,2,3];
167 a3r = a3.splice(0, 0, 2); 168 a3r = a3.splice(0, 0, 2);
168 assertTrue(%HasFastDoubleElements(a3r)); 169 // Commented out since handled in js, which takes the best fit.
170 // assertTrue(%HasFastDoubleElements(a3r));
171 assertTrue(%HasFastSmiElements(a3r));
169 assertTrue(%HasFastDoubleElements(a3)); 172 assertTrue(%HasFastDoubleElements(a3));
170 assertEquals([], a3r); 173 assertEquals([], a3r);
171 assertEquals([2, 1.1, 2, 3], a3); 174 assertEquals([2, 1.1, 2, 3], a3);
172 a3 = [1.1,2,3]; 175 a3 = [1.1,2,3];
173 assertTrue(%HasFastDoubleElements(a3));
174 a3r = a3.splice(0, 1, 2); 176 a3r = a3.splice(0, 1, 2);
175 assertTrue(%HasFastDoubleElements(a3r)); 177 assertTrue(%HasFastDoubleElements(a3r));
176 assertTrue(%HasFastDoubleElements(a3)); 178 assertTrue(%HasFastDoubleElements(a3));
177 assertEquals([1.1], a3r); 179 assertEquals([1.1], a3r);
178 assertEquals([2, 2, 3], a3); 180 assertEquals([2, 2, 3], a3);
179 a3 = [1.1,2,3]; 181 a3 = [1.1,2,3];
180 a3r = a3.splice(0, 0, 2.1); 182 a3r = a3.splice(0, 0, 2.1);
181 assertTrue(%HasFastDoubleElements(a3r)); 183 // Commented out since handled in js, which takes the best fit.
184 // assertTrue(%HasFastDoubleElements(a3r));
185 assertTrue(%HasFastSmiElements(a3r));
182 assertTrue(%HasFastDoubleElements(a3)); 186 assertTrue(%HasFastDoubleElements(a3));
183 assertEquals([], a3r); 187 assertEquals([], a3r);
184 assertEquals([2.1, 1.1, 2, 3], a3); 188 assertEquals([2.1, 1.1, 2, 3], a3);
185 a3 = [1.1,2,3]; 189 a3 = [1.1,2,3];
186 a3r = a3.splice(0, 1, 2.2); 190 a3r = a3.splice(0, 1, 2.2);
187 assertTrue(%HasFastDoubleElements(a3r)); 191 assertTrue(%HasFastDoubleElements(a3r));
188 assertTrue(%HasFastDoubleElements(a3)); 192 assertTrue(%HasFastDoubleElements(a3));
189 assertEquals([1.1], a3r); 193 assertEquals([1.1], a3r);
190 assertEquals([2.2, 2, 3], a3); 194 assertEquals([2.2, 2, 3], a3);
191 a3 = [1,2,3]; 195 a3 = [1,2,3];
192 a3r = a3.splice(0, 0, 2.1); 196 a3r = a3.splice(0, 0, 2.1);
193 assertTrue(%HasFastDoubleElements(a3r)); 197 // Commented out since handled in js, which takes the best fit.
198 // assertTrue(%HasFastDoubleElements(a3r));
199 assertTrue(%HasFastSmiElements(a3r));
194 assertTrue(%HasFastDoubleElements(a3)); 200 assertTrue(%HasFastDoubleElements(a3));
195 assertEquals([], a3r); 201 assertEquals([], a3r);
196 assertEquals([2.1, 1, 2, 3], a3); 202 assertEquals([2.1, 1, 2, 3], a3);
197 a3 = [1,2,3]; 203 a3 = [1,2,3];
198 a3r = a3.splice(0, 1, 2.2); 204 a3r = a3.splice(0, 1, 2.2);
199 assertTrue(%HasFastDoubleElements(a3r)); 205 assertTrue(%HasFastDoubleElements(a3r));
200 assertTrue(%HasFastDoubleElements(a3)); 206 assertTrue(%HasFastDoubleElements(a3));
201 assertEquals([1], a3r); 207 assertEquals([1], a3r);
202 assertEquals([2.2, 2, 3], a3); 208 assertEquals([2.2, 2, 3], a3);
209
203 a3 = [{},2,3]; 210 a3 = [{},2,3];
204 a3r = a3.splice(0, 0); 211 a3r = a3.splice(0, 0);
205 assertTrue(%HasFastObjectElements(a3r)); 212 assertTrue(%HasFastObjectElements(a3r));
206 assertTrue(%HasFastObjectElements(a3)); 213 assertTrue(%HasFastObjectElements(a3));
207 assertEquals([], a3r); 214 assertEquals([], a3r);
208 assertEquals([{}, 2, 3], a3); 215 assertEquals([{}, 2, 3], a3);
209 a3 = [1,2,{}]; 216 a3 = [1,2,{}];
210 a3r = a3.splice(0, 1); 217 a3r = a3.splice(0, 1);
211 assertTrue(%HasFastObjectElements(a3r)); 218 assertTrue(%HasFastObjectElements(a3r));
212 assertTrue(%HasFastObjectElements(a3)); 219 assertTrue(%HasFastObjectElements(a3));
213 assertEquals([1], a3r); 220 assertEquals([1], a3r);
214 assertEquals([2, {}], a3); 221 assertEquals([2, {}], a3);
215 a3 = [1,2,3]; 222 a3 = [1,2,3];
216 a3r = a3.splice(0, 0, {}); 223 a3r = a3.splice(0, 0, {});
217 assertTrue(%HasFastObjectElements(a3r)); 224 assertTrue(%HasFastObjectElements(a3r));
218 assertTrue(%HasFastObjectElements(a3)); 225 assertTrue(%HasFastObjectElements(a3));
219 assertEquals([], a3r); 226 assertEquals([], a3r);
220 assertEquals([{}, 1, 2, 3], a3); 227 assertEquals([{}, 1, 2, 3], a3);
221 a3 = [1,2,3]; 228 a3 = [1,2,3];
222 a3r = a3.splice(0, 1, {}); 229 a3r = a3.splice(0, 1, {});
223 assertTrue(%HasFastObjectElements(a3r)); 230 assertTrue(%HasFastObjectElements(a3r));
224 assertTrue(%HasFastObjectElements(a3)); 231 assertTrue(%HasFastObjectElements(a3));
225 assertEquals([1], a3r); 232 assertEquals([1], a3r);
226 assertEquals([{}, 2, 3], a3); 233 assertEquals([{}, 2, 3], a3);
234
227 a3 = [1.1,2,3]; 235 a3 = [1.1,2,3];
228 a3r = a3.splice(0, 0, {}); 236 a3r = a3.splice(0, 0, {});
229 assertTrue(%HasFastObjectElements(a3r)); 237 assertTrue(%HasFastObjectElements(a3r));
230 assertTrue(%HasFastObjectElements(a3)); 238 assertTrue(%HasFastObjectElements(a3));
231 assertEquals([], a3r); 239 assertEquals([], a3r);
232 assertEquals([{}, 1.1, 2, 3], a3); 240 assertEquals([{}, 1.1, 2, 3], a3);
233 a3 = [1.1,2,3]; 241 a3 = [1.1,2,3];
234 a3r = a3.splice(0, 1, {}); 242 a3r = a3.splice(0, 1, {});
235 assertTrue(%HasFastObjectElements(a3r)); 243 assertTrue(%HasFastObjectElements(a3r));
236 assertTrue(%HasFastObjectElements(a3)); 244 assertTrue(%HasFastObjectElements(a3));
237 assertEquals([1.1], a3r); 245 assertEquals([1.1], a3r);
238 assertEquals([{}, 2, 3], a3); 246 assertEquals([{}, 2, 3], a3);
239 a3 = [1.1, 2.2, 3.3];
240 a3r = a3.splice(2, 1);
241 assertTrue(%HasFastDoubleElements(a3r));
242 assertTrue(%HasFastDoubleElements(a3));
243 assertEquals([3.3], a3r);
244 //assertTrue(%HasFastDoubleElements(a3r));
245 assertEquals([1.1, 2.2], a3);
246 //assertTrue(%HasFastDoubleElements(a3r));
247 a3r = a3.splice(1, 1, 4.4, 5.5);
248 //assertTrue(%HasFastDoubleElements(a3r));
249 //assertTrue(%HasFastDoubleElements(a3));
250 assertEquals([2.2], a3r);
251 assertEquals([1.1, 4.4, 5.5], a3);
252 247
253 // Pop 248 // Pop
254 var a4 = [1,2,3]; 249 var a4 = [1,2,3];
255 assertEquals(3, a4.pop()); 250 assertEquals(3, a4.pop());
256 assertTrue(%HasFastSmiElements(a4)); 251 assertTrue(%HasFastSmiElements(a4));
257 a4 = [1.1,2,3]; 252 a4 = [1.1,2,3];
258 assertEquals(3, a4.pop()); 253 assertEquals(3, a4.pop());
259 assertTrue(%HasFastDoubleElements(a4)); 254 assertTrue(%HasFastDoubleElements(a4));
260 a4 = [{},2,3]; 255 a4 = [{},2,3];
261 assertEquals(3, a4.pop()); 256 assertEquals(3, a4.pop());
(...skipping 27 matching lines...) Expand all
289 a4.unshift(1); 284 a4.unshift(1);
290 assertTrue(%HasFastObjectElements(a4)); 285 assertTrue(%HasFastObjectElements(a4));
291 assertEquals([1,{},2,3], a4); 286 assertEquals([1,{},2,3], a4);
292 a4 = [{},2,3]; 287 a4 = [{},2,3];
293 a4.unshift(1.1); 288 a4.unshift(1.1);
294 assertTrue(%HasFastObjectElements(a4)); 289 assertTrue(%HasFastObjectElements(a4));
295 assertEquals([1.1,{},2,3], a4); 290 assertEquals([1.1,{},2,3], a4);
296 } 291 }
297 292
298 for (var i = 0; i < 3; i++) { 293 for (var i = 0; i < 3; i++) {
299 array_natives_test(false); 294 array_natives_test();
300 } 295 }
301 %OptimizeFunctionOnNextCall(array_natives_test); 296 %OptimizeFunctionOnNextCall(array_natives_test);
302 array_natives_test(true); 297 array_natives_test();
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | test/mjsunit/array-splice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698