js/src/tests/js1_8_5/regress/regress-554955-4.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /*
     3  * Any copyright is dedicated to the Public Domain.
     4  * http://creativecommons.org/licenses/publicdomain/
     5  */
     7 function f() {
     8     return function(a) {
     9         // This eval must take place before the block is cloned, when the
    10         // call object is still not marked as a delegate. The scope chain
    11         // purge for the JSOP_DEFVAR will not change the global's shape,
    12         // and the property cache entry will remain valid.
    13         eval(a);
    14         let (c = 3) {
    15             // This eval forces the block to be cloned, so its shape gets
    16             // used as the property cache key shape.
    17             eval('');
    18             return b;
    19         };
    20     };
    21 }
    23 var b = 1;
    24 var g1 = f();
    25 var g2 = f();
    27 /* Call the lambda once, caching a reference to the global b. */
    28 g1('');
    30 /*
    31  * If this call sees the above cache entry, then it will erroneously use the
    32  * global b.
    33  */
    34 assertEq(g2('var b=2'), 2);
    36 reportCompare(true, true);

mercurial