author | iignatyev |
Fri, 11 Oct 2019 09:43:41 -0700 | |
changeset 58564 | 218a1a642c6f |
parent 50366 | 4d85990f9c4a |
permissions | -rw-r--r-- |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
1 |
/* |
58564 | 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 | 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 | 26 |
import jdk.test.lib.Utils; |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
27 |
|
58564 | 28 |
import java.lang.reflect.InvocationTargetException; |
29 |
import java.util.Random; |
|
30 |
import java.util.Vector; |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
31 |
|
58564 | 32 |
class test3 extends test1 { |
33 |
||
34 |
private final int[] MethodID = {Globals.MethodID_Array[3], Globals.MethodID_Array[4]}; |
|
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 | 41 |
throws InvocationTargetException { |
42 |
Globals.appendSumToSummationVector(MethodID[1], summation); |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
43 |
|
58564 | 44 |
if (CGT.shouldFinish()) { |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
45 |
return; |
58564 | 46 |
} |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
47 |
|
58564 | 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 | 50 |
} |
51 |
||
52 |
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) { |
|
53 |
return; |
|
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 | 59 |
// make a static call |
60 |
if (staticFunctionDepth.intValue() > 0) { |
|
61 |
numFcalls = functionDepth; |
|
62 |
staticFcalls = new Integer(staticFunctionDepth.intValue() - 1); |
|
63 |
methodCallStr = Globals.returnNextStaticMethod(MethodID[1]); |
|
64 |
} else if (localNumLoops > 0) { // make a recursive call |
|
65 |
numFcalls = new Long(functionDepth.longValue() - 1); |
|
66 |
staticFcalls = staticFunctionDepth; |
|
67 |
Globals.addFunctionIDToVector(MethodID[1], ID); |
|
68 |
localNumLoops--; |
|
69 |
selfRecursion(summation, ID, numFcalls, staticFcalls); |
|
70 |
return; |
|
71 |
} else { // make a random call |
|
72 |
numFcalls = new Long(functionDepth.longValue() - 1); |
|
73 |
staticFcalls = staticFunctionDepth; |
|
74 |
methodCallStr = Globals.nextRandomMethod(); |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
75 |
|
58564 | 76 |
// get ready for the next call to this method |
77 |
localNumLoops = loopNumGen.nextInt(maxLoops); |
|
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 | 85 |
throws InvocationTargetException { |
86 |
Globals.appendSumToSummationVector(MethodID[0], summation); |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
87 |
|
58564 | 88 |
if (CGT.shouldFinish()) { |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
89 |
return; |
58564 | 90 |
} |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
91 |
|
58564 | 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 | 94 |
} |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
95 |
|
58564 | 96 |
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) { |
97 |
return; |
|
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 | 102 |
if (staticFunctionDepth.intValue() > 0) { |
103 |
numFcalls = functionDepth; |
|
104 |
staticFcalls = new Integer(staticFunctionDepth.intValue() - 1); |
|
105 |
methodCallStr = Globals.returnNextStaticMethod(MethodID[0]); |
|
106 |
} else { |
|
107 |
numFcalls = new Long(functionDepth.longValue() - 1); |
|
108 |
staticFcalls = staticFunctionDepth; |
|
109 |
methodCallStr = Globals.nextRandomMethod(); |
|
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 |
} |