js/src/jit-test/tests/ion/monomorphic-property-access.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/ion/monomorphic-property-access.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +function Foo() {
     1.5 +    for (var i=0; i<10; i++) {
     1.6 +        this["p" + i] = i;
     1.7 +    }
     1.8 +}
     1.9 +
    1.10 +function test1(foo) {
    1.11 +    for (var i=0; i<10400; i++) {
    1.12 +        foo.p1 = i;
    1.13 +        foo.p9 = i;
    1.14 +        var x = foo.p0 + foo.p1 + foo.p2 + foo.p8 + foo.p4 +
    1.15 +            foo.p5 + foo.p6 + foo.p7 + foo.p3 + foo.p9;
    1.16 +        assertEq(x, i + i + 35);
    1.17 +    }
    1.18 +}
    1.19 +
    1.20 +test1(new Foo);
    1.21 +
    1.22 +function Bar(arg) {
    1.23 +    if (arg) { // Thwart definite-property analysis.
    1.24 +        this.x = 1;
    1.25 +        this.y = 2;
    1.26 +        this.z = 3;
    1.27 +    }
    1.28 +}
    1.29 +
    1.30 +function test2(bar) {
    1.31 +    for (var i=0; i<10400; i++) {
    1.32 +        bar.x++;
    1.33 +        bar.y++;
    1.34 +        bar.z++;
    1.35 +    }
    1.36 +    assertEq(bar.x, 10401);
    1.37 +    assertEq(bar.y, 10402);
    1.38 +    assertEq(bar.z, 10403);
    1.39 +}
    1.40 +
    1.41 +test2(new Bar(true));

mercurial