Skip to content

Commit ef9314d

Browse files
committed
[GR-52973] [GR-53570] [GR-53628] Various fixes for compiler crashes
PullRequest: graal/17486
2 parents ea3bb50 + 6f4daf7 commit ef9314d

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/calc/AndNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import jdk.graal.compiler.nodes.spi.CanonicalizerTool;
4040
import jdk.graal.compiler.nodes.spi.NodeLIRBuilderTool;
4141
import jdk.graal.compiler.nodes.util.GraphUtil;
42-
4342
import jdk.vm.ci.meta.Constant;
4443
import jdk.vm.ci.meta.PrimitiveConstant;
4544

@@ -195,7 +194,7 @@ private static ValueNode canonical(AndNode self, BinaryOp<And> op, ValueNode for
195194
// ~x & ~y |-> ~(x | y)
196195
return new NotNode(OrNode.create(((NotNode) forX).getValue(), ((NotNode) forY).getValue(), view));
197196
}
198-
if (forY instanceof NotNode && ((NotNode) forY).getValue() == forX) {
197+
if (forY instanceof NotNode && ((NotNode) forY).getValue() == forX && rawXStamp instanceof IntegerStamp) {
199198
// x & ~x |-> 0
200199
return ConstantNode.forIntegerStamp(rawXStamp, 0L);
201200
}

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/calc/LeftShiftNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import jdk.graal.compiler.core.common.type.ArithmeticOpTable.ShiftOp;
2929
import jdk.graal.compiler.core.common.type.ArithmeticOpTable.ShiftOp.Shl;
3030
import jdk.graal.compiler.core.common.type.IntegerStamp;
31+
import jdk.graal.compiler.core.common.type.PrimitiveStamp;
3132
import jdk.graal.compiler.core.common.type.Stamp;
3233
import jdk.graal.compiler.debug.Assertions;
3334
import jdk.graal.compiler.graph.NodeClass;
@@ -139,7 +140,7 @@ private static ValueNode canonical(LeftShiftNode leftShiftNode, ArithmeticOpTabl
139140
if (other instanceof LeftShiftNode) {
140141
int total = amount + otherAmount;
141142
if (total != (total & mask)) {
142-
return ConstantNode.forIntegerKind(stamp.getStackKind(), 0);
143+
return ConstantNode.forIntegerBits(PrimitiveStamp.getBits(stamp), 0);
143144
}
144145
return new LeftShiftNode(other.getX(), ConstantNode.forInt(total));
145146
} else if ((other instanceof RightShiftNode || other instanceof UnsignedRightShiftNode) && otherAmount == amount) {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/calc/ObjectEqualsNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -108,7 +108,7 @@ protected LogicNode canonicalizeSymmetricConstant(ConstantReflectionProvider con
108108
if (type != null && nonConstant instanceof GetClassNode) {
109109
GetClassNode getClassNode = (GetClassNode) nonConstant;
110110
ValueNode object = getClassNode.getObject();
111-
assert ((ObjectStamp) object.stamp(view)).nonNull();
111+
assert ((ObjectStamp) object.stamp(view)).nonNull() : "getClassNode %s object %s should have a non-null stamp, got: %s".formatted(getClassNode, object, object.stamp(view));
112112
if (!type.isPrimitive() && (type.isConcrete() || type.isArray())) {
113113
return InstanceOfNode.create(TypeReference.createExactTrusted(type), object);
114114
}

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/calc/RightShiftNode.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -112,7 +112,7 @@ private static ValueNode canonical(RightShiftNode rightShiftNode, ArithmeticOpTa
112112

113113
if (xStamp.lowerBound() >> amount == xStamp.upperBound() >> amount) {
114114
// Right shift turns the result of the expression into a constant.
115-
return ConstantNode.forIntegerKind(stamp.getStackKind(), xStamp.lowerBound() >> amount);
115+
return ConstantNode.forIntegerBits(xStamp.getBits(), xStamp.lowerBound() >> amount);
116116
}
117117
}
118118

@@ -128,10 +128,10 @@ private static ValueNode canonical(RightShiftNode rightShiftNode, ArithmeticOpTa
128128
IntegerStamp istamp = (IntegerStamp) other.getX().stamp(view);
129129

130130
if (istamp.isPositive()) {
131-
return ConstantNode.forIntegerKind(stamp.getStackKind(), 0);
131+
return ConstantNode.forIntegerBits(istamp.getBits(), 0);
132132
}
133133
if (istamp.isStrictlyNegative()) {
134-
return ConstantNode.forIntegerKind(stamp.getStackKind(), -1L);
134+
return ConstantNode.forIntegerBits(istamp.getBits(), -1L);
135135
}
136136

137137
/*

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/calc/UnsignedRightShiftNode.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
2828
import jdk.graal.compiler.core.common.type.ArithmeticOpTable.ShiftOp;
2929
import jdk.graal.compiler.core.common.type.ArithmeticOpTable.ShiftOp.UShr;
3030
import jdk.graal.compiler.core.common.type.IntegerStamp;
31+
import jdk.graal.compiler.core.common.type.PrimitiveStamp;
3132
import jdk.graal.compiler.core.common.type.Stamp;
3233
import jdk.graal.compiler.debug.Assertions;
3334
import jdk.graal.compiler.graph.NodeClass;
@@ -97,7 +98,7 @@ private static ValueNode canonical(UnsignedRightShiftNode node, ArithmeticOpTabl
9798

9899
if (xLowerBound >>> amount == xUpperBound >>> amount) {
99100
// The result of the shift is constant.
100-
return ConstantNode.forIntegerKind(stamp.getStackKind(), xLowerBound >>> amount);
101+
return ConstantNode.forIntegerBits(PrimitiveStamp.getBits(stamp), xLowerBound >>> amount);
101102
}
102103

103104
if (amount == xStamp.getBits() - 1 && xStamp.lowerBound() == -1 && xStamp.upperBound() == 0) {
@@ -113,7 +114,7 @@ private static ValueNode canonical(UnsignedRightShiftNode node, ArithmeticOpTabl
113114
if (other instanceof UnsignedRightShiftNode) {
114115
int total = amount + otherAmount;
115116
if (total != (total & mask)) {
116-
return ConstantNode.forIntegerKind(stamp.getStackKind(), 0);
117+
return ConstantNode.forIntegerBits(PrimitiveStamp.getBits(stamp), 0);
117118
}
118119
return new UnsignedRightShiftNode(other.getX(), ConstantNode.forInt(total));
119120
} else if (other instanceof LeftShiftNode && otherAmount == amount) {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/loop/LoopFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -628,6 +628,7 @@ protected void mergeEarlyExits() {
628628
phi.setNodeSourcePosition(merge.getNodeSourcePosition());
629629
phi.addInput(vpn);
630630
phi.addInput(newVpn);
631+
phi.inferStamp();
631632
introducedPhis.add(phi);
632633
replaceWith = phi;
633634
} else {

0 commit comments

Comments
 (0)