test/script/basic/es6/JDK-8168373.js

Fri, 11 Nov 2016 15:50:51 +0100

author
attila
date
Fri, 11 Nov 2016 15:50:51 +0100
changeset 1980
ee3a76a1dbf2
permissions
-rw-r--r--

8168373: don't emit conversions for symbols outside their lexical scope
Reviewed-by: hannesw, sundar

attila@1980 1 /*
attila@1980 2 * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
attila@1980 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
attila@1980 4 *
attila@1980 5 * This code is free software; you can redistribute it and/or modify it
attila@1980 6 * under the terms of the GNU General Public License version 2 only, as
attila@1980 7 * published by the Free Software Foundation.
attila@1980 8 *
attila@1980 9 * This code is distributed in the hope that it will be useful, but WITHOUT
attila@1980 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
attila@1980 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
attila@1980 12 * version 2 for more details (a copy is included in the LICENSE file that
attila@1980 13 * accompanied this code).
attila@1980 14 *
attila@1980 15 * You should have received a copy of the GNU General Public License version
attila@1980 16 * 2 along with this work; if not, write to the Free Software Foundation,
attila@1980 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
attila@1980 18 *
attila@1980 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
attila@1980 20 * or visit www.oracle.com if you need additional information or have any
attila@1980 21 * questions.
attila@1980 22 */
attila@1980 23
attila@1980 24 /**
attila@1980 25 * JDK-8168373: don't emit conversions for symbols outside their lexical scope
attila@1980 26 *
attila@1980 27 * @test
attila@1980 28 * @run
attila@1980 29 * @option --language=es6
attila@1980 30 */
attila@1980 31
attila@1980 32 function p() { return false } // "predicate"
attila@1980 33 function r(x) { return x } // "read"
attila@1980 34
attila@1980 35 (function() {
attila@1980 36 try { // Try creates control flow edges from assignments into catch blocks.
attila@1980 37 // Lexically scoped, never read int variable (undefined at catch block) but still with a cf edge into catch block.
attila@1980 38 // Since it's never read, it's not written either (Nashorn optimizes some dead writes).
attila@1980 39 let x = 0;
attila@1980 40 if (p()) { throw {}; } // We need `p()` so this block doesn't get optimized away, for possibility of a `throw`
attila@1980 41 x = 0.0; // change the type of x to double
attila@1980 42 r(x); // read x otherwise it's optimized away
attila@1980 43 } catch (e) {} // under the bug, "throw" will try to widen unwritten int x to double for here and cause a verifier error
attila@1980 44 })()

mercurial