use of jdk.vm.ci.meta.ResolvedJavaMethod 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());
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class EdgesTest method testMethod.
private void testMethod(Method method, Object receiver, Object... args) {
try {
// Invoke the method to ensure it has a type profile
for (int i = 0; i < 5000; i++) {
method.invoke(receiver, args);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method);
StructuredGraph g = parseProfiled(javaMethod, AllowAssumptions.NO);
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(new InlineMethodSubstitutionsPolicy(), new CanonicalizerPhase()).apply(g, context);
new CanonicalizerPhase().apply(g, context);
Assert.assertTrue(g.getNodes().filter(InstanceOfNode.class).isEmpty());
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class FloatArraysEqualsTest method testStableArray.
public void testStableArray(String methodName) {
ResolvedJavaMethod method = getResolvedJavaMethod(methodName);
Result expected = executeExpected(method, null);
StructuredGraph graph = parseEager(method, AllowAssumptions.YES);
for (ConstantNode constantNode : graph.getNodes().filter(ConstantNode.class).snapshot()) {
if (getConstantReflection().readArrayLength(constantNode.asJavaConstant()) != null) {
ConstantNode newConstantNode = ConstantNode.forConstant(constantNode.asJavaConstant(), 1, true, getMetaAccess());
newConstantNode = graph.unique(newConstantNode);
constantNode.replaceAndDelete(newConstantNode);
}
}
CompilationResult result = compile(method, graph);
InstalledCode code = addMethod(graph.getDebug(), method, result);
Result actual;
try {
actual = new Result(code.executeVarargs(), null);
} catch (Exception e) {
actual = new Result(null, e);
}
assertEquals(expected, actual);
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class StringEqualsConstantTest method testStringEquals.
private void testStringEquals(String s0, String s1) {
ResolvedJavaMethod method = getResolvedJavaMethod("stringEquals");
StructuredGraph graph = parseForCompile(method);
graph.getParameter(0).replaceAndDelete(asConstant(graph, s0));
graph.getParameter(1).replaceAndDelete(asConstant(graph, s1));
compile(method, graph);
FixedNode firstFixed = graph.start().next();
Assert.assertThat(firstFixed, instanceOf(ReturnNode.class));
ReturnNode ret = (ReturnNode) firstFixed;
JavaConstant result = ret.result().asJavaConstant();
if (result == null) {
Assert.fail("result not constant: " + ret.result());
} else {
int expected = s0.equals(s1) ? 1 : 0;
Assert.assertEquals("result", expected, result.asInt());
}
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class StringHashConstantTest method test2.
@Test
public void test2() {
ResolvedJavaMethod method = getResolvedJavaMethod("constantHashCode");
StructuredGraph graph = parseForCompile(method);
FixedNode firstFixed = graph.start().next();
Assert.assertThat(firstFixed, instanceOf(ReturnNode.class));
ReturnNode ret = (ReturnNode) firstFixed;
JavaConstant result = ret.result().asJavaConstant();
if (result == null) {
Assert.fail("result not constant: " + ret.result());
} else {
int expected = A_CONSTANT_STRING.hashCode();
Assert.assertEquals("result", expected, result.asInt());
}
}
Aggregations