regress-383269-02.js (1531B)
1 // |reftest| random -- unreliable - based on GC timing 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 = 383269; 9 var summary = 'Leak related to arguments object'; 10 var actual = 'No Leak'; 11 var expect = 'No Leak'; 12 13 14 //----------------------------------------------------------------------------- 15 test(); 16 //----------------------------------------------------------------------------- 17 18 function test() 19 { 20 printBugNumber(BUGNUMBER); 21 printStatus (summary); 22 23 function generate_big_object_graph() 24 { 25 var root = {}; 26 f(root, 17); 27 return root; 28 function f(parent, depth) { 29 if (depth == 0) 30 return; 31 --depth; 32 f(parent.a = {}, depth); 33 f(parent.b = {}, depth); 34 } 35 } 36 37 function f(obj) { 38 with (obj) 39 return arguments; 40 } 41 42 function timed_gc() 43 { 44 var t1 = Date.now(); 45 gc(); 46 return Date.now() - t1; 47 } 48 49 var x = f({}); 50 x = null; 51 gc(); 52 var base_time = timed_gc(); 53 54 x = f(generate_big_object_graph()); 55 x = null; 56 gc(); 57 var time = timed_gc(); 58 59 if (time > (base_time + 10) * 3) 60 actual = "generate_big_object_graph() leaked, base_gc_time="+base_time+", last_gc_time="+time; 61 62 reportCompare(expect, actual, summary); 63 }