js/src/jit-test/tests/basic/bug656261.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/basic/bug656261.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +function build_getter(i) {
     1.5 +    var x = [i];
     1.6 +    return function f() { return x; }
     1.7 +}
     1.8 +
     1.9 +function test()
    1.10 +{
    1.11 +    var N = internalConst("INCREMENTAL_MARK_STACK_BASE_CAPACITY") + 2;
    1.12 +    var o = {};
    1.13 +    var descriptor = { enumerable: true};
    1.14 +    for (var i = 0; i != N; ++i) {
    1.15 +	descriptor.get = build_getter(i);
    1.16 +	Object.defineProperty(o, i, descriptor);
    1.17 +    }
    1.18 +
    1.19 +    // At this point we have an object o with N getters. Each getter in turn
    1.20 +    // is a closure storing an array. During the GC we push to the object
    1.21 +    // marking stack all the getters found in an object after we mark it. As N
    1.22 +    // exceeds the size of the object marking stack, this requires to run the
    1.23 +    // dealyed scanning for some closures to mark the array objects stored in
    1.24 +    // them.
    1.25 +    //
    1.26 +    // We run the GC twice to make sure that the background finalization
    1.27 +    // finishes before we access the objects.
    1.28 +    gc();
    1.29 +    gc();
    1.30 +    for (var i = 0; i != N; ++i)
    1.31 +	assertEq(o[i][0], i);
    1.32 +}
    1.33 +
    1.34 +test();

mercurial