8038418: New tests development for type profiling and speculation
Reviewed-by: roland, iignatyev
This commit is contained in:
parent
e00a1f63f8
commit
2b5f33db1e
159
hotspot/test/compiler/types/correctness/CorrectnessTest.java
Normal file
159
hotspot/test/compiler/types/correctness/CorrectnessTest.java
Normal file
@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 CorrectnessTest
|
||||
* @bug 8038418
|
||||
* @library /testlibrary /testlibrary/whitebox
|
||||
* @compile execution/TypeConflict.java execution/TypeProfile.java
|
||||
* execution/MethodHandleDelegate.java
|
||||
* @build CorrectnessTest
|
||||
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
||||
* -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation
|
||||
* -XX:CompileCommand=exclude,execution/*::methodNotToCompile
|
||||
* -XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType
|
||||
* CorrectnessTest RETURN
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
||||
* -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation
|
||||
* -XX:CompileCommand=exclude,execution/*::methodNotToCompile
|
||||
* -XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType
|
||||
* CorrectnessTest PARAMETERS
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
||||
* -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation
|
||||
* -XX:CompileCommand=exclude,execution/*::methodNotToCompile
|
||||
* -XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType
|
||||
* CorrectnessTest ARGUMENTS
|
||||
* @summary Tests correctness of type usage with type profiling and speculations
|
||||
*/
|
||||
|
||||
import com.oracle.java.testlibrary.Asserts;
|
||||
import com.oracle.java.testlibrary.Platform;
|
||||
import execution.Execution;
|
||||
import execution.MethodHandleDelegate;
|
||||
import execution.TypeConflict;
|
||||
import execution.TypeProfile;
|
||||
import hierarchies.*;
|
||||
import scenarios.*;
|
||||
import sun.hotspot.WhiteBox;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class CorrectnessTest {
|
||||
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (!Platform.isServer()) {
|
||||
System.out.println("ALL TESTS SKIPPED");
|
||||
}
|
||||
Asserts.assertGTE(args.length, 1);
|
||||
ProfilingType profilingType = ProfilingType.valueOf(args[0]);
|
||||
if (runTests(profilingType)) {
|
||||
System.out.println("ALL TESTS PASSED");
|
||||
} else {
|
||||
throw new RuntimeException("SOME TESTS FAILED");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static boolean runTests(ProfilingType profilingType) {
|
||||
boolean result = true;
|
||||
|
||||
List<Execution> executionList = new ArrayList<>();
|
||||
executionList.add(new TypeConflict());
|
||||
executionList.add(new TypeProfile());
|
||||
for (int i = 0, n = executionList.size(); i < n; i++) {
|
||||
executionList.add(new MethodHandleDelegate(executionList.get(i)));
|
||||
}
|
||||
|
||||
List<TypeHierarchy> hierarchyList = new ArrayList<>();
|
||||
hierarchyList.add(new DefaultMethodInterface.Hierarchy());
|
||||
hierarchyList.add(new DefaultMethodInterface2.Hierarchy());
|
||||
hierarchyList.add(new Linear.Hierarchy());
|
||||
hierarchyList.add(new Linear2.Hierarchy());
|
||||
hierarchyList.add(new OneRank.Hierarchy());
|
||||
for (int i = 0, n = hierarchyList.size(); i < n; i++) {
|
||||
hierarchyList.add(new NullableType(hierarchyList.get(i)));
|
||||
}
|
||||
|
||||
List<BiFunction<ProfilingType, TypeHierarchy, Scenario<?, ?>>> testCasesConstructors
|
||||
= new ArrayList<>();
|
||||
testCasesConstructors.add(ArrayCopy::new);
|
||||
testCasesConstructors.add(ArrayReferenceStore::new);
|
||||
testCasesConstructors.add(ClassIdentity::new);
|
||||
testCasesConstructors.add(ClassInstanceOf::new);
|
||||
testCasesConstructors.add(ClassIsInstance::new);
|
||||
testCasesConstructors.add(ReceiverAtInvokes::new);
|
||||
testCasesConstructors.add(CheckCast::new);
|
||||
|
||||
for (TypeHierarchy hierarchy : hierarchyList) {
|
||||
for (BiFunction<ProfilingType, TypeHierarchy, Scenario<?, ?>> constructor : testCasesConstructors) {
|
||||
for (Execution execution : executionList) {
|
||||
Scenario<?, ?> scenario = constructor.apply(profilingType, hierarchy);
|
||||
if (scenario.isApplicable()) {
|
||||
result &= executeTest(hierarchy, execution, scenario);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes test case
|
||||
*
|
||||
* @param hierarchy type hierarchy for the test
|
||||
* @param execution execution scenario
|
||||
* @param scenario test scenario executed with given Execution
|
||||
*/
|
||||
private static boolean executeTest(TypeHierarchy hierarchy, Execution execution, Scenario<?, ?> scenario) {
|
||||
boolean testCaseResult = false;
|
||||
String testName = hierarchy.getClass().getName() + " :: " + scenario.getName() + " @ " + execution.getName();
|
||||
clearAllMethodsState(scenario.getClass());
|
||||
try {
|
||||
execution.execute(scenario);
|
||||
testCaseResult = true;
|
||||
} catch (Exception e) {
|
||||
System.err.println(testName + " failed with exception " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println((testCaseResult ? "PASSED: " : "FAILED: ") + testName);
|
||||
return testCaseResult;
|
||||
}
|
||||
|
||||
private static void clearAllMethodsState(Class aClass) {
|
||||
while (aClass != null) {
|
||||
for (Method m : aClass.getDeclaredMethods()) {
|
||||
WHITE_BOX.clearMethodState(m);
|
||||
}
|
||||
aClass = aClass.getSuperclass();
|
||||
}
|
||||
}
|
||||
}
|
108
hotspot/test/compiler/types/correctness/OffTest.java
Normal file
108
hotspot/test/compiler/types/correctness/OffTest.java
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 CorrectnessTest
|
||||
* @bug 8038418
|
||||
* @library /testlibrary /testlibrary/whitebox
|
||||
* @compile execution/TypeConflict.java execution/TypeProfile.java
|
||||
* execution/MethodHandleDelegate.java
|
||||
* @build CorrectnessTest
|
||||
* @build OffTest
|
||||
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/timeout=1200 OffTest
|
||||
*/
|
||||
|
||||
import com.oracle.java.testlibrary.OutputAnalyzer;
|
||||
import com.oracle.java.testlibrary.ProcessTools;
|
||||
import scenarios.ProfilingType;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class OffTest {
|
||||
private static final String[] OPTIONS = {
|
||||
"-Xbootclasspath/a:.",
|
||||
"-XX:+IgnoreUnrecognizedVMOptions",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:+UnlockDiagnosticVMOptions",
|
||||
"-XX:+WhiteBoxAPI",
|
||||
"-XX:CompileCommand=exclude,execution/*::methodNotToCompile",
|
||||
"-XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType",
|
||||
"", // -XX:TypeProfileLevel=?
|
||||
"", // -XX:?UseTypeSpeculation
|
||||
CorrectnessTest.class.getName(),
|
||||
"", // ProfilingType.name()
|
||||
};
|
||||
|
||||
private static final String TYPE_PROFILE_LEVEL = "TypeProfileLevel";
|
||||
private static final String USE_TYPE_SPECULATION = "UseTypeSpeculation";
|
||||
private static final int TYPE_PROFILE_LEVEL_LENGTH = 3;
|
||||
private static final int TYPE_PROFILE_LEVEL_BOUND = 3;
|
||||
private static final int DEFAULT_COUNT = 10;
|
||||
private static final int PROFILING_TYPE_INDEX = OPTIONS.length - 1;
|
||||
private static final int TYPE_PROFILE_INDEX = OPTIONS.length - 4;
|
||||
private static final int USE_TYPE_SPECULATION_INDEX = OPTIONS.length - 3;
|
||||
private static final Random RNG;
|
||||
|
||||
static {
|
||||
String str = System.getProperty("seed");
|
||||
long seed = str != null ? Long.parseLong(str) : new Random().nextLong();
|
||||
RNG = new Random(seed);
|
||||
System.out.printf("-Dseed=%d%n", seed);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
int count = DEFAULT_COUNT;
|
||||
if (args.length > 0) {
|
||||
count = Integer.parseInt(args[0]) ;
|
||||
}
|
||||
for (int i = 0; i < count; ++i) {
|
||||
runTest();
|
||||
}
|
||||
}
|
||||
|
||||
private static void runTest() throws Exception {
|
||||
String useTypeSpeculation = "-XX:" + (RNG.nextBoolean() ? "+" : "-") + USE_TYPE_SPECULATION;
|
||||
String typeProfileLevel = "-XX:" + TYPE_PROFILE_LEVEL + "=" + randomTypeProfileLevel();
|
||||
ProfilingType type = randomProfileType();
|
||||
OPTIONS[TYPE_PROFILE_INDEX] = typeProfileLevel;
|
||||
OPTIONS[USE_TYPE_SPECULATION_INDEX] = useTypeSpeculation;
|
||||
OPTIONS[PROFILING_TYPE_INDEX] = type.name();
|
||||
ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(/* addTestVmOptions= */ true, OPTIONS);
|
||||
OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start());
|
||||
outputAnalyzer.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
private static ProfilingType randomProfileType() {
|
||||
ProfilingType[] value = ProfilingType.values();
|
||||
return value[RNG.nextInt(value.length)];
|
||||
}
|
||||
|
||||
private static String randomTypeProfileLevel() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < TYPE_PROFILE_LEVEL_LENGTH; ++i) {
|
||||
stringBuilder.append(RNG.nextInt(TYPE_PROFILE_LEVEL_BOUND));
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 execution;
|
||||
|
||||
import hierarchies.TypeHierarchy;
|
||||
import scenarios.Scenario;
|
||||
|
||||
/**
|
||||
* Execution scenario represents test methods execution type.
|
||||
* @param <T> parameter type
|
||||
* @param <R> result Type
|
||||
*/
|
||||
public interface Execution<T extends TypeHierarchy.I, R> {
|
||||
/**
|
||||
* Executes the test code of the given scenario
|
||||
* See {@link scenarios.Scenario#run(T)}
|
||||
*
|
||||
* @param scenario test scenario
|
||||
*/
|
||||
void execute(Scenario<T, R> scenario);
|
||||
|
||||
default String getName() {
|
||||
return this.getClass().getName();
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 execution;
|
||||
|
||||
import hierarchies.TypeHierarchy;
|
||||
import scenarios.Scenario;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
|
||||
/**
|
||||
* Executes test scenario using {@link MethodHandle#invoke(Object...)}.
|
||||
* Delegates execution to the given {@link Execution} by creating
|
||||
* new test scenario, see {@link Scenario}
|
||||
*/
|
||||
public class MethodHandleDelegate<T extends TypeHierarchy.I, R> implements Execution<T, R> {
|
||||
private final Execution<T, R> delegate;
|
||||
|
||||
public MethodHandleDelegate(Execution<T, R> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Scenario<T, R> scenario) {
|
||||
delegate.execute(new MHScenario<T, R>(scenario));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MethodHandleDelegate # " + delegate.getName();
|
||||
}
|
||||
|
||||
private static class MHScenario<T extends TypeHierarchy.I, R> extends Scenario<T, R> {
|
||||
private final Scenario<T, R> scenario;
|
||||
private static final MethodHandle METHOD_HANDLE_RUN;
|
||||
|
||||
static {
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
MethodType methodType = MethodType.methodType(Object.class, TypeHierarchy.I.class);
|
||||
|
||||
try {
|
||||
METHOD_HANDLE_RUN = lookup.findVirtual(Scenario.class, "run", methodType);
|
||||
} catch (NoSuchMethodException | IllegalAccessException e) {
|
||||
System.err.println("Failed to get target method run() with " + e);
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param scenario test scenario to be executed
|
||||
*/
|
||||
private MHScenario(Scenario<T, R> scenario) {
|
||||
super("MethodHandle::" + scenario.getName(), scenario.profilingType, scenario.hierarchy);
|
||||
this.scenario = scenario;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs {@link Scenario#run(T)} with {@link MethodHandle#invoke(Object...)}
|
||||
*
|
||||
* @param t subject of the test
|
||||
* @return result of the underlying {@link Scenario#run(T)} invocation
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public R run(T t) {
|
||||
try {
|
||||
return (R) METHOD_HANDLE_RUN.invoke(scenario, t);
|
||||
} catch (Throwable thr) {
|
||||
System.err.println(scenario.getName()
|
||||
+ " failed to invoke target method run() with " + thr);
|
||||
throw new RuntimeException("Invocation failed", thr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check(R r, T t) {
|
||||
scenario.check(r, t);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 execution;
|
||||
|
||||
import hierarchies.TypeHierarchy;
|
||||
import scenarios.Scenario;
|
||||
|
||||
/**
|
||||
* Type profiling conflict execution scenario. The main goal is
|
||||
* to make compiler profile and compile methods with different types.
|
||||
* Scenario tests guards by passing conflicting types (incompatible
|
||||
* for the profiled data).
|
||||
*/
|
||||
public class TypeConflict<T extends TypeHierarchy.I, R> implements Execution<T, R> {
|
||||
/** Test methods execution number to make profile */
|
||||
private final static int POLLUTION_THRESHOLD = 5000;
|
||||
/** Test methods execution number to make it profiled and compiled*/
|
||||
private final static int PROFILE_THRESHOLD = 20000;
|
||||
|
||||
@Override
|
||||
public void execute(Scenario<T, R> scenario) {
|
||||
T base = scenario.getProfiled();
|
||||
T incompatible = scenario.getConflict();
|
||||
|
||||
// pollute profile by passing different types
|
||||
R baseResult = null;
|
||||
R incResult = null;
|
||||
for (int i = 0; i < POLLUTION_THRESHOLD; i++) {
|
||||
baseResult = methodNotToCompile(scenario, base);
|
||||
incResult = methodNotToCompile(scenario, incompatible);
|
||||
}
|
||||
scenario.check(baseResult, base);
|
||||
scenario.check(incResult, incompatible);
|
||||
|
||||
// profile and compile
|
||||
R result = null;
|
||||
for (int i = 0; i < PROFILE_THRESHOLD; i++) {
|
||||
result = methodNotToCompile(scenario, base);
|
||||
}
|
||||
scenario.check(result, base);
|
||||
|
||||
// pass another type to make guard work and recompile
|
||||
for (int i = 0; i < PROFILE_THRESHOLD; i++) {
|
||||
result = methodNotToCompile(scenario, incompatible);
|
||||
}
|
||||
scenario.check(result, incompatible);
|
||||
}
|
||||
|
||||
private R methodNotToCompile(Scenario<T, R> scenario, T t) {
|
||||
return scenario.run(t);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 execution;
|
||||
|
||||
import hierarchies.TypeHierarchy;
|
||||
import scenarios.Scenario;
|
||||
|
||||
/**
|
||||
* Profile type execution scenario. Executes tester method
|
||||
* in a loop without any manipulation with types or instances.
|
||||
*/
|
||||
public class TypeProfile<T extends TypeHierarchy.I, R> implements Execution<T, R> {
|
||||
/** Number of test method execution to make it profiled and compiled */
|
||||
private final static int PROFILE_THRESHOLD = 100000;
|
||||
|
||||
/**
|
||||
* Makes scenario code be profiled and compiled
|
||||
* @param scenario Test scenario
|
||||
*/
|
||||
@Override
|
||||
public void execute(Scenario<T, R> scenario) {
|
||||
R result = null;
|
||||
T prof = scenario.getProfiled();
|
||||
T confl = scenario.getConflict();
|
||||
|
||||
for (int i = 0; i < PROFILE_THRESHOLD; i++) {
|
||||
result = methodNotToCompile(scenario, prof);
|
||||
}
|
||||
scenario.check(result, prof);
|
||||
|
||||
result = methodNotToCompile(scenario, confl);
|
||||
scenario.check(result, confl);
|
||||
}
|
||||
|
||||
protected R methodNotToCompile(Scenario<T, R> scenario, T t) {
|
||||
return scenario.run(t);
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 hierarchies;
|
||||
|
||||
public class DefaultMethodInterface {
|
||||
private DefaultMethodInterface() {
|
||||
}
|
||||
|
||||
public static class Hierarchy
|
||||
extends TypeHierarchy<DefaultMethodInterface.A, DefaultMethodInterface.B> {
|
||||
public Hierarchy() {
|
||||
super(new DefaultMethodInterface.A(), new DefaultMethodInterface.B(),
|
||||
DefaultMethodInterface.A.class, DefaultMethodInterface.B.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static interface I2 extends TypeHierarchy.I {
|
||||
default int m() {
|
||||
return TypeHierarchy.ANSWER;
|
||||
}
|
||||
}
|
||||
|
||||
public static class A implements I2 {
|
||||
// use default method from I2
|
||||
}
|
||||
|
||||
public static class B extends A {
|
||||
@Override
|
||||
public int m() {
|
||||
return TypeHierarchy.YEAR;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 hierarchies;
|
||||
|
||||
public class DefaultMethodInterface2 {
|
||||
private DefaultMethodInterface2() {
|
||||
}
|
||||
|
||||
public static class Hierarchy
|
||||
extends TypeHierarchy<TypeHierarchy.A, DefaultMethodInterface2.B> {
|
||||
public Hierarchy() {
|
||||
super(new TypeHierarchy.A(), new DefaultMethodInterface2.B(),
|
||||
TypeHierarchy.A.class, DefaultMethodInterface2.B.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static interface I2 extends TypeHierarchy.I {
|
||||
default int m() {
|
||||
return TypeHierarchy.ANSWER;
|
||||
}
|
||||
}
|
||||
|
||||
public static class B implements I2 {
|
||||
// default method I2.m()
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 hierarchies;
|
||||
|
||||
public class Linear {
|
||||
private Linear() {
|
||||
}
|
||||
|
||||
public static class Hierarchy extends TypeHierarchy<TypeHierarchy.A, Linear.B> {
|
||||
public Hierarchy() {
|
||||
super(new TypeHierarchy.A(), new Linear.B(),
|
||||
TypeHierarchy.A.class, Linear.B.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static class B extends TypeHierarchy.A {
|
||||
@Override
|
||||
public int m() {
|
||||
return TypeHierarchy.YEAR;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 hierarchies;
|
||||
|
||||
public class Linear2 {
|
||||
private Linear2() {
|
||||
}
|
||||
|
||||
public static class Hierarchy extends TypeHierarchy<TypeHierarchy.A, Linear2.B> {
|
||||
public Hierarchy() {
|
||||
super(new A(), new Linear2.B(),
|
||||
A.class, Linear2.B.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static interface I2 {
|
||||
int m();
|
||||
}
|
||||
|
||||
public static class B extends TypeHierarchy.A implements Linear2.I2 {
|
||||
@Override
|
||||
public int m() {
|
||||
return TypeHierarchy.YEAR;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 hierarchies;
|
||||
|
||||
public class NullableType<M extends TypeHierarchy.I, N extends TypeHierarchy.I>
|
||||
extends TypeHierarchy<M, N> {
|
||||
|
||||
public NullableType(TypeHierarchy<M, N> delegate) {
|
||||
super(delegate.getM(), null,
|
||||
delegate.getClassM(), delegate.getClassN());
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 hierarchies;
|
||||
|
||||
public class OneRank {
|
||||
private OneRank() {
|
||||
}
|
||||
|
||||
public static class Hierarchy extends TypeHierarchy<TypeHierarchy.A, OneRank.B> {
|
||||
public Hierarchy() {
|
||||
super(new TypeHierarchy.A(), new OneRank.B(),
|
||||
TypeHierarchy.A.class, OneRank.B.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static class B implements TypeHierarchy.I {
|
||||
@Override
|
||||
public int m() {
|
||||
return TypeHierarchy.YEAR;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 hierarchies;
|
||||
|
||||
/**
|
||||
* Type hierarchy contains classes the type profiling and speculation are tested with
|
||||
*/
|
||||
public abstract class TypeHierarchy<M extends TypeHierarchy.I, N extends TypeHierarchy.I> {
|
||||
// Magic numbers
|
||||
public static final int ANSWER = 42;
|
||||
public static final int TEMP = 451;
|
||||
public static final int YEAR = 1984;
|
||||
|
||||
private final M m;
|
||||
private final N n;
|
||||
private final Class<M> classM;
|
||||
private final Class<N> classN;
|
||||
|
||||
protected TypeHierarchy(M m, N n, Class<M> classM, Class<N> classN) {
|
||||
this.m = m;
|
||||
this.n = n;
|
||||
this.classM = classM;
|
||||
this.classN = classN;
|
||||
}
|
||||
|
||||
public final M getM() {
|
||||
return m;
|
||||
}
|
||||
|
||||
public final N getN() {
|
||||
return n;
|
||||
}
|
||||
|
||||
public final Class<M> getClassM() {
|
||||
return classM;
|
||||
}
|
||||
|
||||
public final Class<N> getClassN() {
|
||||
return classN;
|
||||
}
|
||||
|
||||
public interface I {
|
||||
int m();
|
||||
}
|
||||
|
||||
public static class A implements I {
|
||||
@Override
|
||||
public int m() {
|
||||
return TypeHierarchy.ANSWER;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 scenarios;
|
||||
|
||||
import hierarchies.TypeHierarchy;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Tests System.arraycopy()
|
||||
*/
|
||||
public class ArrayCopy extends ArrayScenario {
|
||||
public ArrayCopy(ProfilingType profilingType,
|
||||
TypeHierarchy<? extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
|
||||
super("ArrayCopy", profilingType, hierarchy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param obj is used to fill arrays
|
||||
* @return the same obj
|
||||
*/
|
||||
@Override
|
||||
public TypeHierarchy.I run(TypeHierarchy.I obj) {
|
||||
switch (profilingType) {
|
||||
case RETURN:
|
||||
TypeHierarchy.I t = collectReturnType(obj);
|
||||
Arrays.fill(array, t);
|
||||
System.arraycopy(array, 0, matrix[0], 0, array.length);
|
||||
return array[0];
|
||||
case ARGUMENTS:
|
||||
field = obj;
|
||||
Arrays.fill(array, field);
|
||||
System.arraycopy(array, 0, matrix[0], 0, array.length);
|
||||
return array[0];
|
||||
case PARAMETERS:
|
||||
Arrays.fill(array, obj);
|
||||
System.arraycopy(array, 0, matrix[0], 0, array.length);
|
||||
return array[0];
|
||||
}
|
||||
throw new RuntimeException("Should not reach here");
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 scenarios;
|
||||
|
||||
import hierarchies.TypeHierarchy;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Tests aastore bytecode
|
||||
*/
|
||||
public class ArrayReferenceStore extends ArrayScenario {
|
||||
public ArrayReferenceStore(ProfilingType profilingType,
|
||||
TypeHierarchy<? extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
|
||||
super("ArrayReferenceStore", profilingType, hierarchy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param obj is used to fill arrays
|
||||
* @return obj
|
||||
*/
|
||||
@Override
|
||||
public TypeHierarchy.I run(TypeHierarchy.I obj) {
|
||||
switch (profilingType) {
|
||||
case RETURN:
|
||||
TypeHierarchy.I t = collectReturnType(obj);
|
||||
Arrays.fill(array, t);
|
||||
matrix[0] = array;
|
||||
return matrix[0][0];
|
||||
case ARGUMENTS:
|
||||
field = obj;
|
||||
Arrays.fill(array, field);
|
||||
matrix[0] = array;
|
||||
return matrix[0][0];
|
||||
case PARAMETERS:
|
||||
Arrays.fill(array, obj);
|
||||
matrix[0] = array;
|
||||
return matrix[0][0];
|
||||
}
|
||||
throw new RuntimeException("Should not reach here");
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 scenarios;
|
||||
|
||||
import com.oracle.java.testlibrary.Asserts;
|
||||
import hierarchies.TypeHierarchy;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Base class for array scenarios
|
||||
*/
|
||||
public abstract class ArrayScenario extends Scenario<TypeHierarchy.I, TypeHierarchy.I> {
|
||||
protected final TypeHierarchy.I[] array;
|
||||
protected final TypeHierarchy.I[][] matrix;
|
||||
|
||||
protected ArrayScenario(String name, ProfilingType profilingType,
|
||||
TypeHierarchy<? extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
|
||||
super(name, profilingType, hierarchy);
|
||||
final int x = 20;
|
||||
final int y = 10;
|
||||
|
||||
TypeHierarchy.I prof = hierarchy.getM();
|
||||
TypeHierarchy.I confl = hierarchy.getN();
|
||||
|
||||
this.array = (TypeHierarchy.I[]) Array.newInstance(hierarchy.getClassM(), y);
|
||||
Arrays.fill(array, prof);
|
||||
|
||||
this.matrix = (TypeHierarchy.I[][]) Array.newInstance(hierarchy.getClassM(), x, y);
|
||||
for (int i = 0; i < x; i++) {
|
||||
this.matrix[i] = this.array;
|
||||
}
|
||||
|
||||
Asserts.assertEquals(array.length, matrix[0].length, "Invariant");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable() {
|
||||
return hierarchy.getClassM().isAssignableFrom(hierarchy.getClassN());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check(TypeHierarchy.I res, TypeHierarchy.I orig) {
|
||||
Asserts.assertEquals(res, orig, "Check failed");
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 scenarios;
|
||||
|
||||
import com.oracle.java.testlibrary.Asserts;
|
||||
import hierarchies.TypeHierarchy;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Checkcast scenario
|
||||
* @param <T> profiling parameter
|
||||
*/
|
||||
public class CheckCast<T extends TypeHierarchy.I> extends Scenario<T, Integer> {
|
||||
public CheckCast(ProfilingType profilingType, TypeHierarchy<? extends T, ? extends T> hierarchy) {
|
||||
super("CheckCast", profilingType, hierarchy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns type profiling.
|
||||
* @param obj is a profiled parameter for the test
|
||||
* @return parameter casted to the type R
|
||||
*/
|
||||
@Override
|
||||
public Integer run(T obj) {
|
||||
switch (profilingType) {
|
||||
case RETURN:
|
||||
T t = collectReturnType(obj);
|
||||
if (t != null) {
|
||||
return t.m();
|
||||
}
|
||||
return null;
|
||||
case ARGUMENTS:
|
||||
field = obj;
|
||||
if (field != null) {
|
||||
return field.m();
|
||||
}
|
||||
return null;
|
||||
case PARAMETERS:
|
||||
if (obj != null) {
|
||||
return obj.m();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
throw new RuntimeException("Should not reach here");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check(Integer result, T orig) {
|
||||
if (result != null || orig != null) {
|
||||
Objects.requireNonNull(result);
|
||||
Objects.requireNonNull(orig);
|
||||
Asserts.assertEquals(result, orig.m(), "Results mismatch");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 scenarios;
|
||||
|
||||
import com.oracle.java.testlibrary.Asserts;
|
||||
import hierarchies.TypeHierarchy;
|
||||
|
||||
/**
|
||||
* Tests pattern: if (a.getClass() == D.class)
|
||||
*/
|
||||
public class ClassIdentity<T extends TypeHierarchy.I> extends Scenario<T, Integer> {
|
||||
public ClassIdentity(ProfilingType profilingType,
|
||||
TypeHierarchy<? extends T, ? extends T> hierarchy) {
|
||||
super("ClassIdentity", profilingType, hierarchy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable() {
|
||||
return hierarchy.getM() != null && hierarchy.getN() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer run(T obj) {
|
||||
switch (profilingType) {
|
||||
case RETURN:
|
||||
T t = collectReturnType(obj);
|
||||
if (t.getClass() == TypeHierarchy.A.class) {
|
||||
return inlinee(t);
|
||||
}
|
||||
return TypeHierarchy.TEMP;
|
||||
case ARGUMENTS:
|
||||
field = obj;
|
||||
if (field.getClass() == TypeHierarchy.A.class) {
|
||||
return inlinee(field);
|
||||
}
|
||||
return TypeHierarchy.TEMP;
|
||||
case PARAMETERS:
|
||||
if (obj.getClass() == TypeHierarchy.A.class) {
|
||||
return inlinee(obj);
|
||||
}
|
||||
return TypeHierarchy.TEMP;
|
||||
}
|
||||
throw new RuntimeException("Should not reach here");
|
||||
}
|
||||
|
||||
public int inlinee(T obj) {
|
||||
return obj.m();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check(Integer result, T orig) {
|
||||
if (orig.getClass() == TypeHierarchy.A.class) {
|
||||
Asserts.assertEquals(result, orig.m(),
|
||||
"Results are not equal for TypeHierarchy.A.class");
|
||||
} else {
|
||||
Asserts.assertEquals(result, TypeHierarchy.TEMP, "Result differs from expected");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 scenarios;
|
||||
|
||||
import com.oracle.java.testlibrary.Asserts;
|
||||
import hierarchies.TypeHierarchy;
|
||||
|
||||
/**
|
||||
* Tests instanceof
|
||||
*/
|
||||
public class ClassInstanceOf<T extends TypeHierarchy.I> extends Scenario<T, Integer> {
|
||||
public ClassInstanceOf(ProfilingType profilingType,
|
||||
TypeHierarchy<? extends T, ? extends T> hierarchy) {
|
||||
super("ClassInstanceOf", profilingType, hierarchy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer run(T obj) {
|
||||
switch (profilingType) {
|
||||
case RETURN:
|
||||
T t = collectReturnType(obj);
|
||||
if (t instanceof TypeHierarchy.A) {
|
||||
return inlinee(t);
|
||||
}
|
||||
return TypeHierarchy.TEMP;
|
||||
case ARGUMENTS:
|
||||
field = obj;
|
||||
if (field instanceof TypeHierarchy.A) {
|
||||
return inlinee(field);
|
||||
}
|
||||
return TypeHierarchy.TEMP;
|
||||
case PARAMETERS:
|
||||
if (obj instanceof TypeHierarchy.A) {
|
||||
return inlinee(obj);
|
||||
}
|
||||
return TypeHierarchy.TEMP;
|
||||
}
|
||||
throw new RuntimeException("Should not reach here");
|
||||
}
|
||||
|
||||
public int inlinee(T obj) {
|
||||
return obj.m();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check(Integer result, T orig) {
|
||||
if (orig instanceof TypeHierarchy.A) {
|
||||
Asserts.assertEquals(result, orig.m(), "Results are not equal for TypeHierarchy.A");
|
||||
} else {
|
||||
Asserts.assertEquals(result, TypeHierarchy.TEMP, "Result differs from expected");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 scenarios;
|
||||
|
||||
import com.oracle.java.testlibrary.Asserts;
|
||||
import hierarchies.TypeHierarchy;
|
||||
|
||||
/**
|
||||
* Tests {@link Class#isInstance(Object)}
|
||||
*/
|
||||
public class ClassIsInstance<T extends TypeHierarchy.I> extends Scenario<T, Integer> {
|
||||
private final Class<?> baseClass;
|
||||
|
||||
public ClassIsInstance(ProfilingType profilingType,
|
||||
TypeHierarchy<? extends T, ? extends T> hierarchy) {
|
||||
super("ClassIsInstance", profilingType, hierarchy);
|
||||
this.baseClass = hierarchy.getClassM();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer run(T obj) {
|
||||
switch (profilingType) {
|
||||
case RETURN:
|
||||
T t = collectReturnType(obj);
|
||||
if (baseClass.isInstance(t)) {
|
||||
return inlinee(t);
|
||||
}
|
||||
return TypeHierarchy.TEMP;
|
||||
case ARGUMENTS:
|
||||
field = obj;
|
||||
if (baseClass.isInstance(field)) {
|
||||
return inlinee(field);
|
||||
}
|
||||
return TypeHierarchy.TEMP;
|
||||
case PARAMETERS:
|
||||
if (baseClass.isInstance(obj)) {
|
||||
return inlinee(obj);
|
||||
}
|
||||
return TypeHierarchy.TEMP;
|
||||
}
|
||||
throw new RuntimeException("Should not reach here");
|
||||
}
|
||||
|
||||
public int inlinee(T obj) {
|
||||
return obj.m();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check(Integer result, T orig) {
|
||||
if (baseClass.isInstance(orig)) {
|
||||
Asserts.assertEquals(result, orig.m(), "Results are not equal for base class");
|
||||
} else {
|
||||
Asserts.assertEquals(result, TypeHierarchy.TEMP, "Result differs from expected");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 scenarios;
|
||||
|
||||
public enum ProfilingType {
|
||||
/** type profiling of return values of reference types from an invoke */
|
||||
RETURN,
|
||||
/** type profiling for reference parameters on method entries */
|
||||
PARAMETERS,
|
||||
/** type profiling for reference arguments at an invoke */
|
||||
ARGUMENTS,
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 scenarios;
|
||||
|
||||
import com.oracle.java.testlibrary.Asserts;
|
||||
import hierarchies.TypeHierarchy;
|
||||
|
||||
/**
|
||||
* Receiver at invokes profiling and speculation
|
||||
*
|
||||
* @param <T> parameter to be returned
|
||||
*/
|
||||
public class ReceiverAtInvokes<T extends TypeHierarchy.I> extends Scenario<T, Integer> {
|
||||
public ReceiverAtInvokes(ProfilingType profilingType,
|
||||
TypeHierarchy<? extends T, ? extends T> hierarchy) {
|
||||
super("ReceiverAtInvokes", profilingType, hierarchy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable() {
|
||||
return hierarchy.getM() != null && hierarchy.getN() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receiver profiling
|
||||
*
|
||||
* @param obj is a profiled parameter for the test
|
||||
* @return parameter casted to the type R
|
||||
*/
|
||||
@Override
|
||||
public Integer run(T obj) {
|
||||
switch (profilingType) {
|
||||
case RETURN:
|
||||
T t = collectReturnType(obj);
|
||||
return inlinee(t);
|
||||
case ARGUMENTS:
|
||||
field = obj;
|
||||
return inlinee(field);
|
||||
case PARAMETERS:
|
||||
return inlinee(obj);
|
||||
}
|
||||
throw new RuntimeException("Should not reach here");
|
||||
}
|
||||
|
||||
private Integer inlinee(T obj) {
|
||||
return obj.m(); // should be inlined
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check(Integer result, T orig) {
|
||||
Asserts.assertEquals(result, orig.m(), "Results mismatch");
|
||||
}
|
||||
}
|
108
hotspot/test/compiler/types/correctness/scenarios/Scenario.java
Normal file
108
hotspot/test/compiler/types/correctness/scenarios/Scenario.java
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 scenarios;
|
||||
|
||||
import hierarchies.TypeHierarchy;
|
||||
|
||||
/**
|
||||
* Test scenario
|
||||
*
|
||||
* @param <T> parameter type
|
||||
* @param <R> result type
|
||||
*/
|
||||
public abstract class Scenario<T extends TypeHierarchy.I, R> {
|
||||
|
||||
private final String name;
|
||||
public final ProfilingType profilingType;
|
||||
public final TypeHierarchy <? extends T, ? extends T> hierarchy;
|
||||
protected volatile T field;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name scenario name
|
||||
* @param profilingType tested profiling type
|
||||
* @param hierarchy type hierarchy
|
||||
*/
|
||||
protected Scenario(String name, ProfilingType profilingType,
|
||||
TypeHierarchy<? extends T, ? extends T> hierarchy) {
|
||||
this.profilingType = profilingType;
|
||||
this.name = name + " # " + profilingType.name();
|
||||
this.hierarchy = hierarchy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object which should be used as a parameter
|
||||
* for the methods used for profile data
|
||||
*
|
||||
* @return profiled type object
|
||||
*/
|
||||
public T getProfiled() {
|
||||
return hierarchy.getM();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object which makes a conflict for a profiled data
|
||||
* when passed instead of {@linkplain Scenario#getProfiled}
|
||||
*
|
||||
* @return incompatible to profiled object
|
||||
*/
|
||||
public T getConflict() {
|
||||
return hierarchy.getN();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return scenario name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/** Is this scenario applicable for a hierarchy it was constructed with */
|
||||
public boolean isApplicable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs test scenario
|
||||
*
|
||||
* @param t subject of the test
|
||||
* @return result of the test invocation
|
||||
*/
|
||||
public abstract R run(T t);
|
||||
|
||||
/** Used for a return type profiling */
|
||||
protected final T collectReturnType(T t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the result for R and T
|
||||
*
|
||||
* @param r result
|
||||
* @param t original
|
||||
* @throws java.lang.RuntimeException on result mismatch
|
||||
*/
|
||||
public abstract void check(R r, T t);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user