Skip to content

Commit 92c4245

Browse files
authored
Merge pull request #715 from zakkak/2024-04-17-24-0-april-cpu
[24.0] April CPU sync
2 parents 9239a7b + c5c3818 commit 92c4245

File tree

546 files changed

+1201
-64662
lines changed

Some content is hidden

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

546 files changed

+1201
-64662
lines changed

ci/common.jsonnet

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ local common_json = import "../common.json";
6767
assert
6868
local _labsjdk = common_json.jdks["labsjdk-ee-latest"];
6969
local _oraclejdk = common_json.jdks["oraclejdk-latest"];
70-
local _ov = "ee-%s+%s" % [_oraclejdk.version, _oraclejdk.build_id];
71-
local _lv = _labsjdk.version;
70+
local _ov = _oraclejdk.build_id;
71+
local _lv = std.strReplace(_labsjdk.version, "ee-", "jdk-");
7272
# Skip the check if we are not using a labsjdk. This can happen on JDK integration branches.
7373
local no_labsjdk = _labsjdk.name != "labsjdk";
7474
assert no_labsjdk || std.startsWith(_lv, _ov) : "update oraclejdk-latest to match labsjdk-ee-latest: %s+%s vs %s" % [_oraclejdk.version, _oraclejdk.build_id, _labsjdk.version];

common.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@
4444
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b26-debug", "platformspecific": true },
4545
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b26-sulong", "platformspecific": true },
4646

47-
"oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "36", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
48-
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+36-jvmci-b02", "platformspecific": true },
49-
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+36-jvmci-b02-debug", "platformspecific": true },
50-
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+36-jvmci-b02-sulong", "platformspecific": true },
51-
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+36-jvmci-b02", "platformspecific": true },
52-
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+36-jvmci-b02-debug", "platformspecific": true },
53-
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+36-jvmci-b02-sulong", "platformspecific": true }
47+
"oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "jdk-22.0.1+8", "platformspecific": true, "extrabundles": ["static-libs"]},
48+
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22.0.1+8-jvmci-b01", "platformspecific": true },
49+
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22.0.1+8-jvmci-b01-debug", "platformspecific": true },
50+
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22.0.1+8-jvmci-b01-sulong", "platformspecific": true },
51+
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22.0.1+8-jvmci-b01", "platformspecific": true },
52+
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22.0.1+8-jvmci-b01-debug", "platformspecific": true },
53+
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22.0.1+8-jvmci-b01-sulong", "platformspecific": true }
5454
},
5555

