use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class UnsafeSubstitutionsTest method testSubstitution.
public void testSubstitution(String testMethodName, Class<?> holder, String methodName, Class<?>[] parameterTypes, Object receiver, Object[] args1, Object[] args2) {
ResolvedJavaMethod testMethod = getResolvedJavaMethod(testMethodName);
ResolvedJavaMethod originalMethod = getResolvedJavaMethod(holder, methodName, parameterTypes);
// Force compilation
InstalledCode code = getCode(testMethod);
assert code != null;
// Verify that the original method and the substitution produce the same value
Object expected = invokeSafe(originalMethod, receiver, args1);
Object actual = invokeSafe(testMethod, null, args2);
assertDeepEquals(expected, actual);
// Verify that the generated code and the original produce the same value
expected = invokeSafe(originalMethod, receiver, args1);
actual = executeVarargsSafe(code, args2);
assertDeepEquals(expected, actual);
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class StandardMethodSubstitutionsTest method testSubstitution.
public void testSubstitution(String testMethodName, Class<?> intrinsicClass, Class<?> holder, String methodName, boolean optional, Object... args) {
ResolvedJavaMethod realJavaMethod = getResolvedJavaMethod(holder, methodName);
ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod(testMethodName);
StructuredGraph graph = testGraph(testMethodName);
// Check to see if the resulting graph contains the expected node
StructuredGraph replacement = getReplacements().getSubstitution(realJavaMethod, -1, false, null);
if (replacement == null && !optional) {
assertInGraph(graph, intrinsicClass);
}
for (Object l : args) {
// Force compilation
InstalledCode code = getCode(testJavaMethod);
assert optional || code != null;
// Verify that the original method and the substitution produce the same value
Object expected = invokeSafe(realJavaMethod, null, l);
assertDeepEquals(expected, invokeSafe(testJavaMethod, null, l));
// Verify that the generated code and the original produce the same value
assertDeepEquals(expected, executeVarargsSafe(code, l));
}
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class MethodSubstitutionTest method testSubstitution.
protected void testSubstitution(String testMethodName, Class<?> intrinsicClass, Class<?> holder, String methodName, Class<?>[] parameterTypes, boolean optional, Object[] args1, Object[] args2) {
ResolvedJavaMethod realMethod = getResolvedJavaMethod(holder, methodName, parameterTypes);
ResolvedJavaMethod testMethod = getResolvedJavaMethod(testMethodName);
StructuredGraph graph = testGraph(testMethodName);
// Check to see if the resulting graph contains the expected node
StructuredGraph replacement = getReplacements().getSubstitution(realMethod, -1, false, null);
if (replacement == null && !optional) {
assertInGraph(graph, intrinsicClass);
}
// Force compilation
InstalledCode code = getCode(testMethod);
assert optional || code != null;
for (int i = 0; i < args1.length; i++) {
Object arg1 = args1[i];
Object arg2 = args2[i];
Object expected = invokeSafe(realMethod, null, arg1, arg2);
// Verify that the original method and the substitution produce the same value
assertDeepEquals(expected, invokeSafe(testMethod, null, arg1, arg2));
// Verify that the generated code and the original produce the same value
assertDeepEquals(expected, executeVarargsSafe(code, arg1, arg2));
}
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class DeoptimizeOnExceptionTest method test3.
@Test
public void test3() {
Assume.assumeTrue("Only works on jdk8 right now", Java8OrEarlier);
ResolvedJavaMethod method = getResolvedJavaMethod("test3Snippet");
for (int i = 0; i < 2; i++) {
Result actual;
boolean expectedCompiledCode = (method.getProfilingInfo().getDeoptimizationCount(DeoptimizationReason.NotCompiledExceptionHandler) != 0);
InstalledCode code = getCode(method, null, false, true, new OptionValues(getInitialOptions(), HighTier.Options.Inline, false));
assertTrue(code.isValid());
try {
actual = new Result(code.executeVarargs(false), null);
} catch (Exception e) {
actual = new Result(null, e);
}
assertTrue(i > 0 == expectedCompiledCode, "expect compiled code to stay around after the first iteration");
assertEquals(new Result(expectedCompiledCode, null), actual);
assertTrue(expectedCompiledCode == code.isValid());
}
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class DeoptimizeOnVolatileReadTest method test2.
@Test
public void test2() {
ResolvedJavaMethod method = getResolvedJavaMethod("test2Snippet");
Dummy dummy = new Dummy();
Result expected = executeExpected(method, null, dummy);
assertEquals(new Result(0, null), expected);
dummy.f2 = true;
InstalledCode code = getCode(method);
Result actual;
try {
actual = new Result(code.executeVarargs(dummy), null);
} catch (Exception e) {
actual = new Result(null, e);
}
// The code should get deoptimized, and resume execution at the then-branch.
assertEquals(new Result(1, null), actual);
assertFalse(code.isValid());
}
Aggregations