Skip to content

Commit

Permalink
Merge pull request #715 from zakkak/2024-04-17-24-0-april-cpu
Browse files Browse the repository at this point in the history
[24.0] April CPU sync
  • Loading branch information
zakkak authored Apr 18, 2024
2 parents 9239a7b + c5c3818 commit 92c4245
Show file tree
Hide file tree
Showing 546 changed files with 1,201 additions and 64,662 deletions.
4 changes: 2 additions & 2 deletions ci/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ local common_json = import "../common.json";
assert
local _labsjdk = common_json.jdks["labsjdk-ee-latest"];
local _oraclejdk = common_json.jdks["oraclejdk-latest"];
local _ov = "ee-%s+%s" % [_oraclejdk.version, _oraclejdk.build_id];
local _lv = _labsjdk.version;
local _ov = _oraclejdk.build_id;
local _lv = std.strReplace(_labsjdk.version, "ee-", "jdk-");
# Skip the check if we are not using a labsjdk. This can happen on JDK integration branches.
local no_labsjdk = _labsjdk.name != "labsjdk";
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];
Expand Down
14 changes: 7 additions & 7 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b26-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b26-sulong", "platformspecific": true },

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

"eclipse": {
Expand Down
2 changes: 1 addition & 1 deletion compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"sourceinprojectwhitelist" : [],

"groupId" : "org.graalvm.compiler",
"version" : "24.0.0.1",
"version" : "24.0.1.0",
"release" : False,
"url" : "http://www.graalvm.org/",
"developer" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.graal.compiler.core.test;

import java.util.EnumSet;

import org.junit.Test;

import jdk.graal.compiler.api.directives.GraalDirectives;
import jdk.graal.compiler.core.common.GraalOptions;
import jdk.graal.compiler.options.OptionValues;
import jdk.vm.ci.meta.DeoptimizationReason;

public class ConditionalEliminationTest17 extends ConditionalEliminationTestBase {

static final class A {
}

static final class B {
int value = 1337;

int value() {
return value;
}
}

private static boolean equals(byte[] a, byte[] b) {
if (a == b) {
return true;
} else if (a.length != b.length) {
return false;
} else {
for (int i = 0; i < a.length; i++) {
if (a[i] != b[i]) {
return false;
}
}
return true;
}
}

private static final Object X = new Object();
private static final Object Y = new Object();

public static int test1Snippet(byte[][] haystack, byte[] needle, Object[] otherValues) {
Object someValue = otherValues[0];
Object anotherValue1 = otherValues[1];
Object anotherValue2 = otherValues[2];
if (haystack.length != 0) {
for (int i = 0; i < haystack.length; i++) {
byte[] hay = haystack[i];
if (equals(hay, needle)) {
int result = 42;
if (anotherValue1 == X) {
if (anotherValue2 == Y) {
result++;
GraalDirectives.controlFlowAnchor();
}
GraalDirectives.controlFlowAnchor();
}
if (someValue.getClass() != A.class) {
GraalDirectives.deoptimizeAndInvalidate();
}
GraalDirectives.controlFlowAnchor();
return result;
}
}
}
return ((B) someValue).value();
}

@Test
public void test1() {
Object[] args = {new byte[][]{"foo".getBytes(), "bar".getBytes()}, "neither".getBytes(), new Object[]{new B(), X, Y}};
test(getInitialOptions(), EnumSet.allOf(DeoptimizationReason.class), "test1Snippet", args);
}

public static int test2Snippet(byte[][] haystack, byte[] needle, Object[] otherValues) {
Object someValue = otherValues[0];
Object anotherValue1 = otherValues[1];
Object anotherValue2 = otherValues[2];
if (haystack.length != 0) {
for (int i = 0; i < haystack.length; i++) {
byte[] hay = haystack[i];
if (equals(hay, needle)) {
int result = 42;
if (anotherValue1 == X) {
if (anotherValue2 == Y) {
result++;
GraalDirectives.controlFlowAnchor();
}
GraalDirectives.controlFlowAnchor();
}
if (someValue == null || someValue.getClass() != A.class) {
GraalDirectives.deoptimizeAndInvalidate();
}
GraalDirectives.controlFlowAnchor();
return result;
}
}
}
return ((B) someValue).value();
}

@Test
public void test2() {
Object[] args = {new byte[][]{"foo".getBytes(), "bar".getBytes()}, "bad".getBytes(), new Object[]{new B(), X, Y}};
test(getInitialOptions(), EnumSet.allOf(DeoptimizationReason.class), "test2Snippet", args);
}

// simplified and reduced version of equals (semantics of this method is not relevant, only IR
// shape)
private static boolean simpleEquals(byte[][] a) {
for (int i = 0; i < a.length; i++) {
if (GraalDirectives.sideEffect(i) == 123) {
return true;
}
}
return false;

}

// simplified and reduced version of test1Snippet (semantics of this method is not relevant,
// only IR shape)
@SuppressWarnings("unused")
public static int test3Snippet(byte[][] haystack, byte[] needle, Object someValue, Object anotherValue1) {
for (int i = 0; i < haystack.length; i++) {
if (simpleEquals(haystack)) {
int result = 42;
if (anotherValue1 == X) {
GraalDirectives.controlFlowAnchor();
}
if (someValue.getClass() != A.class) {
GraalDirectives.deoptimizeAndInvalidate();
}
return result;
}
}
return 0;
}

@Test
public void test3() {
Object[] args = {new byte[][]{"foo".getBytes(), "bar".getBytes()}, "neither".getBytes(), X, Y};
OptionValues opt = new OptionValues(getInitialOptions(), GraalOptions.OptFloatingReads, false);
test(opt, EnumSet.allOf(DeoptimizationReason.class), "test3Snippet", args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.graal.compiler.core.test;

import org.junit.Test;

import jdk.graal.compiler.api.directives.GraalDirectives;
import jdk.graal.compiler.core.common.type.StampFactory;
import jdk.graal.compiler.nodes.FixedGuardNode;
import jdk.graal.compiler.nodes.GraphState;
import jdk.graal.compiler.nodes.PiNode;
import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.ValueNode;
import jdk.graal.compiler.nodes.java.LoadFieldNode;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.phases.BasePhase;
import jdk.graal.compiler.phases.tiers.HighTierContext;
import jdk.graal.compiler.phases.tiers.Suites;
import jdk.graal.compiler.virtual.phases.ea.FinalPartialEscapePhase;
import jdk.vm.ci.code.InstalledCode;
import jdk.vm.ci.code.InvalidInstalledCodeException;
import jdk.vm.ci.meta.DeoptimizationAction;
import jdk.vm.ci.meta.DeoptimizationReason;

/**
* Tests that correct removal of always deoptimizing {@link FixedGuardNode}s in the presence of
* floating reads. This test modifies the graph after PEA to introduce a {@link FixedGuardNode} in a
* branch which is dominated by another {@link FixedGuardNode} with the inverted condition.
* Replacing the always-deopt guard must ensure a proper cleanup of all attached floating reads.
* This is tested by a floating read for which the removed guard ensures non-nullness of the read
* object. If this read would survive the removal of the guard, a segfault would be triggered. The
* guard branch is deleted in midtier after conditional elimination.
*/
public class FixedGuardSimplificationTest extends GraalCompilerTest {

public static class A {
B b;

public A(B b) {
this.b = b;
}
}

public static class B {
A a;
}

public static void snippet(A a, A a2, int x) {
guardingNull(a);
if (x == 0) {
// a2 is replaced by a1 after FinalPEA
guardingNonNull(a2);
B b = a.b;
A ba = b.a;
GraalDirectives.blackhole(ba);
}
}

@Override
protected Suites createSuites(OptionValues opts) {
Suites s = super.createSuites(opts);
s.getHighTier().findPhase(FinalPartialEscapePhase.class).add(new BasePhase<HighTierContext>() {

@Override
protected void run(StructuredGraph graph, HighTierContext context) {
FixedGuardNode guard = graph.getNodes().filter(FixedGuardNode.class).first();
FixedGuardNode placeholderGuard = graph.getNodes().filter(FixedGuardNode.class).snapshot().get(1);

/*
* Makes the inner guard use the inverted condition of the dominating, outer guard
* and adds the corresponding Pi. This can happen during PartialEscapeAnalysis.
*/
placeholderGuard.setCondition(guard.getCondition(), true);
ValueNode nullProven = (ValueNode) guard.getCondition().asNode().inputs().first();
PiNode pi = (PiNode) graph.addWithoutUnique(PiNode.create(nullProven, StampFactory.objectNonNull(), placeholderGuard));
LoadFieldNode lf = graph.getNodes().filter(LoadFieldNode.class).first();
lf.setObject(pi);
}

@Override
public java.util.Optional<NotApplicable> notApplicableTo(GraphState graphState) {
return ALWAYS_APPLICABLE;
}
});
return s;
}

private static <T> T guardingNull(T value) {
if (value != null) {
GraalDirectives.deoptimize(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.UnreachedCode, true);
}
return value;
}

private static <T> T guardingNonNull(T value) {
if (value == null) {
GraalDirectives.deoptimize(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.UnreachedCode, true);
}
return value;
}

@Test
public void test() throws InvalidInstalledCodeException {
InstalledCode code = getCode(getResolvedJavaMethod("snippet"));
boolean exceptionSeen = false;
try {
code.executeVarargs(null, new A(new B()), 0);
} catch (NullPointerException npe) {
exceptionSeen = true;
}
assert exceptionSeen : "Test expects a NPE to be thrown!";
assert !code.isValid() : "Test expects the code to have deopted!";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ private HotSpotGraalRuntime.HotSpotGC getSelectedGC() throws GraalError {
// of the mark word.
public final int lockingMode = getFlag("LockingMode", Integer.class);

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

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

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

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

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

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

public final long throwAndPostJvmtiExceptionAddress = getAddress("JVMCIRuntime::throw_and_post_jvmti_exception");
public final long throwKlassExternalNameExceptionAddress = getAddress("JVMCIRuntime::throw_klass_external_name_exception");
Expand Down
Loading

0 comments on commit 92c4245

Please sign in to comment.