tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

regress-324278.js (1702B)


      1 // |reftest| skip -- slow, obsoleted by 98409 fix
      2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 //-----------------------------------------------------------------------------
      8 var BUGNUMBER = 324278;
      9 var summary = 'GC without recursion';
     10 var actual = 'No Crash';
     11 var expect = 'No Crash';
     12 
     13 printBugNumber(BUGNUMBER);
     14 printStatus (summary);
     15 
     16 // Number to push native stack size beyond 10MB if GC recurses generating
     17 // segfault on Fedora Core / Ubuntu Linuxes where the stack size by default
     18 // is 10MB/8MB.
     19 var N = 100*1000;
     20 
     21 function build(N) {
     22  // Exploit the fact that (in ES3), regexp literals are shared between
     23  // function invocations. Thus we build the following chain:
     24  // chainTop: function->regexp->function->regexp....->null
     25  // to check how GC would deal with this chain.
     26 
     27  var chainTop = null;
     28  for (var i = 0; i != N; ++i) {
     29    var f = Function('some_arg'+i, ' return /test/;');
     30    var re = f();
     31    re.previous = chainTop;
     32    chainTop = f;
     33  }
     34  return chainTop;
     35 }
     36 
     37 function check(chainTop, N) {
     38  for (var i = 0; i != N; ++i) {
     39    var re = chainTop();
     40    chainTop = re.previous;
     41  }
     42  if (chainTop !== null)
     43    throw "Bad chainTop";
     44 
     45 }
     46 
     47 if (typeof gc != "function") {
     48  gc = function() {
     49    for (var i = 0; i != 50*1000; ++i) {
     50      var tmp = new Object();
     51    }
     52  }
     53 }
     54 
     55 var chainTop = build(N);
     56 printStatus("BUILT");
     57 gc();
     58 check(chainTop, N);
     59 printStatus("CHECKED");
     60 chainTop = null;
     61 gc();
     62 
     63 reportCompare(expect, actual, summary);