use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class PEGraphDecoderTest method test.
@Test
@SuppressWarnings("try")
public void test() {
ResolvedJavaMethod testMethod = getResolvedJavaMethod(PEGraphDecoderTest.class, "doTest", Object.class);
StructuredGraph targetGraph = null;
DebugContext debug = getDebugContext();
try (DebugContext.Scope scope = debug.scope("GraphPETest", testMethod)) {
GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withEagerResolving(true).withUnresolvedIsError(true);
registerPlugins(graphBuilderConfig.getPlugins().getInvocationPlugins());
targetGraph = new StructuredGraph.Builder(getInitialOptions(), debug, AllowAssumptions.YES).method(testMethod).build();
CachingPEGraphDecoder decoder = new CachingPEGraphDecoder(getTarget().arch, targetGraph, getProviders(), graphBuilderConfig, OptimisticOptimizations.NONE, AllowAssumptions.YES, null, null, new InlineInvokePlugin[] { new InlineAll() }, null, null, null, null);
decoder.decode(testMethod, false);
debug.dump(DebugContext.BASIC_LEVEL, targetGraph, "Target Graph");
targetGraph.verify();
PhaseContext context = new PhaseContext(getProviders());
new CanonicalizerPhase().apply(targetGraph, context);
targetGraph.verify();
} catch (Throwable ex) {
if (targetGraph != null) {
debug.dump(DebugContext.BASIC_LEVEL, targetGraph, ex.toString());
}
debug.handle(ex);
}
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class ReplacementsParseTest method testRootCompileStringize.
@Test
public void testRootCompileStringize() {
ResolvedJavaMethod method = getResolvedJavaMethod(TestObject.class, "stringize");
test(method, null, "a string");
test(method, null, Boolean.TRUE);
test(method, null, THROW_EXCEPTION_MARKER);
}
use of jdk.vm.ci.meta.ResolvedJavaMethod 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.meta.ResolvedJavaMethod 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.meta.ResolvedJavaMethod 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());
}
}
Aggregations