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