4326N/A/*
4326N/A * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
4326N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4326N/A *
4326N/A * This code is free software; you can redistribute it and/or modify it
4326N/A * under the terms of the GNU General Public License version 2 only, as
4326N/A * published by the Free Software Foundation.
4326N/A *
4326N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4326N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4326N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4326N/A * version 2 for more details (a copy is included in the LICENSE file that
4326N/A * accompanied this code).
4326N/A *
4326N/A * You should have received a copy of the GNU General Public License version
4326N/A * 2 along with this work; if not, write to the Free Software Foundation,
4326N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4326N/A *
4326N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4326N/A * or visit www.oracle.com if you need additional information or have any
4326N/A * questions.
4326N/A */
4326N/A
4326N/A/*
4326N/A * @test
4326N/A * @bug 8007294
4326N/A * @summary ReduceFieldZeroing doesn't check for dependent load and can lead to incorrect execution
4326N/A * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline -XX:-UseOnStackReplacement -XX:-BackgroundCompilation Test8007294
4326N/A *
4326N/A */
4326N/A
4326N/Apublic class Test8007294 {
4326N/A
4326N/A int i1;
4326N/A int i2;
4326N/A
4326N/A Test8007294(int i1, int i2) {
4326N/A this.i1 = i1;
4326N/A this.i2 = i2;
4326N/A }
4326N/A
4326N/A static int m(int v) {
4326N/A return v;
4326N/A }
4326N/A
4326N/A static Test8007294 test1() {
4326N/A Test8007294 obj = new Test8007294(10, 100);
4326N/A int v1 = obj.i1;
4326N/A
4326N/A int v3 = m(v1);
4326N/A int v2 = obj.i2;
4326N/A obj.i2 = v3;
4326N/A obj.i1 = v2;
4326N/A
4326N/A return obj;
4326N/A }
4326N/A
4326N/A static int test2(int i) {
4326N/A int j = 0;
4326N/A if (i > 0) {
4326N/A j = 1;
4326N/A }
4326N/A
4326N/A int[] arr = new int[10];
4326N/A arr[0] = 1;
4326N/A arr[1] = 2;
4326N/A int v1 = arr[j];
4326N/A arr[0] = 3;
4326N/A arr[1] = 4;
4326N/A
4326N/A return v1;
4326N/A }
4326N/A
4326N/A static public void main(String[] args) {
4326N/A boolean failed = false;
4326N/A for (int i = 0; i < 20000; i++) {
4326N/A Test8007294 obj = test1();
4326N/A if (obj.i1 != 100 || obj.i2 != 10) {
4326N/A System.out.println("FAILED test1 obj.i1 = " + obj.i1 +", obj.i2 = " + obj.i2);
4326N/A failed = true;
4326N/A break;
4326N/A }
4326N/A }
4326N/A for (int i = 0; i < 20000; i++) {
4326N/A int res = test2(1);
4326N/A if (res != 2) {
4326N/A System.out.println("FAILED test2 = " + res);
4326N/A failed = true;
4326N/A break;
4326N/A }
4326N/A }
4326N/A if (failed) {
4326N/A System.exit(97);
4326N/A } else {
4326N/A System.out.println("PASSED");
4326N/A }
4326N/A }
4326N/A}