use of org.graalvm.compiler.nodes.DeadEndNode in project graal by oracle.
the class CEntryPointCallStubMethod method generatePrologueOrEpilogueInvoke.
private static InvokeWithExceptionNode generatePrologueOrEpilogueInvoke(SubstrateGraphKit kit, ResolvedJavaMethod method, ValueNode... args) {
VMError.guarantee(method.isAnnotationPresent(Uninterruptible.class), "The method " + method + " must be uninterruptible as it is used for a prologue or epilogue.");
InvokeWithExceptionNode invoke = kit.startInvokeWithException(method, InvokeKind.Static, kit.getFrameState(), kit.bci(), args);
kit.exceptionPart();
kit.append(new DeadEndNode());
kit.endInvokeWithException();
return invoke;
}
use of org.graalvm.compiler.nodes.DeadEndNode in project graal by oracle.
the class OptimizeExceptionPathsPhase method run.
@Override
protected void run(StructuredGraph graph) {
/*
* First walk back from all exceptional control flow sinks to a control flow split that also
* goes to a "regular" return.
*/
NodeBitMap exceptionPaths = new NodeBitMap(graph);
for (UnwindNode unwind : graph.getNodes(UnwindNode.TYPE)) {
walkBack(unwind, exceptionPaths);
}
for (DeadEndNode deadEnd : graph.getNodes(DeadEndNode.TYPE)) {
walkBack(deadEnd, exceptionPaths);
}
for (LoweredDeadEndNode deadEnd : graph.getNodes(LoweredDeadEndNode.TYPE)) {
walkBack(deadEnd, exceptionPaths);
}
/* Now that we know all control flow splits, we modify the branch probabilities. */
for (Node n : exceptionPaths) {
AbstractBeginNode exceptionBegin = (AbstractBeginNode) n;
ControlSplitNode controlSplitNode = (ControlSplitNode) exceptionBegin.predecessor();
/*
* Only overwrite the branch probability if it comes from non-profiled sources. If we
* have proper PGO information that the exception edge is used, it deserves to be
* optimized.
*/
if (controlSplitNode.getProfileData().getProfileSource() != ProfileData.ProfileSource.PROFILED) {
controlSplitNode.setProbability(exceptionBegin, BranchProbabilityNode.EXTREMELY_SLOW_PATH_PROFILE);
}
}
}
use of org.graalvm.compiler.nodes.DeadEndNode 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