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