Search in sources :

Example 1 with BigBang

use of com.oracle.graal.pointsto.BigBang in project graal by oracle.

the class CloneTypeFlow method onObservedUpdate.

@Override
public void onObservedUpdate(BigBang bb) {
    /* Only a clone should be updated */
    assert this.isClone() && context != null;
    /* The input state has changed, clone its objects. */
    TypeState inputState = input.getState();
    TypeState currentState = getState();
    TypeState resultState;
    if (inputState.isEmpty() || inputState.isNull()) {
        /* Nothing to be cloned if the input state is not a concrete type state. */
        resultState = inputState.forNonNull(bb);
    } else {
        resultState = inputState.typesStream().filter(t -> !currentState.containsType(t)).map(type -> TypeState.forClone(bb, source, cloneSite, type, allocationContext)).reduce(TypeState.forEmpty(), (s1, s2) -> TypeState.forUnion(bb, s1, s2));
        assert !resultState.canBeNull();
    }
    /* Update the clone flow state. */
    addState(bb, resultState);
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) BytecodeLocation(com.oracle.graal.pointsto.flow.context.BytecodeLocation) PointstoOptions(com.oracle.graal.pointsto.api.PointstoOptions) BigBang(com.oracle.graal.pointsto.BigBang) TypeState(com.oracle.graal.pointsto.typestate.TypeState) AnalysisContext(com.oracle.graal.pointsto.flow.context.AnalysisContext) AnalysisObject(com.oracle.graal.pointsto.flow.context.object.AnalysisObject) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) TypeState(com.oracle.graal.pointsto.typestate.TypeState)

Example 2 with BigBang

use of com.oracle.graal.pointsto.BigBang in project graal by oracle.

the class DynamicNewInstanceTypeFlow method onObservedUpdate.

@Override
public void onObservedUpdate(BigBang bb) {
    /* Only a clone should be updated */
    assert this.isClone();
    /* The state of the new type provider has changed. */
    TypeState newTypeState = newTypeFlow.getState();
    TypeState currentTypeState = getState();
    /* Generate a heap object for every new incoming type. */
    TypeState resultState = newTypeState.typesStream().filter(t -> !currentTypeState.containsType(t)).map(type -> TypeState.forAllocation(bb, source, allocationSite, type, allocationContext)).reduce(TypeState.forEmpty(), (s1, s2) -> TypeState.forUnion(bb, s1, s2));
    assert !resultState.canBeNull();
    addState(bb, resultState);
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) BytecodeLocation(com.oracle.graal.pointsto.flow.context.BytecodeLocation) PointstoOptions(com.oracle.graal.pointsto.api.PointstoOptions) BigBang(com.oracle.graal.pointsto.BigBang) TypeState(com.oracle.graal.pointsto.typestate.TypeState) AnalysisContext(com.oracle.graal.pointsto.flow.context.AnalysisContext) TypeState(com.oracle.graal.pointsto.typestate.TypeState)

Example 3 with BigBang

use of com.oracle.graal.pointsto.BigBang in project graal by oracle.

the class PointsToStats method registerTypeState.

