Search in sources :

Example 1 with Fields

use of org.graalvm.compiler.core.common.Fields in project graal by oracle.

the class FieldsOffsetsFeature method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess a) {
    CompilationAccessImpl config = (CompilationAccessImpl) a;
    HostedMetaAccess hMetaAccess = config.getMetaAccess();
    for (FieldsOffsetsReplacement replacement : getReplacements().values()) {
        Fields fields = replacement.fields;
        long[] newOffsets = new long[fields.getCount()];
        for (int i = 0; i < newOffsets.length; i++) {
            Field field = findField(fields, i);
            assert UnsafeAccess.UNSAFE.objectFieldOffset(field) == fields.getOffsets()[i];
            newOffsets[i] = hMetaAccess.lookupJavaField(field).getLocation();
        }
        replacement.newOffsets = newOffsets;
        if (fields instanceof Edges) {
            Edges edges = (Edges) fields;
            replacement.newIterationInitMask = NodeClass.computeIterationMask(edges.type(), edges.getDirectCount(), newOffsets);
        }
        replacement.newValuesAvailable = true;
    }
}
Also used : ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) Field(java.lang.reflect.Field) Fields(org.graalvm.compiler.core.common.Fields) CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl) Edges(org.graalvm.compiler.graph.Edges) HostedMetaAccess(com.oracle.svm.hosted.meta.HostedMetaAccess)

Example 2 with Fields

use of org.graalvm.compiler.core.common.Fields in project graal by oracle.

the class FieldsOffsetsFeature method registerFields.

private static void registerFields(FieldIntrospection<?> introspection, BeforeAnalysisAccessImpl config) {
    if (introspection instanceof NodeClass<?>) {
        NodeClass<?> nodeClass = (NodeClass<?>) introspection;
        Fields dataFields = nodeClass.getData();
        registerFields(dataFields, DefaultUnsafePartition.get(), config);
        Fields inputEdges = nodeClass.getInputEdges();
        registerFields(inputEdges, GraalEdgeUnsafePartition.get(), config);
        Fields successorEdges = nodeClass.getSuccessorEdges();
        registerFields(successorEdges, GraalEdgeUnsafePartition.get(), config);
        /* Ensure field shortName is initialized, so that the instance is immutable. */
        nodeClass.shortName();
    } else {
        for (Fields fields : introspection.getAllFields()) {
            registerFields(fields, DefaultUnsafePartition.get(), config);
        }
    }
}
Also used : NodeClass(org.graalvm.compiler.graph.NodeClass) Fields(org.graalvm.compiler.core.common.Fields)

Example 3 with Fields

use of org.graalvm.compiler.core.common.Fields in project graal by oracle.

the class LIRIntrospection method appendValues.

protected static void appendValues(StringBuilder sb, Object obj, String start, String end, String startMultiple, String endMultiple, String[] prefix, Fields... fieldsList) {
    int total = 0;
    for (Fields fields : fieldsList) {
        total += fields.getCount();
    }
    if (total == 0) {
        return;
    }
    sb.append(start);
    if (total > 1) {
        sb.append(startMultiple);
    }
    String sep = "";
    int i = 0;
    for (Fields fields : fieldsList) {
        for (int j = 0; j < fields.getCount(); j++) {
            sb.append(sep).append(prefix[i]);
            if (total > 1) {
                sb.append(fields.getName(j)).append(": ");
            }
            sb.append(getFieldString(obj, j, fields));
            sep = ", ";
        }
        i++;
    }
    if (total > 1) {
        sb.append(endMultiple);
    }
    sb.append(end);
}
Also used : Fields(org.graalvm.compiler.core.common.Fields)

Example 4 with Fields

use of org.graalvm.compiler.core.common.Fields in project graal by oracle.

the class Node method getDebugProperties.

/**
 * Fills a {@link Map} with properties of this node for use in debugging (e.g., to view in the
 * ideal graph visualizer). Subclasses overriding this method should also fill the map using
 * their superclass.
 *
 * @param map
 */
public Map<Object, Object> getDebugProperties(Map<Object, Object> map) {
    Fields properties = getNodeClass().getData();
    for (int i = 0; i < properties.getCount(); i++) {
        map.put(properties.getName(i), properties.get(this, i));
    }
    NodeSourcePosition pos = getNodeSourcePosition();
    if (pos != null) {
        map.put("nodeSourcePosition", pos);
    }
    NodeCreationStackTrace creation = getCreationPosition();
    if (creation != null) {
        map.put("nodeCreationPosition", creation.getStrackTraceString());
    }
    NodeInsertionStackTrace insertion = getInsertionPosition();
    if (insertion != null) {
        map.put("nodeInsertionPosition", insertion.getStrackTraceString());
    }
    return map;
}
Also used : Fields(org.graalvm.compiler.core.common.Fields)

Example 5 with Fields

use of org.graalvm.compiler.core.common.Fields in project graal by oracle.

the class LoopDetector method readProperties.

protected void readProperties(MethodScope methodScope, Node node) {
    NodeSourcePosition position = (NodeSourcePosition) readObject(methodScope);
    Fields fields = node.getNodeClass().getData();
    for (int pos = 0; pos < fields.getCount(); pos++) {
        if (fields.getType(pos).isPrimitive()) {
            long primitive = methodScope.reader.getSV();
            fields.setRawPrimitive(node, pos, primitive);
        } else {
            Object value = readObject(methodScope);
            fields.putObject(node, pos, value);
        }
    }
    if (graph.trackNodeSourcePosition() && position != null) {
        node.setNodeSourcePosition(methodScope.getCallerBytecodePosition(position));
    }
}
Also used : Fields(org.graalvm.compiler.core.common.Fields) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Aggregations

Fields (org.graalvm.compiler.core.common.Fields)6 CompilationAccessImpl (com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl)1 HostedMetaAccess (com.oracle.svm.hosted.meta.HostedMetaAccess)1 Field (java.lang.reflect.Field)1 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)1 Edges (org.graalvm.compiler.graph.Edges)1 Node (org.graalvm.compiler.graph.Node)1 NodeClass (org.graalvm.compiler.graph.NodeClass)1 NodeSourcePosition (org.graalvm.compiler.graph.NodeSourcePosition)1 Position (org.graalvm.compiler.graph.Position)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 FixedNode (org.graalvm.compiler.nodes.FixedNode)1 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)1 FullInfopointNode (org.graalvm.compiler.nodes.FullInfopointNode)1 PhiNode (org.graalvm.compiler.nodes.PhiNode)1 ProxyNode (org.graalvm.compiler.nodes.ProxyNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 VirtualObjectNode (org.graalvm.compiler.nodes.virtual.VirtualObjectNode)1