diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/basic/bug1013922.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/basic/bug1013922.js')
-rw-r--r-- | js/src/jit-test/tests/basic/bug1013922.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/bug1013922.js b/js/src/jit-test/tests/basic/bug1013922.js new file mode 100644 index 000000000..febe32ea5 --- /dev/null +++ b/js/src/jit-test/tests/basic/bug1013922.js @@ -0,0 +1,67 @@ +String.prototype.repeat = function(num) { + return new Array(num + 1).join(this); +} + +function set_to_length(length, frag_size) +{ + var fragment = "'" + "x".repeat(frag_size) + "' + "; + var frags = Math.floor((length - 1)/frag_size); + var code = "var x = " + fragment.repeat(frags) + "'" + + "x".repeat(length - frags * frag_size) + "';"; + + try { + eval(code); + } + catch(err) { + if (err.message && err.message == "Out of memory") + return -1; + if (err == "out of memory") + return -1; + throw(err); /* Oops, broke something. */ + } + + return code.length; +} + +var first_fail; +var first_pass; +var frag_size; +var pass_code_length; + +function search_up() +{ + if (set_to_length(first_fail, frag_size) < 0) { + setTimeout(binary_search, 0); + return; + } + + first_fail *= 2; +} + +function binary_search() +{ + if (first_fail - first_pass > 1) { + var length = (first_pass + first_fail) / 2; + var code_len = set_to_length(length, frag_size); + if (code_len > 0) { + first_pass = length; + pass_code_length = code_len; + } else + first_fail = length; + setTimeout(binary_search, 0); + return; + } +} + +function run_find_limit() +{ + frag_size = 64; + first_fail = 65536; /* A guess */ + first_pass = 0; + pass_code_length = 0; + + for (var i=0; i<5; i++) + search_up(0); +} + +run_find_limit(); |