use of com.oracle.truffle.api.nodes.NodeClass in project graal by oracle.
the class TruffleTreeDumpHandler method findNamedNodeChildren.
@SuppressWarnings("deprecation")
private static LinkedHashMap<String, Node> findNamedNodeChildren(Node node) {
LinkedHashMap<String, Node> nodes = new LinkedHashMap<>();
NodeClass nodeClass = NodeClass.get(node);
for (com.oracle.truffle.api.nodes.NodeFieldAccessor field : findNodeFields(nodeClass)) {
if (isChildField(nodeClass, field)) {
Object value = findFieldObject(nodeClass, field, node);
if (value != null) {
nodes.put(findFieldName(nodeClass, field), (Node) value);
}
} else if (isChildrenField(nodeClass, field)) {
Object value = findFieldObject(nodeClass, field, node);
if (value != null) {
Object[] children = (Object[]) value;
for (int i = 0; i < children.length; i++) {
if (children[i] != null) {
nodes.put(findFieldName(nodeClass, field) + "[" + i + "]", (Node) children[i]);
}
}
}
}
}
return nodes;
}
use of com.oracle.truffle.api.nodes.NodeClass in project graal by oracle.
the class Target_com_oracle_truffle_api_nodes_Node method registerUnsafeAccess.
@SuppressWarnings("deprecation")
private void registerUnsafeAccess(DuringAnalysisAccessImpl access, Class<? extends Node> clazz) {
if (registeredClasses.contains(clazz)) {
return;
}
registeredClasses.add(clazz);
NodeClass nodeClass = NodeClass.get(clazz);
for (com.oracle.truffle.api.nodes.NodeFieldAccessor accessor : nodeClass.getFields()) {
Field field;
try {
field = accessor.getDeclaringClass().getDeclaredField(accessor.getName());
} catch (NoSuchFieldException ex) {
throw shouldNotReachHere(ex);
}
if (accessor.getKind() == com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind.PARENT || accessor.getKind() == com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind.CHILD || accessor.getKind() == com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind.CHILDREN) {
/*
* It's a field which represents an edge in the graph. Such fields are written with
* Unsafe in the NodeClass, e.g. when making changes in the graph.
*/
// TODO register unsafe accessed Truffle nodes in a separate partition?
access.registerAsUnsafeWritten(field);
}
if (accessor.getKind() == com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind.DATA) {
/*
* It's a normal non-child data field of the node. Such fields are written with
* Unsafe in the NodeUtil.deepCopyImpl.
*/
access.registerAsFrozenUnsafeAccessed(field);
}
/* All other fields are only read with Unsafe. */
access.registerAsAccessed(field);
}
access.requireAnalysisIteration();
}
use of com.oracle.truffle.api.nodes.NodeClass in project graal by oracle.
the class TruffleTreeDumpHandler method readNodeProperties.
@SuppressWarnings("deprecation")
private static void readNodeProperties(ASTNode astNode, Node node) {
NodeClass nodeClass = NodeClass.get(node);
for (com.oracle.truffle.api.nodes.NodeFieldAccessor field : findNodeFields(nodeClass)) {
if (isDataField(nodeClass, field)) {
String key = findFieldName(nodeClass, field);
Object value = findFieldValue(nodeClass, field, node);
astNode.properties.put(key, value);
}
}
}
use of com.oracle.truffle.api.nodes.NodeClass in project graal by oracle.
the class Target_com_oracle_truffle_api_nodes_Node method get.
@Substitute
public static NodeClass get(Class<?> clazz) {
CompilerAsserts.neverPartOfCompilation();
NodeClass nodeClass = (NodeClass) DynamicHub.fromClass(clazz).getMetaType();
if (nodeClass == null) {
throw shouldNotReachHere("Unknown node class: " + clazz.getName());
}
return nodeClass;
}
Aggregations