Search in sources :

Example 11 with PrimitiveConstant

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

the class ArrayCopyCallNode method updateAlignedDisjoint.

public void updateAlignedDisjoint() {
    JavaKind componentKind = elementKind;
    if (srcPos == destPos) {
        // Can treat as disjoint
        disjoint = true;
    }
    PrimitiveConstant constantSrc = (PrimitiveConstant) srcPos.stamp(NodeView.DEFAULT).asConstant();
    PrimitiveConstant constantDst = (PrimitiveConstant) destPos.stamp(NodeView.DEFAULT).asConstant();
    if (constantSrc != null && constantDst != null) {
        if (!aligned) {
            aligned = isHeapWordAligned(constantSrc, componentKind) && isHeapWordAligned(constantDst, componentKind);
        }
        if (constantSrc.asInt() >= constantDst.asInt()) {
            // low to high copy so treat as disjoint
            disjoint = true;
        }
    }
}
Also used : PrimitiveConstant(jdk.vm.ci.meta.PrimitiveConstant) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 12 with PrimitiveConstant

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

the class AnalysisType method getCachedConstantObject.

public AnalysisObject getCachedConstantObject(BigBang bb, JavaConstant constant) {
    /*
         * Constant caching is only used we certain analysis policies. Ideally we would store the
         * cache in the policy, but it is simpler to store the cache for each type.
         */
    assert bb.analysisPolicy().needsConstantCache() : "The analysis policy doesn't specify the need for a constants cache.";
    assert bb.trackConcreteAnalysisObjects(this);
    assert !(constant instanceof PrimitiveConstant) : "The analysis should not model PrimitiveConstant.";
    if (uniqueConstant != null) {
        // The constants have been merged, return the unique constant
        return uniqueConstant;
    }
    if (constantObjectsCache.size() > PointstoOptions.MaxConstantObjectsPerType.getValue(bb.getOptions())) {
        // The number of constant objects has increased above the limit,
        // merge the constants in the uniqueConstant and return it
        mergeConstantObjects(bb);
        return uniqueConstant;
    }
    // Get the analysis ConstantObject modeling the JavaConstant
    AnalysisObject result = constantObjectsCache.get(constant);
    if (result == null) {
        // Create a ConstantObject to model each JavaConstant
        ConstantContextSensitiveObject newValue = new ConstantContextSensitiveObject(bb, this, constant);
        ConstantContextSensitiveObject oldValue = constantObjectsCache.putIfAbsent(constant, newValue);
        result = oldValue != null ? oldValue : newValue;
        if (PointstoOptions.ProfileConstantObjects.getValue(bb.getOptions())) {
            ConstantObjectsProfiler.registerConstant(this);
            ConstantObjectsProfiler.maybeDumpConstantHistogram();
        }
    }
    return result;
}
Also used : AnalysisObject(com.oracle.graal.pointsto.flow.context.object.AnalysisObject) PrimitiveConstant(jdk.vm.ci.meta.PrimitiveConstant) ConstantContextSensitiveObject(com.oracle.graal.pointsto.flow.context.object.ConstantContextSensitiveObject)

Example 13 with PrimitiveConstant

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

the class MulNode method canonical.

private static ValueNode canonical(MulNode self, BinaryOp<Mul> op, Stamp stamp, ValueNode forX, ValueNode forY, NodeView view) {
    if (forY.isConstant()) {
        Constant c = forY.asConstant();
        if (op.isNeutral(c)) {
            return forX;
        }
        if (c instanceof PrimitiveConstant && ((PrimitiveConstant) c).getJavaKind().isNumericInteger()) {
            long i = ((PrimitiveConstant) c).asLong();
            ValueNode result = canonical(stamp, forX, i, view);
            if (result != null) {
                return result;
            }
        }
        if (op.isAssociative()) {
            // canonicalize expressions like "(a * 1) * 2"
            return reassociate(self != null ? self : (MulNode) new MulNode(forX, forY).maybeCommuteInputs(), ValueNode.isConstantPredicate(), forX, forY, view);
        }
    }
    return self != null ? self : new MulNode(forX, forY).maybeCommuteInputs();
}
Also used : Constant(jdk.vm.ci.meta.Constant) PrimitiveConstant(jdk.vm.ci.meta.PrimitiveConstant) PrimitiveConstant(jdk.vm.ci.meta.PrimitiveConstant) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 14 with PrimitiveConstant

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