static void registerTypeState(BigBang bb, TypeState state) {
    if (!bb.reportAnalysisStatistics()) {
        return;
    }
    Integer id = stateToId.computeIfAbsent(state, (s) -> nextStateId.incrementAndGet());
    TypeState actualState = idToState.computeIfAbsent(id, (i) -> state);
    typeStateStats.computeIfAbsent(actualState, (s) -> new AtomicInteger()).incrementAndGet();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UnknownTypeFlow(com.oracle.graal.pointsto.flow.UnknownTypeFlow) FilterTypeFlow(com.oracle.graal.pointsto.flow.FilterTypeFlow) AllInstantiatedTypeFlow(com.oracle.graal.pointsto.flow.AllInstantiatedTypeFlow) JavaWriteTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.JavaWriteTypeFlow) StoreStaticFieldTypeFlow(com.oracle.graal.pointsto.flow.StoreFieldTypeFlow.StoreStaticFieldTypeFlow) StoreInstanceFieldTypeFlow(com.oracle.graal.pointsto.flow.StoreFieldTypeFlow.StoreInstanceFieldTypeFlow) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) StoreIndexedTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.StoreIndexedTypeFlow) BigBang(com.oracle.graal.pointsto.BigBang) UnsafePartitionLoadTypeFlow(com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.UnsafePartitionLoadTypeFlow) Path(java.nio.file.Path) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition) LoadIndexedTypeFlow(com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.LoadIndexedTypeFlow) InitialParamTypeFlow(com.oracle.graal.pointsto.flow.InitialParamTypeFlow) LoadStaticFieldTypeFlow(com.oracle.graal.pointsto.flow.LoadFieldTypeFlow.LoadStaticFieldTypeFlow) UnsafeLoadTypeFlow(com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.UnsafeLoadTypeFlow) FormalParamTypeFlow(com.oracle.graal.pointsto.flow.FormalParamTypeFlow) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) FieldSinkTypeFlow(com.oracle.graal.pointsto.flow.FieldSinkTypeFlow) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) Collectors(java.util.stream.Collectors) AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) Objects(java.util.Objects) ValueNode(org.graalvm.compiler.nodes.ValueNode) JavaType(jdk.vm.ci.meta.JavaType) List(java.util.List) MergeTypeFlow(com.oracle.graal.pointsto.flow.MergeTypeFlow) FieldTypeFlow(com.oracle.graal.pointsto.flow.FieldTypeFlow) Entry(java.util.Map.Entry) AtomicReadTypeFlow(com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.AtomicReadTypeFlow) CompareAndSwapTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.CompareAndSwapTypeFlow) LocalDateTime(java.time.LocalDateTime) InstanceOfTypeFlow(com.oracle.graal.pointsto.flow.InstanceOfTypeFlow) AllSynchronizedTypeFlow(com.oracle.graal.pointsto.flow.AllSynchronizedTypeFlow) Function(java.util.function.Function) ArrayList(java.util.ArrayList) TypeFlowBuilder(com.oracle.graal.pointsto.flow.builder.TypeFlowBuilder) DynamicNewInstanceTypeFlow(com.oracle.graal.pointsto.flow.DynamicNewInstanceTypeFlow) MonitorEnterTypeFlow(com.oracle.graal.pointsto.flow.MonitorEnterTypeFlow) AtomicWriteTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.AtomicWriteTypeFlow) ActualReturnTypeFlow(com.oracle.graal.pointsto.flow.ActualReturnTypeFlow) LoadInstanceFieldTypeFlow(com.oracle.graal.pointsto.flow.LoadFieldTypeFlow.LoadInstanceFieldTypeFlow) CloneTypeFlow(com.oracle.graal.pointsto.flow.CloneTypeFlow) InvokeTypeFlow(com.oracle.graal.pointsto.flow.InvokeTypeFlow) JVMCIError(jdk.vm.ci.common.JVMCIError) SourceTypeFlow(com.oracle.graal.pointsto.flow.SourceTypeFlow) Files(java.nio.file.Files) BufferedWriter(java.io.BufferedWriter) FieldFilterTypeFlow(com.oracle.graal.pointsto.flow.FieldFilterTypeFlow) JavaReadTypeFlow(com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.JavaReadTypeFlow) FileWriter(java.io.FileWriter) FormalReturnTypeFlow(com.oracle.graal.pointsto.flow.FormalReturnTypeFlow) IOException(java.io.IOException) UnsafePartitionStoreTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.UnsafePartitionStoreTypeFlow) UnsafeWriteSinkTypeFlow(com.oracle.graal.pointsto.flow.UnsafeWriteSinkTypeFlow) Consumer(java.util.function.Consumer) NewInstanceTypeFlow(com.oracle.graal.pointsto.flow.NewInstanceTypeFlow) NullCheckTypeFlow(com.oracle.graal.pointsto.flow.NullCheckTypeFlow) DateTimeFormatter(java.time.format.DateTimeFormatter) FrozenFieldFilterTypeFlow(com.oracle.graal.pointsto.flow.FrozenFieldFilterTypeFlow) UnsafeStoreTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.UnsafeStoreTypeFlow) TypeFlow(com.oracle.graal.pointsto.flow.TypeFlow) ArrayElementsTypeFlow(com.oracle.graal.pointsto.flow.ArrayElementsTypeFlow) Comparator(java.util.Comparator) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) FileSystems(java.nio.file.FileSystems) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 4 with BigBang

use of com.oracle.graal.pointsto.BigBang in project graal by oracle.

the class JNIAccessFeature method addField.

