Search in sources :

Example 1 with AnalysisField

use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.

the class MethodTypeFlowBuilder method registerUsedElements.

public static void registerUsedElements(BigBang bb, StructuredGraph graph, MethodTypeFlow methodFlow) {
    for (Node n : graph.getNodes()) {
        if (n instanceof InstanceOfNode) {
            InstanceOfNode node = (InstanceOfNode) n;
            AnalysisType type = (AnalysisType) node.type().getType();
            type.registerAsInTypeCheck();
        } else if (n instanceof NewInstanceNode) {
            NewInstanceNode node = (NewInstanceNode) n;
            AnalysisType type = (AnalysisType) node.instanceClass();
            type.registerAsAllocated(node);
        } else if (n instanceof NewArrayNode) {
            NewArrayNode node = (NewArrayNode) n;
            AnalysisType type = ((AnalysisType) node.elementType()).getArrayClass();
            type.registerAsAllocated(node);
        } else if (n instanceof NewMultiArrayNode) {
            NewMultiArrayNode node = (NewMultiArrayNode) n;
            AnalysisType type = ((AnalysisType) node.type());
            for (int i = 0; i < node.dimensionCount(); i++) {
                type.registerAsAllocated(node);
                type = type.getComponentType();
            }
        } else if (n instanceof BoxNode) {
            BoxNode node = (BoxNode) n;
            AnalysisType type = (AnalysisType) StampTool.typeOrNull(node);
            type.registerAsAllocated(node);
        } else if (n instanceof LoadFieldNode) {
            LoadFieldNode node = (LoadFieldNode) n;
            AnalysisField field = (AnalysisField) node.field();
            field.registerAsRead(methodFlow);
        } else if (n instanceof StoreFieldNode) {
            StoreFieldNode node = (StoreFieldNode) n;
            AnalysisField field = (AnalysisField) node.field();
            field.registerAsWritten(methodFlow);
        } else if (n instanceof StoreIndexedNode) {
            StoreIndexedNode node = (StoreIndexedNode) n;
            AnalysisType arrayType = (AnalysisType) StampTool.typeOrNull(node.array());
            if (arrayType != null) {
                assert arrayType.isArray();
                arrayType.getComponentType().registerAsInTypeCheck();
            }
        } else if (n instanceof BytecodeExceptionNode) {
            BytecodeExceptionNode node = (BytecodeExceptionNode) n;
            AnalysisType type = bb.getMetaAccess().lookupJavaType(node.getExceptionClass());
            type.registerAsInHeap();
        } else if (n instanceof ConstantNode) {
            ConstantNode cn = (ConstantNode) n;
            if (cn.hasUsages() && cn.asJavaConstant().getJavaKind() == JavaKind.Object && cn.asJavaConstant().isNonNull()) {
                assert StampTool.isExactType(cn);
                AnalysisType type = (AnalysisType) StampTool.typeOrNull(cn);
                type.registerAsInHeap();
            }
        } else if (n instanceof ForeignCallNode) {
            ForeignCallNode node = (ForeignCallNode) n;
            registerForeignCall(bb, node.getDescriptor());
        } else if (n instanceof UnaryMathIntrinsicNode) {
            UnaryMathIntrinsicNode node = (UnaryMathIntrinsicNode) n;
            registerForeignCall(bb, node.getOperation().foreignCallDescriptor);
        } else if (n instanceof BinaryMathIntrinsicNode) {
            BinaryMathIntrinsicNode node = (BinaryMathIntrinsicNode) n;
            registerForeignCall(bb, node.getOperation().foreignCallDescriptor);
        }
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) StoreIndexedNode(org.graalvm.compiler.nodes.java.StoreIndexedNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) NewInstanceNode(org.graalvm.compiler.nodes.java.NewInstanceNode) DynamicNewInstanceNode(org.graalvm.compiler.nodes.java.DynamicNewInstanceNode) DynamicNewArrayNode(org.graalvm.compiler.nodes.java.DynamicNewArrayNode) NewArrayNode(org.graalvm.compiler.nodes.java.NewArrayNode) UnaryMathIntrinsicNode(org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode) RawLoadNode(org.graalvm.compiler.nodes.extended.RawLoadNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) WordCastNode(org.graalvm.compiler.word.WordCastNode) DynamicNewArrayNode(org.graalvm.compiler.nodes.java.DynamicNewArrayNode) ObjectEqualsNode(org.graalvm.compiler.nodes.calc.ObjectEqualsNode) BasicObjectCloneNode(org.graalvm.compiler.replacements.nodes.BasicObjectCloneNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) AtomicReadAndWriteNode(org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode) ConvertUnknownValueNode(com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) AnalysisUnsafePartitionLoadNode(com.oracle.graal.pointsto.nodes.AnalysisUnsafePartitionLoadNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) NewInstanceNode(org.graalvm.compiler.nodes.java.NewInstanceNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) AnalysisArraysCopyOfNode(com.oracle.graal.pointsto.nodes.AnalysisArraysCopyOfNode) DynamicNewInstanceNode(org.graalvm.compiler.nodes.java.DynamicNewInstanceNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) NewMultiArrayNode(org.graalvm.compiler.nodes.java.NewMultiArrayNode) LoadIndexedNode(org.graalvm.compiler.nodes.java.LoadIndexedNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) BoxNode(org.graalvm.compiler.nodes.extended.BoxNode) BinaryMathIntrinsicNode(org.graalvm.compiler.replacements.nodes.BinaryMathIntrinsicNode) IfNode(org.graalvm.compiler.nodes.IfNode) RawStoreNode(org.graalvm.compiler.nodes.extended.RawStoreNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) NewArrayNode(org.graalvm.compiler.nodes.java.NewArrayNode) UnsafeCompareAndSwapNode(org.graalvm.compiler.nodes.java.UnsafeCompareAndSwapNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) ExceptionObjectNode(org.graalvm.compiler.nodes.java.ExceptionObjectNode) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode) BasicArrayCopyNode(org.graalvm.compiler.replacements.nodes.BasicArrayCopyNode) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) UnaryMathIntrinsicNode(org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode) StoreIndexedNode(org.graalvm.compiler.nodes.java.StoreIndexedNode) MonitorEnterNode(org.graalvm.compiler.nodes.java.MonitorEnterNode) GetClassNode(org.graalvm.compiler.nodes.extended.GetClassNode) BytecodeExceptionNode(org.graalvm.compiler.nodes.extended.BytecodeExceptionNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) AnalysisUnsafePartitionStoreNode(com.oracle.graal.pointsto.nodes.AnalysisUnsafePartitionStoreNode) BytecodeExceptionNode(org.graalvm.compiler.nodes.extended.BytecodeExceptionNode) BoxNode(org.graalvm.compiler.nodes.extended.BoxNode) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) BinaryMathIntrinsicNode(org.graalvm.compiler.replacements.nodes.BinaryMathIntrinsicNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) NewMultiArrayNode(org.graalvm.compiler.nodes.java.NewMultiArrayNode) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode)

