michael@0: // |reftest| skip -- slow, obsoleted by 98409 fix michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 324278; michael@0: var summary = 'GC without recursion'; michael@0: var actual = 'No Crash'; michael@0: var expect = 'No Crash'; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: // Number to push native stack size beyond 10MB if GC recurses generating michael@0: // segfault on Fedora Core / Ubuntu Linuxes where the stack size by default michael@0: // is 10MB/8MB. michael@0: var N = 100*1000; michael@0: michael@0: function build(N) { michael@0: // Exploit the fact that (in ES3), regexp literals are shared between michael@0: // function invocations. Thus we build the following chain: michael@0: // chainTop: function->regexp->function->regexp....->null michael@0: // to check how GC would deal with this chain. michael@0: michael@0: var chainTop = null; michael@0: for (var i = 0; i != N; ++i) { michael@0: var f = Function('some_arg'+i, ' return /test/;'); michael@0: var re = f(); michael@0: re.previous = chainTop; michael@0: chainTop = f; michael@0: } michael@0: return chainTop; michael@0: } michael@0: michael@0: function check(chainTop, N) { michael@0: for (var i = 0; i != N; ++i) { michael@0: var re = chainTop(); michael@0: chainTop = re.previous; michael@0: } michael@0: if (chainTop !== null) michael@0: throw "Bad chainTop"; michael@0: michael@0: } michael@0: michael@0: if (typeof gc != "function") { michael@0: gc = function() { michael@0: for (var i = 0; i != 50*1000; ++i) { michael@0: var tmp = new Object(); michael@0: } michael@0: } michael@0: } michael@0: michael@0: var chainTop = build(N); michael@0: printStatus("BUILT"); michael@0: gc(); michael@0: check(chainTop, N); michael@0: printStatus("CHECKED"); michael@0: chainTop = null; michael@0: gc(); michael@0: michael@0: reportCompare(expect, actual, summary);