Skip to content

Commit

Permalink
Merge pull request #696 from zakkak/2024-03-13-backports-21-sync
Browse files Browse the repository at this point in the history
2024-03-13 backports 21 sync
  • Loading branch information
zakkak authored Mar 26, 2024
2 parents af3ef2c + 3afc7c4 commit 9162ebc
Show file tree
Hide file tree
Showing 246 changed files with 4,509 additions and 2,519 deletions.
7 changes: 0 additions & 7 deletions ci/ci_common/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,8 @@ common + common.frequencies + {
} + common.jdks + {
# Aliases to edition specific labsjdks
labsjdk17:: self["labsjdk-" + repo_config.graalvm_edition + "-17"],
labsjdk19:: self["labsjdk-" + repo_config.graalvm_edition + "-19"],
labsjdk17Debug:: self["labsjdk-" + repo_config.graalvm_edition + "-17Debug"],
labsjdk19Debug:: self["labsjdk-" + repo_config.graalvm_edition + "-19Debug"],
labsjdk17LLVM:: self["labsjdk-" + repo_config.graalvm_edition + "-17-llvm"],
labsjdk19LLVM:: self["labsjdk-" + repo_config.graalvm_edition + "-19-llvm"],

labsjdk20:: self["labsjdk-" + repo_config.graalvm_edition + "-20"],
labsjdk20Debug:: self["labsjdk-" + repo_config.graalvm_edition + "-20Debug"],
labsjdk20LLVM:: self["labsjdk-" + repo_config.graalvm_edition + "-20-llvm"],

labsjdk21:: self["labsjdk-" + repo_config.graalvm_edition + "-21"],
labsjdk21Debug:: self["labsjdk-" + repo_config.graalvm_edition + "-21Debug"],
Expand Down
16 changes: 3 additions & 13 deletions ci/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ local common_json = import "../common.json";
} + {
[name]: common_json.jdks[name] + { jdk_version:: 17 }
for name in ["oraclejdk17"] + variants("labsjdk-ce-17") + variants("labsjdk-ee-17")
} + {
[name]: common_json.jdks[name] + { jdk_version:: 19 }
for name in ["oraclejdk19"] + variants("labsjdk-ce-19") + variants("labsjdk-ee-19")
} + {
[name]: common_json.jdks[name] + { jdk_version:: 20 }
for name in ["oraclejdk20"] + variants("labsjdk-ce-20") + variants("labsjdk-ee-20")
} + {
[name]: common_json.jdks[name] + { jdk_version:: 21 }
for name in ["oraclejdk21"] + variants("labsjdk-ce-21") + variants("labsjdk-ee-21")
Expand All @@ -43,11 +37,6 @@ local common_json = import "../common.json";
for name in std.objectFields(jdks_data)
} + {
# Some convenient JDK aliases which don't require ["name"] for frequently-used JDKs
labsjdk17ce: self["labsjdk-ce-17"],
labsjdk17ee: self["labsjdk-ee-17"],

labsjdk20ce: self["labsjdk-ce-20"],
labsjdk20ee: self["labsjdk-ee-20"],

labsjdkLatestCE: self["labsjdk-ce-21"],
labsjdkLatestEE: self["labsjdk-ee-21"],
Expand All @@ -58,7 +47,7 @@ local common_json = import "../common.json";
"windows-jdk17": { packages+: { "devkit:VS2022-17.1.0+1": "==0" }},
"windows-jdk19": { packages+: { "devkit:VS2022-17.1.0+1": "==0" }},
"windows-jdk20": { packages+: { "devkit:VS2022-17.1.0+1": "==0" }},
"windows-jdk21": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
"windows-jdk21": { packages+: { "devkit:VS2022-17.6.5+1": "==0" }},
"windows-jdk22": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
"linux-jdk17": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},
"linux-jdk19": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},
Expand Down Expand Up @@ -264,7 +253,8 @@ local common_json = import "../common.json";
},