Example 2 with AnalysisField

use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.

the class BigBang method addSystemClass.

@SuppressWarnings({ "try" })
private AnalysisType addSystemClass(AnalysisType type, boolean addFields, boolean addArrayClass) {
    try (Indent indent = debug.logAndIndent("add system class %s", type.getName())) {
        for (AnalysisField field : type.getInstanceFields(false)) {
            if (addFields) {
                field.registerAsAccessed();
            }
            /*
                 * For system classes any instantiated (sub)type of the declared field type can be
                 * written to the field flow.
                 */
            TypeFlow<?> fieldDeclaredTypeFlow = field.getType().getTypeFlow(this, true);
            fieldDeclaredTypeFlow.addUse(this, type.getContextInsensitiveAnalysisObject().getInstanceFieldFlow(this, field, true));
        }
        if (type.getSuperclass() != null) {
            addSystemClass(type.getSuperclass(), addFields, addArrayClass);
        }
        if (addArrayClass) {
            addSystemClass(type.getArrayClass(), false, false);
        }
    }
    return type;
}
Also used : Indent(org.graalvm.compiler.debug.Indent) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField)

Example 3 with AnalysisField

use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.

the class ObjectScanner method doScan.

/**
 * Processes one constant entry. If the constant has an instance class then it scans its fields,
 * using the constant as a receiver. If the constant has an array class then it scans the array
 * element constants.
 */
