Skip to content

Commit f8628c4

Browse files
authored
Merge pull request #662 from zakkak/2024-01-16-23.1-jan-cpu-sync
[23.1] Sync with upstream for January CPU release
2 parents 0124be0 + e13af23 commit f8628c4

File tree

99 files changed

+8101
-5661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+8101
-5661
lines changed

common.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
"labsjdk-ee-20-llvm": {"name": "labsjdk", "version": "ee-20.0.2+2-jvmci-23.1-b02-sulong", "platformspecific": true },
3636

3737
"oraclejdk21": {"name": "jpg-jdk", "version": "21", "build_id": "33", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
38-
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b19", "platformspecific": true },
39-
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b19-debug", "platformspecific": true },
40-
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b19-sulong", "platformspecific": true },
41-
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.2+7-jvmci-23.1-b24", "platformspecific": true },
42-
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.2+7-jvmci-23.1-b24-debug", "platformspecific": true },
43-
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+7-jvmci-23.1-b24-sulong", "platformspecific": true },
38+
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21.0.2+13-jvmci-23.1-b30", "platformspecific": true },
39+
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21.0.2+13-jvmci-23.1-b30-debug", "platformspecific": true },
40+
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21.0.2+13-jvmci-23.1-b30-sulong", "platformspecific": true },
41+
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b30", "platformspecific": true },
42+
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b30-debug", "platformspecific": true },
43+
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b30-sulong", "platformspecific": true },
4444

4545
"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "2", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
4646
},

