nashorn/test/script/basic/JDK-8010710.js
author lagergren
Fri, 29 Mar 2013 08:55:05 +0100
changeset 16756 73a51c15cea2
parent 16531 nashorn/test/script/basic/JDK-8017010.js@8f1b0de50d07
child 24778 2ff5d7041566
permissions -rw-r--r--
8010995: The bug ID 8010710 accidentally got two digits transposed in the checkin and unit test name Reviewed-by: hannesw, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16531
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
     1
/*
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
     4
 * 
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
     8
 * 
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    13
 * accompanied this code).
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    14
 * 
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    18
 * 
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    21
 * questions.
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    22
 */
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    23
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    24
/**
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    25
 * JDK-8010710 - slot/scope problem with temporary expressions
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    26
 * as array index in self modifying assigns
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    27
 *
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    28
 * @test
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    29
 * @run 
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    30
 */
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    31
function zero() {
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    32
    return 0;
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    33
}
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    34
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    35
//try complex self modifying assignment and force slots to temporary value index operators
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    36
var a = [1, 2, 3, 4, 5];
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    37
var b = [a, a];
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    38
print(b[zero() + 1][2 + a[0]] += 10);
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    39
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    40
//repro for NASHORN-258 that never made it
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    41
function AddRoundKey() {        
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    42
    var r=0;  
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    43
    state[r][1] &= 17;    
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    44
}
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    45
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    46
var srcFiles = [];
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    47
for(i=0;i<100;i++) {
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    48
    srcFiles.push('dummy');
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    49
}
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    50
var added = '';
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    51
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    52
//this broke the javafx build system. verify it works
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    53
function bouncingBall() {
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    54
    for (j=0; j<100; j++) {
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    55
	added += srcFiles[j];
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    56
    }
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    57
}
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    58
bouncingBall();
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    59
print(added);
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    60
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    61
//this is how they should have done it for speed, that works always, verify this too
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    62
function bouncingBall2() {
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    63
    for (var k=0; k<100; k++) {
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    64
	added += srcFiles[k];
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    65
    }
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    66
}
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    67
bouncingBall2();
8f1b0de50d07 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars
lagergren
parents:
diff changeset
    68
print(added);