use of org.graalvm.compiler.hotspot.replacements.FastNotifyNode in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerObjectPlugins.
private static void registerObjectPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) {
Registration r = new Registration(plugins, Object.class, replacements);
r.register(new InlineOnlyInvocationPlugin("clone", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.addPush(JavaKind.Object, new ObjectCloneNode(MacroParams.of(b, targetMethod, object)));
return true;
}
});
r.register(new InlineOnlyInvocationPlugin("hashCode", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.addPush(JavaKind.Int, new HotSpotIdentityHashCodeNode(object, b.bci()));
return true;
}
});
if (config.inlineNotify()) {
r.register(new InlineOnlyInvocationPlugin("notify", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.add(new FastNotifyNode(object, false, b.bci()));
return true;
}
});
}
if (config.inlineNotifyAll()) {
r.register(new InlineOnlyInvocationPlugin("notifyAll", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.add(new FastNotifyNode(object, true, b.bci()));
return true;
}
});
}
}
use of org.graalvm.compiler.hotspot.replacements.FastNotifyNode 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