Search in sources :

Example 1 with PointerEqualsNode

use of org.graalvm.compiler.nodes.calc.PointerEqualsNode in project graal by oracle.

the class HotSpotWordOperationPlugin method processHotSpotWordOperation.

protected void processHotSpotWordOperation(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args, HotSpotOperation operation) {
    JavaKind returnKind = method.getSignature().getReturnKind();
    switch(operation.opcode()) {
        case POINTER_EQ:
        case POINTER_NE:
            assert args.length == 2;
            HotspotOpcode opcode = operation.opcode();
            ValueNode left = args[0];
            ValueNode right = args[1];
            assert left.stamp(NodeView.DEFAULT) instanceof MetaspacePointerStamp : left + " " + left.stamp(NodeView.DEFAULT);
            assert right.stamp(NodeView.DEFAULT) instanceof MetaspacePointerStamp : right + " " + right.stamp(NodeView.DEFAULT);
            assert opcode == POINTER_EQ || opcode == POINTER_NE;
            PointerEqualsNode comparison = b.add(new PointerEqualsNode(left, right));
            ValueNode eqValue = b.add(forBoolean(opcode == POINTER_EQ));
            ValueNode neValue = b.add(forBoolean(opcode == POINTER_NE));
            b.addPush(returnKind, ConditionalNode.create(comparison, eqValue, neValue, NodeView.DEFAULT));
            break;
        case IS_NULL:
            assert args.length == 1;
            ValueNode pointer = args[0];
            assert pointer.stamp(NodeView.DEFAULT) instanceof MetaspacePointerStamp;
            LogicNode isNull = b.addWithInputs(IsNullNode.create(pointer));
            b.addPush(returnKind, ConditionalNode.create(isNull, b.add(forBoolean(true)), b.add(forBoolean(false)), NodeView.DEFAULT));
            break;
        case FROM_POINTER:
            assert args.length == 1;
            b.addPush(returnKind, new PointerCastNode(StampFactory.forKind(wordKind), args[0]));
            break;
        case TO_KLASS_POINTER:
            assert args.length == 1;
            b.addPush(returnKind, new PointerCastNode(KlassPointerStamp.klass(), args[0]));
            break;
        case TO_METHOD_POINTER:
            assert args.length == 1;
            b.addPush(returnKind, new PointerCastNode(MethodPointerStamp.method(), args[0]));
            break;
        case READ_KLASS_POINTER:
            assert args.length == 2 || args.length == 3;
            Stamp readStamp = KlassPointerStamp.klass();
            AddressNode address = makeAddress(b, args[0], args[1]);
            LocationIdentity location;
            if (args.length == 2) {
                location = any();
            } else {
                assert args[2].isConstant();
                location = snippetReflection.asObject(LocationIdentity.class, args[2].asJavaConstant());
            }
            ReadNode read = b.add(new ReadNode(address, location, readStamp, BarrierType.NONE));
            b.push(returnKind, read);
            break;
        default:
            throw GraalError.shouldNotReachHere("unknown operation: " + operation.opcode());
    }
}
Also used : HotspotOpcode(org.graalvm.compiler.hotspot.word.HotSpotOperation.HotspotOpcode) MethodPointerStamp(org.graalvm.compiler.hotspot.nodes.type.MethodPointerStamp) MetaspacePointerStamp(org.graalvm.compiler.hotspot.nodes.type.MetaspacePointerStamp) KlassPointerStamp(org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) MetaspacePointerStamp(org.graalvm.compiler.hotspot.nodes.type.MetaspacePointerStamp) PointerEqualsNode(org.graalvm.compiler.nodes.calc.PointerEqualsNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LocationIdentity(org.graalvm.word.LocationIdentity) LogicNode(org.graalvm.compiler.nodes.LogicNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) PointerCastNode(org.graalvm.compiler.hotspot.word.PointerCastNode) JavaKind(jdk.vm.ci.meta.JavaKind)

Aggregations

JavaKind (jdk.vm.ci.meta.JavaKind)1 Stamp (org.graalvm.compiler.core.common.type.Stamp)1 KlassPointerStamp (org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp)1 MetaspacePointerStamp (org.graalvm.compiler.hotspot.nodes.type.MetaspacePointerStamp)1 MethodPointerStamp (org.graalvm.compiler.hotspot.nodes.type.MethodPointerStamp)1 HotspotOpcode (org.graalvm.compiler.hotspot.word.HotSpotOperation.HotspotOpcode)1 PointerCastNode (org.graalvm.compiler.hotspot.word.PointerCastNode)1 LogicNode (org.graalvm.compiler.nodes.LogicNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 PointerEqualsNode (org.graalvm.compiler.nodes.calc.PointerEqualsNode)1 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)1 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)1 LocationIdentity (org.graalvm.word.LocationIdentity)1