testChangingObjectWithLength.js (925B)
1 function testChangingObjectWithLength() 2 { 3 var obj = { length: 10 }; 4 var dense = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; 5 var slow = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; slow.slow = 5; 6 7 /* 8 * The elements of objs constitute a De Bruijn sequence repeated 4x to trace 9 * and run native code for every object and transition. 10 */ 11 var objs = [obj, obj, obj, obj, 12 obj, obj, obj, obj, 13 dense, dense, dense, dense, 14 obj, obj, obj, obj, 15 slow, slow, slow, slow, 16 dense, dense, dense, dense, 17 dense, dense, dense, dense, 18 slow, slow, slow, slow, 19 slow, slow, slow, slow, 20 obj, obj, obj, obj]; 21 22 var counter = 0; 23 24 for (var i = 0, sz = objs.length; i < sz; i++) 25 { 26 var o = objs[i]; 27 for (var j = 0; j < o.length; j++) 28 counter++; 29 } 30 31 return counter; 32 } 33 assertEq(testChangingObjectWithLength(), 400);