js/src/jit-test/tests/debug/gc-02.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 // Dispatching an event to a debugger must keep enough of it gc-alive to avoid
     2 // crashing.
     4 var g = newGlobal();
     5 var hits;
     7 function addDebug() {
     8     // The loop is here to defeat the conservative GC. :-\
     9     for (var i = 0; i < 4; i++) {
    10         var dbg = new Debugger(g);
    11         dbg.onDebuggerStatement = function (stack) {
    12             hits++;
    13             this.enabled = false;
    14             this.onDebuggerStatement = undefined;
    15             gc();
    16         };
    17         if (i > 0) {
    18             dbg.enabled = false;
    19             dbg.onDebuggerStatement = undefined;
    20             dbg = null;
    21         }
    22     }
    23 }
    25 addDebug();
    26 hits = 0;
    27 g.eval("debugger;");
    28 assertEq(hits, 1);

mercurial