5656
"eclipse": {

compiler/mx.compiler/suite.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"sourceinprojectwhitelist" : [],
55

66
"groupId" : "org.graalvm.compiler",
7-
"version" : "24.0.0.1",
7+
"version" : "24.0.1.0",
88
"release" : False,
99
"url" : "http://www.graalvm.org/",
1010
"developer" : {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package jdk.graal.compiler.core.test;
26+
27+
import java.util.EnumSet;
28+
29+
import org.junit.Test;
30+
31+
import jdk.graal.compiler.api.directives.GraalDirectives;
32+
import jdk.graal.compiler.core.common.GraalOptions;
33+
import jdk.graal.compiler.options.OptionValues;
34+
import jdk.vm.ci.meta.DeoptimizationReason;
35+
36+
public class ConditionalEliminationTest17 extends ConditionalEliminationTestBase {
37+
38+
static final class A {
39+
}
40+
41+
static final class B {
42+
int value = 1337;
43+
44+
int value() {
45+
return value;
46+
}
47+
}
48+
49+
private static boolean equals(byte[] a, byte[] b) {
50+
if (a == b) {
51+
return true;
52+
} else if (a.length != b.length) {
53+
return false;
54+
} else {
55+
for (int i = 0; i < a.length; i++) {
56+
if (a[i] != b[i]) {
57+
return false;
58+
}
59+
}
60+
return true;
61+
}
62+
}
63+
64+
private static final Object X = new Object();
65+
private static final Object Y = new Object();
66+
67+
public static int test1Snippet(byte[][] haystack, byte[] needle, Object[] otherValues) {
68+
Object someValue = otherValues[0];
69+
Object anotherValue1 = otherValues[1];
70+
Object anotherValue2 = otherValues[2];
71+
if (haystack.length != 0) {
72+
for (int i = 0; i < haystack.length; i++) {
73+
byte[] hay = haystack[i];
74+
if (equals(hay, needle)) {
75+
int result = 42;
76+
if (anotherValue1 == X) {
77+
if (anotherValue2 == Y) {
78+
result++;
79+
GraalDirectives.controlFlowAnchor();
80+
}
81+
GraalDirectives.controlFlowAnchor();
82+
}
83+
if (someValue.getClass() != A.class) {
84+
GraalDirectives.deoptimizeAndInvalidate();
85+
}
86+
GraalDirectives.controlFlowAnchor();
87+
return result;
88+
}
89+
}
90+
}
91+
return ((B) someValue).value();
92+
}
93+
94+
@Test
95+
public void test1() {
96+
Object[] args = {new byte[][]{"foo".getBytes(), "bar".getBytes()}, "neither".getBytes(), new Object[]{new B(), X, Y}};
97+
test(getInitialOptions(), EnumSet.allOf(DeoptimizationReason.class), "test1Snippet", args);
98+
}
99+
100+
public static int test2Snippet(byte[][] haystack, byte[] needle, Object[] otherValues) {
101+
Object someValue = otherValues[0];
102+
Object anotherValue1 = otherValues[1];
103+
Object anotherValue2 = otherValues[2];
104+
if (haystack.length != 0) {
105+
for (int i = 0; i < haystack.length; i++) {
106+
byte[] hay = haystack[i];
107+
if (equals(hay, needle)) {
108+
int result = 42;
109+
if (anotherValue1 == X) {
110+
if (anotherValue2 == Y) {
111+
result++;
112+
GraalDirectives.controlFlowAnchor();
113+
}
114+
GraalDirectives.controlFlowAnchor();
115+
}
116+
if (someValue == null || someValue.getClass() != A.class) {
117+
GraalDirectives.deoptimizeAndInvalidate();
118+
}
119+
GraalDirectives.controlFlowAnchor();
120+
return result;
121+
}
122+
}
123+
}
124+
return ((B) someValue).value();
125+
}
126+
127+
@Test
128+
public void test2() {
129+
Object[] args = {new byte[][]{"foo".getBytes(), "bar".getBytes()}, "bad".getBytes(), new Object[]{new B(), X, Y}};
130+
test(getInitialOptions(), EnumSet.allOf(DeoptimizationReason.class), "test2Snippet", args);
131+
}
132+
133+
// simplified and reduced version of equals (semantics of this method is not relevant, only IR
134+
// shape)
135+
private static boolean simpleEquals(byte[][] a) {
136+
for (int i = 0; i < a.length; i++) {
137+
if (GraalDirectives.sideEffect(i) == 123) {
138+
return true;
139+
}
140+
}
141+
return false;
142+
143+
}
144+
145+
// simplified and reduced version of test1Snippet (semantics of this method is not relevant,
146+
// only IR shape)
147+
@SuppressWarnings("unused")
148+
public static int test3Snippet(byte[][] haystack, byte[] needle, Object someValue, Object anotherValue1) {
149+
for (int i = 0; i < haystack.length; i++) {
150+
if (simpleEquals(haystack)) {
151+
int result = 42;
152+
if (anotherValue1 == X) {
153+
GraalDirectives.controlFlowAnchor();
154+
}
155+
if (someValue.getClass() != A.class) {
156+
GraalDirectives.deoptimizeAndInvalidate();
157+
}
158+
return result;
159+
}
160+
}
161+
return 0;
162+
}
163+
164+
@Test
165+
public void test3() {
166+
Object[] args = {new byte[][]{"foo".getBytes(), "bar".getBytes()}, "neither".getBytes(), X, Y};
167+
OptionValues opt = new OptionValues(getInitialOptions(), GraalOptions.OptFloatingReads, false);
168+
test(opt, EnumSet.allOf(DeoptimizationReason.class), "test3Snippet", args);
169+
}
170+
171+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package jdk.graal.compiler.core.test;
26+
27+
import org.junit.Test;
28+
29+
import jdk.graal.compiler.api.directives.GraalDirectives;
30+
import jdk.graal.compiler.core.common.type.StampFactory;
31+
import jdk.graal.compiler.nodes.FixedGuardNode;
32+
import jdk.graal.compiler.nodes.GraphState;
33+
import jdk.graal.compiler.nodes.PiNode;
34+
import jdk.graal.compiler.nodes.StructuredGraph;
35+
import jdk.graal.compiler.nodes.ValueNode;
36+
import jdk.graal.compiler.nodes.java.LoadFieldNode;
37+
import jdk.graal.compiler.options.OptionValues;
38+
import jdk.graal.compiler.phases.BasePhase;
39+
import jdk.graal.compiler.phases.tiers.HighTierContext;
40+
import jdk.graal.compiler.phases.tiers.Suites;
41+
import jdk.graal.compiler.virtual.phases.ea.FinalPartialEscapePhase;
42+
import jdk.vm.ci.code.InstalledCode;
43+
import jdk.vm.ci.code.InvalidInstalledCodeException;
44+
import jdk.vm.ci.meta.DeoptimizationAction;
45+
import jdk.vm.ci.meta.DeoptimizationReason;
46+
47+
/**
48+
* Tests that correct removal of always deoptimizing {@link FixedGuardNode}s in the presence of
49+
* floating reads. This test modifies the graph after PEA to introduce a {@link FixedGuardNode} in a
50+
* branch which is dominated by another {@link FixedGuardNode} with the inverted condition.
51+
* Replacing the always-deopt guard must ensure a proper cleanup of all attached floating reads.
52+
* This is tested by a floating read for which the removed guard ensures non-nullness of the read
53+
* object. If this read would survive the removal of the guard, a segfault would be triggered. The
54+
* guard branch is deleted in midtier after conditional elimination.
55+
*/
56+
public class FixedGuardSimplificationTest extends GraalCompilerTest {
57+
58+
public static class A {
59+
B b;
60+
61+
public A(B b) {
62+
this.b = b;
63+
}
64+
}
65+
66+
public static class B {
67+
A a;
68+
}
69+
70+
public static void snippet(A a, A a2, int x) {
71+
guardingNull(a);
72+
if (x == 0) {
73+
// a2 is replaced by a1 after FinalPEA
74+
guardingNonNull(a2);
75+
B b = a.b;
76+
A ba = b.a;
77+
GraalDirectives.blackhole(ba);
78+
}
79+
}
80+
81+
@Override
82+
protected Suites createSuites(OptionValues opts) {
83+
Suites s = super.createSuites(opts);
84+
s.getHighTier().findPhase(FinalPartialEscapePhase.class).add(new BasePhase<HighTierContext>() {
85+
86+
@Override
87+
protected void run(StructuredGraph graph, HighTierContext context) {
88+
FixedGuardNode guard = graph.getNodes().filter(FixedGuardNode.class).first();
89+
FixedGuardNode placeholderGuard = graph.getNodes().filter(FixedGuardNode.class).snapshot().get(1);
90+
91+
/*
92+
* Makes the inner guard use the inverted condition of the dominating, outer guard
93+
* and adds the corresponding Pi. This can happen during PartialEscapeAnalysis.
94+
*/
95+
placeholderGuard.setCondition(guard.getCondition(), true);
96+
ValueNode nullProven = (ValueNode) guard.getCondition().asNode().inputs().first();
97+
PiNode pi = (PiNode) graph.addWithoutUnique(PiNode.create(nullProven, StampFactory.objectNonNull(), placeholderGuard));
98+
LoadFieldNode lf = graph.getNodes().filter(LoadFieldNode.class).first();
99+
lf.setObject(pi);
100+
}
101+
102+
@Override
103+
public java.util.Optional<NotApplicable> notApplicableTo(GraphState graphState) {
104+
return ALWAYS_APPLICABLE;
105+
}
106+
});
107+
return s;
108+
}
109+
110+
private static <T> T guardingNull(T value) {
111+
if (value != null) {
112+
GraalDirectives.deoptimize(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.UnreachedCode, true);
113+
}
114+
return value;
115+
}
116+
117+
private static <T> T guardingNonNull(T value) {
118+
if (value == null) {
119+
GraalDirectives.deoptimize(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.UnreachedCode, true);
120+
}
121+
return value;
122+
}
123+
124+
@Test
125+
public void test() throws InvalidInstalledCodeException {
126+
InstalledCode code = getCode(getResolvedJavaMethod("snippet"));
127+
boolean exceptionSeen = false;
128+
try {
129+
code.executeVarargs(null, new A(new B()), 0);
130+
} catch (NullPointerException npe) {
131+
exceptionSeen = true;
132+
}
133+
assert exceptionSeen : "Test expects a NPE to be thrown!";
134+
assert !code.isValid() : "Test expects the code to have deopted!";
135+
}
136+
}

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/GraalHotSpotVMConfig.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ private HotSpotGraalRuntime.HotSpotGC getSelectedGC() throws GraalError {
129129
// of the mark word.
130130
public final int lockingMode = getFlag("LockingMode", Integer.class);
131131

132-
public final int lockingModeMonitor = getConstant("LockingMode::LM_MONITOR", Integer.class, 0, JDK >= 22 && JDK_BUILD >= 18);
133-
public final int lockingModeStack = getConstant("LockingMode::LM_LEGACY", Integer.class, 1, JDK >= 22 && JDK_BUILD >= 18);
134-
public final int lockingModeLightweight = getConstant("LockingMode::LM_LIGHTWEIGHT", Integer.class, 2, JDK >= 22 && JDK_BUILD >= 18);
132+
public final int lockingModeMonitor = getConstant("LockingMode::LM_MONITOR", Integer.class, 0, JDK >= 22);
133+
public final int lockingModeStack = getConstant("LockingMode::LM_LEGACY", Integer.class, 1, JDK >= 22);
134+
public final int lockingModeLightweight = getConstant("LockingMode::LM_LIGHTWEIGHT", Integer.class, 2, JDK >= 22);
135135

136136
public final boolean foldStableValues = getFlag("FoldStableValues", Boolean.class);
137137
public final int maxVectorSize = getFlag("MaxVectorSize", Integer.class);
@@ -270,7 +270,7 @@ public final int arrayOopDescLengthOffset() {
270270

271271
public final int threadIsInVTMSTransitionOffset = getFieldOffset("JavaThread::_is_in_VTMS_transition", Integer.class, "bool");
272272
public final int threadIsInTmpVTMSTransitionOffset = getFieldOffset("JavaThread::_is_in_tmp_VTMS_transition", Integer.class, "bool");
273-
public final int threadIsDisableSuspendOffset = getFieldOffset("JavaThread::_is_disable_suspend", Integer.class, "bool", -1, JDK >= 22 && JDK_BUILD >= 31);
273+
public final int threadIsDisableSuspendOffset = getFieldOffset("JavaThread::_is_disable_suspend", Integer.class, "bool", -1, JDK >= 22);
274274

275275
public final int javaLangThreadJFREpochOffset = getFieldValue("java_lang_Thread::_jfr_epoch_offset", Integer.class, "int");
276276
public final int javaLangThreadTIDOffset = getFieldValue("java_lang_Thread::_tid_offset", Integer.class, "int");
@@ -351,7 +351,7 @@ public int threadLastJavaFpOffset() {
351351
public final int objectMonitorEntryList = getFieldOffset("ObjectMonitor::_EntryList", Integer.class, "ObjectWaiter*");
352352
public final int objectMonitorSucc = getFieldOffset("ObjectMonitor::_succ", Integer.class, "JavaThread*");
353353

354-
public final long objectMonitorAnonymousOwner = getConstant("ObjectMonitor::ANONYMOUS_OWNER", Long.class, 1L, JDK >= 22 && JDK_BUILD >= 18);
354+
public final long objectMonitorAnonymousOwner = getConstant("ObjectMonitor::ANONYMOUS_OWNER", Long.class, 1L, JDK >= 22);
355355

356356
public final int markWordNoHashInPlace = getConstant("markWord::no_hash_in_place", Integer.class);
357357
public final int markWordNoLockInPlace = getConstant("markWord::no_lock_in_place", Integer.class);
@@ -599,9 +599,9 @@ private long getZGCAddressField(String name) {
599599
// Tracking of the number of monitors held by the current thread. This is used by loom but in
600600
// JDK 20 was enabled by default to ensure it was correctly implemented.
601601
public final int threadHeldMonitorCountOffset = getFieldOffset("JavaThread::_held_monitor_count", Integer.class, JDK >= 22 ? "intx" : "int64_t");
602-
public final int threadLockStackOffset = getFieldOffset("JavaThread::_lock_stack", Integer.class, "LockStack", -1, JDK >= 22 && JDK_BUILD >= 18);
603-
public final int lockStackTopOffset = getFieldOffset("LockStack::_top", Integer.class, "uint32_t", -1, JDK >= 22 && JDK_BUILD >= 18);
604-
public final int lockStackEndOffset = getConstant("LockStack::_end_offset", Integer.class, -1, JDK >= 22 && JDK_BUILD >= 18);
602+
public final int threadLockStackOffset = getFieldOffset("JavaThread::_lock_stack", Integer.class, "LockStack", -1, JDK >= 22);
603+
public final int lockStackTopOffset = getFieldOffset("LockStack::_top", Integer.class, "uint32_t", -1, JDK >= 22);
604+
public final int lockStackEndOffset = getConstant("LockStack::_end_offset", Integer.class, -1, JDK >= 22);
605605

606606
public final long throwAndPostJvmtiExceptionAddress = getAddress("JVMCIRuntime::throw_and_post_jvmti_exception");
607607
public final long throwKlassExternalNameExceptionAddress = getAddress("JVMCIRuntime::throw_klass_external_name_exception");

0 commit comments

Comments
 (0)