js/src/jit-test/tests/ion/entryOverflowBailout.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 var o;
michael@0 2 var f1;
michael@0 3 var counter = 0;
michael@0 4
michael@0 5 function f2(a) {
michael@0 6 bailout();
michael@0 7 return f2.arguments;
michael@0 8 };
michael@0 9
michael@0 10 var restartCode = "counter = 0; " + f2.toSource();
michael@0 11
michael@0 12 // We need to reevaluate this function everytime, otherwise it is flagged as
michael@0 13 // having an argument object and it would not be re-entered.
michael@0 14
michael@0 15 // This test case is checking that f.arguments reflects the overflow or the
michael@0 16 // underflow of arguments after a bailout. Due to the way bailouts are
michael@0 17 // recovered we need to check for the intial frame and for any other JS frame
michael@0 18 // below.
michael@0 19 //
michael@0 20 // To produce a JSFrame, we need to avoid the 'Hot' counters of f1 to be the
michael@0 21 // same as f2, because IonMonkey will try to inline f2 in f1, and not
michael@0 22 // compiling/calling f2 separately. This explain why we ignore the 5 first call
michael@0 23 // of f1 by returning immediately.
michael@0 24 //
michael@0 25 // Bailouts are caused by calling an object function, which is expected to be a
michael@0 26 // function by IonMonkey. So bailout() cause a bailout in the currently
michael@0 27 // compiled function.
michael@0 28 //
michael@0 29 // To avoid any preventive effect to re-enter f2, we re-evaluate it before every
michael@0 30 // test.
michael@0 31
michael@0 32 // Check bailouts of the initial frame.
michael@0 33
michael@0 34 eval(restartCode);
michael@0 35 while (counter++ < 50) {
michael@0 36 o = f2();
michael@0 37 assertEq(o.length, 0);
michael@0 38 }
michael@0 39
michael@0 40 eval(restartCode);
michael@0 41 while (counter++ < 50) {
michael@0 42 o = f2(21);
michael@0 43 assertEq(o.length, 1);
michael@0 44 assertEq(o[0], 21);
michael@0 45 }
michael@0 46
michael@0 47 eval(restartCode);
michael@0 48 while (counter++ < 50) {
michael@0 49 o = f2(21,42);
michael@0 50 assertEq(o.length, 2);
michael@0 51 assertEq(o[0], 21);
michael@0 52 assertEq(o[1], 42);
michael@0 53 }
michael@0 54
michael@0 55 // 100 arguments.
michael@0 56 eval(restartCode);
michael@0 57 while (counter++ < 50) {
michael@0 58 o = f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 59 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 60 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 61 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 62 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
michael@0 63 assertEq(o.length, 100);
michael@0 64 for (var i in o)
michael@0 65 assertEq(o[i], i % 10);
michael@0 66 }
michael@0 67
michael@0 68 // 200 arguments.
michael@0 69 eval(restartCode);
michael@0 70 while (counter++ < 50) {
michael@0 71 o = f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 72 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 73 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 74 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 75 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 76
michael@0 77 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 78 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 79 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 80 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 81 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
michael@0 82 assertEq(o.length, 200);
michael@0 83 for (var i in o)
michael@0 84 assertEq(o[i], i % 10);
michael@0 85 }
michael@0 86
michael@0 87 // 300 arguments.
michael@0 88 eval(restartCode);
michael@0 89 while (counter++ < 50) {
michael@0 90 o = f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 91 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 92 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 93 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 94 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 95
michael@0 96 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 97 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 98 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 99 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 100 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 101
michael@0 102 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 103 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 104 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 105 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 106 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
michael@0 107 assertEq(o.length, 300);
michael@0 108 for (var i in o)
michael@0 109 assertEq(o[i], i % 10);
michael@0 110 }
michael@0 111
michael@0 112 // Check bailouts of one frame which is not the initial frame.
michael@0 113
michael@0 114 eval(restartCode);
michael@0 115 f1 = function() {
michael@0 116 if (counter < 5) return 0;
michael@0 117 return f2();
michael@0 118 };
michael@0 119 while (counter++ < 50) {
michael@0 120 o = f1();
michael@0 121 if (counter < 5) continue;
michael@0 122 assertEq(o.length, 0);
michael@0 123 }
michael@0 124
michael@0 125 eval(restartCode);
michael@0 126 f1 = function() {
michael@0 127 if (counter < 5) return 0;
michael@0 128 return f2(21);
michael@0 129 };
michael@0 130 while (counter++ < 50) {
michael@0 131 o = f1();
michael@0 132 if (counter < 5) continue;
michael@0 133 assertEq(o.length, 1);
michael@0 134 assertEq(o[0], 21);
michael@0 135 }
michael@0 136
michael@0 137 eval(restartCode);
michael@0 138 f1 = function() {
michael@0 139 if (counter < 5) return 0;
michael@0 140 return f2(21,42);
michael@0 141 };
michael@0 142 while (counter++ < 50) {
michael@0 143 o = f1();
michael@0 144 if (counter < 5) continue;
michael@0 145 assertEq(o.length, 2);
michael@0 146 assertEq(o[0], 21);
michael@0 147 assertEq(o[1], 42);
michael@0 148 }
michael@0 149
michael@0 150 // 100 arguments.
michael@0 151 eval(restartCode);
michael@0 152 f1 = function() {
michael@0 153 if (counter < 5) return 0;
michael@0 154 return f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 155 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 156 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 157 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 158 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
michael@0 159 };
michael@0 160 while (counter++ < 50) {
michael@0 161 o = f1();
michael@0 162 if (counter < 5) continue;
michael@0 163 assertEq(o.length, 100);
michael@0 164 for (var i in o)
michael@0 165 assertEq(o[i], i % 10);
michael@0 166 }
michael@0 167
michael@0 168 // 200 arguments.
michael@0 169 eval(restartCode);
michael@0 170 f1 = function() {
michael@0 171 if (counter < 5) return 0;
michael@0 172 return f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 173 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 174 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 175 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 176 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 177
michael@0 178 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 179 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 180 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 181 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 182 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
michael@0 183 };
michael@0 184 while (counter++ < 50) {
michael@0 185 o = f1();
michael@0 186 if (counter < 5) continue;
michael@0 187 assertEq(o.length, 200);
michael@0 188 for (var i in o)
michael@0 189 assertEq(o[i], i % 10);
michael@0 190 }
michael@0 191
michael@0 192 // 300 arguments.
michael@0 193 eval(restartCode);
michael@0 194 f1 = function() {
michael@0 195 if (counter < 5) return 0;
michael@0 196 return f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 197 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 198 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 199 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 200 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 201
michael@0 202 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 203 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 204 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 205 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 206 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 207
michael@0 208 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 209 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 210 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 211 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
michael@0 212 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
michael@0 213 };
michael@0 214 while (counter++ < 500) {
michael@0 215 o = f1();
michael@0 216 if (counter < 5) continue;
michael@0 217 assertEq(o.length, 300);
michael@0 218 for (var i in o)
michael@0 219 assertEq(o[i], i % 10);
michael@0 220 }

mercurial