local linux = deps_linux + common + { os:: "linux", capabilities+: [self.os] },
local darwin = deps_darwin + common + { os:: "darwin", capabilities+: [self.os] },
# Run darwin jobs on Big Sur or later by excluding all older versions
local darwin = deps_darwin + common + { os:: "darwin", capabilities+: [self.os, "!darwin_sierra", "!darwin_mojave", "!darwin_catalina"] },
local windows = deps_windows + common + { os:: "windows", capabilities+: [self.os] },
local windows_server_2016 = windows + { capabilities+: ["windows_server_2016"] },

Expand Down
2 changes: 1 addition & 1 deletion ci_includes/publish-javadoc.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},

local all_builds = [
common.post_merge + linux_amd64 + common.labsjdk17 + javadoc_publisher,
common.post_merge + linux_amd64 + common.labsjdk21 + javadoc_publisher,
],
// adds a "defined_in" field to all builds mentioning the location of this current file
builds:: [{ defined_in: std.thisFile } + b for b in all_builds]
Expand Down
22 changes: 3 additions & 19 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,13 @@
"labsjdk-ee-17Debug": {"name": "labsjdk", "version": "ee-17.0.8+2-jvmci-23.1-b02-debug", "platformspecific": true },
"labsjdk-ee-17-llvm": {"name": "labsjdk", "version": "ee-17.0.8+2-jvmci-23.1-b02-sulong", "platformspecific": true },

