use of org.graalvm.compiler.nodes.LogicNode in project graal by oracle.
the class UseTrappingNullChecksPhase method checkPredecessor.
private static void checkPredecessor(AbstractDeoptimizeNode deopt, Node predecessor, DeoptimizationReason deoptimizationReason, long implicitNullCheckLimit) {
Node current = predecessor;
AbstractBeginNode branch = null;
while (current instanceof AbstractBeginNode) {
branch = (AbstractBeginNode) current;
if (branch.anchored().isNotEmpty()) {
// some input of the deopt framestate is anchored to this branch
return;
}
current = current.predecessor();
}
if (current instanceof IfNode) {
IfNode ifNode = (IfNode) current;
if (branch != ifNode.trueSuccessor()) {
return;
}
LogicNode condition = ifNode.condition();
if (condition instanceof IsNullNode) {
replaceWithTrappingNullCheck(deopt, ifNode, condition, deoptimizationReason, implicitNullCheckLimit);
}
}
}
use of org.graalvm.compiler.nodes.LogicNode in project graal by oracle.
the class TypeGuardInlineInfo method createGuard.
@SuppressWarnings("try")
private void createGuard(StructuredGraph graph, Providers providers) {
try (DebugCloseable context = invoke.asNode().withNodeSourcePosition()) {
ValueNode nonNullReceiver = InliningUtil.nonNullReceiver(invoke);
LoadHubNode receiverHub = graph.unique(new LoadHubNode(providers.getStampProvider(), nonNullReceiver));
ConstantNode typeHub = ConstantNode.forConstant(receiverHub.stamp(NodeView.DEFAULT), providers.getConstantReflection().asObjectHub(type), providers.getMetaAccess(), graph);
LogicNode typeCheck = CompareNode.createCompareNode(graph, CanonicalCondition.EQ, receiverHub, typeHub, providers.getConstantReflection(), NodeView.DEFAULT);
FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile));
assert invoke.predecessor() != null;
ValueNode anchoredReceiver = InliningUtil.createAnchoredReceiver(graph, guard, type, nonNullReceiver, true);
invoke.callTarget().replaceFirstInput(nonNullReceiver, anchoredReceiver);
graph.addBeforeFixed(invoke.asNode(), guard);
}
}
use of org.graalvm.compiler.nodes.LogicNode in project graal by oracle.
the class ReflectionSubstitutionType method createCheckcast.
private static ValueNode createCheckcast(HostedGraphKit graphKit, ValueNode value, ResolvedJavaType type, boolean nonNull) {
TypeReference typeRef = TypeReference.createTrusted(graphKit.getAssumptions(), type);
LogicNode condition;
if (nonNull) {
condition = graphKit.append(InstanceOfNode.create(typeRef, value));
} else {
condition = graphKit.append(InstanceOfNode.createAllowNull(typeRef, value, null, null));
}
graphKit.startIf(condition, BranchProbabilityNode.FAST_PATH_PROBABILITY);
graphKit.thenPart();
PiNode ret = graphKit.createPiNode(value, StampFactory.object(typeRef, nonNull));
graphKit.elsePart();
throwFailedCast(graphKit, type, value);
graphKit.endIf();
return ret;
}
Aggregations