private static void addField(Field reflField, DuringAnalysisAccessImpl access) {
    BigBang bigBang = access.getBigBang();
    JNIAccessibleClass jniClass = addClass(reflField.getDeclaringClass(), access);
    jniClass.addFieldIfAbsent(reflField.getName(), n -> {
        AnalysisField field = access.getMetaAccess().lookupJavaField(reflField);
        field.registerAsAccessed();
        // Same as BigBang.addSystemField() and BigBang.addSystemStaticField():
        // create type flows for any subtype of the field's declared type
        TypeFlow<?> declaredTypeFlow = field.getType().getTypeFlow(bigBang, true);
        if (field.isStatic()) {
            declaredTypeFlow.addUse(bigBang, field.getStaticFieldFlow());
        } else {
            FieldTypeFlow instanceFieldFlow = field.getDeclaringClass().getContextInsensitiveAnalysisObject().getInstanceFieldFlow(bigBang, field, true);
            declaredTypeFlow.addUse(bigBang, instanceFieldFlow);
        }
        return new JNIAccessibleField(jniClass, reflField.getName(), field.getJavaKind(), field.getModifiers());
    });
}
Also used : FieldTypeFlow(com.oracle.graal.pointsto.flow.FieldTypeFlow) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) BigBang(com.oracle.graal.pointsto.BigBang)

Example 5 with BigBang

use of com.oracle.graal.pointsto.BigBang in project graal by oracle.

the class UniverseBuilder method build.

/**
 * This step is single threaded, i.e., all the maps are modified only by a single thread, so no
 * synchronization is necessary. Accesses (the lookup methods) are multi-threaded.
 */
@SuppressWarnings("try")
public void build(DebugContext debug) {
    for (AnalysisField aField : aUniverse.getFields()) {
        if (aField.wrapped instanceof ComputedValueField) {
            ((ComputedValueField) aField.wrapped).processAnalysis(aMetaAccess);
        }
    }
    aUniverse.seal();
    try (Indent indent = debug.logAndIndent("build universe")) {
        for (AnalysisType aType : aUniverse.getTypes()) {
            makeType(aType);
        }
        for (AnalysisField aField : aUniverse.getFields()) {
            makeField(aField);
        }
        for (AnalysisMethod aMethod : aUniverse.getMethods()) {
            makeMethod(aMethod);
        }
        BigBang bb = staticAnalysisResultsBuilder.getBigBang();
        ForkJoinTask<?> profilingInformationBuildTask = ForkJoinTask.adapt(this::buildProfilingInformation).fork();
        buildSubTypes();
        buildOrderedTypes();
        buildTypeCheckIDs();
        collectDeclaredMethods();
        collectMonitorFieldInfo(bb);
        collectHashCodeFieldInfo(bb);
        layoutInstanceFields();
        layoutStaticFields();
        collectMethodImplementations();
        buildVTables();
        buildHubs();
        setConstantFieldValues();
        hUniverse.orderedMethods = new ArrayList<>(hUniverse.methods.values());
        Collections.sort(hUniverse.orderedMethods);
        hUniverse.orderedFields = new ArrayList<>(hUniverse.fields.values());
        Collections.sort(hUniverse.orderedFields);
        profilingInformationBuildTask.join();
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) Indent(org.graalvm.compiler.debug.Indent) AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) ComputedValueField(com.oracle.svm.hosted.substitute.ComputedValueField) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) BigBang(com.oracle.graal.pointsto.BigBang)

Aggregations

BigBang (com.oracle.graal.pointsto.BigBang)5 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)4 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)3 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 PointstoOptions (com.oracle.graal.pointsto.api.PointstoOptions)2 FieldTypeFlow (com.oracle.graal.pointsto.flow.FieldTypeFlow)2 AnalysisContext (com.oracle.graal.pointsto.flow.context.AnalysisContext)2 BytecodeLocation (com.oracle.graal.pointsto.flow.context.BytecodeLocation)2 TypeState (com.oracle.graal.pointsto.typestate.TypeState)2 ActualReturnTypeFlow (com.oracle.graal.pointsto.flow.ActualReturnTypeFlow)1 AllInstantiatedTypeFlow (com.oracle.graal.pointsto.flow.AllInstantiatedTypeFlow)1 AllSynchronizedTypeFlow (com.oracle.graal.pointsto.flow.AllSynchronizedTypeFlow)1 ArrayElementsTypeFlow (com.oracle.graal.pointsto.flow.ArrayElementsTypeFlow)1 CloneTypeFlow (com.oracle.graal.pointsto.flow.CloneTypeFlow)1 DynamicNewInstanceTypeFlow (com.oracle.graal.pointsto.flow.DynamicNewInstanceTypeFlow)1 FieldFilterTypeFlow (com.oracle.graal.pointsto.flow.FieldFilterTypeFlow)1 FieldSinkTypeFlow (com.oracle.graal.pointsto.flow.FieldSinkTypeFlow)1 FilterTypeFlow (com.oracle.graal.pointsto.flow.FilterTypeFlow)1 FormalParamTypeFlow (com.oracle.graal.pointsto.flow.FormalParamTypeFlow)1 FormalReturnTypeFlow (com.oracle.graal.pointsto.flow.FormalReturnTypeFlow)1