test/hotspot/jtreg/vmTestbase/jit/graph/test3.java
author iignatyev
Fri, 11 Oct 2019 09:43:41 -0700
changeset 58564 218a1a642c6f
parent 50366 4d85990f9c4a
permissions -rw-r--r--
8225654: rework vmTestbase/jit/graph Reviewed-by: thartmann, neliasso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     1
/*
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
     2
 * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     4
 *
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     8
 *
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    14
 *
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    18
 *
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    21
 * questions.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    22
 */
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    23
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    24
package jit.graph;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    25
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    26
import jdk.test.lib.Utils;
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    27
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    28
import java.lang.reflect.InvocationTargetException;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    29
import java.util.Random;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    30
import java.util.Vector;
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    31
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    32
class test3 extends test1 {
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    33
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    34
    private final int[] MethodID = {Globals.MethodID_Array[3], Globals.MethodID_Array[4]};
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    35
    private static Random loopNumGen = new Random(Utils.SEED);
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    36
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    37
    private final int maxLoops = 10;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    38
    private int localNumLoops = loopNumGen.nextInt(maxLoops);
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    39
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    40
    public void selfRecursion(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    41
            throws InvocationTargetException {
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    42
        Globals.appendSumToSummationVector(MethodID[1], summation);
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    43
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    44
        if (CGT.shouldFinish()) {
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    45
            return;
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    46
        }
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    47
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    48
        if (Globals.VERBOSE) {
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    49
            System.out.println("test3.selfRecursion");
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    50
        }
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    51
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    52
        if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    53
            return;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    54
        }
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    55
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    56
        MethodData methodCallStr;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    57
        Long numFcalls;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    58
        Integer staticFcalls;
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    59
        // make a static call
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    60
        if (staticFunctionDepth.intValue() > 0) {
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    61
            numFcalls = functionDepth;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    62
            staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    63
            methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    64
        } else if (localNumLoops > 0) { // make a recursive call
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    65
            numFcalls = new Long(functionDepth.longValue() - 1);
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    66
            staticFcalls = staticFunctionDepth;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    67
            Globals.addFunctionIDToVector(MethodID[1], ID);
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    68
            localNumLoops--;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    69
            selfRecursion(summation, ID, numFcalls, staticFcalls);
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    70
            return;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    71
        } else { // make a random call
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    72
            numFcalls = new Long(functionDepth.longValue() - 1);
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    73
            staticFcalls = staticFunctionDepth;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    74
            methodCallStr = Globals.nextRandomMethod();
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    75
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    76
            // get ready for the next call to this method
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    77
            localNumLoops = loopNumGen.nextInt(maxLoops);
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    78
        }
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    79
        Globals.addFunctionIDToVector(methodCallStr.id, ID);
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    80
        Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    81
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    82
    }
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    83
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    84
    public void callMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    85
            throws InvocationTargetException {
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    86
        Globals.appendSumToSummationVector(MethodID[0], summation);
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    87
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    88
        if (CGT.shouldFinish()) {
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    89
            return;
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    90
        }
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    91
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    92
        if (Globals.VERBOSE) {
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    93
            System.out.println("test3.callMe");
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    94
        }
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    95
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    96
        if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    97
            return;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
    98
        }
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    99
        MethodData methodCallStr;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   100
        Long numFcalls;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   101
        Integer staticFcalls;
58564
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
   102
        if (staticFunctionDepth.intValue() > 0) {
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
   103
            numFcalls = functionDepth;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
   104
            staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
   105
            methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
   106
        } else {
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
   107
            numFcalls = new Long(functionDepth.longValue() - 1);
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
   108
            staticFcalls = staticFunctionDepth;
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
   109
            methodCallStr = Globals.nextRandomMethod();
218a1a642c6f 8225654: rework vmTestbase/jit/graph
iignatyev
parents: 50366
diff changeset
   110
        }
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   111
        Globals.addFunctionIDToVector(methodCallStr.id, ID);
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   112
        Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   113
    }
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   114
}