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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/ion/entryOverflowBailout.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,220 @@
     1.4 +var o;
     1.5 +var f1;
     1.6 +var counter = 0;
     1.7 +
     1.8 +function f2(a) {
     1.9 +    bailout();
    1.10 +    return f2.arguments;
    1.11 +};
    1.12 +
    1.13 +var restartCode = "counter = 0; " + f2.toSource();
    1.14 +
    1.15 +// We need to reevaluate this function everytime, otherwise it is flagged as
    1.16 +// having an argument object and it would not be re-entered.
    1.17 +
    1.18 +// This test case is checking that f.arguments reflects the overflow or the
    1.19 +// underflow of arguments after a bailout.  Due to the way bailouts are
    1.20 +// recovered we need to check for the intial frame and for any other JS frame
    1.21 +// below.
    1.22 +//
    1.23 +// To produce a JSFrame, we need to avoid the 'Hot' counters of f1 to be the
    1.24 +// same as f2, because IonMonkey will try to inline f2 in f1, and not
    1.25 +// compiling/calling f2 separately. This explain why we ignore the 5 first call
    1.26 +// of f1 by returning immediately.
    1.27 +//
    1.28 +// Bailouts are caused by calling an object function, which is expected to be a
    1.29 +// function by IonMonkey.  So bailout() cause a bailout in the currently
    1.30 +// compiled function.
    1.31 +//
    1.32 +// To avoid any preventive effect to re-enter f2, we re-evaluate it before every
    1.33 +// test.
    1.34 +
    1.35 +// Check bailouts of the initial frame.
    1.36 +
    1.37 +eval(restartCode);
    1.38 +while (counter++ < 50) {
    1.39 +    o = f2();
    1.40 +    assertEq(o.length, 0);
    1.41 +}
    1.42 +
    1.43 +eval(restartCode);
    1.44 +while (counter++ < 50) {
    1.45 +    o = f2(21);
    1.46 +    assertEq(o.length, 1);
    1.47 +    assertEq(o[0], 21);
    1.48 +}
    1.49 +
    1.50 +eval(restartCode);
    1.51 +while (counter++ < 50) {
    1.52 +    o = f2(21,42);
    1.53 +    assertEq(o.length, 2);
    1.54 +    assertEq(o[0], 21);
    1.55 +    assertEq(o[1], 42);
    1.56 +}
    1.57 +
    1.58 +// 100 arguments.
    1.59 +eval(restartCode);
    1.60 +while (counter++ < 50) {
    1.61 +    o = f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.62 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.63 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.64 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.65 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
    1.66 +    assertEq(o.length, 100);
    1.67 +    for (var i in o)
    1.68 +        assertEq(o[i], i % 10);
    1.69 +}
    1.70 +
    1.71 +// 200 arguments.
    1.72 +eval(restartCode);
    1.73 +while (counter++ < 50) {
    1.74 +    o = f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.75 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.76 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.77 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.78 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.79 +
    1.80 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.81 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.82 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.83 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.84 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
    1.85 +    assertEq(o.length, 200);
    1.86 +    for (var i in o)
    1.87 +        assertEq(o[i], i % 10);
    1.88 +}
    1.89 +
    1.90 +// 300 arguments.
    1.91 +eval(restartCode);
    1.92 +while (counter++ < 50) {
    1.93 +    o = f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.94 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.95 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.96 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.97 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
    1.98 +
    1.99 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.100 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.101 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.102 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.103 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.104 +
   1.105 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.106 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.107 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.108 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.109 +           0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
   1.110 +    assertEq(o.length, 300);
   1.111 +    for (var i in o)
   1.112 +        assertEq(o[i], i % 10);
   1.113 +}
   1.114 +
   1.115 +// Check bailouts of one frame which is not the initial frame.
   1.116 +
   1.117 +eval(restartCode);
   1.118 +f1 = function() {
   1.119 +    if (counter < 5) return 0;
   1.120 +    return f2();
   1.121 +};
   1.122 +while (counter++ < 50) {
   1.123 +    o = f1();
   1.124 +    if (counter < 5) continue;
   1.125 +    assertEq(o.length, 0);
   1.126 +}
   1.127 +
   1.128 +eval(restartCode);
   1.129 +f1 = function() {
   1.130 +    if (counter < 5) return 0;
   1.131 +    return f2(21);
   1.132 +};
   1.133 +while (counter++ < 50) {
   1.134 +    o = f1();
   1.135 +    if (counter < 5) continue;
   1.136 +    assertEq(o.length, 1);
   1.137 +    assertEq(o[0], 21);
   1.138 +}
   1.139 +
   1.140 +eval(restartCode);
   1.141 +f1 = function() {
   1.142 +    if (counter < 5) return 0;
   1.143 +    return f2(21,42);
   1.144 +};
   1.145 +while (counter++ < 50) {
   1.146 +    o = f1();
   1.147 +    if (counter < 5) continue;
   1.148 +    assertEq(o.length, 2);
   1.149 +    assertEq(o[0], 21);
   1.150 +    assertEq(o[1], 42);
   1.151 +}
   1.152 +
   1.153 +// 100 arguments.
   1.154 +eval(restartCode);
   1.155 +f1 = function() {
   1.156 +    if (counter < 5) return 0;
   1.157 +    return f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.158 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.159 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.160 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.161 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
   1.162 +};
   1.163 +while (counter++ < 50) {
   1.164 +    o = f1();
   1.165 +    if (counter < 5) continue;
   1.166 +    assertEq(o.length, 100);
   1.167 +    for (var i in o)
   1.168 +        assertEq(o[i], i % 10);
   1.169 +}
   1.170 +
   1.171 +// 200 arguments.
   1.172 +eval(restartCode);
   1.173 +f1 = function() {
   1.174 +    if (counter < 5) return 0;
   1.175 +    return f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.176 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.177 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.178 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.179 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.180 +
   1.181 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.182 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.183 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.184 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.185 +              0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
   1.186 +};
   1.187 +while (counter++ < 50) {
   1.188 +    o = f1();
   1.189 +    if (counter < 5) continue;
   1.190 +    assertEq(o.length, 200);
   1.191 +    for (var i in o)
   1.192 +        assertEq(o[i], i % 10);
   1.193 +}
   1.194 +
   1.195 +// 300 arguments.
   1.196 +eval(restartCode);
   1.197 +f1 = function() {
   1.198 +  if (counter < 5) return 0;
   1.199 +  return f2(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.200 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.201 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.202 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.203 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.204 +
   1.205 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.206 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.207 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.208 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.209 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.210 +
   1.211 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.212 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.213 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.214 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
   1.215 +            0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9);
   1.216 +};
   1.217 +while (counter++ < 500) {
   1.218 +    o = f1();
   1.219 +    if (counter < 5) continue;
   1.220 +    assertEq(o.length, 300);
   1.221 +    for (var i in o)
   1.222 +        assertEq(o[i], i % 10);
   1.223 +}

mercurial