Search in sources :

Example 46 with JavaConstant

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

the class CollectingObjectReferenceVisitor method verifyValue.

private void verifyValue(CompilationResult compilation, JavaValue expectedValue, ValueInfo actualValue, FrameInfoQueryResult actualFrame, BitSet visitedVirtualObjects) {
    if (ValueUtil.isIllegalJavaValue(expectedValue)) {
        assert actualValue.getType() == ValueType.Illegal;
    } else if (ValueUtil.isConstantJavaValue(expectedValue)) {
        assert actualValue.getType() == ValueType.Constant || actualValue.getType() == ValueType.DefaultConstant;
        JavaConstant expectedConstant = ValueUtil.asConstantJavaValue(expectedValue);
        JavaConstant actualConstant = actualValue.getValue();
        FrameInfoVerifier.verifyConstant(expectedConstant, actualConstant);
    } else if (expectedValue instanceof StackSlot) {
        assert actualValue.getType() == ValueType.StackSlot;
        int expectedOffset = ((StackSlot) expectedValue).getOffset(compilation.getTotalFrameSize());
        long actualOffset = actualValue.getData();
        assert expectedOffset == actualOffset;
    } else if (ValueUtil.isVirtualObject(expectedValue)) {
        assert actualValue.getType() == ValueType.VirtualObject;
        int expectedId = ValueUtil.asVirtualObject(expectedValue).getId();
        long actualId = actualValue.getData();
        assert expectedId == actualId;
        verifyVirtualObject(compilation, ValueUtil.asVirtualObject(expectedValue), actualFrame.getVirtualObjects()[expectedId], actualFrame, visitedVirtualObjects);
    } else {
        throw shouldNotReachHere();
    }
}
Also used : StackSlot(jdk.vm.ci.code.StackSlot) JavaConstant(jdk.vm.ci.meta.JavaConstant) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint)

Example 47 with JavaConstant

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

the class SPARCAddressLowering method lower.

@Override
public AddressNode lower(ValueNode base, ValueNode offset) {
    JavaConstant immBase = asImmediate(base);
    if (immBase != null && SPARCAssembler.isSimm13(immBase)) {
        return lower(offset, immBase.asLong());
    }
    JavaConstant immOffset = asImmediate(offset);
    if (immOffset != null && SPARCAssembler.isSimm13(immOffset)) {
        return lower(base, immOffset.asLong());
    }
    return base.graph().unique(new SPARCIndexedAddressNode(base, offset));
}
Also used : JavaConstant(jdk.vm.ci.meta.JavaConstant)

Example 48 with JavaConstant

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

the class SPARCArithmeticLIRGenerator method emitStore.

@Override
public void emitStore(ValueKind<?> kind, Value address, Value inputVal, LIRFrameState state) {
    SPARCAddressValue storeAddress = getLIRGen().asAddressValue(address);
    if (isJavaConstant(inputVal)) {
        JavaConstant c = asJavaConstant(inputVal);
        if (c.isDefaultForKind()) {
            getLIRGen().append(new StoreConstantOp(kind.getPlatformKind(), storeAddress, c, state));
            return;
        }
    }
    Variable input = getLIRGen().load(inputVal);
    getLIRGen().append(new StoreOp(kind.getPlatformKind(), storeAddress, input, state));
}
Also used : Variable(org.graalvm.compiler.lir.Variable) SPARCAddressValue(org.graalvm.compiler.lir.sparc.SPARCAddressValue) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRValueUtil.asJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant) LIRValueUtil.isJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant) StoreOp(org.graalvm.compiler.lir.sparc.SPARCMove.StoreOp) StoreConstantOp(org.graalvm.compiler.lir.sparc.SPARCMove.StoreConstantOp)

Example 49 with JavaConstant

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

the class SPARCArithmeticLIRGenerator method emitSignExtend.