compiler/src/jdk.internal.vm.compiler.test/src/org/graalvm/compiler/core/test/ea/EscapeAnalysisTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ public boolean testInstanceOfSnippet() {
406406

407407
@SuppressWarnings("unused")
408408
public static void testNewNodeSnippet() {
409-
new ValueAnchorNode(null);
409+
new ValueAnchorNode();
410410
}
411411

412412
/**

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/java/BytecodeParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -4516,7 +4516,7 @@ protected void genCheckCast(ResolvedJavaType resolvedType, ValueNode objectIn) {
45164516
if (profile.getNullSeen().isFalse()) {
45174517
SpeculationLog.Speculation speculation = mayUseTypeProfile();
45184518
if (speculation != null) {
4519-
object = nullCheckedValue(object);
4519+
object = addNonNullCast(object, InvalidateReprofile);
45204520
ResolvedJavaType singleType = profile.asSingleType();
45214521
if (singleType != null && checkedType.getType().isAssignableFrom(singleType)) {
45224522
LogicNode typeCheck = append(createInstanceOf(TypeReference.createExactTrusted(singleType), object, profile));
@@ -4579,7 +4579,7 @@ protected void genInstanceOf(ResolvedJavaType resolvedType, ValueNode objectIn)
45794579
LogicNode instanceOfNode = null;
45804580
if (profile != null) {
45814581
if (profile.getNullSeen().isFalse()) {
4582-
object = nullCheckedValue(object);
4582+
object = addNonNullCast(object, InvalidateReprofile);
45834583
boolean createGuard = true;
45844584
ResolvedJavaType singleType = profile.asSingleType();
45854585
if (singleType != null) {

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/java/LambdaUtils.java

+43-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
import org.graalvm.compiler.nodes.StructuredGraph;
4040
import org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin;
4141
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
42+
import org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext;
4243
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
44+
import org.graalvm.compiler.nodes.spi.CoreProviders;
4345
import org.graalvm.compiler.options.OptionValues;
4446
import org.graalvm.compiler.phases.OptimisticOptimizations;
4547
import org.graalvm.compiler.phases.tiers.HighTierContext;
@@ -117,7 +119,7 @@ public static String findStableLambdaName(ClassInitializationPlugin cip, Provide
117119
*/
118120
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(lambdaProxyMethods[0]).build();
119121
try (DebugContext.Scope ignored = debug.scope("Lambda target method analysis", graph, lambdaType, ctx)) {
120-
GraphBuilderPhase lambdaParserPhase = new GraphBuilderPhase(buildLambdaParserConfig(cip));
122+
GraphBuilderPhase lambdaParserPhase = new LambdaGraphBuilder(LambdaUtils.buildLambdaParserConfig(cip));
121123
HighTierContext context = new HighTierContext(providers, null, OptimisticOptimizations.NONE);
122124
lambdaParserPhase.apply(graph, context);
123125
} catch (Throwable e) {
@@ -180,4 +182,44 @@ public static String digest(String value) {
180182
public static String capturingClass(String className) {
181183
return className.split(LambdaUtils.SERIALIZATION_TEST_LAMBDA_CLASS_SPLIT_PATTERN)[0];
182184
}
185+
186+
private static final class LambdaGraphBuilder extends GraphBuilderPhase {
187+
188+
private LambdaGraphBuilder(GraphBuilderConfiguration config) {
189+
super(config);
190+
}
191+
192+
@Override
193+
protected GraphBuilderPhase.Instance createInstance(CoreProviders providers, GraphBuilderConfiguration instanceGBConfig, OptimisticOptimizations optimisticOpts,
194+
IntrinsicContext initialIntrinsicContext) {
195+
return new Instance(providers, instanceGBConfig, optimisticOpts, initialIntrinsicContext);
196+
}
197+
198+
private static class Instance extends GraphBuilderPhase.Instance {
199+
Instance(CoreProviders providers, GraphBuilderConfiguration instanceGBConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
200+
super(providers, instanceGBConfig, optimisticOpts, initialIntrinsicContext);
201+
}
202+
203+
@Override
204+
protected BytecodeParser createBytecodeParser(StructuredGraph graph, BytecodeParser parent, ResolvedJavaMethod method, int entryBCI, IntrinsicContext intrinsicContext) {
205+
return new LambdaBytecodeParser(this, graph, parent, method, entryBCI, intrinsicContext);
206+
}
207+
}
208+
}
209+
210+
private static class LambdaBytecodeParser extends BytecodeParser {
211+
212+
LambdaBytecodeParser(GraphBuilderPhase.Instance instance, StructuredGraph graph, BytecodeParser parent, ResolvedJavaMethod method, int entryBCI, IntrinsicContext intrinsicContext) {
213+
super(instance, graph, parent, method, entryBCI, intrinsicContext);
214+
}
215+
216+
@Override
217+
protected Object lookupConstant(int cpi, int opcode, boolean allowBootstrapMethodInvocation) {
218+
/*
219+
* Native Image forces bootstrap method invocation at build time until support has been
220+
* added for doing the invocation at runtime (GR-45806)
221+
*/
222+
return super.lookupConstant(cpi, opcode, true);
223+
}
224+
}
183225
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/ConditionAnchorNode.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Node canonical(CanonicalizerTool tool, Node forValue) {
8686
if (c.getValue() != negated) {
8787
return null;
8888
} else {
89-
return new ValueAnchorNode(null);
89+
return new ValueAnchorNode();
9090
}
9191
}
9292
if (tool.allUsagesAvailable() && this.hasNoUsages()) {
@@ -98,7 +98,7 @@ public Node canonical(CanonicalizerTool tool, Node forValue) {
9898
@Override
9999
public void lower(LoweringTool tool) {
100100
if (graph().getGuardsStage() == GraphState.GuardsStage.FIXED_DEOPTS) {
101-
ValueAnchorNode newAnchor = graph().add(new ValueAnchorNode(null));
101+
ValueAnchorNode newAnchor = graph().add(new ValueAnchorNode());
102102
graph().replaceFixedWithFixed(this, newAnchor);
103103
}
104104
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/PiNode.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public void virtualize(VirtualizerTool tool) {
226226
}
227227
}
228228

229-
public static ValueNode canonical(ValueNode object, Stamp piStamp, GuardingNode guard, PiNode self) {
229+
public static ValueNode canonical(ValueNode object, Stamp piStamp, GuardingNode guard, ValueNode self) {
230230
// Use most up to date stamp.
231231
Stamp computedStamp = piStamp.improveWith(object.stamp(NodeView.DEFAULT));
232232

@@ -256,15 +256,16 @@ public static ValueNode canonical(ValueNode object, Stamp piStamp, GuardingNode
256256
}
257257
if (otherPi.object() == self || otherPi.object() == object) {
258258
// Check if other pi's stamp is more precise
259-
Stamp joinedStamp = piStamp.improveWith(otherPi.piStamp());
260-
if (joinedStamp.equals(piStamp)) {
259+
Stamp joinedPiStamp = piStamp.improveWith(otherPi.piStamp());
260+
if (joinedPiStamp.equals(piStamp)) {
261261
// Stamp did not get better, nothing to do.
262-
} else if (otherPi.object() == object && joinedStamp.equals(otherPi.piStamp())) {
262+
} else if (otherPi.object() == object && joinedPiStamp.equals(otherPi.piStamp())) {
263263
// We can be replaced with the other pi.
264264
return otherPi;
265-
} else {
266-
// Create a new pi node with the more precise joined stamp.
267-
return new PiNode(object, joinedStamp, guard.asNode());
265+
} else if (self != null && self.hasExactlyOneUsage() && otherPi.object == self) {
266+
if (joinedPiStamp.equals(otherPi.piStamp)) {
267+
return object;
268+
}
268269
}
269270
}
270271
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/extended/ValueAnchorNode.java

+11-72
Original file line numberDiff line numberDiff line change
@@ -30,106 +30,45 @@
3030
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_0;
3131

3232
import org.graalvm.compiler.core.common.type.StampFactory;
33+
import org.graalvm.compiler.graph.Node;
3334
import org.graalvm.compiler.graph.NodeClass;
3435
import org.graalvm.compiler.graph.spi.NodeWithIdentity;
3536
import org.graalvm.compiler.nodeinfo.NodeInfo;
36-
import org.graalvm.compiler.nodes.AbstractBeginNode;
37-
import org.graalvm.compiler.nodes.FixedNode;
3837
import org.graalvm.compiler.nodes.FixedWithNextNode;
39-
import org.graalvm.compiler.nodes.ValueNode;
4038
import org.graalvm.compiler.nodes.debug.ControlFlowAnchored;
41-
import org.graalvm.compiler.nodes.memory.FixedAccessNode;
39+
import org.graalvm.compiler.nodes.spi.Canonicalizable;
40+
import org.graalvm.compiler.nodes.spi.CanonicalizerTool;
4241
import org.graalvm.compiler.nodes.spi.LIRLowerable;
4342
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
44-
import org.graalvm.compiler.nodes.spi.Simplifiable;
45-
import org.graalvm.compiler.nodes.spi.SimplifierTool;
46-
import org.graalvm.compiler.nodes.spi.Virtualizable;
47-
import org.graalvm.compiler.nodes.spi.VirtualizerTool;
48-
import org.graalvm.compiler.nodes.util.GraphUtil;
49-
import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
5043

5144
/**
52-
* This node can be used for two different kinds of anchoring for non-CFG (floating) nodes: It can
53-
* 1) keep one node above a certain point in the graph by specifying that node as the
54-
* {@link #anchored} node; or 2) it can keep nodes below a certain point in the graph by using this
55-
* node as an Anchor or Guard input.
45+
* This node can be used to keep nodes below a certain point in the graph by using this node as an
46+
* Anchor or Guard input.
5647
*
5748
* This node must not move in the CFG, because that would change the anchor point. So optimizations
5849
* like de-duplication are not allowed and this node implements {@link NodeWithIdentity}. However,
5950
* duplication is allowed, i.e., it is on purpose that this node does not implement
6051
* {@link ControlFlowAnchored}.
6152
*/
6253
@NodeInfo(allowedUsageTypes = {Anchor, Guard}, cycles = CYCLES_0, size = SIZE_0)
63-
public final class ValueAnchorNode extends FixedWithNextNode implements LIRLowerable, Simplifiable, Virtualizable, AnchoringNode, GuardingNode, NodeWithIdentity {
54+
public final class ValueAnchorNode extends FixedWithNextNode implements LIRLowerable, Canonicalizable, AnchoringNode, GuardingNode, NodeWithIdentity {
6455

6556
public static final NodeClass<ValueAnchorNode> TYPE = NodeClass.create(ValueAnchorNode.class);
66-
@OptionalInput(Guard) ValueNode anchored;
6757

68-
public ValueAnchorNode(ValueNode value) {
58+
public ValueAnchorNode() {
6959
super(TYPE, StampFactory.forVoid());
70-
this.anchored = value;
7160
}
7261

7362
@Override
7463
public void generate(NodeLIRBuilderTool gen) {
7564
// Nothing to emit, since this node is used for structural purposes only.
7665
}
7766

78-
public ValueNode getAnchoredNode() {
79-
return anchored;
80-
}
81-
8267
@Override
83-
public void simplify(SimplifierTool tool) {
84-
while (next() instanceof ValueAnchorNode) {
85-
ValueAnchorNode nextAnchor = (ValueAnchorNode) next();
86-
if (nextAnchor.anchored == anchored || nextAnchor.anchored == null) {
87-
// two anchors for the same anchored -> coalesce
88-
// nothing anchored on the next anchor -> coalesce
89-
nextAnchor.replaceAtUsages(this);
90-
GraphUtil.removeFixedWithUnusedInputs(nextAnchor);
91-
/*
92-
* Combining two anchors can allow the combining of two PiNode that are now anchored
93-
* at the same place.
94-
*/
95-
tool.addToWorkList(usages());
96-
} else {
97-
break;
98-
}
99-
}
100-
if (tool.allUsagesAvailable() && hasNoUsages() && next() instanceof FixedAccessNode) {
101-
FixedAccessNode currentNext = (FixedAccessNode) next();
102-
if (currentNext.getGuard() == anchored) {
103-
GraphUtil.removeFixedWithUnusedInputs(this);
104-
return;
105-
}
106-
}
107-
108-
if (anchored != null && (anchored.isConstant() || anchored instanceof FixedNode)) {
109-
// anchoring fixed nodes and constants is useless
110-
removeAnchoredNode();
111-
}
112-
113-
if (anchored == null && hasNoUsages()) {
114-
// anchor is not necessary any more => remove.
115-
GraphUtil.removeFixedWithUnusedInputs(this);
68+
public Node canonical(CanonicalizerTool tool) {
69+
if (tool.allUsagesAvailable() && hasNoUsages()) {
70+
return null;
11671
}
117-
}
118-
119-
@Override
120-
public void virtualize(VirtualizerTool tool) {
121-
if (anchored == null || anchored instanceof AbstractBeginNode) {
122-
tool.delete();
123-
} else {
124-
ValueNode alias = tool.getAlias(anchored);
125-
if (alias instanceof VirtualObjectNode) {
126-
tool.delete();
127-
}
128-
}
129-
}
130-
131-
public void removeAnchoredNode() {
132-
this.updateUsages(anchored, null);
133-
this.anchored = null;
72+
return this;
13473
}
13574
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderContext.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,16 @@ default Node canonicalizeAndAdd(Node value) {
142142
}
143143

144144
default ValueNode addNonNullCast(ValueNode value) {
145+
return addNonNullCast(value, DeoptimizationAction.None);
146+
}
147+
148+
default ValueNode addNonNullCast(ValueNode value, DeoptimizationAction action) {
145149
AbstractPointerStamp valueStamp = (AbstractPointerStamp) value.stamp(NodeView.DEFAULT);
146150
if (valueStamp.nonNull()) {
147151
return value;
148152
} else {
149153
LogicNode isNull = add(IsNullNode.create(value));
150-
FixedGuardNode fixedGuard = add(new FixedGuardNode(isNull, DeoptimizationReason.NullCheckException, DeoptimizationAction.None, true));
154+
FixedGuardNode fixedGuard = add(new FixedGuardNode(isNull, DeoptimizationReason.NullCheckException, action, true));
151155
Stamp newStamp = valueStamp.improveWith(StampFactory.objectNonNull());
152156
return add(PiNode.create(value, newStamp, fixedGuard));
153157
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/loop/LoopFragmentInside.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ protected CompareNode placeNewSegmentAndCleanup(LoopEx loop, EconomicMap<Node, N
316316
* anchor point here ensuring nothing can flow above the original iteration.
317317
*/
318318
if (!(lastCodeNode instanceof GuardingNode) || !(lastCodeNode instanceof AnchoringNode)) {
319-
ValueAnchorNode newAnchoringPointAfterPrevIteration = graph.add(new ValueAnchorNode(null));
319+
ValueAnchorNode newAnchoringPointAfterPrevIteration = graph.add(new ValueAnchorNode());
320320
graph.addAfterFixed(lastCodeNode, newAnchoringPointAfterPrevIteration);
321321
lastCodeNode = newAnchoringPointAfterPrevIteration;
322322
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/ConditionalEliminationPhase.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ protected void processConditionAnchor(ConditionAnchorNode node) {
440440
GraphUtil.unlinkFixedNode(node);
441441
GraphUtil.killWithUnusedFloatingInputs(node);
442442
} else {
443-
ValueAnchorNode valueAnchor = node.graph().add(new ValueAnchorNode(null));
443+
ValueAnchorNode valueAnchor = node.graph().add(new ValueAnchorNode());
444444
node.replaceAtUsages(valueAnchor);
445445
node.graph().replaceFixedWithFixed(node, valueAnchor);
446446
}
@@ -452,7 +452,11 @@ protected void processConditionAnchor(ConditionAnchorNode node) {
452452
protected void processGuard(GuardNode node) {
453453
if (!tryProveGuardCondition(node, node.getCondition(), (guard, result, guardedValueStamp, newInput) -> {
454454
if (result != node.isNegated()) {
455+
ValueNode condition = node.getCondition();
455456
node.replaceAndDelete(guard.asNode());
457+
if (condition.hasNoUsages()) {
458+
GraphUtil.killWithUnusedFloatingInputs(condition);
459+
}
456460
if (guard instanceof DeoptimizingGuard && !((DeoptimizingGuard) guard).isNegated()) {
457461
rebuildPiNodes((DeoptimizingGuard) guard);
458462
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/inlining/InliningUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ public static Pair<ValueNode, FixedNode> replaceInvokeAtUsages(ValueNode invokeN
684684
StructuredGraph graph = origReturn.graph();
685685
if (!(anchorCandidate instanceof AbstractBeginNode)) {
686686
// Add anchor for pi after the original candidate
687-
ValueAnchorNode anchor = graph.add(new ValueAnchorNode(null));
687+
ValueAnchorNode anchor = graph.add(new ValueAnchorNode());
688688
if (anchorCandidate.predecessor() == null) {
689689
anchor.setNext(anchorCandidate);
690690
} else {

0 commit comments

Comments
 (0)