--- a/test/hotspot/jtreg/TEST.quick-groups Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/TEST.quick-groups Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -1652,18 +1652,18 @@
vmTestbase/jit/escape/LockElision/MatMul/MatMul.java \
vmTestbase/jit/escape/LockCoarsening/LockCoarsening002/TestDescription.java \
vmTestbase/jit/exception/exception.java \
- vmTestbase/jit/graph/cgt0/cgt0.java \
- vmTestbase/jit/graph/cgt1/cgt1.java \
- vmTestbase/jit/graph/cgt2/cgt2.java \
- vmTestbase/jit/graph/cgt3/cgt3.java \
- vmTestbase/jit/graph/cgt4/cgt4.java \
- vmTestbase/jit/graph/cgt5/cgt5.java \
- vmTestbase/jit/graph/cgt6/cgt6.java \
- vmTestbase/jit/graph/cgt7/cgt7.java \
- vmTestbase/jit/graph/cgt8/cgt8.java \
- vmTestbase/jit/graph/cgt9/cgt9.java \
- vmTestbase/jit/graph/cgt10/cgt10.java \
- vmTestbase/jit/graph/cgt11/cgt11.java \
+ vmTestbase/jit/graph/cgt0.java \
+ vmTestbase/jit/graph/cgt1.java \
+ vmTestbase/jit/graph/cgt2.java \
+ vmTestbase/jit/graph/cgt3.java \
+ vmTestbase/jit/graph/cgt4.java \
+ vmTestbase/jit/graph/cgt5.java \
+ vmTestbase/jit/graph/cgt6.java \
+ vmTestbase/jit/graph/cgt7.java \
+ vmTestbase/jit/graph/cgt8.java \
+ vmTestbase/jit/graph/cgt9.java \
+ vmTestbase/jit/graph/cgt10.java \
+ vmTestbase/jit/graph/cgt11.java \
vmTestbase/jit/init/init01/init01.java \
vmTestbase/jit/init/init02/init02.java \
vmTestbase/jit/inline/inline003/inline003.java \
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/CGT.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/CGT.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,245 +22,219 @@
*/
package jit.graph;
-import java.util.*;
+
+import jdk.test.lib.Utils;
+import jtreg.SkippedException;
import nsk.share.TestFailure;
import nsk.share.test.StressOptions;
-class CGT extends Thread
-{
- private static StressOptions stressOptions = new StressOptions();
- private final static String version = "1.0";
- private static String ClistPath = "";
+import java.lang.reflect.InvocationTargetException;
+import java.util.Vector;
- private static long finishTime;
+public class CGT {
+ private static StressOptions stressOptions = new StressOptions();
+ private static String ClistPath = "";
+ private static long finishTime;
+
+ private final Vector summation = new Vector(100000);
+ private final Vector idList = new Vector(100000);
- public CGT( String[] args )
- {
- parse (args);
- Globals.initialize(ClistPath);
- outputStats (args);
- }
+ public CGT(String[] args) {
+ parse(args);
+ Globals.initialize(ClistPath);
+ outputStats(args);
+ }
-
- public static void main( String[] args )
- {
- stressOptions.parseCommandLine(args);
- CGT jnimt = new CGT(args);
- jnimt.start();
- }
+ public static void main(String[] args) {
+ stressOptions.parseCommandLine(args);
+ new CGT(args).run();
+ }
- public void outputStats( String[] args )
- {
- System.out.println("CGT command line options:");
- for (int i=0; i < args.length; ++i )
- System.out.println("# " + args[i] );
-
- System.out.println();
+ public void outputStats(String[] args) {
+ System.out.println("CGT command line options:");
+ for (String arg : args) {
+ System.out.println("# " + arg);
+ }
- System.out.println("CGT parameters");
- System.out.println("Seed: " +Globals.RANDOM_SEED);
- System.out.println("Number of Threads: " +Globals.NUM_THREADS);
- System.out.println("Number of Random Loop iterations: " + Globals.RANDOM_LOOP);
- System.out.println("Number of Static Loop iterations: " + Globals.STATIC_LOOP);
- System.out.println("Max number of Methods in the Graph: " + Globals.NUM_TEST_CLASSES);
- System.out.println("Verbose function calls: " + Globals.VERBOSE);
+ System.out.println();
- System.out.println();
- }
-
- public void run()
- {
- finishTime = System.currentTimeMillis() + stressOptions.getTime() * 1000;
+ System.out.println("CGT parameters");
+ System.out.println("Seed: " + Utils.SEED);
+ System.out.println("Number of Random Loop iterations: " + Globals.RANDOM_LOOP);
+ System.out.println("Number of Static Loop iterations: " + Globals.STATIC_LOOP);
+ System.out.println("Max number of Methods in the Graph: " + Globals.NUM_TEST_CLASSES);
+ System.out.println("Verbose function calls: " + Globals.VERBOSE);
- for (int i = 0; i< Globals.NUM_THREADS; i++)
- new CGTThread("CGT Thread " + i).start();
- }
+ System.out.println();
+ }
- public static boolean shouldFinish()
- {
- return System.currentTimeMillis() >= finishTime;
- }
+ public void run() {
+ finishTime = System.currentTimeMillis() + stressOptions.getTime() * 1000;
+ Long numFcalls = Globals.RANDOM_LOOP - 1;
+ Integer staticFcalls = Globals.STATIC_LOOP;
+ MethodData methodCallStr = Globals.nextRandomMethod();
+ Globals.addFunctionIDToVector(methodCallStr.id, idList);
+ Throwable invocationExcept;
- public void parse (String args[])
- {
- for (int i = 0; i<args.length; i++)
- {
- if ((args[i].equalsIgnoreCase("-help")) || (args[i].equalsIgnoreCase("-h")) || (args[i].equalsIgnoreCase("-?")))
- {
- usage ();
- }
- else if (args[i].equalsIgnoreCase("-version"))
- {
- version();
- }
- else if (args[i].equalsIgnoreCase("-seed"))
- {
- int argIndex = i+1;
- if (argIndex < args.length)
- {
- try
- {
- Globals.RANDOM_SEED = Math.abs(Long.parseLong(args[argIndex]));
- }
- catch (NumberFormatException e)
- {
- System.out.println("Improper Argument: " + args[i] + " " + args[argIndex]);
- usage ();
- }
- i++;
- }
- else
- {
- System.out.println("Improper Argument: " + args[i]);
- usage ();
- }
+ try {
+ methodCallStr.nextMethod.invoke(methodCallStr.instance, summation, idList, numFcalls, staticFcalls);
+ } catch (IllegalAccessException e) {
+ throw new TestFailure("Illegal Access Exception", e);
+ } catch (InvocationTargetException e) {
+ System.out.println("Invocation Target Exception");
+ invocationExcept = e.getTargetException();
+ System.out.println(invocationExcept);
+ if (invocationExcept.getClass() == e.getClass()) {
+ System.out.println("Processing Exception Invocation Target Exception");
+ while (invocationExcept.getClass() == e.getClass()) {
+ invocationExcept = ((InvocationTargetException) invocationExcept).getTargetException();
+ }
+ System.out.println(invocationExcept);
+ }
+ if (invocationExcept instanceof StackOverflowError) {
+ throw new SkippedException("stack overflow: skipping verification.", invocationExcept);
+ } else if (invocationExcept instanceof OutOfMemoryError) {
+ throw new SkippedException("test devoured heap ;), skipping verification.", invocationExcept);
+ } else {
+ throw new TestFailure(invocationExcept);
+ }
+ }
+
+ verify();
+ }
- }
- else if ((args[i].equalsIgnoreCase("-thread")) || (args[i].equalsIgnoreCase("-threads")))
- {
- int argIndex = i+1;
- if (argIndex < args.length)
- {
- try
- {
- Globals.NUM_THREADS = Math.abs(Integer.parseInt(args[argIndex])) * stressOptions.getThreadsFactor();
- }
- catch (NumberFormatException e)
- {
- System.out.println("Improper Argument: " + args[i] + " " + args[argIndex]);
- usage ();
- }
- if(Globals.NUM_THREADS == 0)
- Globals.NUM_THREADS = 1;
- i++;
- }
- else
- {
- System.out.println("Improper Argument: " + args[i]);
- usage ();
- }
+ private void verify() {
+ long oldsum = 0;
+ long newsum;
+ System.out.println("begin call stack validation");
+ if (summation.size() != idList.size()) {
+ throw new TestFailure("Vector Length's Do Not Match, VERIFY ERROR : Summation Element Count = " + summation.size() + " ID Element Count = " + idList.size());
+ }
+ long vectorSize = summation.size();
+
+ while (!summation.isEmpty()) {
+ if (CGT.shouldFinish()) {
+ throw new SkippedException("skipping verification due to timeout");
+ }
+
+ newsum = (Long) summation.firstElement();
+ summation.removeElementAt(0);
+
+ int functionID = (Integer) idList.firstElement();
+ idList.removeElementAt(0);
+
+ if ((newsum - oldsum) != (functionID)) {
+ throw new TestFailure("Function Call structure invalid, VERIFY ERROR. Expected = " + (newsum - oldsum) + " Actual = " + functionID);
+ }
+ oldsum = newsum;
+ }
+
+ System.out.println("function call structure validated successfully (" + vectorSize + " calls validated)");
+ }
- }
- else if (args[i].equalsIgnoreCase("-staticLoop"))
- {
- int argIndex = i+1;
- if (argIndex < args.length)
- {
- try
- {
- Globals.STATIC_LOOP = Math.abs(Integer.parseInt(args[argIndex])) * stressOptions.getIterationsFactor();
- }
- catch (NumberFormatException e)
- {
- System.out.println("Improper Argument: " + args[i] + " " + args[argIndex]);
- usage ();
- }
- i++;
- }
- else
- {
- System.out.println("Improper Argument: " + args[i]);
- usage ();
- }
+ public static boolean shouldFinish() {
+ return System.currentTimeMillis() >= finishTime;
+ }
- }
- else if (args[i].equalsIgnoreCase("-randomLoop"))
- {
- int argIndex = i+1;
- if (argIndex < args.length)
- {
- try
- {
- Globals.RANDOM_LOOP = Math.abs(Long.parseLong(args[argIndex])) * stressOptions.getIterationsFactor();
- }
- catch (NumberFormatException e)
- {
- System.out.println("Improper Argument: " + args[i] + " " + args[argIndex]);
- usage ();
- }
- i++;
- }
- else
- {
- System.out.println("Improper Argument: " + args[i]);
- usage ();
- }
+ public void parse(String args[]) {
+ for (int i = 0; i < args.length; i++) {
+ String arg = args[i].toLowerCase();
+ switch (arg) {
+ case "-help":
+ case "-h":
+ case "-?": {
+ usage();
+ System.exit(1);
+ break;
+ }
+ case "-staticloop": {
+ int argIndex = i + 1;
+ if (argIndex < args.length) {
+ try {
+ Globals.STATIC_LOOP = Math.abs(Integer.parseInt(args[argIndex])) * stressOptions.getIterationsFactor();
+ } catch (NumberFormatException e) {
+ usage();
+ throw new Error("TESTBUG: Improper Argument: " + args[i] + " " + args[argIndex], e);
+ }
+ i++;
+ } else {
+ usage();
+ throw new Error("TESTBUG: Improper Argument: " + args[i]);
+ }
+ break;
+ }
+ case "-randomloop": {
+ int argIndex = i + 1;
+ if (argIndex < args.length) {
+ try {
+ Globals.RANDOM_LOOP = Math.abs(Long.parseLong(args[argIndex])) * stressOptions.getIterationsFactor();
+ } catch (NumberFormatException e) {
+ usage();
+ throw new Error("TESTBUG: Improper Argument: " + args[i] + " " + args[argIndex], e);
+ }
+ i++;
+ } else {
+ usage();
+ throw new Error("TESTBUG: Improper Argument: " + args[i]);
- }
- else if (args[i].equalsIgnoreCase("-numTestClass"))
- {
- int argIndex = i+1;
- if (argIndex < args.length)
- {
- try
- {
- Globals.NUM_TEST_CLASSES = Math.abs(Integer.parseInt(args[argIndex]));
- }
- catch (NumberFormatException e)
- {
- System.out.println("Improper Argument: " + args[i] + " " + args[argIndex]);
- usage ();
- }
- i++;
- }
- else
- {
- System.out.println("Improper Argument: " + args[i]);
- usage ();
- }
+ }
+ break;
+ }
+ case "-numtestclass": {
+ int argIndex = i + 1;
+ if (argIndex < args.length) {
+ try {
+ Globals.NUM_TEST_CLASSES = Math.abs(Integer.parseInt(args[argIndex]));
+ } catch (NumberFormatException e) {
+ usage();
+ throw new Error("TESTBUG: Improper Argument: " + args[i] + " " + args[argIndex], e);
+ }
+ i++;
+ } else {
+ usage();
+ throw new Error("TESTBUG: Improper Argument: " + args[i]);
+ }
+ break;
+ }
+ case "-verbose":
+ case "-v": {
+ Globals.VERBOSE = true;
+ break;
+ }
+ case "-path": {
+ int argIndex = i + 1;
+ if (argIndex < args.length) {
+ ClistPath = args[argIndex];
+ i++;
+ } else {
+ usage();
+ throw new Error("TESTBUG: Improper Argument: " + args[i]);
+ }
+ break;
+ }
+ default: {
+ if (!arg.startsWith("-stress")) {
+ usage();
+ throw new Error("TESTBUG: Invalid Argument: " + args[i]);
+ }
+ }
+ }
+ }
- }
- else if (args[i].equalsIgnoreCase("-v") || args[i].equalsIgnoreCase("-verbose"))
- {
- Globals.VERBOSE = true;
- }
- else if (args[i].equalsIgnoreCase("-path"))
- {
- int argIndex = i+1;
- if (argIndex < args.length)
- {
- ClistPath = args[argIndex];
- i++;
- }
- else
- {
- System.out.println("Improper Argument: " + args[i]);
- usage ();
- }
- }
- else if (args[i].startsWith("-stress"))
- {
- break;
- }
- else
- {
- System.out.println("Invalid Argument: " + args[i]);
- usage ();
- }
+ if ("".equals(ClistPath)) {
+ usage();
+ throw new Error("TESTBUG: class list path not defined");
}
- if (ClistPath.equals(""))
- {
- System.out.println("class list path not defined");
- usage();
- }
- }
+ }
- public void usage ()
- {
- System.out.println("usage: java CGT [options]");
- System.out.println(" -help prints out this message");
- System.out.println(" -numTestClass # limits the number of \"Test Methods\" to #");
- System.out.println(" -randomcLoop # # of random function calls");
- System.out.println(" -seed # uses the specified seed rather than the System Time");
- System.out.println(" -staticLoop # # of non-random static function calls");
- System.out.println(" -threads # # number of test threads, NOTE: no maximum value");
- System.out.println(" -version print out the tool version");
- System.out.println(" -v -verbose turn on verbose mode");
- throw new TestFailure(" -path <path to classlist> required, argument so program can find classes");
- }
-
- public void version ()
- {
- throw new TestFailure("CGT version = " + version);
- }
+ public void usage() {
+ System.out.println("usage: java CGT [options]");
+ System.out.println(" -help prints out this message");
+ System.out.println(" -numTestClass # limits the number of \"Test Methods\" to #");
+ System.out.println(" -randomcLoop # # of random function calls");
+ System.out.println(" -seed # uses the specified seed rather than the System Time");
+ System.out.println(" -staticLoop # # of non-random static function calls");
+ System.out.println(" -v -verbose turn on verbose mode");
+ System.out.println(" -path <path to classlist> required, argument so program can find classes");
+ }
}
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/CGTThread.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jit.graph;
-import java.util.*;
-import java.lang.*;
-import java.lang.reflect.*;
-import nsk.share.TestFailure;
-
-class CGTThread extends Thread
-{
- private String ThreadName = null;
- private Vector Sumation = new Vector(100000);
- private Vector IDlist = new Vector(100000);
-
-
- CGTThread( String name )
- {
- ThreadName = name;
- setName(name);
- }
-
-
- public void run()
- {
- if (Globals.VERBOSE)
- System.out.println("\t\t" + Thread.currentThread().getName() + " started");
- Long numFcalls = new Long(Globals.RANDOM_LOOP - 1);
- Integer staticFcalls = new Integer(Globals.STATIC_LOOP);
- MethodData methodCallStr = Globals.nextRandomMethod();
- Globals.addFunctionIDToVector(methodCallStr.id, IDlist);
- Throwable invocationExcept = null;
-
- boolean skipVerify = false;
-
- try
- {
- methodCallStr.nextMethod.invoke(methodCallStr.instance, new Object []{Sumation, IDlist, numFcalls, staticFcalls});
- }
- catch (IllegalAccessException iax)
- {
- throw new TestFailure("Illegal Access Exception");
- }
- catch (InvocationTargetException itx)
- {
- System.out.println("Invocation Target Exception");
- invocationExcept = itx.getTargetException();
- System.out.println(invocationExcept);
- if (invocationExcept.getClass() == itx.getClass())
- {
- System.out.println("Processing Exception Invocation Target Exception");
- while (invocationExcept.getClass() == itx.getClass())
- invocationExcept = ((InvocationTargetException)invocationExcept).getTargetException();
- System.out.println(invocationExcept);
- }
- if (invocationExcept instanceof StackOverflowError)
- //StackOverFlow is not a failure
- {
- System.out.println("Warning: stack overflow: skipping verification...");
- skipVerify = true;
- }
- else if (invocationExcept instanceof OutOfMemoryError)
- //OutOfMemoryError is not a failure
- {
- System.out.println("Warning: test devoured heap ;), skipping verification...");
- skipVerify = true;
- }
- else
- {
- invocationExcept.printStackTrace();
- System.exit(1);
- }
- }
-
- if( !skipVerify )
- verify(Sumation, IDlist);
- }
-
- void verify(Vector Sum, Vector ID)
- {
- long oldsum = 0;
- long newsum;
- System.out.println(ThreadName + " has begun call stack validation");
- if (Sum.size() != ID.size())
- {
- System.out.println("Vector Length's Do Not Match, VERIFY ERROR");
- System.out.println("Thread Name: " + ThreadName);
- throw new TestFailure("Sumation Element Count = " + Sum.size() + " ID Element Count = " +ID.size());
- }
- long vectorSize = Sum.size();
- while (!Sum.isEmpty())
- {
- if (CGT.shouldFinish())
- {
- System.out.println(Thread.currentThread().getName() + ": skipping verification due to timeout");
- return;
- }
-
- newsum = ((Long)Sum.firstElement()).longValue();
- Sum.removeElementAt(0);
-
- int functionID = ((Integer)ID.firstElement()).intValue();
- ID.removeElementAt(0);
-
- if ((newsum - oldsum) != (functionID))
- {
- System.out.println("Function Call structure invalid, VERIFY ERROR");
- System.out.println("Thread Name: " + ThreadName);
- System.out.println("Expected = " +(newsum - oldsum) + " Actual = " +functionID);
- throw new TestFailure("Test failed.");
-// System.exit(1);
- }
- oldsum = newsum;
- }
- Globals.decNumThreads();
- System.out.println(ThreadName + "'s function call structure validated succesfully ("+vectorSize+" calls validated)");
- }
-
-}
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/Globals.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/Globals.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,263 +22,200 @@
*/
package jit.graph;
-import java.io.*;
-import java.util.*;
-import java.lang.*;
-import java.lang.reflect.*;
+
+import jdk.test.lib.Utils;
import nsk.share.TestFailure;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Random;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+public final class Globals {
+
-public final class Globals
-{
- // Minimum and Maximum number of threads
- public static int NUM_THREADS = 1;
- public static long RANDOM_SEED = System.currentTimeMillis();
- public static int STATIC_LOOP = 0;
- public static int NUM_TEST_CLASSES = 7;
- public static long RANDOM_LOOP = 100;
- public static boolean VERBOSE = false;
- private static Random indexGenerator = null;
+ public static int STATIC_LOOP = 0;
+ public static int NUM_TEST_CLASSES = 7;
+ public static long RANDOM_LOOP = 100;
+ public static boolean VERBOSE = false;
- //private static TestLoader CGTTestLoader = null;
- private static String [] ClassArray = null;
- private static Class [] ClassInstanceArray = null;
- private static int maxClassIndex = 0;
+ private static final Random indexGenerator = Utils.getRandomInstance();
+ private static String[] ClassArray = null;
+ private static Class[] ClassInstanceArray = null;
+ private static int maxClassIndex = 0;
- private static String [] MethodName_Array = null;
- private static Method [] MethodInstance_Array = null;
+ private static String[] MethodName_Array = null;
+ private static Method[] MethodInstance_Array = null;
- //Should be prime, so that odds of an incorrect verification reduced
- public static int [] MethodID_Array = null;
-
-
- //Number of threads will be reduced as threads finish
- public static synchronized void decNumThreads(){NUM_THREADS--;};
-
- public static synchronized void initialize(String testListPath)
- {
+ // Should be prime, so that odds of an incorrect verification reduced
+ public static int[] MethodID_Array = null;
- File td = new File (testListPath);
- if (!td.exists())
- {
- System.err.println("File " + testListPath + " Not found");
- System.exit(1);
- }
- if (!td.isFile())
- {
- System.err.println(testListPath + " Must be a File");
- System.exit(1);
- }
+ public static synchronized void initialize(String testListPath) {
+ File td = new File(testListPath);
+ if (!td.exists()) {
+ throw new Error("TESTBUG: File " + testListPath + " Not found");
+ }
+
+ if (!td.isFile()) {
+ throw new Error("TESTBUG: " + testListPath + " Must be a File");
+ }
BufferedReader classList = null;
-
- try
- {
- classList = new BufferedReader(new FileReader(td));
- }
- catch (FileNotFoundException fnfx)
- {
- System.err.println("Error finding Classlist");
- System.exit(1);
- }
-
- String line = null;
- try
- {
- line = classList.readLine();
- }
- catch (IOException iox)
- {
- System.err.println("Error reading Classlist");
- System.exit(1);
+ try {
+ try {
+ classList = new BufferedReader(new FileReader(td));
+ } catch (FileNotFoundException e) {
+ throw new Error("TESTBUG: Error finding Classlist", e);
}
- try
- {
- maxClassIndex = Math.abs(Integer.parseInt(line));//ClassArray.length;
+ String line = null;
+ try {
+ line = classList.readLine();
+ } catch (IOException e) {
+ throw new Error("TESTBUG: Error reading Classlist", e);
}
- catch (NumberFormatException nfx)
- {
- System.err.println("Error reading Classlist - first number must be number of methods defined");
- System.exit(1);
+
+ try {
+ // ClassArray.length;
+ maxClassIndex = Math.abs(Integer.parseInt(line));
+ } catch (NumberFormatException e) {
+ throw new Error("TESTBUG: Error reading Classlist - first number must be number of methods defined", e);
}
- ClassArray = new String [maxClassIndex];
-ClassInstanceArray = new Class [maxClassIndex];
- MethodName_Array = new String [maxClassIndex];
- MethodInstance_Array = new Method [maxClassIndex];
- MethodID_Array = new int [maxClassIndex];
+ ClassArray = new String[maxClassIndex];
+ ClassInstanceArray = new Class[maxClassIndex];
+ MethodName_Array = new String[maxClassIndex];
+ MethodInstance_Array = new Method[maxClassIndex];
+ MethodID_Array = new int[maxClassIndex];
- int i;
- for (i = 0; (i<maxClassIndex) && (line != null); i++)
- {
- try
- {
- line = classList.readLine();
- }
- catch (IOException iox)
- {
- System.err.println("Error reading ClasslistFile: testListPath");
- System.exit(1);
- }
+ int i;
+ for (i = 0; i < maxClassIndex; i++) {
+ try {
+ line = classList.readLine();
+ } catch (IOException e) {
+ throw new Error("TESTBUG: Error reading ClasslistFile: testListPath", e);
+ }
StringTokenizer lineTokens = new StringTokenizer(line, "\t ");
- if (lineTokens.countTokens() <3)
- {
- System.out.println("Error reading ClasslistFile: Errored line");
- i--;
- }
- else
- {
+ if (lineTokens.countTokens() < 3) {
+ throw new Error("TESTBUG: ClasslistFile: unexpected line:" + line);
+ } else {
ClassArray[i] = lineTokens.nextToken();
- MethodName_Array[i] =lineTokens.nextToken();
+ MethodName_Array[i] = lineTokens.nextToken();
MethodID_Array[i] = Integer.parseInt(lineTokens.nextToken());
- }
+ }
}
- maxClassIndex = i;
+ maxClassIndex = i;
+ } finally {
+ if (classList != null) {
+ try {
+ classList.close();
+ } catch (IOException e) {
+ throw new Error("can't close file", e);
+ }
+ }
+ }
- indexGenerator = new Random(RANDOM_SEED);
- if ((NUM_TEST_CLASSES < ClassArray.length) && (NUM_TEST_CLASSES > 0))
- maxClassIndex = NUM_TEST_CLASSES;
- else
- NUM_TEST_CLASSES = maxClassIndex;
+ if ((NUM_TEST_CLASSES < ClassArray.length) && (NUM_TEST_CLASSES > 0)) {
+ maxClassIndex = NUM_TEST_CLASSES;
+ } else {
+ NUM_TEST_CLASSES = maxClassIndex;
+ }
}
- //does a binary serach to find the index for the ID of a method
- private static int ID_BinSearch(int begin, int end, int ID)
- {
- if (end < begin)
- return(-1);
+ // does a binary search to find the index for the ID of a method
+ private static int ID_BinSearch(int begin, int end, int ID) {
+ if (end < begin) {
+ return (-1);
+ }
- int mid = (begin + end)/2;
+ int mid = (begin + end) / 2;
int midvalue = MethodID_Array[mid];
- if (ID == midvalue)
+ if (ID == midvalue) {
return (mid);
- else if (ID < midvalue)
- return(ID_BinSearch(begin, mid-1, ID));
- else
- return(ID_BinSearch(mid+1, end, ID));
+ } else if (ID < midvalue) {
+ return (ID_BinSearch(begin, mid - 1, ID));
+ } else {
+ return (ID_BinSearch(mid + 1, end, ID));
+ }
}
- //based off a static index, this function selects the method to be called
- public static MethodData returnNextStaticMethod(int Method_ID)
- {
- //int i = ID_BinSearch(0, MethodID_Array.length - 1, Method_ID);
- int i = ID_BinSearch(0, maxClassIndex - 1, Method_ID);
+ // based off a static index, this function selects the method to be called
+ public static MethodData returnNextStaticMethod(int Method_ID) {
+ //int i = ID_BinSearch(0, MethodID_Array.length - 1, Method_ID);
+ int i = ID_BinSearch(0, maxClassIndex - 1, Method_ID);
- return(nextStaticMethod((i==-1)?0:i));
+ return (nextStaticMethod((i == -1) ? 0 : i));
}
- //this function randomly selects the next method to be called by the test class
- public static MethodData nextRandomMethod()
- {
-
+ // this function randomly selects the next method to be called by the test class
+ public static MethodData nextRandomMethod() {
int i = indexGenerator.nextInt(maxClassIndex);
- return(nextStaticMethod(i));
+ return (nextStaticMethod(i));
}
- private static MethodData nextStaticMethod(int i)
- {
+ private static MethodData nextStaticMethod(int i) {
Class methodsClass = null;
Method nextMethod = null;
- try
- {
- //methodsClass = CGTTestLoader.findClass(ClassArray[i]);
- methodsClass = ClassInstanceArray[i];
- if (methodsClass == null)
- {
- methodsClass = Class.forName(ClassArray[i]);
- ClassInstanceArray[i] = methodsClass;
- }
- nextMethod = MethodInstance_Array[i];
- if (nextMethod == null )
- {
- nextMethod =
- methodsClass.getMethod(MethodName_Array[i],
- new Class[]{java.util.Vector.class, java.util.Vector.class,
- java.lang.Long.class, java.lang.Integer.class});
- //sum vector, ID vector, function depth, static function call depth
- MethodInstance_Array[i] = nextMethod;
- }
+ try {
+ methodsClass = ClassInstanceArray[i];
+ if (methodsClass == null) {
+ methodsClass = Class.forName(ClassArray[i]);
+ ClassInstanceArray[i] = methodsClass;
}
- catch (ClassNotFoundException cnfx)
- {
- System.out.println("Class: " +ClassArray[i]+ " Not Found");
- System.exit(-1);
+ nextMethod = MethodInstance_Array[i];
+ if (nextMethod == null) {
+ nextMethod = methodsClass.getMethod(MethodName_Array[i],
+ Vector.class, Vector.class, Long.class, Integer.class);
+ // sum vector, ID vector, function depth, static function call depth
+ MethodInstance_Array[i] = nextMethod;
}
- catch (NoSuchMethodException nsmx)
- {
- System.out.println("Class: " +ClassArray[i]);
- System.out.println("Method: " +MethodName_Array[i]+" Not Found");
- System.exit(-1);
- }
- catch (SecurityException sx)
- {
- System.out.println("Class: " +ClassArray[i]);
- System.out.println("Method: " +MethodName_Array[i]);
- System.out.println("Security Exception Generated, by above method call");
- System.exit(-1);
- }
- return(new MethodData(ClassArray[i], MethodName_Array[i], methodsClass, nextMethod, MethodID_Array[i]));
+ } catch (ClassNotFoundException e) {
+ throw new Error("TESTBUG Class: " + ClassArray[i] + " Not Found", e);
+ } catch (NoSuchMethodException e) {
+ throw new Error("TESTBUG Method: " + ClassArray[i] + "::" + MethodName_Array[i] + " Not Found", e);
+ } catch (SecurityException e) {
+ throw new Error("TESTBUG Security Exception Generated by " + ClassArray[i] + "::" + MethodName_Array[i], e);
+ }
+ return new MethodData(ClassArray[i], MethodName_Array[i], methodsClass, nextMethod, MethodID_Array[i]);
}
- /*These two functions are used to verify that all function were called in the proper order*/
+ /* These two functions are used to verify that all function were called in the proper order */
- //called by "parent" function to add childs ID to vector
- public static void addFunctionIDToVector(int FunctionIndex, Vector IDVector)
- {
- IDVector.addElement(new Integer(FunctionIndex));
+ // called by "parent" function to add childs ID to vector
+ public static void addFunctionIDToVector(int FunctionIndex, Vector IDVector) {
+ IDVector.addElement(FunctionIndex);
}
- //called by "child" to add Function Index to Vector
- public static void appendSumToSumationVector(int FunctionIndex, Vector SummationVector)
- {
- if (SummationVector.isEmpty())
- SummationVector.addElement(new Long(FunctionIndex));
- else
- SummationVector.addElement(new Long(((Long)SummationVector.lastElement()).longValue() + FunctionIndex));
+ // called by "child" to add Function Index to Vector
+ public static void appendSumToSummationVector(int FunctionIndex, Vector SummationVector) {
+ if (SummationVector.isEmpty()) {
+ SummationVector.addElement((long) FunctionIndex);
+ } else {
+ SummationVector.addElement((Long) SummationVector.lastElement() + FunctionIndex);
+ }
}
- //This function calls a method based off of MethodData
+ // This function calls a method based off of MethodData
public static void callMethod(MethodData methodCallStr,
Vector summation, Vector ID,
Long numFcalls, Integer staticFcalls)
- throws InvocationTargetException
-
- {
- if(NUM_THREADS >1)
- {
- if ((staticFcalls.intValue() + numFcalls.longValue()) %23 == 0)
- {
- try
- {
- Thread.sleep(225);
- }
- catch (InterruptedException ie)
- {}
- if (VERBOSE)
- System.out.println("\t\tCurrentThread:" + Thread.currentThread().getName());
- }
- }
-
- try
- {
- methodCallStr.nextMethod.invoke(methodCallStr.instance,
- new Object []{summation, ID, numFcalls, staticFcalls});
- }
- catch (IllegalAccessException iax) //should never happen with a valid testfile
- {
- throw new TestFailure("Illegal Access Exception");
- }
- /*
- catch (InvocationTargetException itx)
- {
- itx.printStackTrace();
- System.out.println("Invocation Target Exception");
- System.exit(1);
- }*/
+ throws InvocationTargetException {
+ try {
+ methodCallStr.nextMethod.invoke(methodCallStr.instance,
+ summation, ID, numFcalls, staticFcalls);
+ } catch (IllegalAccessException e) {
+ // should never happen with a valid testfile
+ throw new TestFailure("Illegal Access Exception", e);
+ }
}
}
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/MethodData.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/MethodData.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -20,37 +20,33 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package jit.graph;
-import java.lang.reflect.*;
+
+import java.lang.reflect.Method;
+
import nsk.share.TestFailure;
-public final class MethodData
-{
- public String ClassName;
- public String MethodName;
- public Class ClassObject;
- public Method nextMethod;
- public int id;
- public Object instance = null;
+public final class MethodData {
+ public String ClassName;
+ public String MethodName;
+ public Class ClassObject;
+ public Method nextMethod;
+ public int id;
+ public Object instance;
- MethodData(String ClassName, String MethodName, Class ClassObject,Method nextMethod, int id)
- {
- this.ClassName = ClassName;
- this.MethodName = MethodName;
- this.nextMethod = nextMethod;
- this.id = id;
- this.ClassObject = ClassObject;
- try
- {
- this.instance = ClassObject.newInstance();
- }
- catch (InstantiationException ix)
- {
- throw new TestFailure("Class: " +ClassName+ " Instantiation Exception");
- }
- catch (IllegalAccessException iax)
- {
- throw new TestFailure("Class: " +ClassName+ " Illegal Access Exception");
- }
- }
+ MethodData(String ClassName, String MethodName, Class ClassObject, Method nextMethod, int id) {
+ this.ClassName = ClassName;
+ this.MethodName = MethodName;
+ this.nextMethod = nextMethod;
+ this.id = id;
+ this.ClassObject = ClassObject;
+ try {
+ this.instance = ClassObject.newInstance();
+ } catch (InstantiationException e) {
+ throw new TestFailure("Class: " + ClassName + " Instantiation Exception", e);
+ } catch (IllegalAccessException e) {
+ throw new TestFailure("Class: " + ClassName + " Illegal Access Exception", e);
+ }
+ }
}
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/Node.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/Node.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -20,114 +20,102 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package jit.graph;
-import nsk.share.TestFailure;
// This class define the tree node.
-public class Node
-{
- public final static int Black = 0; // constants used to define the
- public final static int Red = 1; // node color
- public final static int Left_son = 2; // constants used to identify
- public final static int Right_son = 3;// the node parent and sons.
- public final static int Parent = 4;
+public class Node {
+ public final static int Black = 0; // constants used to define the
+ public final static int Red = 1; // node color
+ public final static int Left_son = 2; // constants used to identify
+ public final static int Right_son = 3;// the node parent and sons.
+ public final static int Parent = 4;
-
- private int color;
- private int key;
- private Node L,R,P; // L-left son,R-right son,P-parent
+ private int color;
+ private int key;
+ private Node L, R, P; // L-left son,R-right son,P-parent
- // constructor create a new node the default color is red
- // the default appearance (bold) is regular.
- // initialize the key field.
+ // constructor create a new node the default color is red
+ // the default appearance (bold) is regular.
+ // initialize the key field.
- public Node(int k)
- {
- color = Red;
- key = k;
- L = null;
- R = null;
- P = null;
- }
+ public Node(int k) {
+ color = Red;
+ key = k;
+ L = null;
+ R = null;
+ P = null;
+ }
- // constructor for constructing a tree null object, is color
- // is black.
+ // constructor for constructing a tree null object, is color
+ // is black.
- public Node()
- {
- color = Black;
- key = -1;
- L = null;
- R = null;
- P = null;
- }
+ public Node() {
+ color = Black;
+ key = -1;
+ L = null;
+ R = null;
+ P = null;
+ }
- // This method set the node key.
+ // This method set the node key.
- public void setKey(int k)
- {
- key = k;
- }
+ public void setKey(int k) {
+ key = k;
+ }
- // This method return the node key.
+ // This method return the node key.
- public int getKey()
- {
- return (key);
- }
+ public int getKey() {
+ return (key);
+ }
- // This method set the node color.
+ // This method set the node color.
- public void setColor(int c)
- {
- if (c == Black)
- color = Black;
- else
- if (c == Red)
+ public void setColor(int c) {
+ if (c == Black) {
+ color = Black;
+ } else if (c == Red) {
color = Red;
- }
+ }
+ }
- // This method return the node color.
+ // This method return the node color.
- public int getColor()
- {
- return (color);
- }
+ public int getColor() {
+ return (color);
+ }
- // This method set the node parent or childs acording to the who
- // parameter.
+ // This method set the node parent or childs acording to the who
+ // parameter.
- public void setNode(int who,Node n)
- {
- switch (who)
- {
- case Left_son:
- L = n;
- break;
- case Right_son:
- R = n;
- break;
- case Parent:
- P = n;
- break;
- }
- }
+ public void setNode(int who, Node n) {
+ switch (who) {
+ case Left_son:
+ L = n;
+ break;
+ case Right_son:
+ R = n;
+ break;
+ case Parent:
+ P = n;
+ break;
+ }
+ }
- // This method return the node parent or childs acording to the who
- // parameter.
+ // This method return the node parent or childs acording to the who
+ // parameter.
- public Node getNode(int who)
- {
- switch (who)
- {
- case Left_son:
- return (L);
- case Right_son:
- return (R);
- case Parent:
- return (P);
- }
- return (null);
- }
+ public Node getNode(int who) {
+ switch (who) {
+ case Left_son:
+ return L;
+ case Right_son:
+ return R;
+ case Parent:
+ return P;
+ }
+ return null;
+ }
}
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/RBTree.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/RBTree.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -20,708 +20,626 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package jit.graph;
-import nsk.share.TestFailure;
-
-//import Node;
-
// This class defines the tree object.
-
-public class RBTree
-{
- public final static int maxNodes = 70; // maximum nodes allowed.
- public final static int INSERT = 0; // constants indicating
- public final static int DELETE = 1; // the current operation
- public final static int NOP = 2;
- public final static Node treeNull = new Node(); // the tree NULL node.
+public class RBTree {
+ public final static int maxNodes = 70; // maximum nodes allowed.
+ public final static int INSERT = 0; // constants indicating
+ public final static int DELETE = 1; // the current operation
+ public final static int NOP = 2;
+ public final static Node treeNull = new Node(); // the tree NULL node.
- private Node root;
- private int num_of_nodes;
- private int height; // The tree heigth ,it is updated
- // in each operation.
+ private Node root;
+ private int num_of_nodes;
+ private int height; // The tree height, it is updated
+ // in each operation.
- // since the algorithem is executed in stages I have to remember data
- // on the state.
- private Node node; // The current operation is being done on it.
- private int action;// The operation being performed (insert / delete)
- private int stage; // The current stage of execution
-
- // the constructor initialize the object fields.
+ // since the algorithm is executed in stages I have to remember data
+ // on the state.
+ private Node node; // The current operation is being done on it.
+ private int action; // The operation being performed (insert / delete)
+ private int stage; // The current stage of execution
- public RBTree()
- {
- root = treeNull;
- node = treeNull;
- num_of_nodes = 0;
- height = 0;
- action = NOP;
- stage = 0;
- }
-
- // This method return the root of the tree.
+ // the constructor initializes the object fields.
+ public RBTree() {
+ root = treeNull;
+ node = treeNull;
+ num_of_nodes = 0;
+ height = 0;
+ action = NOP;
+ stage = 0;
+ }
- public Node getRoot()
- {
- return root;
- }
-
- // This method return the number of nodes in the tree.
+ // This method returns the root of the tree.
+ public Node getRoot() {
+ return root;
+ }
- public int getNodes()
- {
- return num_of_nodes;
- }
+ // This method returns the number of nodes in the tree.
+ public int getNodes() {
+ return num_of_nodes;
+ }
- // This method return the heigth of the tree.
-
- public int getHeight()
- {
- return height;
- }
+ // This method returns the height of the tree.
+ public int getHeight() {
+ return height;
+ }
-
- // This method inserts k into the Red Black Tree
+ // This method inserts k into the Red Black Tree
+ public boolean RBInsert(int k) {
+ // checking similar to the RB_Insert method
+ if (action != NOP) {
+ System.out.println("Only one operation can be done at a time.");
+ return false;
+ }
- public boolean RBInsert(int k)
- {
+ if (num_of_nodes == maxNodes) {
+ System.out.println("The maximum nodes allowed is already reached.");
+ return false;
+ }
- Thread Pause = new Thread(); // this thread is used for delay
- // between the stages.
- if (action != NOP) // checking similar to the RB_Insert method
- {
- System.out.println
- ("Only one operation can be done at a time.");
- return false;
- }
- if (num_of_nodes == maxNodes)
- {
- System.out.println
- ("The maximum nodes allowed is already reached.");
- return false;
- }
- if (Search(k) == treeNull) // Check if there is already node with key k.
- {
- action = INSERT;
- node = new Node(k);
- node.setNode(Node.Left_son,treeNull);
- node.setNode(Node.Right_son,treeNull);
- node.setNode(Node.Parent,treeNull);
- stage = 1;
- while (stage != 0) // This is the loop that perform all the
- { // operation steps.
- InsertStep(); // perform one step
- updateHeight(); // update the tree height
- }
- action = NOP; // set the action to NoOPretion.
- return true;
- }
- else
- System.out.println
- ("Insertion failed. This key already exist.");
- return false;
- }
+ // Check if there is already node with key k.
+ if (Search(k) == treeNull) {
+ action = INSERT;
+ node = new Node(k);
+ node.setNode(Node.Left_son, treeNull);
+ node.setNode(Node.Right_son, treeNull);
+ node.setNode(Node.Parent, treeNull);
+ stage = 1;
+ // This is the loop that perform all the operation steps.
+ while (stage != 0) {
+ // perform one step
+ InsertStep();
+ // update the tree height
+ updateHeight();
+ }
+ // set the action to NoOPretion.
+ action = NOP;
+ return true;
+ } else
+ System.out.println("Insertion failed. This key already exist.");
+ return false;
+ }
- // This method deletes the element k from the Red Black tree
-
- public boolean RBDelete(int k)
- {
- Thread Pause = new Thread(); // this thread is used for delay
- // between the stages.
- if (action != NOP)
- { // checking like in RB_Delete method
- System.out.println
- ("Only one operation can be done at a time.");
- return false;
- }
- node = Search(k);
- if (node != treeNull) // Check if there is a node with key k.
- {
- action = DELETE;
- stage = 1;
- while (stage != 0) // this loop perform all the operation
- { // steps.
- DeleteStep(); // perform one step
- updateHeight(); // update the tree height
-
- }
- action = NOP;
- return true;
- }
- else
- System.out.println
- ("Deletion failed. This key doesn't exist.");
- return false;
- }
+ // This method deletes the element k from the Red Black tree
+ public boolean RBDelete(int k) {
+ // checking like in RB_Delete method
+ if (action != NOP) {
+ System.out.println("Only one operation can be done at a time.");
+ return false;
+ }
+ node = Search(k);
+ // Check if there is a node with key k.
+ if (node != treeNull) {
+ action = DELETE;
+ stage = 1;
+ // this loop perform all the operation steps.
+ while (stage != 0) {
+ // perform one step
+ DeleteStep();
+ // update the tree height
+ updateHeight();
+ }
+ action = NOP;
+ return true;
+ } else
+ System.out.println("Deletion failed. This key doesn't exist.");
+ return false;
+ }
- // This method perform one step in the insertion operation.
- // If perform a step acording to the stage variable.
- // I will not explain exactly what each stage do, just that they
- // divided to 4 categories:
- // 1. inserting a node to the tree.
- // 2. marking nodes that will be recolored.
- // 3. recoloring nodes.
- // 4. rotating right or left.
-
- private void InsertStep()
- {
- Node Pr,GrPr,Un; // Pr is parent, GrPr is grandparent
- // and Un is uncle.
- switch (stage)
- {
- case 1: // Inserting a node to the tree
- /*
- System.out.println // send a message to the screen
- (new String("Inserting ")
- .concat(Integer.toString(node.getKey())));
- */
- Tree_Insert(); // inserting an element to the tree
- break;
- case 2: // mid stage that move to algorithem to the
- // proper next stage, and send proper message
- // to the screen
- Pr = node.getNode(Node.Parent);
- GrPr = Pr.getNode(Node.Parent);
- if (Pr == GrPr.getNode(Node.Left_son))
- {
- Un = GrPr.getNode(Node.Right_son);
- if (Un.getColor() == Node.Red)
- {
+ // This method performs one step in the insertion operation.
+ // It performs a step according to the stage variable.
+ // I will not explain exactly what each stage do, just that they
+ // divided to 4 categories:
+ // 1. inserting a node to the tree.
+ // 2. marking nodes that will be recolored.
+ // 3. recoloring nodes.
+ // 4. rotating right or left.
+ private void InsertStep() {
+ // Pr is parent, GrPr is grandparent and Un is uncle.
+ Node Pr, GrPr, Un;
+ switch (stage) {
+ // Inserting a node to the tree
+ case 1:
+ Tree_Insert();
+ break;
+ // mid stage that moves the algorithm to the proper next stage
+ case 2:
+ Pr = node.getNode(Node.Parent);
+ GrPr = Pr.getNode(Node.Parent);
+ if (Pr == GrPr.getNode(Node.Left_son)) {
+ Un = GrPr.getNode(Node.Right_son);
+ if (Un.getColor() == Node.Red) {
+ stage = 3;
+ } else if (node == Pr.getNode(Node.Right_son)) {
+ node = Pr;
+ stage = 5;
+ } else {
+ stage = 6;
+ }
+ } else {
+ Un = GrPr.getNode(Node.Left_son);
+ if (Un.getColor() == Node.Red) {
stage = 3;
- }
- else
- if (node == Pr.getNode(Node.Right_son))
- {
- node = Pr;
- stage = 5;
- }
- else
- {
- stage = 6;
- }
- }
- else
- {
- Un = GrPr.getNode(Node.Left_son);
- if (Un.getColor() == Node.Red)
- {
- stage = 3;
- }
- else
- if (node == Pr.getNode(Node.Left_son))
- {
- node = Pr;
- stage = 5;
- }
- else
- {
- stage = 6;
- }
- }
- break;
- case 3: // This stage marks node that will be recolored
- Pr = node.getNode(Node.Parent);
- GrPr = Pr.getNode(Node.Parent);
- if (Pr == GrPr.getNode(Node.Left_son))
- Un = GrPr.getNode(Node.Right_son);
- else
- Un = GrPr.getNode(Node.Left_son);
+ } else if (node == Pr.getNode(Node.Left_son)) {
+ node = Pr;
+ stage = 5;
+ } else {
+ stage = 6;
+ }
+ }
+ break;
+ // This stage marks node that will be recolored
+ case 3:
+ Pr = node.getNode(Node.Parent);
+ GrPr = Pr.getNode(Node.Parent);
+ if (Pr == GrPr.getNode(Node.Left_son)) {
+ Un = GrPr.getNode(Node.Right_son);
+ } else {
+ Un = GrPr.getNode(Node.Left_son);
+ }
+ node = GrPr;
+ stage = 4;
+ break;
+ // This stage recolors marked nodes.
+ case 4:
+ node.setColor(Node.Red);
+ node.getNode(Node.Left_son).setColor(Node.Black);
+ node.getNode(Node.Right_son).setColor(Node.Black);
- node = GrPr;
- stage = 4;
- break;
- case 4: // this stage recolor marked nodes.
- node.setColor(Node.Red);
- (node.getNode(Node.Left_son)).setColor(Node.Black);
- (node.getNode(Node.Right_son)).setColor(Node.Black);
-
- if ((node == root) ||
- ((node.getNode(Node.Parent)).getColor() == Node.Black))
- if (root.getColor() == Node.Red)
- {
+ if ((node == root) ||
+ (node.getNode(Node.Parent).getColor() == Node.Black)) {
+ if (root.getColor() == Node.Red) {
stage = 9;
- }
- else
+ } else
stage = 0;
- else
- {
- stage = 2;
- InsertStep();
- }
- break;
- case 5: // This stage perform rotation operation
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- Left_Rotate(node);
- else
- Right_Rotate(node);
+ } else {
+ stage = 2;
+ InsertStep();
+ }
+ break;
+ // This stage performs rotation operation
+ case 5:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Left_Rotate(node);
+ } else {
+ Right_Rotate(node);
+ }
+ stage = 6;
+ break;
+ // This stage marks nodes that will be recolor.
+ case 6:
+ Pr = node.getNode(Node.Parent);
+ GrPr = Pr.getNode(Node.Parent);
- stage = 6;
- break;
- case 6: // This stage marks nodes that will be recolor.
- Pr = node.getNode(Node.Parent);
- GrPr = Pr.getNode(Node.Parent);
-
- stage = 7;
- break;
- case 7: // This stage recolor marked nodes.
- Pr = node.getNode(Node.Parent);
- Pr.setColor(Node.Black);
- GrPr = Pr.getNode(Node.Parent);
- GrPr.setColor(Node.Red);
+ stage = 7;
+ break;
+ // This stage recolors marked nodes.
+ case 7:
+ Pr = node.getNode(Node.Parent);
+ Pr.setColor(Node.Black);
+ GrPr = Pr.getNode(Node.Parent);
+ GrPr.setColor(Node.Red);
- stage = 8;
- break;
- case 8: // This stage perform rotation operation
- Pr = node.getNode(Node.Parent);
- GrPr = Pr.getNode(Node.Parent);
- if (Pr == GrPr.getNode(Node.Left_son))
- Right_Rotate(GrPr);
- else
- Left_Rotate(GrPr);
- if (root.getColor() == Node.Red)
- {
- stage = 9;
- }
- else
- stage = 0;
- break;
- case 9: // this stage mark the root.
- stage = 10;
- break;
- case 10: // This stage recolor the root.
- root.setColor(Node.Black);
- stage = 0;
- break;
- }
- }
+ stage = 8;
+ break;
+ // This stage performs rotation operation
+ case 8:
+ Pr = node.getNode(Node.Parent);
+ GrPr = Pr.getNode(Node.Parent);
+ if (Pr == GrPr.getNode(Node.Left_son)) {
+ Right_Rotate(GrPr);
+ } else {
+ Left_Rotate(GrPr);
+ }
+ if (root.getColor() == Node.Red) {
+ stage = 9;
+ } else
+ stage = 0;
+ break;
+ // this stage marks the root.
+ case 9:
+ stage = 10;
+ break;
+ // This stage recolors the root.
+ case 10:
+ root.setColor(Node.Black);
+ stage = 0;
+ break;
+ }
+ }
- // This method perform one step in the deletion operation.
- // If perform a step acording to the stage variable.
- // I will explain exactly what each stage do, just that they
- // divided to 4 categories:
- // 1. deleting a node from the tree.
- // 2. marking nodes that will be recolored.
- // 3. recoloring nodes.
- // 4. rotating right or left.
+ // This method performs one step in the deletion operation.
+ // It perform sa step according to the stage variable.
+ // I will explain exactly what each stage do, just that they
+ // divided to 4 categories:
+ // 1. deleting a node from the tree.
+ // 2. marking nodes that will be recolored.
+ // 3. recoloring nodes.
+ // 4. rotating right or left.
+ public void DeleteStep() {
+ // Pr is Parent, Br is Brother
+ Node Pr, Br;
+ switch (stage) {
+ // This stage delete a node from the tree.
+ case 1:
+ Tree_Delete();
+ break;
+ // This stage marks a nodes that will be recolored or perform other stage.
+ case 2:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Br = Pr.getNode(Node.Right_son);
+ } else {
+ Br = Pr.getNode(Node.Left_son);
+ }
+ if (Br.getColor() == Node.Red) {
+ stage = 3;
+ } else if ((Br.getNode(Node.Right_son).getColor() == Node.Black)
+ && (Br.getNode(Node.Left_son).getColor() == Node.Black)) {
+ stage = 5;
+ DeleteStep();
+ } else {
+ stage = 7;
+ DeleteStep();
+ }
+ break;
+ // This stage recolors marked nodes.
+ case 3:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Br = Pr.getNode(Node.Right_son);
+ } else {
+ Br = Pr.getNode(Node.Left_son);
+ }
+ Br.setColor(Node.Black);
+ Pr.setColor(Node.Red);
- public void DeleteStep()
- {
- Node Pr,Br; // Pr is Parent ,Br is Brother
- switch (stage)
- {
- case 1: // This stage delete a node from the tree.
- /*
- System.out.println
- (new String("Deleting ")
- .concat(Integer.toString(node.getKey())));
- */
- Tree_Delete();
- break;
- case 2: // This stage marks a nodes that will be recolored
- // or perform other stage.
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- Br = Pr.getNode(Node.Right_son);
- else
- Br = Pr.getNode(Node.Left_son);
- if (Br.getColor() == Node.Red)
- {
- stage = 3;
+ stage = 4;
+ break;
+ // This stage performs rotation operation
+ case 4:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Left_Rotate(Pr);
+ Br = Pr.getNode(Node.Right_son);
+ } else {
+ Right_Rotate(Pr);
+ Br = Pr.getNode(Node.Left_son);
+ }
+ if ((Br.getNode(Node.Right_son).getColor() == Node.Black)
+ && (Br.getNode(Node.Left_son).getColor() == Node.Black)) {
+ stage = 5;
+ } else {
+ stage = 7;
+ }
+
+ break;
+ // This stage marks nodes that will be recolor.
+ case 5:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Br = Pr.getNode(Node.Right_son);
+ } else {
+ Br = Pr.getNode(Node.Left_son);
+ }
+ stage = 6;
+ break;
+ // This stage recolors marked nodes.
+ case 6:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Br = Pr.getNode(Node.Right_son);
+ } else {
+ Br = Pr.getNode(Node.Left_son);
+ }
+ Br.setColor(Node.Red);
+ node = Pr;
+
+ if ((node != root) && (node.getColor() == Node.Black)) {
+ stage = 2;
+ } else if (node.getColor() == Node.Red) {
+ stage = 13;
+ } else
+ stage = 0;
+ break;
+ // This stage marks nodes that will be recolor or perform other stage.
+ case 7:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Br = Pr.getNode(Node.Right_son);
+ if ((Br.getNode(Node.Right_son)).getColor() == Node.Black) {
+ stage = 8;
+ } else {
+ stage = 10;
+ DeleteStep();
}
- else
- if (((Br.getNode(Node.Right_son)).getColor() == Node.Black)
- && ((Br.getNode(Node.Left_son)).getColor() == Node.Black))
- {
- stage = 5;
- DeleteStep();
- }
- else
- {
- stage = 7;
- DeleteStep();
- }
- break;
- case 3: // this stage recolor marked nodes.
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- {
- Br = Pr.getNode(Node.Right_son);
-
- }
- else
- {
- Br = Pr.getNode(Node.Left_son);
- }
- Br.setColor(Node.Black);
- Pr.setColor(Node.Red);
-
- stage = 4;
- break;
- case 4: // this stage perform rotation operation
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- {
- Left_Rotate(Pr);
- Br = Pr.getNode(Node.Right_son);
- }
- else
- {
- Right_Rotate(Pr);
- Br = Pr.getNode(Node.Left_son);
- }
- if (((Br.getNode(Node.Right_son)).getColor() == Node.Black)
- && ((Br.getNode(Node.Left_son)).getColor() == Node.Black))
- stage = 5;
- else
- stage = 7;
-
- break;
- case 5: // this stage marks nodes that will be recolor.
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- Br = Pr.getNode(Node.Right_son);
- else
- Br = Pr.getNode(Node.Left_son);
-
- stage = 6;
- break;
- case 6: // This stage recolor marked nodes.
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- Br = Pr.getNode(Node.Right_son);
- else
- Br = Pr.getNode(Node.Left_son);
- Br.setColor(Node.Red);
- node = Pr;
-
- if ((node != root) && (node.getColor() == Node.Black))
- stage = 2;
- else
- if (node.getColor() == Node.Red)
- {
- stage = 13;
- }
- else
- stage = 0;
- break;
- case 7: // this stage marks nodes that will be recolor
- // or perform other stage.
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- {
- Br = Pr.getNode(Node.Right_son);
- if ((Br.getNode(Node.Right_son)).getColor() == Node.Black)
- {
- stage = 8;
- }
- else
- {
- stage = 10;
- DeleteStep();
- }
+ } else {
+ Br = Pr.getNode(Node.Left_son);
+ if ((Br.getNode(Node.Left_son)).getColor() == Node.Black) {
+ stage = 8;
+ } else {
+ stage = 10;
+ DeleteStep();
}
- else
- {
- Br = Pr.getNode(Node.Left_son);
- if ((Br.getNode(Node.Left_son)).getColor() == Node.Black)
- {
- stage = 8;
- }
- else
- {
- stage = 10;
- DeleteStep();
- }
- }
- break;
- case 8: // this stage recolor marked nodes.
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- {
- Br = Pr.getNode(Node.Right_son);
- (Br.getNode(Node.Left_son)).setColor(Node.Black);
-
- }
- else
- {
- Br = Pr.getNode(Node.Left_son);
- (Br.getNode(Node.Right_son)).setColor(Node.Black);
+ }
+ break;
+ // This stage recolors marked nodes.
+ case 8:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Br = Pr.getNode(Node.Right_son);
+ Br.getNode(Node.Left_son).setColor(Node.Black);
+ } else {
+ Br = Pr.getNode(Node.Left_son);
+ Br.getNode(Node.Right_son).setColor(Node.Black);
+ }
+ Br.setColor(Node.Red);
+ stage = 9;
+ break;
+ // This stage performs rotation operation
+ case 9:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Br = Pr.getNode(Node.Right_son);
+ Right_Rotate(Br);
+ } else {
+ Br = Pr.getNode(Node.Left_son);
+ Left_Rotate(Br);
+ }
- }
- Br.setColor(Node.Red);
- stage = 9;
- break;
- case 9: // this stage perform rotation operation
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- {
- Br = Pr.getNode(Node.Right_son);
- Right_Rotate(Br);
- }
- else
- {
- Br = Pr.getNode(Node.Left_son);
- Left_Rotate(Br);
- }
-
- stage = 10;
- break;
- case 10: // This stage marks node that will be recolor.
+ stage = 10;
+ break;
+ // This stage marks node that will be recolor.
+ case 10:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Br = Pr.getNode(Node.Right_son);
+ } else {
+ Br = Pr.getNode(Node.Left_son);
+ }
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- {
- Br = Pr.getNode(Node.Right_son);
- }
- else
- {
- Br = Pr.getNode(Node.Left_son);
- }
+ stage = 11;
+ break;
+ // This stage recolors marked nodes.
+ case 11:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Br = Pr.getNode(Node.Right_son);
+ Br.getNode(Node.Right_son).setColor(Node.Black);
+ } else {
+ Br = Pr.getNode(Node.Left_son);
+ Br.getNode(Node.Left_son).setColor(Node.Black);
- stage = 11;
- break;
- case 11: // this stage recolor marked nodes.
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- {
- Br = Pr.getNode(Node.Right_son);
- (Br.getNode(Node.Right_son)).setColor(Node.Black);
- }
- else
- {
- Br = Pr.getNode(Node.Left_son);
- (Br.getNode(Node.Left_son)).setColor(Node.Black);
+ }
+ if (Br.getColor() != Pr.getColor()) {
+ Br.setColor(Pr.getColor());
+ }
+ if (Pr.getColor() != Node.Black) {
+ Pr.setColor(Node.Black);
+ }
- }
- if (Br.getColor() != Pr.getColor())
- Br.setColor(Pr.getColor());
- if (Pr.getColor() != Node.Black)
- Pr.setColor(Node.Black);
-
- stage = 12;
- break;
- case 12: // this stage perform rotation operation.
- Pr = node.getNode(Node.Parent);
- if (node == Pr.getNode(Node.Left_son))
- Left_Rotate(Pr);
- else
- Right_Rotate(Pr);
- node = root;
- if (node.getColor() == Node.Red)
- {
- stage = 13;
- }
- else
- stage = 0;
- break;
- case 13: // this stage marks a node that will be recolor
- stage = 14;
- break;
- case 14: // this stage recolor marked node.
- node.setColor(Node.Black);
+ stage = 12;
+ break;
+ // This stage performs rotation operation.
+ case 12:
+ Pr = node.getNode(Node.Parent);
+ if (node == Pr.getNode(Node.Left_son)) {
+ Left_Rotate(Pr);
+ } else {
+ Right_Rotate(Pr);
+ }
+ node = root;
+ if (node.getColor() == Node.Red) {
+ stage = 13;
+ } else {
stage = 0;
- break;
- }
- }
-
- // This method insert the node 'node' to the tree.
- // it called from the first stage in the InsertStep method.
- // we 'dive' from the root to a leaf acording to the node key
- // and insert the node in the proper place.
+ }
+ break;
+ // This stage marks a node that will be recolored
+ case 13:
+ stage = 14;
+ break;
+ // This stage recolors marked node.
+ case 14:
+ node.setColor(Node.Black);
+ stage = 0;
+ break;
+ }
+ }
- private void Tree_Insert()
- {
- Node n1,n2;
- n1 = root;
- n2 = treeNull;
- while (n1 != treeNull)
- {
- n2 = n1;
- if (node.getKey() < n1.getKey())
- n1 = n1.getNode(Node.Left_son);
- else
- n1 = n1.getNode(Node.Right_son);
- }
- node.setNode(Node.Parent,n2);
- if (n2 == treeNull)
- root = node;
- else
- {
- if (node.getKey() < n2.getKey())
- n2.setNode(Node.Left_son,node);
- else
- n2.setNode(Node.Right_son,node);
- }
- //Parent.display.drawTree();
- // updating the insertion stage.
- if ((node == root) ||
- ((node.getNode(Node.Parent)).getColor() == Node.Black))
- if (root.getColor() == Node.Red)
- {
- stage = 9;
- }
- else
- stage = 0;
- else
- {
- stage = 2;
- InsertStep();
- }
- num_of_nodes++; // increasing the number of nodes
- }
+ // This method inserts the node 'node' to the tree.
+ // it called from the first stage in the InsertStep method.
+ // we 'dive' from the root to a leaf according to the node key
+ // and insert the node in the proper place.
+ private void Tree_Insert() {
+ Node n1, n2;
+ n1 = root;
+ n2 = treeNull;
+ while (n1 != treeNull) {
+ n2 = n1;
+ if (node.getKey() < n1.getKey()) {
+ n1 = n1.getNode(Node.Left_son);
+ } else {
+ n1 = n1.getNode(Node.Right_son);
+ }
+ }
+ node.setNode(Node.Parent, n2);
+ if (n2 == treeNull) {
+ root = node;
+ }
+ else {
+ if (node.getKey() < n2.getKey()) {
+ n2.setNode(Node.Left_son, node);
+ } else {
+ n2.setNode(Node.Right_son, node);
+ }
+ }
+ // updating the insertion stage.
+ if ((node == root) ||
+ (node.getNode(Node.Parent).getColor() == Node.Black)) {
+ if (root.getColor() == Node.Red) {
+ stage = 9;
+ } else {
+ stage = 0;
+ }
+ } else {
+ stage = 2;
+ InsertStep();
+ }
+ num_of_nodes++; // increasing the number of nodes
+ }
- // This method delete the node 'node' from the tree.
- // it called from the first stage in the DeleteStep method.
- // if node has at most one son we just remove it and connect
- // his son and parent. If it has 2 sons we delete his successor
- // that has at most one son and replace him with the successor.
+ // This method deletes the node 'node' from the tree.
+ // it called from the first stage in the DeleteStep method.
+ // if node has at most one son we just remove it and connect
+ // his son and parent. If it has 2 sons we delete his successor
+ // that has at most one son and replace him with the successor.
+ private void Tree_Delete() {
+ Node n1, n2, n3;
+ if ((node.getNode(Node.Left_son) == treeNull) ||
+ (node.getNode(Node.Right_son) == treeNull)) {
+ n1 = node;
+ } else {
+ n1 = Tree_Successor(node);
+ }
- private void Tree_Delete()
- {
- Node n1,n2,n3;
- if ((node.getNode(Node.Left_son) == treeNull) ||
- (node.getNode(Node.Right_son) == treeNull))
- n1 = node;
- else
- n1 = Tree_Successor(node);
- if (n1.getNode(node.Left_son) != treeNull)
- n2 = n1.getNode(Node.Left_son);
- else
- n2 = n1.getNode(Node.Right_son);
+ if (n1.getNode(Node.Left_son) != treeNull) {
+ n2 = n1.getNode(Node.Left_son);
+ } else {
+ n2 = n1.getNode(Node.Right_son);
+ }
- n3 = n1.getNode(Node.Parent);
- n2.setNode(Node.Parent,n3);
- if (n3 == treeNull)
- root = n2;
- else
- if (n1 == n3.getNode(Node.Left_son))
- n3.setNode(Node.Left_son,n2);
- else
- n3.setNode(Node.Right_son,n2);
+ n3 = n1.getNode(Node.Parent);
+ n2.setNode(Node.Parent, n3);
+ if (n3 == treeNull) {
+ root = n2;
+ } else if (n1 == n3.getNode(Node.Left_son)) {
+ n3.setNode(Node.Left_son, n2);
+ } else {
+ n3.setNode(Node.Right_son, n2);
+ }
- if (n1 != node)
- {
- node.setKey(n1.getKey());
- }
-
+ if (n1 != node) {
+ node.setKey(n1.getKey());
+ }
- node = n2;
- if (n1.getColor() == Node.Black)
- if ((node != root) && (node.getColor() == Node.Black))
- stage = 2;
- else
- if (node.getColor() == Node.Red)
- stage = 13;
- else
- stage = 0;
- else
- stage = 0;
- num_of_nodes--; // decrease the number of nodes.
- }
-
- // This method return the successor of the node n in the tree.
+ node = n2;
+ if (n1.getColor() == Node.Black) {
+ if ((node != root) && (node.getColor() == Node.Black)) {
+ stage = 2;
+ } else if (node.getColor() == Node.Red) {
+ stage = 13;
+ } else {
+ stage = 0;
+ }
+ } else {
+ stage = 0;
+ }
+ // decrease the number of nodes.
+ num_of_nodes--;
+ }
- private Node Tree_Successor(Node n)
- {
- Node n1;
- if (n.getNode(Node.Right_son) != treeNull)
- {
- n = n.getNode(Node.Right_son);
- while (n.getNode(Node.Left_son) != treeNull)
- n = n.getNode(Node.Left_son);
- return n;
- }
- n1 = n.getNode(Node.Parent);
- while ((n1 != treeNull) && (n == n1.getNode(Node.Right_son)))
- {
- n = n1;
- n1 = n1.getNode(Node.Parent);
- }
- return n1;
- }
+ // This method returns the successor of the node n in the tree.
+ private Node Tree_Successor(Node n) {
+ Node n1;
+ if (n.getNode(Node.Right_son) != treeNull) {
+ n = n.getNode(Node.Right_son);
+ while (n.getNode(Node.Left_son) != treeNull) {
+ n = n.getNode(Node.Left_son);
+ }
+ return n;
+ }
+ n1 = n.getNode(Node.Parent);
+ while ((n1 != treeNull) && (n == n1.getNode(Node.Right_son))) {
+ n = n1;
+ n1 = n1.getNode(Node.Parent);
+ }
+ return n1;
+ }
- // This method perform Left Rotation with n1.
+ // This method performs Left Rotation with n1.
+ private void Left_Rotate(Node n1) {
+ Node n2;
- private void Left_Rotate(Node n1)
- {
- Node n2;
+ n2 = n1.getNode(Node.Right_son);
+ n1.setNode(Node.Right_son, n2.getNode(Node.Left_son));
+ if (n2.getNode(Node.Left_son) != treeNull) {
+ n2.getNode(Node.Left_son).setNode(Node.Parent, n1);
+ }
+ n2.setNode(Node.Parent, n1.getNode(Node.Parent));
+ if (n1.getNode(Node.Parent) == treeNull) {
+ root = n2;
+ } else if (n1 == n1.getNode(Node.Parent).getNode(Node.Left_son)) {
+ n1.getNode(Node.Parent).setNode(Node.Left_son, n2);
+ } else {
+ n1.getNode(Node.Parent).setNode(Node.Right_son, n2);
+ }
+ n2.setNode(Node.Left_son, n1);
+ n1.setNode(Node.Parent, n2);
+ }
- n2 = n1.getNode(Node.Right_son);
- n1.setNode(Node.Right_son,n2.getNode(Node.Left_son));
- if (n2.getNode(Node.Left_son) != treeNull)
- (n2.getNode(Node.Left_son)).setNode(Node.Parent,n1);
- n2.setNode(Node.Parent,n1.getNode(Node.Parent));
- if (n1.getNode(Node.Parent) == treeNull)
- root = n2;
- else
- if (n1 == (n1.getNode(Node.Parent)).getNode(Node.Left_son))
- (n1.getNode(Node.Parent)).setNode(Node.Left_son,n2);
- else
- (n1.getNode(Node.Parent)).setNode(Node.Right_son,n2);
- n2.setNode(Node.Left_son,n1);
- n1.setNode(Node.Parent,n2);
- }
-
- // This method perform Right Rotation with n1.
-
- private void Right_Rotate(Node n1)
- {
- Node n2;
+ // This method performs Right Rotation with n1.
+ private void Right_Rotate(Node n1) {
+ Node n2;
- n2 = n1.getNode(Node.Left_son);
- n1.setNode(Node.Left_son,n2.getNode(Node.Right_son));
- if (n2.getNode(Node.Right_son) != treeNull)
- (n2.getNode(Node.Right_son)).setNode(Node.Parent,n1);
- n2.setNode(Node.Parent,n1.getNode(Node.Parent));
- if (n1.getNode(Node.Parent) == treeNull)
- root = n2;
- else
- if (n1 == (n1.getNode(Node.Parent)).getNode(Node.Left_son))
- (n1.getNode(Node.Parent)).setNode(Node.Left_son,n2);
- else
- (n1.getNode(Node.Parent)).setNode(Node.Right_son,n2);
- n2.setNode(Node.Right_son,n1);
- n1.setNode(Node.Parent,n2);
- }
-
- // This method search the tree for a node with key 'key', and
- // return the node on success otherwise treeNull.
+ n2 = n1.getNode(Node.Left_son);
+ n1.setNode(Node.Left_son, n2.getNode(Node.Right_son));
+ if (n2.getNode(Node.Right_son) != treeNull) {
+ n2.getNode(Node.Right_son).setNode(Node.Parent, n1);
+ }
+ n2.setNode(Node.Parent, n1.getNode(Node.Parent));
+ if (n1.getNode(Node.Parent) == treeNull) {
+ root = n2;
+ } else if (n1 == (n1.getNode(Node.Parent)).getNode(Node.Left_son)) {
+ n1.getNode(Node.Parent).setNode(Node.Left_son, n2);
+ } else {
+ n1.getNode(Node.Parent).setNode(Node.Right_son, n2);
+ }
+ n2.setNode(Node.Right_son, n1);
+ n1.setNode(Node.Parent, n2);
+ }
- public Node Search(int key)
- {
- Node node;
- node = root;
- while ((node != treeNull) && (key != node.getKey()))
- if (key < node.getKey())
- node = node.getNode(Node.Left_son);
- else
- node = node.getNode(Node.Right_son);
- return node;
- }
-
- // This method update the tree height it uses a recursive method
- // findheight.
+ // This method searches the tree for a node with key 'key', and
+ // returns the node on success otherwise treeNull.
+ public Node Search(int key) {
+ Node node;
+ node = root;
+ while ((node != treeNull) && (key != node.getKey())) {
+ if (key < node.getKey()) {
+ node = node.getNode(Node.Left_son);
+ } else {
+ node = node.getNode(Node.Right_son);
+ }
+ }
+ return node;
+ }
- private void updateHeight()
- {
- height = 0;
- if (root != treeNull)
- findHeight(root,1);
- }
-
- // This is a recursive method that find a node height.
+ // This method updates the tree height. it uses a recursive method
+ // findHeight.
+ private void updateHeight() {
+ height = 0;
+ if (root != treeNull) {
+ findHeight(root, 1);
+ }
+ }
- private void findHeight(Node n,int curr)
- {
- if (height < curr)
- height = curr;
- if (n.getNode(Node.Left_son) != treeNull)
- findHeight(n.getNode(Node.Left_son),curr+1);
- if (n.getNode(Node.Right_son) != treeNull)
- findHeight(n.getNode(Node.Right_son),curr+1);
- }
+ // This is a recursive method that find a node height.
+ private void findHeight(Node n, int curr) {
+ if (height < curr) {
+ height = curr;
+ }
+ if (n.getNode(Node.Left_son) != treeNull) {
+ findHeight(n.getNode(Node.Left_son), curr + 1);
+ }
+ if (n.getNode(Node.Right_son) != treeNull) {
+ findHeight(n.getNode(Node.Right_son), curr + 1);
+ }
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt0.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt0.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 1
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt0/cgt0.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt0.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 1
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt1.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt1.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 2
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt1/cgt1.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt1.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 2
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt10.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt10.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 11
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt10/cgt10.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt10.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 11
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt11.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt11.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 12
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt11/cgt11.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt11.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 12
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt2.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt2.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 3
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt2/cgt2.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt2.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 3
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt3.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt3.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 4
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt3/cgt3.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt3.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 4
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt4.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt4.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 5
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt4/cgt4.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt4.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 5
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt5.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt5.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 6
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt5/cgt5.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt5.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 6
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt6.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt6.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 7
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt6/cgt6.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt6.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 7
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt7.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt7.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 8
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt7/cgt7.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt7.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 8
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt8.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt8.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 9
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt8/cgt8.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt8.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 9
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/cgt9.java Fri Oct 11 09:43:41 2019 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ *
+ * @summary converted from VM Testbase jit/graph/cgt9.
+ * VM Testbase keywords: [jit, quick]
+ *
+ * @library /vmTestbase
+ * /test/lib
+ * @run driver jdk.test.lib.FileInstaller data/main.data main.data
+ * @build jit.graph.*
+ * @run main
+ * jit.graph.CGT
+ * -path main.data
+ * -numTestClass 10
+ * -randomLoop 40
+ * -staticLoop 40
+ */
+
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/cgt9/cgt9.java Thu Oct 10 11:40:59 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase jit/graph/cgt9.
- * VM Testbase keywords: [jit, quick]
- *
- * @library /vmTestbase
- * /test/lib
- * @run driver jdk.test.lib.FileInstaller . .
- * @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
- * @build jit.graph.*
- * @run driver ExecDriver --java
- * jit.graph.CGT
- * -path main.data
- * -numTestClass 10
- * -thread 1
- * -randomLoop 40
- * -staticLoop 40
- */
-
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/test1.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/test1.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -20,31 +20,30 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package jit.graph;
-
-
-import java.util.*;
-import java.lang.reflect.*;
import nsk.share.TestFailure;
-class test1
-{
+import java.lang.reflect.InvocationTargetException;
+import java.util.Vector;
+
+class test1 {
private final int classID = Globals.MethodID_Array[0];
public void callMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(classID, summation);
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(classID, summation);
- if (CGT.shouldFinish())
+ if (CGT.shouldFinish()) {
return;
+ }
- if (Globals.VERBOSE)
+ if (Globals.VERBOSE) {
System.out.println("test1.callMe");
+ }
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
return;
}
@@ -52,16 +51,12 @@
Long numFcalls;
Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0)
- {
+ if (staticFunctionDepth.intValue() > 0) {
numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- //methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(classID));
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
methodCallStr = Globals.returnNextStaticMethod(classID);
- }
- else
- {
- numFcalls = new Long(functionDepth.longValue() -1);
+ } else {
+ numFcalls = new Long(functionDepth.longValue() - 1);
staticFcalls = staticFunctionDepth;
methodCallStr = Globals.nextRandomMethod();
}
@@ -69,10 +64,10 @@
Globals.addFunctionIDToVector(methodCallStr.id, ID);
try {
- methodCallStr.nextMethod.invoke(methodCallStr.instance,
- new Object []{summation, ID, numFcalls, staticFcalls});
+ methodCallStr.nextMethod.invoke(methodCallStr.instance,
+ new Object[]{summation, ID, numFcalls, staticFcalls});
} catch (IllegalAccessException iax) {
- throw new TestFailure("Illegal Access Exception");
+ throw new TestFailure("Illegal Access Exception");
}
}
}
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/test2.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/test2.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -20,126 +20,98 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package jit.graph;
-import java.util.*;
-import java.lang.reflect.*;
import nsk.share.TestFailure;
-class test2
-{
- private final int[] MethodID = {Globals.MethodID_Array[1],Globals.MethodID_Array[2]};
+import java.lang.reflect.InvocationTargetException;
+import java.util.Vector;
+
+class test2 {
+ private final int[] MethodID = {Globals.MethodID_Array[1], Globals.MethodID_Array[2]};
public void CallCallMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[1], summation);
- {
- Globals.appendSumToSumationVector(MethodID[1], summation);
-
- if (CGT.shouldFinish())
+ if (CGT.shouldFinish()) {
return;
+ }
- if (Globals.VERBOSE)
+ if (Globals.VERBOSE) {
System.out.println("test2.CallCallMe");
+ }
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
- MethodData methodCallStr;
- Long numFcalls;
- Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0)
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- //methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[1]));
- methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
+ MethodData methodCallStr;
+ Long numFcalls;
+ Integer staticFcalls;
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
- Globals.addFunctionIDToVector(methodCallStr.id, ID);
- }
- else
- {
- numFcalls = new Long(functionDepth.longValue()-1);
- staticFcalls = staticFunctionDepth;
- Globals.addFunctionIDToVector(MethodID[0], ID);
- callMe(summation, ID, numFcalls, staticFcalls);
- return;
- }
+ Globals.addFunctionIDToVector(methodCallStr.id, ID);
+ } else {
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ Globals.addFunctionIDToVector(MethodID[0], ID);
+ callMe(summation, ID, numFcalls, staticFcalls);
+ return;
+ }
- try
- {
- methodCallStr.nextMethod.invoke(methodCallStr.instance,
- new Object []{summation, ID, numFcalls, staticFcalls});
- }
- catch (IllegalAccessException iax)
- {
- throw new TestFailure("Illegal Access Exception");
- }
- /*
- catch (InvocationTargetException itx)
- {
- throw itx;
- }
- */
+ try {
+ methodCallStr.nextMethod.invoke(methodCallStr.instance,
+ new Object[]{summation, ID, numFcalls, staticFcalls});
+ } catch (IllegalAccessException iax) {
+ throw new TestFailure("Illegal Access Exception");
+ }
}
public void callMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(MethodID[0], summation);
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[0], summation);
- if (CGT.shouldFinish())
+ if (CGT.shouldFinish()) {
return;
+ }
- if (Globals.VERBOSE)
+ if (Globals.VERBOSE) {
System.out.println("test2.callMe");
+ }
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
- MethodData methodCallStr;
- Long numFcalls;
- Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0)
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- //methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[0]));
- methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
+ MethodData methodCallStr;
+ Long numFcalls;
+ Integer staticFcalls;
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
- }
- else
- {
- numFcalls = new Long(functionDepth.longValue() -1);
- staticFcalls = staticFunctionDepth;
- methodCallStr = Globals.nextRandomMethod();
- }
+ } else {
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ methodCallStr = Globals.nextRandomMethod();
+ }
- Globals.addFunctionIDToVector(methodCallStr.id, ID);
+ Globals.addFunctionIDToVector(methodCallStr.id, ID);
- try
- {
- methodCallStr.nextMethod.invoke(methodCallStr.instance,
- new Object []{summation, ID, numFcalls, staticFcalls});
- }
- catch (IllegalAccessException iax)
- {
- throw new TestFailure("Illegal Access Exception");
- }
-/*
- catch (InvocationTargetException itx)
- {
- System.out.println("itx test 2");
-
- throw itx;
- }
- */
+ try {
+ methodCallStr.nextMethod.invoke(methodCallStr.instance,
+ new Object[]{summation, ID, numFcalls, staticFcalls});
+ } catch (IllegalAccessException iax) {
+ throw new TestFailure("Illegal Access Exception");
+ }
}
}
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/test3.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/test3.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -20,102 +20,95 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package jit.graph;
-import java.util.*;
-import java.lang.reflect.*;
-import nsk.share.TestFailure;
-
+import jdk.test.lib.Utils;
-class test3 extends test1
-{
+import java.lang.reflect.InvocationTargetException;
+import java.util.Random;
+import java.util.Vector;
- private final int[] MethodID = {Globals.MethodID_Array[3],Globals.MethodID_Array[4]};
- private static Random loopNumGen = new Random(Globals.RANDOM_SEED);
+class test3 extends test1 {
+
+ private final int[] MethodID = {Globals.MethodID_Array[3], Globals.MethodID_Array[4]};
+ private static Random loopNumGen = new Random(Utils.SEED);
private final int maxLoops = 10;
private int localNumLoops = loopNumGen.nextInt(maxLoops);
public void selfRecursion(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(MethodID[1], summation);
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[1], summation);
- if (CGT.shouldFinish())
+ if (CGT.shouldFinish()) {
return;
+ }
- if (Globals.VERBOSE)
+ if (Globals.VERBOSE) {
System.out.println("test3.selfRecursion");
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
+ }
+
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0) //make a static call
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- //methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[1]));
- methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
- }
- else if (localNumLoops > 0) //make a recursive call
- {
- numFcalls = new Long(functionDepth.longValue()-1);
- staticFcalls = staticFunctionDepth;
- Globals.addFunctionIDToVector(MethodID[1], ID);
- localNumLoops--;
- selfRecursion(summation, ID, numFcalls, staticFcalls);
- return;
- }
- else //make a random call
- {
- numFcalls = new Long(functionDepth.longValue() -1);
- staticFcalls = staticFunctionDepth;
- methodCallStr = Globals.nextRandomMethod();
+ // make a static call
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
+ } else if (localNumLoops > 0) { // make a recursive call
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ Globals.addFunctionIDToVector(MethodID[1], ID);
+ localNumLoops--;
+ selfRecursion(summation, ID, numFcalls, staticFcalls);
+ return;
+ } else { // make a random call
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ methodCallStr = Globals.nextRandomMethod();
- localNumLoops = loopNumGen.nextInt(maxLoops); //get ready for the next call to this method
- }
+ // get ready for the next call to this method
+ localNumLoops = loopNumGen.nextInt(maxLoops);
+ }
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
}
public void callMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(MethodID[0], summation);
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[0], summation);
- if (CGT.shouldFinish())
+ if (CGT.shouldFinish()) {
return;
+ }
- if (Globals.VERBOSE)
+ if (Globals.VERBOSE) {
System.out.println("test3.callMe");
+ }
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0)
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- //methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[0]));
- methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
- }
- else
- {
- numFcalls = new Long(functionDepth.longValue() -1);
- staticFcalls = staticFunctionDepth;
- methodCallStr = Globals.nextRandomMethod();
- }
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
+ } else {
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ methodCallStr = Globals.nextRandomMethod();
+ }
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
-
}
}
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/test4.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/test4.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -20,114 +20,106 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package jit.graph;
-import java.util.*;
-import java.lang.reflect.*;
-import nsk.share.TestFailure;
-
+import java.lang.reflect.InvocationTargetException;
+import java.util.Vector;
-class test4 extends test2
-{
- private final int[] MethodID = {Globals.MethodID_Array[1],Globals.MethodID_Array[5], Globals.MethodID_Array[6]};
+class test4 extends test2 {
+ private final int[] MethodID = {Globals.MethodID_Array[1], Globals.MethodID_Array[5], Globals.MethodID_Array[6]};
- //this method verifies that a child can make a call to its parent
+ // this method verifies that a child can make a call to its parent
public void CallCallMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(MethodID[1], summation);
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[1], summation);
- if (CGT.shouldFinish())
+ if (CGT.shouldFinish()) {
return;
+ }
- if (Globals.VERBOSE)
+ if (Globals.VERBOSE) {
System.out.println("test4.CallCallMe");
+ }
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0)
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- //methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[1]));
- methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
- Globals.addFunctionIDToVector(methodCallStr.id, ID);
- }
- else
- {
- numFcalls = new Long(functionDepth.longValue()-1);
- staticFcalls = staticFunctionDepth;
- Globals.addFunctionIDToVector(MethodID[0], ID);
- super.callMe(summation, ID, numFcalls, staticFcalls);
- return;
- }
+ Globals.addFunctionIDToVector(methodCallStr.id, ID);
+ } else {
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ Globals.addFunctionIDToVector(MethodID[0], ID);
+ super.callMe(summation, ID, numFcalls, staticFcalls);
+ return;
+ }
Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
}
- //this method makes a Y fork in the method call structure
+ // this method makes a Y fork in the method call structure
public void callMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(MethodID[2], summation);
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[2], summation);
- if (CGT.shouldFinish())
+ if (CGT.shouldFinish()) {
return;
-
- if (Globals.VERBOSE)
- System.out.println("test4.callMe");
+ }
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
+ if (Globals.VERBOSE) {
+ System.out.println("test4.callMe");
+ }
+
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0)
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- //methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[2]));
- methodCallStr = Globals.returnNextStaticMethod(MethodID[2]);
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[2]);
+ } else {
+ long temp = functionDepth.longValue() - 2;
+ numFcalls = new Long(temp / 2);
+ staticFcalls = staticFunctionDepth;
+ if (Globals.VERBOSE) {
+ System.out.println(" test4.callMe - Starting Branch 1");
}
- else
- {
- long temp = functionDepth.longValue()-2;
- numFcalls = new Long(temp/2);
- staticFcalls = staticFunctionDepth;
+ methodCallStr = Globals.nextRandomMethod();
+ Globals.addFunctionIDToVector(methodCallStr.id, ID);
+ Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
- if (Globals.VERBOSE)
- System.out.println(" test4.callMe - Starting Branch 1");
- methodCallStr = Globals.nextRandomMethod();
- Globals.addFunctionIDToVector(methodCallStr.id, ID);
- Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
-
- if (CGT.shouldFinish())
- return;
+ if (CGT.shouldFinish()) {
+ return;
+ }
- temp -= temp/2;
- if (temp <0)
- {
- if (Globals.VERBOSE)
- System.out.println(" test4.callMe - Skipping Branch 2");
- return;
- }
- if (Globals.VERBOSE)
- System.out.println(" test4.callMe - Starting Branch 2");
- numFcalls = new Long(temp);
- methodCallStr = Globals.nextRandomMethod();
+ temp -= temp / 2;
+ if (temp < 0) {
+ if (Globals.VERBOSE) {
+ System.out.println(" test4.callMe - Skipping Branch 2");
+ }
+ return;
}
+ if (Globals.VERBOSE) {
+ System.out.println(" test4.callMe - Starting Branch 2");
+ }
+ numFcalls = new Long(temp);
+ methodCallStr = Globals.nextRandomMethod();
+ }
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
}
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/test5.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/test5.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -20,320 +20,305 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package jit.graph;
-import java.util.*;
-import java.lang.reflect.*;
+import jdk.test.lib.Utils;
import nsk.share.TestFailure;
-class test5
-{
- private final int[] MethodID = {Globals.MethodID_Array[7],
- Globals.MethodID_Array[8],
- Globals.MethodID_Array[9],
- Globals.MethodID_Array[10]};
- private static Random loopNumGen = new Random(Globals.RANDOM_SEED);
+import java.lang.reflect.InvocationTargetException;
+import java.util.Random;
+import java.util.Vector;
- private final int maxLoops = 12;
+class test5 {
+ private final int[] MethodID = {Globals.MethodID_Array[7],
+ Globals.MethodID_Array[8],
+ Globals.MethodID_Array[9],
+ Globals.MethodID_Array[10]};
+ private static Random loopNumGen = new Random(Utils.SEED);
- private long factorial(int n)
- {
- if(n>1)
- return(n*factorial(n-1));
- else
- return (1);
- }
+ private final int maxLoops = 12;
+
+ private long factorial(int n) {
+ if (n > 1) {
+ return (n * factorial(n - 1));
+ } else {
+ return (1);
+ }
+ }
- private long fibonacci(long num1, long num2, int n)
- {
- if (n <= 0)
- return(num2);
- else
- return (fibonacci(num2, num1+num2, n-1));
- }
+ private long fibonacci(long num1, long num2, int n) {
+ if (n <= 0) {
+ return (num2);
+ } else {
+ return (fibonacci(num2, num1 + num2, n - 1));
+ }
+ }
- private long combination(int n, int r)
- {
- if ((r==0) || (n==r))
- return 1;
- else
- return(combination(n-1, r) +combination(n - 1, r - 1));
- }
+ private long combination(int n, int r) {
+ if ((r == 0) || (n == r)) {
+ return 1;
+ } else {
+ return (combination(n - 1, r) + combination(n - 1, r - 1));
+ }
+ }
- private int[] pascalsTriangle(int[] source, int n)
- {
- if (n>0)
- {
- int sourceLength = source.length;
- int [] temp = new int[sourceLength +1];
- temp[0] = 1;
- temp[sourceLength] = 1;
-
- int j=1;
- for(int i = 0; i<(sourceLength - 1); i++)
- temp[j++] = source[i] + source[i+1];
+ private int[] pascalsTriangle(int[] source, int n) {
+ if (n > 0) {
+ int sourceLength = source.length;
+ int[] temp = new int[sourceLength + 1];
+ temp[0] = 1;
+ temp[sourceLength] = 1;
- return(pascalsTriangle(temp, n-1));
- }
- else
- return source;
- }
+ int j = 1;
+ for (int i = 0; i < (sourceLength - 1); i++) {
+ temp[j++] = source[i] + source[i + 1];
+ }
- private boolean verifyArray(int[] ArrayToBeVerified, int[] MasterArray)
- {
- if (ArrayToBeVerified.length != MasterArray.length)
- return false;
+ return pascalsTriangle(temp, n - 1);
+ } else {
+ return source;
+ }
+ }
- for (int i =0; i<MasterArray.length; i++)
- if (MasterArray[i] != ArrayToBeVerified[i])
- return false;
- return true;
- }
+ private boolean verifyArray(int[] ArrayToBeVerified, int[] MasterArray) {
+ if (ArrayToBeVerified.length != MasterArray.length) {
+ return false;
+ }
- private int[] verifyPascal(int n)
- {
- int [] pascalOut = new int[n+1];
- int [][] dataArray = new int[n+1][n+1];
+ for (int i = 0; i < MasterArray.length; i++) {
+ if (MasterArray[i] != ArrayToBeVerified[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
- for (int i = 0; i<=n; i++)
- {
- for (int j = 0; j<=n; j++)
- {
- if (j==0)
- dataArray[i][0] = 1;
- else if (j==i)
- dataArray[i][i] = 1;
- else if (j<i)
- dataArray[i][j] = dataArray[i-1][j-1] + dataArray[i-1][j];
- }
- }
+ private int[] verifyPascal(int n) {
+ int[] pascalOut = new int[n + 1];
+ int[][] dataArray = new int[n + 1][n + 1];
- int j = n; //could be a little more efficient
- for (int i = 0; i<=n; i++) //but not that important
- pascalOut[i] = dataArray[j][i];
- return pascalOut;
- }
+ for (int i = 0; i <= n; i++) {
+ for (int j = 0; j <= n; j++) {
+ if (j == 0) {
+ dataArray[i][0] = 1;
+ } else if (j == i) {
+ dataArray[i][i] = 1;
+ } else if (j < i) {
+ dataArray[i][j] = dataArray[i - 1][j - 1] + dataArray[i - 1][j];
+ }
+ }
+ }
- private long verifyFact(int n)
- {
- long answer = 1;
- for (int i=2; i<=n; i++)
- answer*=i;
- return answer;
- }
-
- private long verifyFibo(int n)
- {
- long num1=1;
- long num2=1;
+ // could be a little more efficient, but not that important
+ int j = n;
+ for (int i = 0; i <= n; i++) {
+ pascalOut[i] = dataArray[j][i];
+ }
+ return pascalOut;
+ }
- for (int i = 0; i< n; i++)
- {
- long temp = num1+num2;
- num1 = num2;
- num2 = temp;
- }
-
- return num2;
- }
+ private long verifyFact(int n) {
+ long answer = 1;
+ for (int i = 2; i <= n; i++) {
+ answer *= i;
+ }
+ return answer;
+ }
- private long verifyComb(int n, int r)
- {
- return(verifyFact(n)/(verifyFact(n-r)*verifyFact(r)));
- }
+ private long verifyFibo(int n) {
+ long num1 = 1;
+ long num2 = 1;
- public void factTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(MethodID[0], summation);
+ for (int i = 0; i < n; i++) {
+ long temp = num1 + num2;
+ num1 = num2;
+ num2 = temp;
+ }
- if (CGT.shouldFinish())
- return;
+ return num2;
+ }
- if (Globals.VERBOSE)
- System.out.println("test5.factTest");
+ private long verifyComb(int n, int r) {
+ return (verifyFact(n) / (verifyFact(n - r) * verifyFact(r)));
+ }
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
- MethodData methodCallStr;
- Long numFcalls;
- Integer staticFcalls;
+ public void factTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[0], summation);
- if (staticFunctionDepth.intValue() > 0)
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
- //methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[0]));
- }
- else
- {
- numFcalls = new Long(functionDepth.longValue() -1);
- staticFcalls = staticFunctionDepth;
- methodCallStr = Globals.nextRandomMethod();
- }
+ if (CGT.shouldFinish()) {
+ return;
+ }
+
+ if (Globals.VERBOSE) {
+ System.out.println("test5.factTest");
+ }
+
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
+ MethodData methodCallStr;
+ Long numFcalls;
+ Integer staticFcalls;
- int localNumLoops = loopNumGen.nextInt(maxLoops);
- long facFunctionValue = factorial(localNumLoops);
- long facVerValue = verifyFact(localNumLoops);
- if (facFunctionValue != facVerValue)
- {
- System.out.println("Factorial Computed Incorrectly");
- System.out.println("Specific Factorial Requested "+localNumLoops +"!");
- throw new TestFailure("Expected: " + facVerValue + " Actual "+ facFunctionValue);
- }
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
+ } else {
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ methodCallStr = Globals.nextRandomMethod();
+ }
- Globals.addFunctionIDToVector(methodCallStr.id, ID);
- Globals.callMethod(methodCallStr,summation, ID, numFcalls, staticFcalls);
- }
+ int localNumLoops = loopNumGen.nextInt(maxLoops);
+ long facFunctionValue = factorial(localNumLoops);
+ long facVerValue = verifyFact(localNumLoops);
+ if (facFunctionValue != facVerValue) {
+ System.out.println("Factorial Computed Incorrectly");
+ System.out.println("Specific Factorial Requested " + localNumLoops + "!");
+ throw new TestFailure("Expected: " + facVerValue + " Actual " + facFunctionValue);
+ }
- public void fiboTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(MethodID[1], summation);
+ Globals.addFunctionIDToVector(methodCallStr.id, ID);
+ Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
+ }
- if (CGT.shouldFinish())
- return;
+ public void fiboTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[1], summation);
- if (Globals.VERBOSE)
- System.out.println("test5.fiboTest");
+ if (CGT.shouldFinish()) {
+ return;
+ }
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
- MethodData methodCallStr;
- Long numFcalls;
- Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0)
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
- }
- else
- {
- numFcalls = new Long(functionDepth.longValue() -1);
- staticFcalls = staticFunctionDepth;
- methodCallStr = Globals.nextRandomMethod();
- }
- int localNumLoops = loopNumGen.nextInt(maxLoops*3);
- long fiboFunctionValue = fibonacci(1,1,localNumLoops);
- long fiboVerValue = verifyFibo(localNumLoops);
- if (fiboFunctionValue != fiboVerValue)
- {
- System.out.println("Fibonacci Series Computed Incorrectly");
- System.out.println("Specific Digit Requested "+localNumLoops);
- throw new TestFailure("Expected: " + fiboVerValue + " Actual "+ fiboFunctionValue);
- }
+ if (Globals.VERBOSE) {
+ System.out.println("test5.fiboTest");
+ }
- Globals.addFunctionIDToVector(methodCallStr.id, ID);
- Globals.callMethod(methodCallStr,summation, ID, numFcalls, staticFcalls);
- }
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
+ MethodData methodCallStr;
+ Long numFcalls;
+ Integer staticFcalls;
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
+ } else {
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ methodCallStr = Globals.nextRandomMethod();
+ }
+ int localNumLoops = loopNumGen.nextInt(maxLoops * 3);
+ long fiboFunctionValue = fibonacci(1, 1, localNumLoops);
+ long fiboVerValue = verifyFibo(localNumLoops);
+ if (fiboFunctionValue != fiboVerValue) {
+ System.out.println("Fibonacci Series Computed Incorrectly");
+ System.out.println("Specific Digit Requested " + localNumLoops);
+ throw new TestFailure("Expected: " + fiboVerValue + " Actual " + fiboFunctionValue);
+ }
+
+ Globals.addFunctionIDToVector(methodCallStr.id, ID);
+ Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
+ }
- public void combTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(MethodID[2], summation);
-
- if (CGT.shouldFinish())
- return;
-
- if (Globals.VERBOSE)
- System.out.println("test5.combTest");
+ public void combTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[2], summation);
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
- MethodData methodCallStr;
- Long numFcalls;
- Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0)
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
+ if (CGT.shouldFinish()) {
+ return;
+ }
+
+ if (Globals.VERBOSE) {
+ System.out.println("test5.combTest");
+ }
- methodCallStr = Globals.returnNextStaticMethod(MethodID[2]);
- //methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[2]));
- }
- else
- {
- numFcalls = new Long(functionDepth.longValue() -1);
- staticFcalls = staticFunctionDepth;
- methodCallStr = Globals.nextRandomMethod();
- }
- int n = loopNumGen.nextInt(maxLoops);
- int k = (n>0)?loopNumGen.nextInt(n):0;
- long combFunctionValue = combination(n, k);
- long combVerValue = verifyComb(n, k);
- if (combFunctionValue != combVerValue)
- {
- System.out.println("Combination Computed Incorrectly");
- System.out.println("N = " + n +"K = " + k);
- throw new TestFailure("Expected: " + combVerValue + " Actual "+ combFunctionValue);
- }
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
+ MethodData methodCallStr;
+ Long numFcalls;
+ Integer staticFcalls;
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[2]);
+ } else {
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ methodCallStr = Globals.nextRandomMethod();
+ }
+ int n = loopNumGen.nextInt(maxLoops);
+ int k = (n > 0) ? loopNumGen.nextInt(n) : 0;
+ long combFunctionValue = combination(n, k);
+ long combVerValue = verifyComb(n, k);
+ if (combFunctionValue != combVerValue) {
+ System.out.println("Combination Computed Incorrectly");
+ System.out.println("N = " + n + "K = " + k);
+ throw new TestFailure("Expected: " + combVerValue + " Actual " + combFunctionValue);
+ }
- Globals.addFunctionIDToVector(methodCallStr.id, ID);
- Globals.callMethod(methodCallStr,summation, ID, numFcalls, staticFcalls);
- }
+ Globals.addFunctionIDToVector(methodCallStr.id, ID);
+ Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
+ }
- public void pascalTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(MethodID[3], summation);
+ public void pascalTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[3], summation);
- if (CGT.shouldFinish())
- return;
+ if (CGT.shouldFinish()) {
+ return;
+ }
-int [] x = new int[1 << 30];
-x[1 << 24] = 1;
+ if (Globals.VERBOSE) {
+ System.out.println("test5.pascalTest");
+ }
- if (Globals.VERBOSE)
- System.out.println("test5.pascalTest");
+ int[] x = new int[1 << 30];
+ x[1 << 24] = 1;
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
- MethodData methodCallStr;
- Long numFcalls;
- Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0)
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- methodCallStr = Globals.returnNextStaticMethod(MethodID[3]);
- //methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[3]));
- }
- else
- {
- numFcalls = new Long(functionDepth.longValue() -1);
- staticFcalls = staticFunctionDepth;
- methodCallStr = Globals.nextRandomMethod();
- }
- int num = loopNumGen.nextInt(maxLoops);
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
+ MethodData methodCallStr;
+ Long numFcalls;
+ Integer staticFcalls;
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[3]);
+ } else {
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ methodCallStr = Globals.nextRandomMethod();
+ }
+ int num = loopNumGen.nextInt(maxLoops);
- int[] pascalFunctionValue = pascalsTriangle(new int[] {1}, num);
- int[] pascalVerValue = verifyPascal(num);
- if (!verifyArray(pascalFunctionValue, pascalVerValue))
- {
- String temp = new String("Expected: ");
- for (int i=0; i<pascalVerValue.length; i++)
- temp += pascalVerValue[i] +", ";
- temp+= " Actual ";
- for (int i=0; i<pascalFunctionValue.length; i++)
- temp += pascalFunctionValue[i] +", ";
- System.out.println("Pascal Tringle Row Computed Incorrectly");
- System.out.println("Row Number " + num);
- throw new TestFailure(temp);
- }
+ int[] pascalFunctionValue = pascalsTriangle(new int[]{1}, num);
+ int[] pascalVerValue = verifyPascal(num);
+ if (!verifyArray(pascalFunctionValue, pascalVerValue)) {
+ StringBuilder temp = new StringBuilder("Expected: ");
+ for (int aPascalVerValue : pascalVerValue) {
+ temp.append(aPascalVerValue)
+ .append(", ");
+ }
+ temp.append(" Actual ");
+ for (int aPascalFunctionValue : pascalFunctionValue) {
+ temp.append(aPascalFunctionValue)
+ .append(", ");
+ }
+ System.out.println("Pascal Tringle Row Computed Incorrectly");
+ System.out.println("Row Number " + num);
+ throw new TestFailure(temp.toString());
+ }
- Globals.addFunctionIDToVector(methodCallStr.id, ID);
- Globals.callMethod(methodCallStr,summation, ID, numFcalls, staticFcalls);
- }
+ Globals.addFunctionIDToVector(methodCallStr.id, ID);
+ Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
+ }
}
--- a/test/hotspot/jtreg/vmTestbase/jit/graph/test6.java Thu Oct 10 11:40:59 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/jit/graph/test6.java Fri Oct 11 09:43:41 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -20,61 +20,58 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package jit.graph;
-import java.util.*;
-import java.lang.reflect.*;
+import jdk.test.lib.Utils;
import nsk.share.TestFailure;
-public class test6
-{
+import java.lang.reflect.InvocationTargetException;
+import java.util.Random;
+import java.util.Vector;
+
+public class test6 {
private static final int[] MethodID = {Globals.MethodID_Array[11]};
- private static Random localNumGen = new Random(Globals.RANDOM_SEED);
+ private static Random localNumGen = new Random(Utils.SEED);
private static final int maxEntries = 25;
- //flattens the binary tree into an array
- private void getSortedArray(Node root, int [] dataArray, int[] index)
- {
- if ((root != null) && (root!=RBTree.treeNull))
- {
- getSortedArray(root.getNode(Node.Left_son), dataArray, index);
- dataArray[index[0]++] = root.getKey();
- getSortedArray(root.getNode(Node.Right_son), dataArray, index);
- }
+ // flattens the binary tree into an array
+ private void getSortedArray(Node root, int[] dataArray, int[] index) {
+ if ((root != null) && (root != RBTree.treeNull)) {
+ getSortedArray(root.getNode(Node.Left_son), dataArray, index);
+ dataArray[index[0]++] = root.getKey();
+ getSortedArray(root.getNode(Node.Right_son), dataArray, index);
+ }
}
public synchronized void rbTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
- throws InvocationTargetException
- {
- Globals.appendSumToSumationVector(MethodID[0], summation);
-
- if (CGT.shouldFinish())
- return;
+ throws InvocationTargetException {
+ Globals.appendSumToSummationVector(MethodID[0], summation);
- if (Globals.VERBOSE)
+ if (CGT.shouldFinish()) {
+ return;
+ }
+ if (Globals.VERBOSE) {
System.out.println("test6.rbTest");
+ }
- if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
- {
- return;
- }
+ if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0)) {
+ return;
+ }
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
- if (staticFunctionDepth.intValue() > 0)
- {
- numFcalls = functionDepth;
- staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
- methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
- }
- else
- {
- numFcalls = new Long(functionDepth.longValue() -1);
- staticFcalls = staticFunctionDepth;
- methodCallStr = Globals.nextRandomMethod();
- }
+ if (staticFunctionDepth.intValue() > 0) {
+ numFcalls = functionDepth;
+ staticFcalls = new Integer(staticFunctionDepth.intValue() - 1);
+ methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
+ } else {
+ numFcalls = new Long(functionDepth.longValue() - 1);
+ staticFcalls = staticFunctionDepth;
+ methodCallStr = Globals.nextRandomMethod();
+ }
RBTree myTree = new RBTree();
int numElements = 1 + localNumGen.nextInt(maxEntries);
@@ -82,81 +79,64 @@
boolean insertArray[] = new boolean[numElements];
Vector temp = new Vector(numElements);
- for(int i=0; i<numElements; i++)
- { //code guarantees no duplicates
- int nextKey = localNumGen.nextInt(16385);
- while (temp.indexOf(new Integer(nextKey)) != -1)
- nextKey = localNumGen.nextInt(16385);
+ // code guarantees no duplicates
+ for (int i = 0; i < numElements; i++) {
+ int nextKey = localNumGen.nextInt(16385);
+ while (temp.indexOf(new Integer(nextKey)) != -1) {
+ nextKey = localNumGen.nextInt(16385);
+ }
- temp.addElement(new Integer(nextKey));
- dataArray[i] = nextKey;
+ temp.addElement(new Integer(nextKey));
+ dataArray[i] = nextKey;
- insertArray[i] = false;
- }
+ insertArray[i] = false;
+ }
temp = null;
int numLoops = 10 + localNumGen.nextInt(1024);
- for (int i=0; i<numLoops; i++)
- {
- int nextIndex = localNumGen.nextInt(numElements);
- if (!insertArray[nextIndex])
- {
- myTree.RBInsert(dataArray[nextIndex]);
- insertArray[nextIndex] = true;
- }
- else
- {
- myTree.RBDelete(dataArray[nextIndex]);
- insertArray[nextIndex] = false;
- }
+ for (int i = 0; i < numLoops; i++) {
+ int nextIndex = localNumGen.nextInt(numElements);
+ if (!insertArray[nextIndex]) {
+ myTree.RBInsert(dataArray[nextIndex]);
+ insertArray[nextIndex] = true;
+ } else {
+ myTree.RBDelete(dataArray[nextIndex]);
+ insertArray[nextIndex] = false;
}
+ }
int numValid = 0;
- for (int i = 0; i<numElements; i++)
- {
- Node searchNode = myTree.Search(dataArray[i]);
- if (insertArray[i] && (searchNode == RBTree.treeNull))
- {
- System.out.println("Valid Node Not Found in Binary Tree");
- System.out.println("Node " + dataArray[i]);
- System.exit(1);
- }
- else if ((!insertArray[i]) && (searchNode != RBTree.treeNull))
- {
- System.out.println("Deleted Node Found in Binary Tree");
- System.out.println("Node " + dataArray[i]);
- System.exit(1);
- }
- else if (insertArray[i])
- numValid++;
- insertArray[i] = true; //so that verification is only done once
+ for (int i = 0; i < numElements; i++) {
+ Node searchNode = myTree.Search(dataArray[i]);
+ if (insertArray[i] && (searchNode == RBTree.treeNull)) {
+ throw new TestFailure("Valid Node Not Found in Binary Tree. Node " + dataArray[i]);
+ } else if ((!insertArray[i]) && (searchNode != RBTree.treeNull)) {
+ throw new TestFailure("Deleted Node Found in Binary Tree. Node " + dataArray[i]);
+ } else if (insertArray[i]) {
+ numValid++;
}
+ // so that verification is only done once
+ insertArray[i] = true;
+ }
- int [] sortedArray = new int[numValid];
- getSortedArray(myTree.getRoot(), sortedArray, new int [] {0});
+ int[] sortedArray = new int[numValid];
+ getSortedArray(myTree.getRoot(), sortedArray, new int[]{0});
- for (int i=1; i<numValid; i++)
- if (sortedArray[i] <= sortedArray[i-1])
- {
- String outStr = new String("Actual ");
- for (int j=0; j<sortedArray.length; j++)
- outStr += sortedArray[j] +", ";
- System.out.println("Binary Tree Property Not Held");
- System.out.println("Root " + myTree.getRoot().getKey());
- System.out.println(outStr);
- System.exit(1);
+ for (int i = 1; i < numValid; i++) {
+ if (sortedArray[i] <= sortedArray[i - 1]) {
+ StringBuilder outStr = new StringBuilder("Actual ");
+ for (int aSortedArray : sortedArray) {
+ outStr.append(aSortedArray)
+ .append(", ");
}
-
- //Should make more memory available for future instances
- myTree = null;
- sortedArray = null;
- dataArray = null;
- insertArray = null;
-// System.gc();
+ System.out.println("Binary Tree Property Not Held");
+ System.out.println("Root " + myTree.getRoot()
+ .getKey());
+ throw new TestFailure(outStr.toString());
+ }
+ }
Globals.addFunctionIDToVector(methodCallStr.id, ID);
- Globals.callMethod(methodCallStr,summation, ID, numFcalls, staticFcalls);
-
-
+ Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
}
}