Tue, 16 Aug 2016 21:41:28 -0700
Added tag jdk8u102-b33 for changeset 36e3c21b5fca
sundar@1541 | 1 | /* |
sundar@1541 | 2 | * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
sundar@1541 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
sundar@1541 | 4 | * |
sundar@1541 | 5 | * This code is free software; you can redistribute it and/or modify it |
sundar@1541 | 6 | * under the terms of the GNU General Public License version 2 only, as |
sundar@1541 | 7 | * published by the Free Software Foundation. |
sundar@1541 | 8 | * |
sundar@1541 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
sundar@1541 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
sundar@1541 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
sundar@1541 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
sundar@1541 | 13 | * accompanied this code). |
sundar@1541 | 14 | * |
sundar@1541 | 15 | * You should have received a copy of the GNU General Public License version |
sundar@1541 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
sundar@1541 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
sundar@1541 | 18 | * |
sundar@1541 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
sundar@1541 | 20 | * or visit www.oracle.com if you need additional information or have any |
sundar@1541 | 21 | * questions. |
sundar@1541 | 22 | */ |
sundar@1541 | 23 | |
sundar@1541 | 24 | /** |
sundar@1541 | 25 | * JDK-8136694: Megemorphic scope access does not throw ReferenceError when property is missing |
sundar@1541 | 26 | * |
sundar@1541 | 27 | * @test |
sundar@1541 | 28 | * @fork |
sundar@1541 | 29 | * @option -Dnashorn.unstable.relink.threshold=16 |
sundar@1541 | 30 | * @run |
sundar@1541 | 31 | */ |
sundar@1541 | 32 | |
sundar@1541 | 33 | function checkFoo() { |
sundar@1541 | 34 | try { |
sundar@1541 | 35 | // The 'foo' access becomes megamorphic |
sundar@1541 | 36 | foo; |
sundar@1541 | 37 | return true; |
sundar@1541 | 38 | } catch (e) { |
sundar@1541 | 39 | return false; |
sundar@1541 | 40 | } |
sundar@1541 | 41 | } |
sundar@1541 | 42 | |
sundar@1541 | 43 | |
sundar@1541 | 44 | // Similar check for 'with' blocks as well. |
sundar@1541 | 45 | function checkFooInWith() { |
sundar@1541 | 46 | with({}) { |
sundar@1541 | 47 | try { |
sundar@1541 | 48 | // The 'foo' access becomes megamorphic |
sundar@1541 | 49 | foo; |
sundar@1541 | 50 | return true; |
sundar@1541 | 51 | } catch (e) { |
sundar@1541 | 52 | return false; |
sundar@1541 | 53 | } |
sundar@1541 | 54 | } |
sundar@1541 | 55 | } |
sundar@1541 | 56 | |
sundar@1541 | 57 | function loop(checker) { |
sundar@1541 | 58 | // LIMIT has to be more than the megamorphic threashold |
sundar@1541 | 59 | // set via @option in this test header! |
sundar@1541 | 60 | var LIMIT = 20; |
sundar@1541 | 61 | for (var i = 0; i < LIMIT; i++) { |
sundar@1541 | 62 | // make sure global has no "foo" |
sundar@1541 | 63 | delete foo; |
sundar@1541 | 64 | Assert.assertFalse(checker(), "Expected false in interation " + i); |
sundar@1541 | 65 | |
sundar@1541 | 66 | // now add 'foo' in global |
sundar@1541 | 67 | foo = 44; |
sundar@1541 | 68 | Assert.assertTrue(checker(), "Expected true in interation " + i); |
sundar@1541 | 69 | } |
sundar@1541 | 70 | } |
sundar@1541 | 71 | |
sundar@1541 | 72 | |
sundar@1541 | 73 | loop(checkFoo); |
sundar@1541 | 74 | loop(checkFooInWith); |