private void doScan(WorklistEntry entry) {
    Object valueObj = bb.getSnippetReflectionProvider().asObject(Object.class, entry.constant);
    assert checkCorrectClassloaders(entry, valueObj) : "Invalid classloader " + valueObj.getClass().getClassLoader() + " for " + valueObj + ".\nThis error happens when objects from previous image compilations are reached in the current compilation. " + "To prevent this issue reset all static state from the bootclasspath and application classpath that points to the application objects. " + "For reference, see com.oracle.svm.truffle.TruffleFeature.cleanup().";
    AnalysisType type = bb.getMetaAccess().lookupJavaType(valueObj.getClass());
    if (type.isInstanceClass()) {
        /* Scan constant's instance fields. */
        for (AnalysisField field : type.getInstanceFields(true)) {
            if (field.getJavaKind() == JavaKind.Object && field.isAccessed()) {
                assert !Modifier.isStatic(field.getModifiers());
                scanField(field, entry.constant, entry);
            }
        }
    } else if (type.isArray() && bb.getProviders().getWordTypes().asKind(type.getComponentType()) == JavaKind.Object) {
        /* Scan the array elements. */
        scanArray(entry.constant, entry);
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField)

Example 4 with AnalysisField

use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.

the class CloneTypeFlow method update.

@Override
public void update(BigBang bb) {
    assert this.isClone();
    TypeState inputState = input.getState();
    TypeState cloneState = this.getState();
    for (AnalysisType type : inputState.types()) {
        if (type.isArray()) {
            /* The object array clones must also get the elements flows of the originals. */
            for (AnalysisObject originalObject : inputState.objects(type)) {
                if (originalObject.isPrimitiveArray() || originalObject.isEmptyObjectArrayConstant(bb)) {
                    /* Nothing to read from a primitive array or an empty array constant. */
                    continue;
                }
                ArrayElementsTypeFlow originalObjectElementsFlow = originalObject.getArrayElementsFlow(bb, false);
                for (AnalysisObject cloneObject : cloneState.objects(type)) {
                    if (cloneObject.isPrimitiveArray() || cloneObject.isEmptyObjectArrayConstant(bb)) {
                        /* Cannot write to a primitive array or an empty array constant. */
                        continue;
                    }
                    ArrayElementsTypeFlow cloneObjectElementsFlow = cloneObject.getArrayElementsFlow(bb, true);
                    originalObjectElementsFlow.addUse(bb, cloneObjectElementsFlow);
                }
            }
        } else {
            /* The object clones must get field flows of the originals. */
            for (AnalysisObject originalObject : inputState.objects(type)) {
                /* Link all the field flows of the original to the clone. */
                for (AnalysisField field : type.getInstanceFields(true)) {
                    FieldTypeFlow originalObjectFieldFlow = originalObject.getInstanceFieldFlow(bb, field, false);
                    for (AnalysisObject cloneObject : cloneState.objects(type)) {
                        FieldTypeFlow cloneObjectFieldFlow = cloneObject.getInstanceFieldFlow(bb, field, true);
                        originalObjectFieldFlow.addUse(bb, cloneObjectFieldFlow);
                    }
                }
            }
        }
    }
    /* Element flows of array clones (if any) have been updated, update the uses. */
    super.update(bb);
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) AnalysisObject(com.oracle.graal.pointsto.flow.context.object.AnalysisObject) TypeState(com.oracle.graal.pointsto.typestate.TypeState) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField)

Example 5 with AnalysisField

use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.

the class PointsToStats method formatSource.

private static String formatSource(TypeFlow<?> flow) {
    Object source = flow.getSource();
    if (source instanceof ValueNode) {
        ValueNode node = (ValueNode) source;
        NodeSourcePosition nodeSource = node.getNodeSourcePosition();
        if (nodeSource != null) {
            return formatMethod(nodeSource.getMethod()) + ":" + nodeSource.getBCI();
        } else if (flow.graphRef() != null) {
            return formatMethod(flow.graphRef().getMethod());
        } else {
            return "<unknown-source>";
        }
    } else if (source instanceof AnalysisType) {
        return formatType((AnalysisType) source);
    } else if (source instanceof AnalysisField) {
        return formatField((AnalysisField) source);
    } else if (source == null) {
        return "<no-source>";
    } else {
        return source.getClass().getSimpleName();
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) ValueNode(org.graalvm.compiler.nodes.ValueNode) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Aggregations

AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)21 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)9 Indent (org.graalvm.compiler.debug.Indent)4 FieldTypeFlow (com.oracle.graal.pointsto.flow.FieldTypeFlow)3 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)3 SubstrateField (com.oracle.svm.graal.meta.SubstrateField)3 BigBang (com.oracle.graal.pointsto.BigBang)2 HostedField (com.oracle.svm.hosted.meta.HostedField)2 ComputedValueField (com.oracle.svm.hosted.substitute.ComputedValueField)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)2 UnsupportedFeatureException (com.oracle.graal.pointsto.constraints.UnsupportedFeatureException)1 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