use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class UnsafeVirtualizationTest method testPartialEscapeReadElimination.
public void testPartialEscapeReadElimination(String snippet, boolean canonicalizeBefore, Object... args) {
assert AF1Offset % 8 == 0 : "First of the two int-fields must be 8-byte aligned";
ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
OptionValues options = graph.getOptions();
PhaseContext context = getDefaultHighTierContext();
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
if (canonicalizeBefore) {
canonicalizer.apply(graph, context);
}
Result r = executeExpected(method, null, args);
new PartialEscapePhase(true, true, canonicalizer, null, options).apply(graph, context);
try {
InstalledCode code = getCode(method, graph);
Object result = code.executeVarargs(args);
assertEquals(r, new Result(result, null));
} catch (Throwable e) {
assertFalse(true, e.toString());
}
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class CompiledMethodTest method test3.
@Test
public void test3() {
final ResolvedJavaMethod javaMethod = getResolvedJavaMethod("testMethod");
InstalledCode compiledMethod = getCode(javaMethod);
try {
Object result = compiledMethod.executeVarargs("1", "2", "3");
Assert.assertEquals("1 2 3", result);
} catch (InvalidInstalledCodeException t) {
Assert.fail("method invalidated");
}
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class MarkUnsafeAccessTest method testCompiled.
@Test
public void testCompiled() throws IOException {
ResolvedJavaMethod getMethod = asResolvedJavaMethod(getMethod(ByteBuffer.class, "get", new Class<?>[] {}));
ResolvedJavaType mbbClass = getMetaAccess().lookupJavaType(MappedByteBuffer.class);
ResolvedJavaMethod getMethodImpl = mbbClass.findUniqueConcreteMethod(getMethod).getResult();
Assert.assertNotNull(getMethodImpl);
StructuredGraph graph = parseForCompile(getMethodImpl);
HighTierContext highContext = getDefaultHighTierContext();
new CanonicalizerPhase().apply(graph, highContext);
new InliningPhase(new InlineEverythingPolicy(), new CanonicalizerPhase()).apply(graph, highContext);
InstalledCode compiledCode = getCode(getMethodImpl, graph);
testMappedByteBuffer(mbb -> {
try {
return (byte) compiledCode.executeVarargs(mbb);
} catch (InvalidInstalledCodeException e) {
Assert.fail();
return 0;
}
});
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class InstalledCodeInvalidationTest method testInstalledCodeInvalidation.
/**
* Test that after uncommon trapping in an installed code it's still possible to invalidate all
* existing activations of that installed code.
*
* @throws InvalidInstalledCodeException
*/
@Test
public void testInstalledCodeInvalidation() throws InvalidInstalledCodeException {
InstalledCode code = getCode(getMetaAccess().lookupJavaMethod(getMethod("recurse")));
code.executeVarargs(this, code, 3);
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class GraalTutorial method testStringHashCode.
/*
* A simple Graal compilation example: Compile the method String.hashCode()
*/
@Test
public void testStringHashCode() throws InvalidInstalledCodeException {
int expectedResult = "Hello World".hashCode();
InstalledCode installedCode = compileAndInstallMethod(findMethod(String.class, "hashCode"));
int result = (int) installedCode.executeVarargs("Hello World");
Assert.assertEquals(expectedResult, result);
}
Aggregations