Search in sources :

Example 21 with TypeReference

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;
}
Also used : LogicNode(org.graalvm.compiler.nodes.LogicNode) TypeReference(org.graalvm.compiler.core.common.type.TypeReference) PiNode(org.graalvm.compiler.nodes.PiNode)

Aggregations

TypeReference (org.graalvm.compiler.core.common.type.TypeReference)21 ValueNode (org.graalvm.compiler.nodes.ValueNode)15 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)13 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)8 LogicNode (org.graalvm.compiler.nodes.LogicNode)8 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)6 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)6 Assumptions (jdk.vm.ci.meta.Assumptions)4 JavaType (jdk.vm.ci.meta.JavaType)4 Stamp (org.graalvm.compiler.core.common.type.Stamp)4 PiNode (org.graalvm.compiler.nodes.PiNode)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)3 HostedType (com.oracle.svm.hosted.meta.HostedType)2 RuntimeConstraint (jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)2 JavaKind (jdk.vm.ci.meta.JavaKind)2 JavaTypeProfile (jdk.vm.ci.meta.JavaTypeProfile)2 Signature (jdk.vm.ci.meta.Signature)2 AbstractObjectStamp (org.graalvm.compiler.core.common.type.AbstractObjectStamp)2