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.

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

mercurial