summaryrefslogtreecommitdiffstats
path: root/js/src/tests/shell/gcstats.js
blob: 6343b56bbeb87866ca848d6332fad018998c1ed3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// |reftest| skip-if(!xulRuntime.shell)
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 */

function garbage() {
  var x;
  for (var i = 0; i < 100000; i++)
    x = { 'i': i };
}

setGCCallback({
  action: "majorGC",
  depth: 1,
  phases: "both"
});

gc();
garbage();

setGCCallback({
  action: "majorGC",
  depth: 2,
  phases: "both"
});

gc();
garbage();

setGCCallback({
  action: "majorGC",
  depth: 10,
  phases: "begin"
});

gc();
garbage();

setGCCallback({
  action: "minorGC",
  phases: "both"
});

gc();
garbage();

var caught = false;
try {
  setGCCallback({
    action: "majorGC",
    depth: 10000,
    phases: "begin"
  });
} catch (e) {
  caught = ((""+e).indexOf("Nesting depth too large") >= 0);
}

reportCompare(caught, true);