use of org.graalvm.compiler.nodes.gc.G1PreWriteBarrier in project graal by oracle.
the class WriteBarrierAdditionTest method verifyBarriers.
private void verifyBarriers(StructuredGraph graph) {
Assert.assertTrue("Unknown collector selected", knownSupport.contains(runtime().getGarbageCollector()));
Assert.assertNotEquals("test must set expected barrier count", expectedBarriers, -1);
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(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 || write.getLocationIdentity().isImmutable());
}
} 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) {
if (read.getAddress() instanceof OffsetAddressNode) {
JavaConstant constDisp = ((OffsetAddressNode) read.getAddress()).getOffset().asJavaConstant();
if (constDisp != null) {
Assert.assertEquals(referentOffset(getMetaAccess()), constDisp.asLong());
}
}
Assert.assertTrue(BarrierType.WEAK_FIELD == read.getBarrierType() || BarrierType.PHANTOM_FIELD == read.getBarrierType());
if (config.useG1GC) {
Assert.assertTrue(read.next() instanceof G1ReferentFieldReadBarrier);
}
}
}
}
use of org.graalvm.compiler.nodes.gc.G1PreWriteBarrier in project graal by oracle.
the class DefaultHotSpotLoweringProvider method lowerWithoutDelegation.
/**
* Handles the lowering of {@code n} without delegating to plugins or super.
*
* @return {@code true} if this method handles lowering of {@code n}
*/
private boolean lowerWithoutDelegation(Node n, LoweringTool tool) {
StructuredGraph graph = (StructuredGraph) n.graph();
if (n instanceof Invoke) {
lowerInvoke((Invoke) n, tool, graph);
} else if (n instanceof LoadMethodNode) {
lowerLoadMethodNode((LoadMethodNode) n);
} else if (n instanceof GetClassNode) {
lowerGetClassNode((GetClassNode) n, tool, graph);
} else if (n instanceof StoreHubNode) {
lowerStoreHubNode((StoreHubNode) n, graph);
} else if (n instanceof OSRStartNode) {
lowerOSRStartNode((OSRStartNode) n);
} else if (n instanceof BytecodeExceptionNode) {
lowerBytecodeExceptionNode((BytecodeExceptionNode) n);
} else if (n instanceof InstanceOfNode) {
InstanceOfNode instanceOfNode = (InstanceOfNode) n;
if (graph.getGuardsStage().areDeoptsFixed()) {
instanceofSnippets.lower(instanceOfNode, tool);
} else {
if (instanceOfNode.allowsNull()) {
ValueNode object = instanceOfNode.getValue();
LogicNode newTypeCheck = graph.addOrUniqueWithInputs(InstanceOfNode.create(instanceOfNode.type(), object, instanceOfNode.profile(), instanceOfNode.getAnchor()));
LogicNode newNode = LogicNode.or(graph.unique(IsNullNode.create(object)), newTypeCheck, BranchProbabilityNode.NOT_LIKELY_PROFILE);
instanceOfNode.replaceAndDelete(newNode);
}
}
} else if (n instanceof InstanceOfDynamicNode) {
InstanceOfDynamicNode instanceOfDynamicNode = (InstanceOfDynamicNode) n;
if (graph.getGuardsStage().areDeoptsFixed()) {
instanceofSnippets.lower(instanceOfDynamicNode, tool);
} else {
ValueNode mirror = instanceOfDynamicNode.getMirrorOrHub();
if (mirror.stamp(NodeView.DEFAULT).getStackKind() == JavaKind.Object) {
ClassGetHubNode classGetHub = graph.unique(new ClassGetHubNode(mirror));
instanceOfDynamicNode.setMirror(classGetHub);
}
if (instanceOfDynamicNode.allowsNull()) {
ValueNode object = instanceOfDynamicNode.getObject();
LogicNode newTypeCheck = graph.addOrUniqueWithInputs(InstanceOfDynamicNode.create(graph.getAssumptions(), tool.getConstantReflection(), instanceOfDynamicNode.getMirrorOrHub(), object, false, /* null checked below */
instanceOfDynamicNode.isExact()));
LogicNode newNode = LogicNode.or(graph.unique(IsNullNode.create(object)), newTypeCheck, BranchProbabilityNode.NOT_LIKELY_PROFILE);
instanceOfDynamicNode.replaceAndDelete(newNode);
}
}
} else if (n instanceof ClassIsAssignableFromNode) {
if (graph.getGuardsStage().areDeoptsFixed()) {
instanceofSnippets.lower((ClassIsAssignableFromNode) n, tool);
}
} else if (n instanceof NewInstanceNode) {
if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
getAllocationSnippets().lower((NewInstanceNode) n, tool);
}
} else if (n instanceof DynamicNewInstanceNode) {
if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
getAllocationSnippets().lower((DynamicNewInstanceNode) n, tool);
}
} else if (n instanceof ValidateNewInstanceClassNode) {
ValidateNewInstanceClassNode validateNewInstance = (ValidateNewInstanceClassNode) n;
if (validateNewInstance.getClassClass() == null) {
JavaConstant classClassMirror = constantReflection.asJavaClass(metaAccess.lookupJavaType(Class.class));
ConstantNode classClass = ConstantNode.forConstant(classClassMirror, tool.getMetaAccess(), graph);
validateNewInstance.setClassClass(classClass);
}
getAllocationSnippets().lower(validateNewInstance, tool);
} else if (n instanceof NewArrayNode) {
if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
getAllocationSnippets().lower((NewArrayNode) n, tool);
}
} else if (n instanceof DynamicNewArrayNode) {
DynamicNewArrayNode dynamicNewArrayNode = (DynamicNewArrayNode) n;
if (dynamicNewArrayNode.getVoidClass() == null) {
JavaConstant voidClassMirror = constantReflection.asJavaClass(metaAccess.lookupJavaType(void.class));
ConstantNode voidClass = ConstantNode.forConstant(voidClassMirror, tool.getMetaAccess(), graph);
dynamicNewArrayNode.setVoidClass(voidClass);
}
if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
getAllocationSnippets().lower(dynamicNewArrayNode, tool);
}
} else if (n instanceof VerifyHeapNode) {
if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
getAllocationSnippets().lower((VerifyHeapNode) n, tool);
}
} else if (n instanceof MonitorEnterNode) {
if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
monitorSnippets.lower((MonitorEnterNode) n, registers, tool);
} else {
loadHubForMonitorEnterNode((MonitorEnterNode) n, tool, graph);
}
} else if (n instanceof MonitorExitNode) {
if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
monitorSnippets.lower((MonitorExitNode) n, registers, tool);
}
} else if (n instanceof ArrayCopyNode) {
arraycopySnippets.lower((ArrayCopyNode) n, tool);
} else if (n instanceof ArrayCopyWithDelayedLoweringNode) {
arraycopySnippets.lower((ArrayCopyWithDelayedLoweringNode) n, tool);
} else if (n instanceof G1PreWriteBarrier) {
g1WriteBarrierSnippets.lower((G1PreWriteBarrier) n, tool);
} else if (n instanceof G1PostWriteBarrier) {
g1WriteBarrierSnippets.lower((G1PostWriteBarrier) n, tool);
} else if (n instanceof G1ReferentFieldReadBarrier) {
g1WriteBarrierSnippets.lower((G1ReferentFieldReadBarrier) n, tool);
} else if (n instanceof SerialWriteBarrier) {
serialWriteBarrierSnippets.lower((SerialWriteBarrier) n, tool);
} else if (n instanceof SerialArrayRangeWriteBarrier) {
serialWriteBarrierSnippets.lower((SerialArrayRangeWriteBarrier) n, tool);
} else if (n instanceof G1ArrayRangePreWriteBarrier) {
g1WriteBarrierSnippets.lower((G1ArrayRangePreWriteBarrier) n, tool);
} else if (n instanceof G1ArrayRangePostWriteBarrier) {
g1WriteBarrierSnippets.lower((G1ArrayRangePostWriteBarrier) n, tool);
} else if (n instanceof NewMultiArrayNode) {
if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
getAllocationSnippets().lower((NewMultiArrayNode) n, tool);
}
} else if (n instanceof LoadExceptionObjectNode) {
exceptionObjectSnippets.lower((LoadExceptionObjectNode) n, registers, tool);
} else if (n instanceof AssertionNode) {
assertionSnippets.lower((AssertionNode) n, tool);
} else if (n instanceof LogNode) {
logSnippets.lower((LogNode) n, tool);
} else if (n instanceof StringToBytesNode) {
if (graph.getGuardsStage().areDeoptsFixed()) {
stringToBytesSnippets.lower((StringToBytesNode) n, tool);
}
} else if (n instanceof IntegerDivRemNode) {
// Nothing to do for division nodes. The HotSpot signal handler catches divisions by
// zero and the MIN_VALUE / -1 cases.
} else if (n instanceof AbstractDeoptimizeNode || n instanceof UnwindNode || n instanceof RemNode || n instanceof SafepointNode) {
/* No lowering, we generate LIR directly for these nodes. */
} else if (n instanceof ClassGetHubNode) {
lowerClassGetHubNode((ClassGetHubNode) n, tool);
} else if (n instanceof HubGetClassNode) {
lowerHubGetClassNode((HubGetClassNode) n, tool);
} else if (n instanceof KlassLayoutHelperNode) {
lowerKlassLayoutHelperNode((KlassLayoutHelperNode) n, tool);
} else if (n instanceof KlassBeingInitializedCheckNode) {
getAllocationSnippets().lower((KlassBeingInitializedCheckNode) n, tool);
} else if (n instanceof FastNotifyNode) {
if (graph.getGuardsStage() == GuardsStage.AFTER_FSA) {
objectSnippets.lower(n, tool);
}
} else if (n instanceof UnsafeCopyMemoryNode) {
if (graph.getGuardsStage() == GuardsStage.AFTER_FSA) {
unsafeSnippets.lower((UnsafeCopyMemoryNode) n, tool);
}
} else if (n instanceof RegisterFinalizerNode) {
lowerRegisterFinalizer((RegisterFinalizerNode) n, tool);
} else if (n instanceof DeadEndNode) {
lowerDeadEnd((DeadEndNode) n);
} else {
return false;
}
return true;
}
Aggregations