js/src/jit-test/tests/basic/bug972961.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 // Bug 972961 - Test compiler with very long chains of property accesses
     3 // Return true if we can compile a chain of n property accesses,
     4 // false if we cannot. Throw if compilation fails in an unexpected way.
     5 function test(n) {
     6     print("testing " + n);
     7     try {
     8         eval('if (false) {' + Array(n).join(("a.")) + 'a}');
     9     } catch (exc) {
    10         // Expected outcome if the expression is too deeply nested is an InternalError.
    11         if (!(exc instanceof InternalError))
    12             throw exc;
    13         print(exc.message);
    14         return false;
    15     }
    16     print("no exception");
    17     return true;
    18 }
    20 // Find out how long a chain is enough to break the compiler.
    21 var n = 4, LIMIT = 0x000fffff;
    22 var lo = 1, hi = 1;
    23 while (n <= LIMIT && test(n)) {
    24     lo = n;
    25     n *= 4;
    26 }
    28 // Using binary search, find a pass/fail boundary (in order to
    29 // test the edge case).
    30 if (n <= LIMIT) {
    31     hi = n;
    32     while (lo !== hi) {
    33         var mid = Math.floor((lo + hi) / 2);
    34         if (test(mid))
    35             lo = mid + 1;
    36         else
    37             hi = mid;
    38     }
    39     print((lo - 1) + " attributes should be enough for anyone");
    40 }

mercurial