"oraclejdk19": {"name": "jpg-jdk", "version": "19", "build_id": "26", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-19": {"name": "labsjdk", "version": "ce-19.0.1+10-jvmci-23.0-b04", "platformspecific": true },
"labsjdk-ce-19Debug": {"name": "labsjdk", "version": "ce-19.0.1+10-jvmci-23.0-b04-debug", "platformspecific": true },
"labsjdk-ce-19-llvm": {"name": "labsjdk", "version": "ce-19.0.1+10-jvmci-23.0-b04-sulong", "platformspecific": true },
"labsjdk-ee-19": {"name": "labsjdk", "version": "ee-19.0.2+7-jvmci-23.0-b05", "platformspecific": true },
"labsjdk-ee-19Debug": {"name": "labsjdk", "version": "ee-19.0.2+7-jvmci-23.0-b05-debug", "platformspecific": true },
"labsjdk-ee-19-llvm": {"name": "labsjdk", "version": "ee-19.0.2+7-jvmci-23.0-b05-sulong", "platformspecific": true },

"oraclejdk20": {"name": "jpg-jdk", "version": "20", "build_id": "34", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-20": {"name": "labsjdk", "version": "ce-20.0.1+9-jvmci-23.1-b02", "platformspecific": true },
"labsjdk-ce-20Debug": {"name": "labsjdk", "version": "ce-20.0.1+9-jvmci-23.1-b02-debug", "platformspecific": true },
"labsjdk-ce-20-llvm": {"name": "labsjdk", "version": "ce-20.0.1+9-jvmci-23.1-b02-sulong", "platformspecific": true },
"labsjdk-ee-20": {"name": "labsjdk", "version": "ee-20.0.2+2-jvmci-23.1-b02", "platformspecific": true },
"labsjdk-ee-20Debug": {"name": "labsjdk", "version": "ee-20.0.2+2-jvmci-23.1-b02-debug", "platformspecific": true },
"labsjdk-ee-20-llvm": {"name": "labsjdk", "version": "ee-20.0.2+2-jvmci-23.1-b02-sulong", "platformspecific": true },

"oraclejdk21": {"name": "jpg-jdk", "version": "21", "build_id": "33", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21.0.2+13-jvmci-23.1-b30", "platformspecific": true },
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21.0.2+13-jvmci-23.1-b30-debug", "platformspecific": true },
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21.0.2+13-jvmci-23.1-b30-sulong", "platformspecific": true },
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b30", "platformspecific": true },
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b30-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b30-sulong", "platformspecific": true },
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.3+6-jvmci-23.1-b36", "platformspecific": true },
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.3+6-jvmci-23.1-b36-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.3+6-jvmci-23.1-b36-sulong", "platformspecific": true },

"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "2", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
},
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" : "23.1.2.1",
"version" : "23.1.3.0",
"release" : False,
"url" : "http://www.graalvm.org/",
"developer" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright (c) 2023, 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 org.graalvm.compiler.core.test;

import org.graalvm.compiler.nodes.ConstantNode;
import org.graalvm.compiler.nodes.FixedGuardNode;
import org.graalvm.compiler.nodes.IfNode;
import org.graalvm.compiler.nodes.LogicNode;
import org.graalvm.compiler.nodes.NodeView;
import org.graalvm.compiler.nodes.StructuredGraph;
import org.graalvm.compiler.nodes.ValueNode;
import org.graalvm.compiler.nodes.calc.AndNode;
import org.graalvm.compiler.nodes.calc.IntegerEqualsNode;
import org.graalvm.compiler.nodes.calc.IntegerTestNode;
import org.graalvm.compiler.nodes.calc.SignExtendNode;
import org.graalvm.compiler.nodes.util.GraphUtil;
import org.graalvm.compiler.phases.common.ConditionalEliminationPhase;
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
import org.junit.Test;

import jdk.vm.ci.code.InvalidInstalledCodeException;
import jdk.vm.ci.meta.DeoptimizationAction;
import jdk.vm.ci.meta.DeoptimizationReason;

/**
* Tests the correctness of conditional elimination when inverting stamps along
* {@link SignExtendNode}. The test artificially creates a graph whith the optimizable pattern:
* {@code ((val & CONST) == CONST)}, which provides information about the set bits in val, if the
* condition is used in a guard which is assumed to hold. The partial information about bits which
* are set in {@code x} are propagated "upwards". A {@link SignExtendNode} must treat the partial
* information correctly with respect to the extension bits and handle contradictions.
* </p>
* If {@code CONST = 1 << 4 = 0001 0000} and we assume the condition holds, we can refine a stamp
* {@code xxxx xx11} for {@code val} to {@code xxx1 xx11}. Inverting this refined stamp along an
* artificial 4->8 bit sign extension should treat the extension as {@code 1111} and produce an
* inverted stamp of {@code xx11} or, even better {@code 1x11}, because we know the MSB has to be
* one from the extension.
* </p>
* If the inversion is performed incorrectly, the inner condition could be considered as always
* false and removing it during conditional elimination.
*/
public class ConditionalEliminationStampInversionTest extends GraalCompilerTest {

public static boolean snippet(byte b) {
short s = b;
int i = s;

if ((i & (1 << 16)) == (1 << 16)) {
if (s == -5) {
return true;
}
}
return false;
}

@Test
public void test() throws InvalidInstalledCodeException {
StructuredGraph g = parseEager("snippet", AllowAssumptions.YES);

// replace the IntegerTest by an equivalent and/== pattern
ValueNode intTest = g.getNodes().filter(IntegerTestNode.class).first();
assertTrue("IntegerTestNode expected in graph.", intTest != null);

ValueNode signExtend = g.getNodes().filter(SignExtendNode.class).first();
assertTrue("SignExtendNode expected in graph.", signExtend != null);

ValueNode and = g.addOrUnique(AndNode.create(signExtend, ConstantNode.forInt(1 << 16, g), NodeView.DEFAULT));
and.inferStamp();
LogicNode intEq = g.addOrUnique(IntegerEqualsNode.create(and, ConstantNode.forInt(1 << 16, g), NodeView.DEFAULT));
intEq.inferStamp();

intTest.replaceAtUsages(intEq);

// replace the if by a fixed guard to trigger conditional elimination for the and/== pattern
ValueNode ifNode = (ValueNode) intEq.usages().first();
assertTrue("IfNode expected as first usage of IntegerEqualsNode.", ifNode != null && ifNode instanceof IfNode);

FixedGuardNode guard = g.add(new FixedGuardNode(intEq, DeoptimizationReason.ArithmeticException, DeoptimizationAction.InvalidateRecompile));
GraphUtil.killCFG(((IfNode) ifNode).trueSuccessor());
g.replaceSplitWithFixed((IfNode) ifNode, guard, ((IfNode) ifNode).falseSuccessor());

new ConditionalEliminationPhase(false).apply(g, getDefaultHighTierContext());

// the inner condition should still be alive and the following execution return true
assert (boolean) getCode(getResolvedJavaMethod("snippet"), g, true, true, getInitialOptions()).executeVarargs((byte) -5);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* 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 org.graalvm.compiler.hotspot.amd64.test;

import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_0;
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_0;

import org.junit.Test;
import org.graalvm.compiler.api.directives.GraalDirectives;
import org.graalvm.compiler.core.common.type.StampFactory;
import org.graalvm.compiler.core.test.GraalCompilerTest;
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.NodeClass;
import org.graalvm.compiler.nodeinfo.InputType;
import org.graalvm.compiler.nodeinfo.NodeInfo;
import org.graalvm.compiler.nodes.FixedWithNextNode;
import org.graalvm.compiler.nodes.ValueNode;
import org.graalvm.compiler.nodes.calc.IsNullNode;
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration;
import org.graalvm.compiler.nodes.memory.ReadNode;
import org.graalvm.compiler.nodes.spi.Canonicalizable;
import org.graalvm.compiler.nodes.spi.CanonicalizerTool;
import org.graalvm.compiler.phases.common.UseTrappingNullChecksPhase;

import jdk.vm.ci.code.InstalledCode;
import jdk.vm.ci.code.InvalidInstalledCodeException;
import jdk.vm.ci.meta.ResolvedJavaMethod;

/**
* Test to ensure that late elimination of memory reads preserves necessary null check semantic with
* respect to {@link UseTrappingNullChecksPhase}.
*/
public class ReadEliminateLowTierTest extends GraalCompilerTest {
static class T {
int x;
int y;
int z;
}

public static int trappingSnippet(T t) {
if (t == null) {
GraalDirectives.deoptimizeAndInvalidate();
return -1;
}
/*
* The first read from t here will act as trapping null check for all the others. We must
* not remove this read if its used as a null check even if it does not have any usages any
* more.
*/
foldAfterTrappingNullChecks(t.x);
int result = t.y + t.z;
return result;
}

static void foldAfterTrappingNullChecks(@SuppressWarnings("unused") int i) {
}

@Override
protected Plugins getDefaultGraphBuilderPlugins() {
Plugins p = super.getDefaultGraphBuilderPlugins();
Registration r = new Registration(p.getInvocationPlugins(), ReadEliminateLowTierTest.class);
r.register(new InvocationPlugin("foldAfterTrappingNullChecks", int.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
b.append(new FixedUsageUntilFinalCanon(arg));
return true;
}
});
return p;
}

/**
* Node that gets optimized away be late canonicalization.
*/
@NodeInfo(cycles = CYCLES_0, size = SIZE_0, allowedUsageTypes = {InputType.Anchor})
public static class FixedUsageUntilFinalCanon extends FixedWithNextNode implements Canonicalizable {
public static final NodeClass<FixedUsageUntilFinalCanon> TYPE = NodeClass.create(FixedUsageUntilFinalCanon.class);

@OptionalInput ValueNode object;

public FixedUsageUntilFinalCanon(ValueNode object) {
super(TYPE, StampFactory.forVoid());
this.object = object;
}

@Override
public Node canonical(CanonicalizerTool tool) {
// after trapping nulls
if (graph().getNodes().filter(IsNullNode.class).count() == 0) {
if (tool.allUsagesAvailable() && object instanceof ReadNode) {
ReadNode r = (ReadNode) object;
if (r.hasExactlyOneUsage() && r.usages().first().equals(this)) {
return null;
}
}
}
return this;
}
}

@Test
public void test() throws InvalidInstalledCodeException {
InstalledCode ic = getCode(getResolvedJavaMethod("trappingSnippet"));
assert lastCompiledGraph != null;
ic.executeVarargs(new T());
ic.executeVarargs((Object) null);
}

}
Loading

0 comments on commit 9162ebc

Please sign in to comment.