Debian Codegraph @

js/src/tests/shell/gcstats.js

raw
1 // |reftest| skip-if(!xulRuntime.shell)
2 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /*
4 * Any copyright is dedicated to the Public Domain.
5 * http://creativecommons.org/licenses/publicdomain/
6 */
7
8 function garbage() {
9 var x;
10 for (var i = 0; i < 100000; i++)
11 x = { 'i': i };
12 }
13
14 setGCCallback({
15 action: "majorGC",
16 depth: 1,
17 phases: "both"
18 });
19
20 gc();
21 garbage();
22
23 setGCCallback({
24 action: "majorGC",
25 depth: 2,
26 phases: "both"
27 });
28
29 gc();
30 garbage();
31
32 setGCCallback({
33 action: "majorGC",
34 depth: 8,
35 phases: "begin"
36 });
37
38 gc();
39 garbage();
40
41 setGCCallback({
42 action: "minorGC",
43 phases: "both"
44 });
45
46 gc();
47 garbage();
48
49 var caught = false;
50 try {
51 setGCCallback({
52 action: "majorGC",
53 depth: 10000,
54 phases: "begin"
55 });
56 } catch (e) {
57 caught = ((""+e).indexOf("Nesting depth too large") >= 0);
58 }
59
60 reportCompare(caught, true);