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;
}
}
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);
}
}
}
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);
}
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;
}
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));
}
}
Aggregations