the class SubstrateMemoryAccessProviderImpl method readObjectConstant.

private static JavaConstant readObjectConstant(Constant baseConstant, long displacement, boolean requireCompressed) {
    SignedWord offset = WordFactory.signed(displacement);
    if (baseConstant instanceof SubstrateObjectConstant) {
        // always compressed (if enabled)
        assert !requireCompressed || ReferenceAccess.singleton().haveCompressedReferences();
        Object baseObject = ((SubstrateObjectConstant) baseConstant).getObject();
        assert baseObject != null : "SubstrateObjectConstant does not wrap null value";
        Object rawValue = BarrieredAccess.readObject(baseObject, offset);
        return SubstrateObjectConstant.forObject(rawValue, requireCompressed);
    }
    if (baseConstant instanceof PrimitiveConstant) {
        // never compressed
        assert !requireCompressed;
        PrimitiveConstant prim = (PrimitiveConstant) baseConstant;
        if (!prim.getJavaKind().isNumericInteger()) {
            return null;
        }
        Word baseAddress = WordFactory.unsigned(prim.asLong());
        if (baseAddress.equal(0)) {
            return null;
        }
        Word address = baseAddress.add(offset);
        Object rawValue = ReferenceAccess.singleton().readObjectAt(address, false);
        return SubstrateObjectConstant.forObject(rawValue, false);
    }
    return null;
}
Also used : Word(org.graalvm.compiler.word.Word) SignedWord(org.graalvm.word.SignedWord) PrimitiveConstant(jdk.vm.ci.meta.PrimitiveConstant) SubstrateObjectConstant(com.oracle.svm.core.meta.SubstrateObjectConstant) SignedWord(org.graalvm.word.SignedWord)

Example 15 with PrimitiveConstant

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

the class HotSpotResolvedObjectTypeTest method testKlassLayoutHelper.

@Test
public void testKlassLayoutHelper() {
    Constant klass = HotSpotResolvedObjectType.fromObjectClass(this.getClass()).klass();
    MemoryAccessProvider memoryAccess = getProviders().getConstantReflection().getMemoryAccessProvider();
    GraalHotSpotVMConfig config = runtime().getVMConfig();
    Constant c = StampFactory.forKind(JavaKind.Int).readConstant(memoryAccess, klass, config.klassLayoutHelperOffset);
    assertTrue(c.toString(), c.getClass() == PrimitiveConstant.class);
    PrimitiveConstant pc = (PrimitiveConstant) c;
    assertTrue(pc.toString(), pc.getJavaKind() == JavaKind.Int);
}
Also used : MemoryAccessProvider(jdk.vm.ci.meta.MemoryAccessProvider) Constant(jdk.vm.ci.meta.Constant) PrimitiveConstant(jdk.vm.ci.meta.PrimitiveConstant) PrimitiveConstant(jdk.vm.ci.meta.PrimitiveConstant) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig) Test(org.junit.Test)

Aggregations

PrimitiveConstant (jdk.vm.ci.meta.PrimitiveConstant)17 Constant (jdk.vm.ci.meta.Constant)8 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)3 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 SubstrateObjectConstant (com.oracle.svm.core.meta.SubstrateObjectConstant)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)2 SignedWord (org.graalvm.word.SignedWord)2 AnalysisObject (com.oracle.graal.pointsto.flow.context.object.AnalysisObject)1 ConstantContextSensitiveObject (com.oracle.graal.pointsto.flow.context.object.ConstantContextSensitiveObject)1 RegisterValue (jdk.vm.ci.code.RegisterValue)1 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 JavaKind (jdk.vm.ci.meta.JavaKind)1 MemoryAccessProvider (jdk.vm.ci.meta.MemoryAccessProvider)1 Value (jdk.vm.ci.meta.Value)1 AbstractObjectStamp (org.graalvm.compiler.core.common.type.AbstractObjectStamp)1 FloatStamp (org.graalvm.compiler.core.common.type.FloatStamp)1 GraalHotSpotVMConfig (org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)1 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)1 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)1 AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)1