Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/graph/test3.java
40948 views
/*1* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package jit.graph;2425import jdk.test.lib.Utils;2627import java.lang.reflect.InvocationTargetException;28import java.util.Random;29import java.util.Vector;3031class test3 extends test1 {3233private final int[] MethodID = {Globals.MethodID_Array[3], Globals.MethodID_Array[4]};34private static Random loopNumGen = new Random(Utils.SEED);3536private final int maxLoops = 10;37private int localNumLoops = loopNumGen.nextInt(maxLoops);3839public void selfRecursion(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)40throws InvocationTargetException {41Globals.appendSumToSummationVector(MethodID[1], summation);4243if (CGT.shouldFinish()) {44return;45}4647if (Globals.VERBOSE) {48System.out.println("test3.selfRecursion");49}5051if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {52return;53}5455MethodData methodCallStr;56Long numFcalls;57Integer staticFcalls;58// make a static call59if (staticFunctionDepth.intValue() > 0) {60numFcalls = functionDepth;61staticFcalls = Integer.valueOf(staticFunctionDepth.intValue() - 1);62methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);63} else if (localNumLoops > 0) { // make a recursive call64numFcalls = Long.valueOf(functionDepth.longValue() - 1);65staticFcalls = staticFunctionDepth;66Globals.addFunctionIDToVector(MethodID[1], ID);67localNumLoops--;68selfRecursion(summation, ID, numFcalls, staticFcalls);69return;70} else { // make a random call71numFcalls = Long.valueOf(functionDepth.longValue() - 1);72staticFcalls = staticFunctionDepth;73methodCallStr = Globals.nextRandomMethod();7475// get ready for the next call to this method76localNumLoops = loopNumGen.nextInt(maxLoops);77}78Globals.addFunctionIDToVector(methodCallStr.id, ID);79Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);8081}8283public void callMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)84throws InvocationTargetException {85Globals.appendSumToSummationVector(MethodID[0], summation);8687if (CGT.shouldFinish()) {88return;89}9091if (Globals.VERBOSE) {92System.out.println("test3.callMe");93}9495if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {96return;97}98MethodData methodCallStr;99Long numFcalls;100Integer staticFcalls;101if (staticFunctionDepth.intValue() > 0) {102numFcalls = functionDepth;103staticFcalls = Integer.valueOf(staticFunctionDepth.intValue() - 1);104methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);105} else {106numFcalls = Long.valueOf(functionDepth.longValue() - 1);107staticFcalls = staticFunctionDepth;108methodCallStr = Globals.nextRandomMethod();109}110Globals.addFunctionIDToVector(methodCallStr.id, ID);111Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);112}113}114115116