Search in sources :

Example 1 with Constant

use of jdk.vm.ci.meta.Constant in project graal by oracle.

the class AArch64HotSpotLIRGenerator method emitCompare.

@Override
protected boolean emitCompare(PlatformKind cmpKind, Value a, Value b, Condition condition, boolean unorderedIsTrue) {
    Value localA = a;
    Value localB = b;
    if (isConstantValue(a)) {
        Constant c = asConstant(a);
        if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) {
            localA = AArch64.zr.asValue(LIRKind.value(AArch64Kind.DWORD));
        } else if (c instanceof HotSpotObjectConstant) {
            localA = load(localA);
        }
    }
    if (isConstantValue(b)) {
        Constant c = asConstant(b);
        if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) {
            localB = AArch64.zr.asValue(LIRKind.value(AArch64Kind.DWORD));
        } else if (c instanceof HotSpotObjectConstant) {
            localB = load(localB);
        }
    }
    return super.emitCompare(cmpKind, localA, localB, condition, unorderedIsTrue);
}
Also used : Constant(jdk.vm.ci.meta.Constant) JavaConstant(jdk.vm.ci.meta.JavaConstant) HotSpotCompressedNullConstant(jdk.vm.ci.hotspot.HotSpotCompressedNullConstant) HotSpotObjectConstant(jdk.vm.ci.hotspot.HotSpotObjectConstant) LIRValueUtil.asConstant(org.graalvm.compiler.lir.LIRValueUtil.asConstant) LIRValueUtil.isConstantValue(org.graalvm.compiler.lir.LIRValueUtil.isConstantValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) AArch64AddressValue(org.graalvm.compiler.lir.aarch64.AArch64AddressValue) RegisterValue(jdk.vm.ci.code.RegisterValue) HotSpotObjectConstant(jdk.vm.ci.hotspot.HotSpotObjectConstant)

Example 2 with Constant

use of jdk.vm.ci.meta.Constant in project graal by oracle.

the class GetClassNode method virtualize.

@Override
public void virtualize(VirtualizerTool tool) {
    ValueNode alias = tool.getAlias(getObject());
    if (alias instanceof VirtualObjectNode) {
        VirtualObjectNode virtual = (VirtualObjectNode) alias;
        Constant javaClass = tool.getConstantReflectionProvider().asJavaClass(virtual.type());
        tool.replaceWithValue(ConstantNode.forConstant(stamp(NodeView.DEFAULT), javaClass, tool.getMetaAccessProvider(), graph()));
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) Constant(jdk.vm.ci.meta.Constant) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 3 with Constant

use of jdk.vm.ci.meta.Constant in project graal by oracle.

the class RawLoadNode method canonical.

@Override
public Node canonical(CanonicalizerTool tool) {
    if (!isAnyLocationForced() && getLocationIdentity().isAny()) {
        ValueNode targetObject = object();
        if (offset().isConstant() && targetObject.isConstant() && !targetObject.isNullConstant()) {
            ConstantNode objectConstant = (ConstantNode) targetObject;
            ResolvedJavaType type = StampTool.typeOrNull(objectConstant);
            if (type != null && type.isArray()) {
                JavaConstant arrayConstant = objectConstant.asJavaConstant();
                if (arrayConstant != null) {
                    int stableDimension = objectConstant.getStableDimension();
                    if (stableDimension > 0) {
                        NodeView view = NodeView.from(tool);
                        long constantOffset = offset().asJavaConstant().asLong();
                        Constant constant = stamp(view).readConstant(tool.getConstantReflection().getMemoryAccessProvider(), arrayConstant, constantOffset);
                        boolean isDefaultStable = objectConstant.isDefaultStable();
                        if (constant != null && (isDefaultStable || !constant.isDefaultForKind())) {
                            return ConstantNode.forConstant(stamp(view), constant, stableDimension - 1, isDefaultStable, tool.getMetaAccess());
                        }
                    }
                }
            }
        }
    }
    return super.canonical(tool);
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) Constant(jdk.vm.ci.meta.Constant) JavaConstant(jdk.vm.ci.meta.JavaConstant) ValueNode(org.graalvm.compiler.nodes.ValueNode) JavaConstant(jdk.vm.ci.meta.JavaConstant) NodeView(org.graalvm.compiler.nodes.NodeView) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 4 with Constant

use of jdk.vm.ci.meta.Constant in project graal by oracle.

the class ConvertDeoptimizeToGuardPhase method processFixedGuardAndMerge.

@SuppressWarnings("try")
private void processFixedGuardAndMerge(FixedGuardNode fixedGuard, PhaseContext context, CompareNode compare, ValueNode x, ValuePhiNode xPhi, ValueNode y, ValuePhiNode yPhi, AbstractMergeNode merge) {
    List<EndNode> mergePredecessors = merge.cfgPredecessors().snapshot();
    for (int i = 0; i < mergePredecessors.size(); ++i) {
        AbstractEndNode mergePredecessor = mergePredecessors.get(i);
        if (!mergePredecessor.isAlive()) {
            break;
        }
        Constant xs;
        if (xPhi == null) {
            xs = x.asConstant();
        } else {
            xs = xPhi.valueAt(mergePredecessor).asConstant();
        }
        Constant ys;
        if (yPhi == null) {
            ys = y.asConstant();
        } else {
            ys = yPhi.valueAt(mergePredecessor).asConstant();
        }
        if (xs != null && ys != null && compare.condition().foldCondition(xs, ys, context.getConstantReflection(), compare.unorderedIsTrue()) == fixedGuard.isNegated()) {
            try (DebugCloseable position = fixedGuard.withNodeSourcePosition()) {
                propagateFixed(mergePredecessor, fixedGuard, context.getLowerer());
            }
        }
    }
}
Also used : AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) EndNode(org.graalvm.compiler.nodes.EndNode) Constant(jdk.vm.ci.meta.Constant) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Example 5 with Constant

use of jdk.vm.ci.meta.Constant in project graal by oracle.

the class GraphUtil method foldIfConstantAndRemove.

public static Constant foldIfConstantAndRemove(ValueNode node, ValueNode constant) {
    assert node.inputs().contains(constant);
    if (constant.isConstant()) {
        node.replaceFirstInput(constant, null);
        Constant result = constant.asConstant();
        tryKillUnused(constant);
        return result;
    }
    return null;
}
Also used : Constant(jdk.vm.ci.meta.Constant)

Aggregations

Constant (jdk.vm.ci.meta.Constant)31 JavaConstant (jdk.vm.ci.meta.JavaConstant)15 PrimitiveConstant (jdk.vm.ci.meta.PrimitiveConstant)11 ValueNode (org.graalvm.compiler.nodes.ValueNode)9 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)6 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)5 Stamp (org.graalvm.compiler.core.common.type.Stamp)5 ArrayList (java.util.ArrayList)4 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)4 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)3 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)3 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)3 RegisterValue (jdk.vm.ci.code.RegisterValue)2 HotSpotCompressedNullConstant (jdk.vm.ci.hotspot.HotSpotCompressedNullConstant)2 HotSpotObjectConstant (jdk.vm.ci.hotspot.HotSpotObjectConstant)2 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)2 SerializableConstant (jdk.vm.ci.meta.SerializableConstant)2 VMConstant (jdk.vm.ci.meta.VMConstant)2 Value (jdk.vm.ci.meta.Value)2 OperandSize (org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)2