hotspot/test/compiler/6589834/Test_ia32.java
author prr
Thu, 25 Apr 2013 16:49:54 -0700
changeset 18254 e4083179f1c9
parent 15864 2757a5eae916
child 22234 da823d78ad65
permissions -rw-r--r--
8012421: Better positioning of PairPositioning Reviewed-by: srl, mschoene, vadim
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2574
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2575
diff changeset
     2
 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
2574
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
     4
 *
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
     8
 *
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    13
 * accompanied this code).
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    14
 *
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2575
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2575
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2575
diff changeset
    21
 * questions.
2574
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    22
 */
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    23
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    24
/**
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    25
 * @test
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    26
 * @bug 6589834
2575
518dc8f6575a 6833951: Extra ":" Causes Testcase in CR 6589834 "Parse Exception: Invalid tag: summary:"
cfang
parents: 2574
diff changeset
    27
 * @summary deoptimization problem with -XX:+DeoptimizeALot
2574
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    28
 *
15864
2757a5eae916 7115383: TEST_BUG: some jtreg tests fail because they explicitly specify -server option
collins
parents: 5547
diff changeset
    29
 * @run main Test_ia32
2574
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    30
 */
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    31
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    32
/***************************************************************************************
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    33
NOTE: The bug shows up (with several "Bug!" message) even without the
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    34
      flag -XX:+DeoptimizeALot. In a debug build, you may want to try
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    35
      the flags -XX:+VerifyStack and -XX:+DeoptimizeALot to get more information.
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    36
****************************************************************************************/
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    37
import java.lang.reflect.Constructor;
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    38
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    39
public class Test_ia32 {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    40
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    41
    public static int NUM_THREADS = 100;
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    42
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    43
    public static int CLONE_LENGTH = 1000;
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    44
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    45
    public static void main(String[] args) throws InterruptedException, ClassNotFoundException {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    46
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    47
        Reflector[] threads = new Reflector[NUM_THREADS];
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    48
        for (int i = 0; i < threads.length; i++) {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    49
            threads[i] = new Reflector();
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    50
            threads[i].start();
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    51
        }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    52
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    53
        System.out.println("Give Reflector.run() some time to compile...");
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    54
        Thread.sleep(5000);
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    55
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    56
        System.out.println("Load RMISecurityException causing run() deoptimization");
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    57
        ClassLoader.getSystemClassLoader().loadClass("java.rmi.RMISecurityException");
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    58
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    59
        for (Reflector thread : threads)
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    60
            thread.requestStop();
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    61
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    62
        for (Reflector thread : threads)
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    63
            try {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    64
                thread.join();
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    65
            } catch (InterruptedException e) {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    66
                System.out.println(e);
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    67
            }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    68
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    69
    }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    70
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    71
}
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    72
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    73
class Reflector extends Thread {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    74
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    75
    volatile boolean _doSpin = true;
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    76
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    77
    Test_ia32[] _tests;
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    78
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    79
    Reflector() {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    80
        _tests = new Test_ia32[Test_ia32.CLONE_LENGTH];
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    81
        for (int i = 0; i < _tests.length; i++) {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    82
            _tests[i] = new Test_ia32();
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    83
        }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    84
    }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    85
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    86
    static int g(int i1, int i2, Test_ia32[] arr, int i3, int i4) {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    87
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    88
        if (!(i1==1 && i2==2 && i3==3 && i4==4)) {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    89
            System.out.println("Bug!");
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    90
        }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    91
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    92
        return arr.length;
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    93
    }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    94
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    95
    static int f(Test_ia32[] arr) {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    96
        return g(1, 2, arr.clone(), 3, 4);
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    97
    }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    98
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
    99
    @Override
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   100
    public void run() {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   101
        Constructor[] ctrs = null;
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   102
        Class<Test_ia32> klass = Test_ia32.class;
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   103
        try {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   104
            ctrs = klass.getConstructors();
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   105
        } catch (SecurityException e) {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   106
            System.out.println(e);
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   107
        }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   108
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   109
        try {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   110
            while (_doSpin) {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   111
                if (f(_tests) < 0)
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   112
                    System.out.println("return value usage");
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   113
            }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   114
        } catch (NullPointerException e) {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   115
            e.printStackTrace();
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   116
        }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   117
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   118
        System.out.println(this + " - stopped.");
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   119
    }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   120
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   121
    public void requestStop() {
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   122
        System.out.println(this + " - stop requested.");
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   123
        _doSpin = false;
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   124
    }
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   125
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents:
diff changeset
   126
}