use of org.graalvm.compiler.core.common.type.TypeReference 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