Search in sources :

Example 1 with ConstantContextSensitiveObject

use of com.oracle.graal.pointsto.flow.context.object.ConstantContextSensitiveObject 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)

Aggregations

AnalysisObject (com.oracle.graal.pointsto.flow.context.object.AnalysisObject)1 ConstantContextSensitiveObject (com.oracle.graal.pointsto.flow.context.object.ConstantContextSensitiveObject)1 PrimitiveConstant (jdk.vm.ci.meta.PrimitiveConstant)1