test/compiler/c2/TestReplacedNodesOSR.java

Thu, 16 Feb 2017 15:14:44 -0800

author
roland
date
Thu, 16 Feb 2017 15:14:44 -0800
changeset 8796
b1f3fbe39975
parent 8724
e62be4f3f523
permissions
-rw-r--r--

8175097: [TESTBUG] 8174164 fix missed the test
Reviewed-by: kvn

roland@8724 1 /*
roland@8724 2 * Copyright (c) 2017, Red Hat, Inc. All rights reserved.
roland@8724 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
roland@8724 4 *
roland@8724 5 * This code is free software; you can redistribute it and/or modify it
roland@8724 6 * under the terms of the GNU General Public License version 2 only, as
roland@8724 7 * published by the Free Software Foundation.
roland@8724 8 *
roland@8724 9 * This code is distributed in the hope that it will be useful, but WITHOUT
roland@8724 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
roland@8724 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
roland@8724 12 * version 2 for more details (a copy is included in the LICENSE file that
roland@8724 13 * accompanied this code).
roland@8724 14 *
roland@8724 15 * You should have received a copy of the GNU General Public License version
roland@8724 16 * 2 along with this work; if not, write to the Free Software Foundation,
roland@8724 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
roland@8724 18 *
roland@8724 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
roland@8724 20 * or visit www.oracle.com if you need additional information or have any
roland@8724 21 * questions.
roland@8724 22 */
roland@8724 23
roland@8724 24 /**
roland@8724 25 * @test
roland@8724 26 * @bug 8174164
roland@8724 27 * @summary SafePointNode::_replaced_nodes breaks with irreducible loops
roland@8724 28 * @run main/othervm -XX:-BackgroundCompilation TestReplacedNodesOSR
roland@8724 29 *
roland@8724 30 */
roland@8724 31
roland@8724 32 public class TestReplacedNodesOSR {
roland@8724 33
roland@8724 34 static Object dummy;
roland@8724 35
roland@8724 36 static interface I {
roland@8724 37 }
roland@8724 38
roland@8724 39 static class A implements I {
roland@8724 40 }
roland@8724 41
roland@8724 42 static final class MyException extends Exception {
roland@8724 43 }
roland@8724 44
roland@8724 45 static final A obj = new A();
roland@8724 46 static I static_field() { return obj; }
roland@8724 47
roland@8724 48 // When OSR compiled, this method has an irreducible loop
roland@8724 49 static void test(int v, MyException e) {
roland@8724 50 int i = 0;
roland@8724 51 for (;;) {
roland@8724 52 if (i == 1000) {
roland@8724 53 break;
roland@8724 54 }
roland@8724 55 try {
roland@8724 56 if ((i%2) == 0) {
roland@8724 57 int j = 0;
roland@8724 58 for (;;) {
roland@8724 59 j++;
roland@8724 60 if (i+j != v) {
roland@8724 61 if (j == 1000) {
roland@8724 62 break;
roland@8724 63 }
roland@8724 64 } else {
roland@8724 65 A a = (A)static_field();
roland@8724 66 // replaced node recorded here
roland@8724 67 throw e;
roland@8724 68 }
roland@8724 69 }
roland@8724 70 }
roland@8724 71 } catch(MyException ex) {
roland@8724 72 }
roland@8724 73 i++;
roland@8724 74 // replaced node applied on return of the method
roland@8724 75 // replaced node used here
roland@8724 76 dummy = static_field();
roland@8724 77 }
roland@8724 78 }
roland@8724 79
roland@8724 80
roland@8724 81 static public void main(String[] args) {
roland@8724 82 for (int i = 0; i < 1000; i++) {
roland@8724 83 test(1100, new MyException());
roland@8724 84 }
roland@8724 85 }
roland@8724 86 }

mercurial