@Override
public Value emitSignExtend(Value inputVal, int fromBits, int toBits) {
    assert fromBits <= toBits && toBits <= XWORD.getSizeInBits();
    LIRKind shiftKind = LIRKind.value(WORD);
    LIRKind resultKind = LIRKind.combine(inputVal).changeType(toBits > 32 ? XWORD : WORD);
    int shiftCount = XWORD.getSizeInBits() - fromBits;
    if (fromBits == toBits) {
        return inputVal;
    } else if (isJavaConstant(inputVal)) {
        JavaConstant javaConstant = asJavaConstant(inputVal);
        long constant;
        if (javaConstant.isNull()) {
            constant = 0;
        } else {
            constant = javaConstant.asLong();
        }
        return new ConstantValue(resultKind, JavaConstant.forLong((constant << shiftCount) >> shiftCount));
    } else {
        AllocatableValue inputAllocatable = getLIRGen().asAllocatable(inputVal);
        Variable result = getLIRGen().newVariable(resultKind);
        if (fromBits == WORD.getSizeInBits() && toBits == XWORD.getSizeInBits()) {
            getLIRGen().append(new SPARCOP3Op(Sra, inputAllocatable, g0.asValue(LIRKind.value(WORD)), result));
        } else {
            Variable tmp = getLIRGen().newVariable(resultKind.changeType(XWORD));
            getLIRGen().append(new SPARCOP3Op(Sllx, inputAllocatable, new ConstantValue(shiftKind, JavaConstant.forInt(shiftCount)), tmp));
            getLIRGen().append(new SPARCOP3Op(Srax, tmp, new ConstantValue(shiftKind, JavaConstant.forInt(shiftCount)), result));
        }
        return result;
    }
}
Also used : Variable(org.graalvm.compiler.lir.Variable) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRValueUtil.asJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant) LIRValueUtil.isJavaConstant(org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant) LIRKind(org.graalvm.compiler.core.common.LIRKind) ConstantValue(org.graalvm.compiler.lir.ConstantValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCOP3Op(org.graalvm.compiler.lir.sparc.SPARCOP3Op)

Example 50 with JavaConstant

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

the class SPARCNodeMatchRules method ifCompareLogicCas.

@MatchRule("(If (ObjectEquals=compare value LogicCompareAndSwap=cas))")
@MatchRule("(If (PointerEquals=compare value LogicCompareAndSwap=cas))")
@MatchRule("(If (FloatEquals=compare value LogicCompareAndSwap=cas))")
@MatchRule("(If (IntegerEquals=compare value LogicCompareAndSwap=cas))")
public ComplexMatchResult ifCompareLogicCas(IfNode root, CompareNode compare, ValueNode value, LogicCompareAndSwapNode cas) {
    JavaConstant constant = value.asJavaConstant();
    assert compare.condition() == CanonicalCondition.EQ;
    if (constant != null && cas.usages().count() == 1) {
        long constantValue = constant.asLong();
        boolean successIsTrue;
        if (constantValue == 0) {
            successIsTrue = false;
        } else if (constantValue == 1) {
            successIsTrue = true;
        } else {
            return null;
        }
        return builder -> {
            LIRKind kind = getLirKind(cas);
            LabelRef trueLabel = getLIRBlock(root.trueSuccessor());
            LabelRef falseLabel = getLIRBlock(root.falseSuccessor());
            double trueLabelProbability = root.probability(root.trueSuccessor());
            Value expectedValue = operand(cas.getExpectedValue());
            Value newValue = operand(cas.getNewValue());
            SPARCAddressValue address = (SPARCAddressValue) operand(cas.getAddress());
            Condition condition = successIsTrue ? Condition.EQ : Condition.NE;
            Value result = getLIRGeneratorTool().emitValueCompareAndSwap(address, expectedValue, newValue);
            getLIRGeneratorTool().emitCompareBranch(kind.getPlatformKind(), result, expectedValue, condition, false, trueLabel, falseLabel, trueLabelProbability);
            return null;
        };
    }
    return null;
}
Also used : CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) XWORD(jdk.vm.ci.sparc.SPARCKind.XWORD) LabelRef(org.graalvm.compiler.lir.LabelRef) SPARCKind(jdk.vm.ci.sparc.SPARCKind) WORD(jdk.vm.ci.sparc.SPARCKind.WORD) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) Condition(org.graalvm.compiler.core.common.calc.Condition) HWORD(jdk.vm.ci.sparc.SPARCKind.HWORD) IfNode(org.graalvm.compiler.nodes.IfNode) LIRKind(org.graalvm.compiler.core.common.LIRKind) LIRLowerableAccess(org.graalvm.compiler.nodes.memory.LIRLowerableAccess) BYTE(jdk.vm.ci.sparc.SPARCKind.BYTE) DeoptimizingNode(org.graalvm.compiler.nodes.DeoptimizingNode) CanonicalCondition(org.graalvm.compiler.core.common.calc.CanonicalCondition) JavaConstant(jdk.vm.ci.meta.JavaConstant) ValueNode(org.graalvm.compiler.nodes.ValueNode) Value(jdk.vm.ci.meta.Value) ComplexMatchResult(org.graalvm.compiler.core.match.ComplexMatchResult) Access(org.graalvm.compiler.nodes.memory.Access) NodeMatchRules(org.graalvm.compiler.core.gen.NodeMatchRules) GraalError(org.graalvm.compiler.debug.GraalError) LIRGeneratorTool(org.graalvm.compiler.lir.gen.LIRGeneratorTool) SPARCAddressValue(org.graalvm.compiler.lir.sparc.SPARCAddressValue) MatchRule(org.graalvm.compiler.core.match.MatchRule) LogicCompareAndSwapNode(org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode) Condition(org.graalvm.compiler.core.common.calc.Condition) CanonicalCondition(org.graalvm.compiler.core.common.calc.CanonicalCondition) Value(jdk.vm.ci.meta.Value) SPARCAddressValue(org.graalvm.compiler.lir.sparc.SPARCAddressValue) JavaConstant(jdk.vm.ci.meta.JavaConstant) SPARCAddressValue(org.graalvm.compiler.lir.sparc.SPARCAddressValue) LIRKind(org.graalvm.compiler.core.common.LIRKind) LabelRef(org.graalvm.compiler.lir.LabelRef) MatchRule(org.graalvm.compiler.core.match.MatchRule)

Aggregations

JavaConstant (jdk.vm.ci.meta.JavaConstant)122 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)33 ValueNode (org.graalvm.compiler.nodes.ValueNode)24 Test (org.junit.Test)19 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)17 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)15 Stamp (org.graalvm.compiler.core.common.type.Stamp)11 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)11 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)11 JavaKind (jdk.vm.ci.meta.JavaKind)10 Constant (jdk.vm.ci.meta.Constant)9 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)8 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)7 Condition (org.graalvm.compiler.core.common.calc.Condition)7 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)6 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)6 LogicNode (org.graalvm.compiler.nodes.LogicNode)6 FixedNode (org.graalvm.compiler.nodes.FixedNode)5 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)5 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)5