use of org.graalvm.compiler.phases.common.inlining.policy.InlineEverythingPolicy 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 org.graalvm.compiler.phases.common.inlining.policy.InlineEverythingPolicy in project graal by oracle.
the class WriteBarrierAdditionTest method testHelper.
@SuppressWarnings("try")
private void testHelper(final String snippetName, final int expectedBarriers) throws Exception, SecurityException {
ResolvedJavaMethod snippet = getResolvedJavaMethod(snippetName);
DebugContext debug = getDebugContext();
try (DebugContext.Scope s = debug.scope("WriteBarrierAdditionTest", snippet)) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO, debug);
HighTierContext highContext = getDefaultHighTierContext();
MidTierContext midContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
new InliningPhase(new InlineEverythingPolicy(), new CanonicalizerPhase()).apply(graph, highContext);
new CanonicalizerPhase().apply(graph, highContext);
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highContext);
new GuardLoweringPhase().apply(graph, midContext);
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
new WriteBarrierAdditionPhase(config).apply(graph);
debug.dump(DebugContext.BASIC_LEVEL, graph, "After Write Barrier Addition");
int barriers = 0;
if (config.useG1GC) {
barriers = graph.getNodes().filter(G1ReferentFieldReadBarrier.class).count() + graph.getNodes().filter(G1PreWriteBarrier.class).count() + graph.getNodes().filter(G1PostWriteBarrier.class).count();
} else {
barriers = graph.getNodes().filter(SerialWriteBarrier.class).count();
}
if (expectedBarriers != barriers) {
Assert.assertEquals(getScheduledGraphString(graph), expectedBarriers, barriers);
}
for (WriteNode write : graph.getNodes().filter(WriteNode.class)) {
if (config.useG1GC) {
if (write.getBarrierType() != BarrierType.NONE) {
Assert.assertEquals(1, write.successors().count());
Assert.assertTrue(write.next() instanceof G1PostWriteBarrier);
Assert.assertTrue(write.predecessor() instanceof G1PreWriteBarrier);
}
} else {
if (write.getBarrierType() != BarrierType.NONE) {
Assert.assertEquals(1, write.successors().count());
Assert.assertTrue(write.next() instanceof SerialWriteBarrier);
}
}
}
for (ReadNode read : graph.getNodes().filter(ReadNode.class)) {
if (read.getBarrierType() != BarrierType.NONE) {
Assert.assertTrue(read.getAddress() instanceof OffsetAddressNode);
JavaConstant constDisp = ((OffsetAddressNode) read.getAddress()).getOffset().asJavaConstant();
Assert.assertNotNull(constDisp);
Assert.assertEquals(referentOffset, constDisp.asLong());
Assert.assertTrue(config.useG1GC);
Assert.assertEquals(BarrierType.PRECISE, read.getBarrierType());
Assert.assertTrue(read.next() instanceof G1ReferentFieldReadBarrier);
}
}
} catch (Throwable e) {
throw debug.handle(e);
}
}
Aggregations