Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure source position for new instance node is tracked #3621

Merged
merged 3 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {

protected VirtualBoxingNode createVirtualBoxingNode() {
VirtualBoxingNode node = new VirtualBoxingNode(StampTool.typeOrNull(stamp(NodeView.DEFAULT)), boxingKind);
node.setNodeSourcePosition(getNodeSourcePosition());
return node;
}

Expand All @@ -151,7 +150,8 @@ public void virtualize(VirtualizerTool tool) {
VirtualBoxingNode newVirtual = createVirtualBoxingNode();
assert newVirtual.getFields().length == 1;

tool.createVirtualObject(newVirtual, new ValueNode[]{alias}, Collections.<MonitorIdNode> emptyList(), false);

tool.createVirtualObject(newVirtual, new ValueNode[]{alias}, Collections.<MonitorIdNode> emptyList(), getNodeSourcePosition(),false);
tool.replaceWithVirtual(newVirtual);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void virtualize(VirtualizerTool tool) {
}

VirtualObjectNode virtualObject = new VirtualArrayNode(elementType(), constantLength);
tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), false);
tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), getNodeSourcePosition(), false);
tool.replaceWithVirtual(virtualObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void virtualize(VirtualizerTool tool) {
for (int i = 0; i < state.length; i++) {
state[i] = ConstantNode.defaultForKind(tool.getMetaAccessExtensionProvider().getStorageKind(fields[i].getType()), graph());
}
tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), false);
tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), getNodeSourcePosition(), false);
tool.replaceWithVirtual(virtualObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.NodeSourcePosition;
import org.graalvm.compiler.nodes.ValueNode;
import org.graalvm.compiler.nodes.WithExceptionNode;
import org.graalvm.compiler.nodes.java.MonitorIdNode;
Expand Down Expand Up @@ -61,9 +62,10 @@ public interface VirtualizerTool extends CoreProviders {
* @param virtualObject the new virtual object.
* @param entryState the initial state of the virtual object's fields.
* @param locks the initial locking depths.
* @param sourcePosition a source position for the new node or null if none is available
* @param ensureVirtualized true if this object needs to stay virtual
*/
void createVirtualObject(VirtualObjectNode virtualObject, ValueNode[] entryState, List<MonitorIdNode> locks, boolean ensureVirtualized);
void createVirtualObject(VirtualObjectNode virtualObject, ValueNode[] entryState, List<MonitorIdNode> locks, NodeSourcePosition sourcePosition, boolean ensureVirtualized);

/**
* Returns a VirtualObjectNode if the given value is aliased with a virtual object that is still
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ public static void virtualizeArrayCopy(VirtualizerTool tool, ValueNode source, V
}
/* Perform the replacement. */
VirtualArrayNode newVirtualArray = virtualArrayProvider.apply(newComponentType, newLengthInt);
tool.createVirtualObject(newVirtualArray, newEntryState, Collections.<MonitorIdNode> emptyList(), false);
tool.createVirtualObject(newVirtualArray, newEntryState, Collections.<MonitorIdNode> emptyList(), source.getNodeSourcePosition(), false);
tool.replaceWithVirtual(newVirtualArray);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public void virtualize(VirtualizerTool tool) {
for (int i = 0; i < virtualObjects.size(); i++) {
VirtualObjectNode virtualObject = virtualObjects.get(i);
int entryCount = virtualObject.entryCount();
tool.createVirtualObject(virtualObject, values.subList(pos, pos + entryCount).toArray(new ValueNode[entryCount]), getLocks(i), ensureVirtual.get(i));
/* n.b. the node source position of virtualObject will have been set when it was created */
tool.createVirtualObject(virtualObject, values.subList(pos, pos + entryCount).toArray(new ValueNode[entryCount]), getLocks(i), null, ensureVirtual.get(i));
adinn marked this conversation as resolved.
Show resolved Hide resolved
pos += entryCount;
}
tool.delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.graalvm.compiler.core.common.type.ObjectStamp;
import org.graalvm.compiler.core.common.type.Stamp;
import org.graalvm.compiler.core.common.type.StampFactory;
import org.graalvm.compiler.graph.NodeSourcePosition;
import org.graalvm.compiler.nodes.ConstantNode;
import org.graalvm.compiler.nodes.NodeView;
import org.graalvm.compiler.nodes.StateSplit;
Expand Down Expand Up @@ -95,7 +96,9 @@ default LoadIndexedNode genLoadIndexedNode(Assumptions assumptions, ValueNode or

@Override
default void virtualize(VirtualizerTool tool) {
ValueNode originalAlias = tool.getAlias(getObject());
ValueNode original = getObject();
ValueNode originalAlias = tool.getAlias(original);
NodeSourcePosition sourcePosition = original.getNodeSourcePosition();
if (originalAlias instanceof VirtualObjectNode) {
VirtualObjectNode originalVirtual = (VirtualObjectNode) originalAlias;
if (originalVirtual.type().isCloneableWithAllocation()) {
Expand All @@ -104,7 +107,8 @@ default void virtualize(VirtualizerTool tool) {
newEntryState[i] = tool.getEntry(originalVirtual, i);
}
VirtualObjectNode newVirtual = originalVirtual.duplicate();
tool.createVirtualObject(newVirtual, newEntryState, Collections.<MonitorIdNode> emptyList(), false);
/* n.b. duplicate will replicate the source position so pass null */
tool.createVirtualObject(newVirtual, newEntryState, Collections.<MonitorIdNode> emptyList(), null, false);
tool.replaceWithVirtual(newVirtual);
}
} else {
Expand All @@ -122,7 +126,7 @@ default void virtualize(VirtualizerTool tool) {
state[i] = load;
tool.addNode(load);
}
tool.createVirtualObject(newVirtual, state, Collections.<MonitorIdNode> emptyList(), false);
tool.createVirtualObject(newVirtual, state, Collections.<MonitorIdNode> emptyList(), sourcePosition, false);
tool.replaceWithVirtual(newVirtual);
} else {
ValueNode length = findLength(FindLengthMode.SEARCH_ONLY, tool.getConstantReflection());
Expand All @@ -145,7 +149,7 @@ default void virtualize(VirtualizerTool tool) {
tool.addNode(load);
}
VirtualObjectNode virtualObject = new VirtualArrayNode(componentType, constantLength);
tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), false);
tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), sourcePosition, false);
tool.replaceWithVirtual(virtualObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.NodeClass;
import org.graalvm.compiler.graph.NodeInputList;
import org.graalvm.compiler.graph.NodeSourcePosition;
import org.graalvm.compiler.nodes.spi.Canonicalizable;
import org.graalvm.compiler.nodes.spi.CanonicalizerTool;
import org.graalvm.compiler.nodeinfo.NodeInfo;
Expand Down Expand Up @@ -268,12 +269,13 @@ public void virtualize(VirtualizerTool tool) {
}
}

tool.createVirtualObject(virtualFrameObjectArray, objectArrayEntryState, Collections.<MonitorIdNode> emptyList(), false);
NodeSourcePosition sourcePosition = getNodeSourcePosition();
adinn marked this conversation as resolved.
Show resolved Hide resolved
tool.createVirtualObject(virtualFrameObjectArray, objectArrayEntryState, Collections.<MonitorIdNode> emptyList(), sourcePosition, false);
if (virtualFramePrimitiveArray != null) {
tool.createVirtualObject(virtualFramePrimitiveArray, primitiveArrayEntryState, Collections.<MonitorIdNode> emptyList(), false);
tool.createVirtualObject(virtualFramePrimitiveArray, primitiveArrayEntryState, Collections.<MonitorIdNode> emptyList(), sourcePosition, false);
}
if (virtualFrameTagArray != null) {
tool.createVirtualObject(virtualFrameTagArray, tagArrayEntryState, Collections.<MonitorIdNode> emptyList(), false);
tool.createVirtualObject(virtualFrameTagArray, tagArrayEntryState, Collections.<MonitorIdNode> emptyList(), sourcePosition, false);
}

assert frameFields.length == 5 || frameFields.length == 3;
Expand All @@ -293,7 +295,7 @@ public void virtualize(VirtualizerTool tool) {
* materialized. This can only be lifted by a AllowMaterializeNode, which corresponds to a
* frame.materialize() call.
*/
tool.createVirtualObject(virtualFrame, frameEntryState, Collections.<MonitorIdNode> emptyList(), true);
tool.createVirtualObject(virtualFrame, frameEntryState, Collections.<MonitorIdNode> emptyList(), sourcePosition, true);
tool.replaceWithVirtual(virtualFrame);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.NodeSourcePosition;
import org.graalvm.compiler.nodes.spi.CanonicalizerTool;
import org.graalvm.compiler.nodes.ConstantNode;
import org.graalvm.compiler.nodes.FixedNode;
Expand Down Expand Up @@ -290,7 +291,7 @@ public void addNode(ValueNode node) {
}

@Override
public void createVirtualObject(VirtualObjectNode virtualObject, ValueNode[] entryState, List<MonitorIdNode> locks, boolean ensureVirtualized) {
public void createVirtualObject(VirtualObjectNode virtualObject, ValueNode[] entryState, List<MonitorIdNode> locks, NodeSourcePosition sourcePosition, boolean ensureVirtualized) {
VirtualUtil.trace(options, debug, "{{%s}} ", current);
if (!virtualObject.isAlive()) {
effects.addFloatingNode(virtualObject, "newVirtualObject");
Expand All @@ -309,6 +310,10 @@ public void createVirtualObject(VirtualObjectNode virtualObject, ValueNode[] ent
closure.addVirtualAlias(virtualObject, virtualObject);
PartialEscapeClosure.COUNTER_ALLOCATION_REMOVED.increment(debug);
effects.addVirtualizationDelta(1);
if (sourcePosition != null) {
assert virtualObject.getNodeSourcePosition() == null : "source pos already set!";
adinn marked this conversation as resolved.
Show resolved Hide resolved
virtualObject.setNodeSourcePosition(sourcePosition);
}
}

@Override
Expand Down