src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/NodeClass.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/NodeClass.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/NodeClass.java
Print this page
*** 43,57 ****
import java.util.concurrent.atomic.AtomicInteger;
import org.graalvm.compiler.core.common.FieldIntrospection;
import org.graalvm.compiler.core.common.Fields;
import org.graalvm.compiler.core.common.FieldsScanner;
! import org.graalvm.compiler.debug.Debug;
import org.graalvm.compiler.debug.DebugCloseable;
! import org.graalvm.compiler.debug.DebugCounter;
! import org.graalvm.compiler.debug.DebugTimer;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.graph.Edges.Type;
import org.graalvm.compiler.graph.Graph.DuplicationReplacement;
import org.graalvm.compiler.graph.Node.EdgeVisitor;
import org.graalvm.compiler.graph.Node.Input;
import org.graalvm.compiler.graph.Node.OptionalInput;
--- 43,57 ----
import java.util.concurrent.atomic.AtomicInteger;
import org.graalvm.compiler.core.common.FieldIntrospection;
import org.graalvm.compiler.core.common.Fields;
import org.graalvm.compiler.core.common.FieldsScanner;
! import org.graalvm.compiler.debug.CounterKey;
import org.graalvm.compiler.debug.DebugCloseable;
! import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.GraalError;
+ import org.graalvm.compiler.debug.TimerKey;
import org.graalvm.compiler.graph.Edges.Type;
import org.graalvm.compiler.graph.Graph.DuplicationReplacement;
import org.graalvm.compiler.graph.Node.EdgeVisitor;
import org.graalvm.compiler.graph.Node.Input;
import org.graalvm.compiler.graph.Node.OptionalInput;
*** 77,103 ****
* </ul>
*/
public final class NodeClass<T> extends FieldIntrospection<T> {
// Timers for creation of a NodeClass instance
! private static final DebugTimer Init_FieldScanning = Debug.timer("NodeClass.Init.FieldScanning");
! private static final DebugTimer Init_FieldScanningInner = Debug.timer("NodeClass.Init.FieldScanning.Inner");
! private static final DebugTimer Init_AnnotationParsing = Debug.timer("NodeClass.Init.AnnotationParsing");
! private static final DebugTimer Init_Edges = Debug.timer("NodeClass.Init.Edges");
! private static final DebugTimer Init_Data = Debug.timer("NodeClass.Init.Data");
! private static final DebugTimer Init_AllowedUsages = Debug.timer("NodeClass.Init.AllowedUsages");
! private static final DebugTimer Init_IterableIds = Debug.timer("NodeClass.Init.IterableIds");
public static final long MAX_EDGES = 8;
public static final long MAX_LIST_EDGES = 6;
public static final long OFFSET_MASK = 0xFC;
public static final long LIST_MASK = 0x01;
public static final long NEXT_EDGE = 0x08;
@SuppressWarnings("try")
! private static <T extends Annotation> T getAnnotationTimed(AnnotatedElement e, Class<T> annotationClass) {
! try (DebugCloseable s = Init_AnnotationParsing.start()) {
return e.getAnnotation(annotationClass);
}
}
/**
--- 77,103 ----
* </ul>
*/
public final class NodeClass<T> extends FieldIntrospection<T> {
// Timers for creation of a NodeClass instance
! private static final TimerKey Init_FieldScanning = DebugContext.timer("NodeClass.Init.FieldScanning");
! private static final TimerKey Init_FieldScanningInner = DebugContext.timer("NodeClass.Init.FieldScanning.Inner");
! private static final TimerKey Init_AnnotationParsing = DebugContext.timer("NodeClass.Init.AnnotationParsing");
! private static final TimerKey Init_Edges = DebugContext.timer("NodeClass.Init.Edges");
! private static final TimerKey Init_Data = DebugContext.timer("NodeClass.Init.Data");
! private static final TimerKey Init_AllowedUsages = DebugContext.timer("NodeClass.Init.AllowedUsages");
! private static final TimerKey Init_IterableIds = DebugContext.timer("NodeClass.Init.IterableIds");
public static final long MAX_EDGES = 8;
public static final long MAX_LIST_EDGES = 6;
public static final long OFFSET_MASK = 0xFC;
public static final long LIST_MASK = 0x01;
public static final long NEXT_EDGE = 0x08;
@SuppressWarnings("try")
! private static <T extends Annotation> T getAnnotationTimed(AnnotatedElement e, Class<T> annotationClass, DebugContext debug) {
! try (DebugCloseable s = Init_AnnotationParsing.start(debug)) {
return e.getAnnotation(annotationClass);
}
}
/**
*** 142,153 ****
private final EnumSet<InputType> allowedUsageTypes;
private int[] iterableIds;
private final long inputsIteration;
private final long successorIteration;
! private static final DebugCounter ITERABLE_NODE_TYPES = Debug.counter("IterableNodeTypes");
! private final DebugCounter nodeIterableCount;
/**
* Determines if this node type implements {@link Canonicalizable}.
*/
private final boolean isCanonicalizable;
--- 142,152 ----
private final EnumSet<InputType> allowedUsageTypes;
private int[] iterableIds;
private final long inputsIteration;
private final long successorIteration;
! private static final CounterKey ITERABLE_NODE_TYPES = DebugContext.counter("IterableNodeTypes");
/**
* Determines if this node type implements {@link Canonicalizable}.
*/
private final boolean isCanonicalizable;
*** 170,179 ****
--- 169,179 ----
}
@SuppressWarnings("try")
public NodeClass(Class<T> clazz, NodeClass<? super T> superNodeClass, FieldsScanner.CalcOffset calcOffset, int[] presetIterableIds, int presetIterableId) {
super(clazz);
+ DebugContext debug = DebugContext.forCurrentThread();
this.superNodeClass = superNodeClass;
assert NODE_CLASS.isAssignableFrom(clazz);
this.isCanonicalizable = Canonicalizable.class.isAssignableFrom(clazz);
this.isCommutative = BinaryCommutative.class.isAssignableFrom(clazz);
*** 181,202 ****
assert Canonicalizable.Unary.class.isAssignableFrom(clazz) ^ Canonicalizable.Binary.class.isAssignableFrom(clazz) : clazz + " should implement either Unary or Binary, not both";
}
this.isSimplifiable = Simplifiable.class.isAssignableFrom(clazz);
! NodeFieldsScanner fs = new NodeFieldsScanner(calcOffset, superNodeClass);
! try (DebugCloseable t = Init_FieldScanning.start()) {
fs.scan(clazz, clazz.getSuperclass(), false);
}
! try (DebugCloseable t1 = Init_Edges.start()) {
successors = new SuccessorEdges(fs.directSuccessors, fs.successors);
successorIteration = computeIterationMask(successors.type(), successors.getDirectCount(), successors.getOffsets());
inputs = new InputEdges(fs.directInputs, fs.inputs);
inputsIteration = computeIterationMask(inputs.type(), inputs.getDirectCount(), inputs.getOffsets());
}
! try (DebugCloseable t1 = Init_Data.start()) {
data = new Fields(fs.data);
}
isLeafNode = inputs.getCount() + successors.getCount() == 0;
if (isLeafNode) {
--- 181,202 ----
assert Canonicalizable.Unary.class.isAssignableFrom(clazz) ^ Canonicalizable.Binary.class.isAssignableFrom(clazz) : clazz + " should implement either Unary or Binary, not both";
}
this.isSimplifiable = Simplifiable.class.isAssignableFrom(clazz);
! NodeFieldsScanner fs = new NodeFieldsScanner(calcOffset, superNodeClass, debug);
! try (DebugCloseable t = Init_FieldScanning.start(debug)) {
fs.scan(clazz, clazz.getSuperclass(), false);
}
! try (DebugCloseable t1 = Init_Edges.start(debug)) {
successors = new SuccessorEdges(fs.directSuccessors, fs.successors);
successorIteration = computeIterationMask(successors.type(), successors.getDirectCount(), successors.getOffsets());
inputs = new InputEdges(fs.directInputs, fs.inputs);
inputsIteration = computeIterationMask(inputs.type(), inputs.getDirectCount(), inputs.getOffsets());
}
! try (DebugCloseable t1 = Init_Data.start(debug)) {
data = new Fields(fs.data);
}
isLeafNode = inputs.getCount() + successors.getCount() == 0;
if (isLeafNode) {
*** 206,236 ****
}
canGVN = Node.ValueNumberable.class.isAssignableFrom(clazz);
startGVNNumber = clazz.getName().hashCode();
! NodeInfo info = getAnnotationTimed(clazz, NodeInfo.class);
assert info != null : "Missing NodeInfo annotation on " + clazz;
if (!info.nameTemplate().isEmpty()) {
this.nameTemplate = info.nameTemplate();
} else if (!info.shortName().isEmpty()) {
this.nameTemplate = info.shortName();
} else {
this.nameTemplate = "";
}
! try (DebugCloseable t1 = Init_AllowedUsages.start()) {
allowedUsageTypes = superNodeClass == null ? EnumSet.noneOf(InputType.class) : superNodeClass.allowedUsageTypes.clone();
allowedUsageTypes.addAll(Arrays.asList(info.allowedUsageTypes()));
}
if (presetIterableIds != null) {
this.iterableIds = presetIterableIds;
this.iterableId = presetIterableId;
} else if (IterableNodeType.class.isAssignableFrom(clazz)) {
! ITERABLE_NODE_TYPES.increment();
! try (DebugCloseable t1 = Init_IterableIds.start()) {
this.iterableId = nextIterableId.getAndIncrement();
NodeClass<?> snc = superNodeClass;
while (snc != null && IterableNodeType.class.isAssignableFrom(snc.getClazz())) {
snc.addIterableId(iterableId);
--- 206,236 ----
}
canGVN = Node.ValueNumberable.class.isAssignableFrom(clazz);
startGVNNumber = clazz.getName().hashCode();
! NodeInfo info = getAnnotationTimed(clazz, NodeInfo.class, debug);
assert info != null : "Missing NodeInfo annotation on " + clazz;
if (!info.nameTemplate().isEmpty()) {
this.nameTemplate = info.nameTemplate();
} else if (!info.shortName().isEmpty()) {
this.nameTemplate = info.shortName();
} else {
this.nameTemplate = "";
}
! try (DebugCloseable t1 = Init_AllowedUsages.start(debug)) {
allowedUsageTypes = superNodeClass == null ? EnumSet.noneOf(InputType.class) : superNodeClass.allowedUsageTypes.clone();
allowedUsageTypes.addAll(Arrays.asList(info.allowedUsageTypes()));
}
if (presetIterableIds != null) {
this.iterableIds = presetIterableIds;
this.iterableId = presetIterableId;
} else if (IterableNodeType.class.isAssignableFrom(clazz)) {
! ITERABLE_NODE_TYPES.increment(debug);
! try (DebugCloseable t1 = Init_IterableIds.start(debug)) {
this.iterableId = nextIterableId.getAndIncrement();
NodeClass<?> snc = superNodeClass;
while (snc != null && IterableNodeType.class.isAssignableFrom(snc.getClazz())) {
snc.addIterableId(iterableId);
*** 241,254 ****
}
} else {
this.iterableId = Node.NOT_ITERABLE;
this.iterableIds = null;
}
- nodeIterableCount = Debug.counter("NodeIterable_%s", clazz);
assert verifyIterableIds();
! try (Debug.Scope scope = Debug.scope("NodeCosts")) {
/*
* Note: We do not check for the existence of the node cost annotations during
* construction as not every node needs to have them set. However if costs are queried,
* after the construction of the node class, they must be properly set. This is
* important as we can not trust our cost model if there are unspecified nodes. Nodes
--- 241,253 ----
}
} else {
this.iterableId = Node.NOT_ITERABLE;
this.iterableIds = null;
}
assert verifyIterableIds();
! try (DebugContext.Scope scope = debug.scope("NodeCosts")) {
/*
* Note: We do not check for the existence of the node cost annotations during
* construction as not every node needs to have them set. However if costs are queried,
* after the construction of the node class, they must be properly set. This is
* important as we can not trust our cost model if there are unspecified nodes. Nodes
*** 269,281 ****
size = superNodeClass != null ? superNodeClass.size : NodeSize.SIZE_UNSET;
} else {
size = s;
}
assert size != null;
! Debug.log("Node cost for node of type __| %s |_, cycles:%s,size:%s", clazz, cycles, size);
}
-
}
private final NodeCycles cycles;
private final NodeSize size;
--- 268,279 ----
size = superNodeClass != null ? superNodeClass.size : NodeSize.SIZE_UNSET;
} else {
size = s;
}
assert size != null;
! debug.log("Node cost for node of type __| %s |_, cycles:%s,size:%s", clazz, cycles, size);
}
}
private final NodeCycles cycles;
private final NodeSize size;
*** 355,366 ****
@Override
public Fields[] getAllFields() {
return new Fields[]{data, inputs, successors};
}
! public int[] iterableIds() {
! nodeIterableCount.increment();
return iterableIds;
}
public int iterableId() {
return iterableId;
--- 353,363 ----
@Override
public Fields[] getAllFields() {
return new Fields[]{data, inputs, successors};
}
! int[] iterableIds() {
return iterableIds;
}
public int iterableId() {
return iterableId;
*** 449,461 ****
public final ArrayList<InputInfo> inputs = new ArrayList<>();
public final ArrayList<EdgeInfo> successors = new ArrayList<>();
int directInputs;
int directSuccessors;
! protected NodeFieldsScanner(FieldsScanner.CalcOffset calc, NodeClass<?> superNodeClass) {
super(calc);
if (superNodeClass != null) {
translateInto(superNodeClass.inputs, inputs);
translateInto(superNodeClass.successors, successors);
translateInto(superNodeClass.data, data);
directInputs = superNodeClass.inputs.getDirectCount();
--- 446,460 ----
public final ArrayList<InputInfo> inputs = new ArrayList<>();
public final ArrayList<EdgeInfo> successors = new ArrayList<>();
int directInputs;
int directSuccessors;
+ final DebugContext debug;
! protected NodeFieldsScanner(FieldsScanner.CalcOffset calc, NodeClass<?> superNodeClass, DebugContext debug) {
super(calc);
+ this.debug = debug;
if (superNodeClass != null) {
translateInto(superNodeClass.inputs, inputs);
translateInto(superNodeClass.successors, successors);
translateInto(superNodeClass.data, data);
directInputs = superNodeClass.inputs.getDirectCount();
*** 464,477 ****
}
@SuppressWarnings("try")
@Override
protected void scanField(Field field, long offset) {
! Input inputAnnotation = getAnnotationTimed(field, Node.Input.class);
! OptionalInput optionalInputAnnotation = getAnnotationTimed(field, Node.OptionalInput.class);
! Successor successorAnnotation = getAnnotationTimed(field, Successor.class);
! try (DebugCloseable s = Init_FieldScanningInner.start()) {
Class<?> type = field.getType();
int modifiers = field.getModifiers();
if (inputAnnotation != null || optionalInputAnnotation != null) {
assert successorAnnotation == null : "field cannot be both input and successor";
--- 463,476 ----
}
@SuppressWarnings("try")
@Override
protected void scanField(Field field, long offset) {
! Input inputAnnotation = getAnnotationTimed(field, Node.Input.class, debug);
! OptionalInput optionalInputAnnotation = getAnnotationTimed(field, Node.OptionalInput.class, debug);
! Successor successorAnnotation = getAnnotationTimed(field, Successor.class, debug);
! try (DebugCloseable s = Init_FieldScanningInner.start(debug)) {
Class<?> type = field.getType();
int modifiers = field.getModifiers();
if (inputAnnotation != null || optionalInputAnnotation != null) {
assert successorAnnotation == null : "field cannot be both input and successor";
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/NodeClass.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File