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

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

Issue 1317053006: Adding ElementsAccessor::Shift (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-09-01_array_builtin_cleanup
Patch Set: Only use range checks in builtins Created 5 years, 3 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') | 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 this.__sequence = this.__sequence + 1; 46 this.__sequence = this.__sequence + 1;
47 return "/* " + this.__sequence + " */ " + literal; 47 return "/* " + this.__sequence + " */ " + literal;
48 } 48 }
49 function make_array(literal) { 49 function make_array(literal) {
50 return eval(make_array_string(literal)); 50 return eval(make_array_string(literal));
51 } 51 }
52 52
53 // Push 53 // Push
54 var a0 = make_array("[1, 2, 3]"); 54 var a0 = make_array("[1, 2, 3]");
55 assertTrue(%HasFastSmiElements(a0)); 55 assertTrue(%HasFastSmiElements(a0));
56 a0.push(4); 56 assertEquals(4, a0.push(4));
57 assertTrue(%HasFastSmiElements(a0)); 57 assertTrue(%HasFastSmiElements(a0));
58 a0.push(1.3); 58 assertEquals(5, a0.push(1.3));
59 assertTrue(%HasFastDoubleElements(a0)); 59 assertTrue(%HasFastDoubleElements(a0));
60 a0.push(1.5); 60 assertEquals(6, a0.push(1.5));
61 assertTrue(%HasFastDoubleElements(a0)); 61 assertTrue(%HasFastDoubleElements(a0));
62 a0.push({}); 62 assertEquals(7, a0.push({}));
63 assertTrue(%HasFastObjectElements(a0)); 63 assertTrue(%HasFastObjectElements(a0));
64 a0.push({}); 64 assertEquals(8, a0.push({}));
65 assertTrue(%HasFastObjectElements(a0)); 65 assertTrue(%HasFastObjectElements(a0));
66 assertEquals([1,2,3,4,1.3,1.5,{},{}], a0); 66 assertEquals([1,2,3,4,1.3,1.5,{},{}], a0);
67 67
68 // Concat 68 // Concat
69 var a1; 69 var a1;
70 a1 = [1,2,3].concat([]); 70 a1 = [1,2,3].concat([]);
71 assertTrue(%HasFastSmiElements(a1)); 71 assertTrue(%HasFastSmiElements(a1));
72 assertEquals([1,2,3], a1); 72 assertEquals([1,2,3], a1);
73 a1 = [1,2,3].concat([4,5,6]); 73 a1 = [1,2,3].concat([4,5,6]);
74 assertTrue(%HasFastSmiElements(a1)); 74 assertTrue(%HasFastSmiElements(a1));
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 //assertTrue(%HasFastDoubleElements(a3r)); 246 //assertTrue(%HasFastDoubleElements(a3r));
247 a3r = a3.splice(1, 1, 4.4, 5.5); 247 a3r = a3.splice(1, 1, 4.4, 5.5);
248 //assertTrue(%HasFastDoubleElements(a3r)); 248 //assertTrue(%HasFastDoubleElements(a3r));
249 //assertTrue(%HasFastDoubleElements(a3)); 249 //assertTrue(%HasFastDoubleElements(a3));
250 assertEquals([2.2], a3r); 250 assertEquals([2.2], a3r);
251 assertEquals([1.1, 4.4, 5.5], a3); 251 assertEquals([1.1, 4.4, 5.5], a3);
252 252
253 // Pop 253 // Pop
254 var a4 = [1,2,3]; 254 var a4 = [1,2,3];
255 assertEquals(3, a4.pop()); 255 assertEquals(3, a4.pop());
256 assertTrue(%HasFastSmiElements(a4)); 256 assertEquals([1,2], a4);
257 //assertTrue(%HasFastSmiElements(a4));
257 a4 = [1.1,2,3]; 258 a4 = [1.1,2,3];
258 assertEquals(3, a4.pop()); 259 assertEquals(3, a4.pop());
259 assertTrue(%HasFastDoubleElements(a4)); 260 assertEquals([1.1,2], a4);
261 //assertTrue(%HasFastDoubleElements(a4));
260 a4 = [{},2,3]; 262 a4 = [{},2,3];
261 assertEquals(3, a4.pop()); 263 assertEquals(3, a4.pop());
262 assertTrue(%HasFastObjectElements(a4)); 264 assertEquals([{},2], a4);
265 //assertTrue(%HasFastObjectElements(a4));
263 266
264 // Shift 267 // Shift
265 var a4 = [1,2,3]; 268 var a4 = [1,2,3];
266 assertEquals(1, a4.shift()); 269 assertEquals(1, a4.shift());
267 assertTrue(%HasFastSmiElements(a4)); 270 assertEquals([2,3], a4);
271 //assertTrue(%HasFastSmiElements(a4));
268 a4 = [1.1,2,3]; 272 a4 = [1.1,2,3];
269 assertEquals(1.1, a4.shift()); 273 assertEquals(1.1, a4.shift());
270 assertTrue(%HasFastDoubleElements(a4)); 274 assertEquals([2,3], a4);
275 //assertTrue(%HasFastDoubleElements(a4));
271 a4 = [{},2,3]; 276 a4 = [{},2,3];
272 assertEquals({}, a4.shift()); 277 assertEquals({}, a4.shift());
273 assertTrue(%HasFastObjectElements(a4)); 278 assertEquals([2,3], a4);
279 //assertTrue(%HasFastObjectElements(a4));
274 280
275 // Unshift 281 // Unshift
276 var a4 = [1,2,3]; 282 var a4 = [1,2,3];
277 a4.unshift(1); 283 assertEquals(4, a4.unshift(1));
278 assertTrue(%HasFastSmiElements(a4)); 284 assertTrue(%HasFastSmiElements(a4));
279 assertEquals([1,1,2,3], a4); 285 assertEquals([1,1,2,3], a4);
280 a4 = [1,2,3]; 286 a4 = [1,2,3];
281 a4.unshift(1.1); 287 assertEquals(4, a4.unshift(1.1));
282 assertTrue(%HasFastDoubleElements(a4)); 288 assertTrue(%HasFastDoubleElements(a4));
283 assertEquals([1.1,1,2,3], a4); 289 assertEquals([1.1,1,2,3], a4);
284 a4 = [1.1,2,3]; 290 a4 = [1.1,2,3];
285 a4.unshift(1); 291 assertEquals(4, a4.unshift(1));
286 assertTrue(%HasFastDoubleElements(a4)); 292 assertTrue(%HasFastDoubleElements(a4));
287 assertEquals([1,1.1,2,3], a4); 293 assertEquals([1,1.1,2,3], a4);
288 a4 = [{},2,3]; 294 a4 = [{},2,3];
289 a4.unshift(1); 295 assertEquals(4, a4.unshift(1));
290 assertTrue(%HasFastObjectElements(a4)); 296 assertTrue(%HasFastObjectElements(a4));
291 assertEquals([1,{},2,3], a4); 297 assertEquals([1,{},2,3], a4);
292 a4 = [{},2,3]; 298 a4 = [{},2,3];
293 a4.unshift(1.1); 299 assertEquals(4, a4.unshift(1.1));
294 assertTrue(%HasFastObjectElements(a4)); 300 assertTrue(%HasFastObjectElements(a4));
295 assertEquals([1.1,{},2,3], a4); 301 assertEquals([1.1,{},2,3], a4);
296 } 302 }
297 303
298 for (var i = 0; i < 3; i++) { 304 for (var i = 0; i < 3; i++) {
299 array_natives_test(); 305 array_natives_test();
300 } 306 }
301 %OptimizeFunctionOnNextCall(array_natives_test); 307 %OptimizeFunctionOnNextCall(array_natives_test);
302 array_natives_test(); 308 array_natives_test();
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698