js/src/jit-test/tests/arguments/access-formals.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 function g1(x, args) {
     2     args[0] = 88;
     3 }
     5 // We assume we can optimize arguments access in |f|.
     6 //
     7 // Then the apply-call invalidates the arguments optimization,
     8 // and creates a real arguments object.
     9 //
    10 // Test that x and y fetch the values from the args object when
    11 // that happens.
    12 function f1(x, y, o) {
    13     var res = 0;
    14     for (var i=0; i<50; i++) {
    15 	res += x + y;
    16 	if (i > 10)
    17 	    o.apply(null, arguments);
    18     }
    19     return res;
    20 }
    22 var o1 = {apply: g1};
    23 assertEq(f1(3, 5, o1), 3630);
    24 assertEq(f1(3, 5, o1), 3630);
    26 // In strict mode, the arguments object does not alias formals.
    27 function g2(x, args) {
    28     args[0] = 88;
    29 }
    31 function f2(x, y, o) {
    32     "use strict";
    33     var res = 0;
    34     for (var i=0; i<50; i++) {
    35 	res += x + y;
    36 	if (i > 10)
    37 	    o.apply(null, arguments);
    38     }
    39     return res;
    40 }
    42 var o2 = {apply: g2};
    43 assertEq(f2(3, 5, o2), 400);
    44 assertEq(f2(3, 5, o2), 400);

mercurial