~ubuntu-branches/ubuntu/vivid/mozjs24/vivid

« back to all changes in this revision

Viewing changes to js/src/jit-test/tests/debug/gc-04.js

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2014-02-11 21:55:34 UTC
  • Revision ID: package-import@ubuntu.com-20140211215534-m1zyq5aj59md3y07
Tags: upstream-24.2.0
ImportĀ upstreamĀ versionĀ 24.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Storing a Debugger.Object as a key in a WeakMap protects it from GC as long as
 
2
// the referent is alive.
 
3
 
 
4
var g = newGlobal('new-compartment');
 
5
var N = g.N = 10;
 
6
var dbg = Debugger(g);
 
7
var cache = new WeakMap;
 
8
 
 
9
var i = 0;
 
10
dbg.onDebuggerStatement = function (frame) {
 
11
    cache.set(frame.arguments[0], i++);
 
12
};
 
13
g.eval("function f(x) { debugger; }");
 
14
g.eval("var arr = [], j; for (j = 0; j < N; j++) arr[j] = {};");
 
15
g.eval("for (j = 0; j < N; j++) f(arr[j]);");
 
16
assertEq(i, N);
 
17
 
 
18
gc(); gc();
 
19
 
 
20
i = 0;
 
21
dbg.onDebuggerStatement = function (frame) {
 
22
    assertEq(cache.get(frame.arguments[0]), i++)
 
23
};
 
24
g.eval("for (j = 0; j < N; j++) f(arr[j]);");
 
25
assertEq(i, N);