nashorn/test/script/basic/JDK-8041995.js
author martin
Wed, 10 Dec 2014 09:23:00 -0800
changeset 28057 1a47ceecdba5
parent 24778 2ff5d7041566
permissions -rw-r--r--
8065804: JEP 171: Clarifications/corrections for fence intrinsics Reviewed-by: dholmes, shade, dl, psandoz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24747
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
     1
/*
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
     2
 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
     4
 *
24747
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
     8
 *
24747
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    13
 * accompanied this code).
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    14
 *
24747
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    18
 *
24747
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    21
 * questions.
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    22
 */
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    23
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    24
/**
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    25
 * JDK-8041995: optimistic object property maps were only updated if the outermost program
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    26
 * point in a property setter failed, not an inner one, which is wrong.
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    27
 *
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    28
 * @test
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    29
 * @run
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    30
 */
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    31
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    32
function xyzzy() {
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    33
    return 17.4711;
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    34
}
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    35
var obj = {
24747
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    36
    z: -xyzzy()
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    37
};
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    38
print(obj.z);
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    39
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    40
function phlug() {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    41
    var obj = {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    42
    4: -Infinity,
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    43
     5: Infinity,
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    44
    length: 5 - Math.pow(2, 32)
24747
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    45
    };
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    46
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    47
    return Array.prototype.lastIndexOf.call(obj, -Infinity) === 4;
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    48
}
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    49
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    50
var d = new Date;
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    51
print(phlug());
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    52
var d2 = new Date - d;
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    53
print(d2 < 5000); // if this takes more than five seconds we have read the double length as an int
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    54
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    55
function wrong() {
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    56
    var obj = {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    57
    length1: 5 - Math.pow(2, 32),
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    58
    length2: 4 - Math.pow(2, 32),
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    59
    length3: 3 - Math.pow(2, 32),
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    60
    length4: 2 - Math.pow(2, 32),
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    61
    length5: 1 - Math.pow(2, 32),
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24747
diff changeset
    62
    length6: Math.pow(2, 32)
24747
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    63
    };
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    64
    for (var i in obj) {
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    65
       print(obj[i]);
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    66
    }
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    67
}
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    68
c7485e5d6cf4 8041995: Problems when loading tree expressions with several optimistic program points when optimistically initializing ObjectNodes
lagergren
parents:
diff changeset
    69
wrong();