Skip to content

Commit

Permalink
Merge remote-tracking branch 'oracle/master' into causality-export_wi…
Browse files Browse the repository at this point in the history
…th-evaluation

# Conflicts:
#	substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/SourceTypeFlow.java
#	substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisElement.java
#	substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java
  • Loading branch information
ChristophTF committed Oct 29, 2024
2 parents 76b8358 + 4e691ab commit cc01c00
Show file tree
Hide file tree
Showing 665 changed files with 16,909 additions and 10,695 deletions.
18 changes: 9 additions & 9 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
],

"mx_version": "7.33.0",
"mx_version": "7.33.1",

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
"galahad-jdk": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+19-2105", "platformspecific": true, "extrabundles": ["static-libs"]},
"galahad-jdk": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+21-2436", "platformspecific": true, "extrabundles": ["static-libs"]},

"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.7", "build_id": "jdk-17.0.7+8", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.1-b02", "platformspecific": true },
Expand Down Expand Up @@ -45,13 +45,13 @@

"oraclejdk23": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+37", "platformspecific": true, "extrabundles": ["static-libs"]},

"oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+19", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+19-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+19-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+19-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+19-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+19-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+19-jvmci-b01-sulong", "platformspecific": true }
"oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+21", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+21-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+21-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+21-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+21-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+21-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+21-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import jdk.graal.compiler.test.SubprocessUtil;
import org.graalvm.word.LocationIdentity;
import org.junit.Assert;
import org.junit.Assume;
Expand Down Expand Up @@ -103,6 +102,7 @@
import jdk.graal.compiler.phases.util.Providers;
import jdk.graal.compiler.runtime.RuntimeProvider;
import jdk.graal.compiler.test.AddExports;
import jdk.graal.compiler.test.SubprocessUtil;
import jdk.internal.misc.Unsafe;
import jdk.vm.ci.code.BailoutException;
import jdk.vm.ci.code.Register;
Expand Down Expand Up @@ -344,6 +344,8 @@ public static void runTest(InvariantsTool tool) {
verifiers.add(new VerifyStringCaseUsage());
verifiers.add(new VerifyMathAbs());
verifiers.add(new VerifyLoopInfo());
verifiers.add(new VerifyRuntimeVersionFeature());
verifiers.add(new VerifyGuardsStageUsages());
VerifyAssertionUsage assertionUsages = null;
boolean checkAssertions = tool.checkAssertions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

import java.util.Optional;

import jdk.graal.compiler.debug.DebugOptions;
import org.junit.Assert;
import org.junit.Test;

import jdk.graal.compiler.api.directives.GraalDirectives;
import jdk.graal.compiler.core.common.GraalOptions;
import jdk.graal.compiler.debug.DebugOptions;
import jdk.graal.compiler.debug.TTY;
import jdk.graal.compiler.graph.Graph;
import jdk.graal.compiler.nodes.EndNode;
Expand All @@ -40,6 +40,7 @@
import jdk.graal.compiler.nodes.GraphState;
import jdk.graal.compiler.nodes.LoopBeginNode;
import jdk.graal.compiler.nodes.LoopEndNode;
import jdk.graal.compiler.nodes.LoopExitNode;
import jdk.graal.compiler.nodes.PhiNode;
import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.StructuredGraph.AllowAssumptions;
Expand Down Expand Up @@ -78,7 +79,7 @@ public void test01() {
test(opt, "snippet01");
Assert.fail("Should have detected that the phase in this class does not retain the mustNotSafepoint flag of a loop begin");
} catch (Throwable t) {
assert t.getMessage().contains("previously the loop had canHaveSafepoints=false but now it has canHaveSafepoints=true");
assert t.toString().contains("previously the loop had canHaveSafepoints=false but now it has canHaveSafepoints=true") : t;
}
}

Expand Down Expand Up @@ -144,6 +145,9 @@ protected void run(StructuredGraph graph, HighTierContext context) {

LoopBeginNode oldLoopBegin = lex.loopBegin();
EndNode fwd = oldLoopBegin.forwardEnd();
for (LoopExitNode exit : oldLoopBegin.loopExits().snapshot()) {
exit.setLoopBegin(lb);
}

FixedNode next = oldLoopBegin.next();
oldLoopBegin.setNext(null);
Expand All @@ -153,10 +157,8 @@ protected void run(StructuredGraph graph, HighTierContext context) {
lb.addForwardEnd(fwdEnd);

FixedWithNextNode fwn = (FixedWithNextNode) fwd.predecessor();
fwn.setNext(null);
GraphUtil.killCFG(fwd);
fwn.setNext(fwdEnd);

GraphUtil.killCFG(fwd);
}

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
*/
package jdk.graal.compiler.core.test;

import org.junit.Test;

import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.calc.NegateNode;
import jdk.graal.compiler.nodes.calc.RightShiftNode;
import jdk.graal.compiler.nodes.calc.UnsignedRightShiftNode;
import org.junit.Test;

public class NegateCanonicalizationTest extends GraalCompilerTest {

Expand All @@ -49,19 +50,37 @@ public static long signExtractLong(long x) {
return (x >> 63) >>> 63;
}

private void checkNodes(String methodName) {
public static int negateNegate(int x) {
int var0 = -x;
int var1 = -(0 ^ var0);
return var1;
}

public static int negateNotDecrement(int x) {
return -~(x - 1);
}

private void checkNodesOnlyUnsignedRightShift(String methodName) {
StructuredGraph graph = parseForCompile(getResolvedJavaMethod(methodName));
createCanonicalizerPhase().apply(graph, getProviders());
assertTrue(graph.getNodes().filter(NegateNode.class).count() == 0);
assertTrue(graph.getNodes().filter(RightShiftNode.class).count() == 0);
assertTrue(graph.getNodes().filter(UnsignedRightShiftNode.class).count() == 1);
}

private void checkNodesNoNegate(String methodName) {
StructuredGraph graph = parseForCompile(getResolvedJavaMethod(methodName));
createCanonicalizerPhase().apply(graph, getProviders());
assertTrue(graph.getNodes().filter(NegateNode.class).count() == 0);
}

@Test
public void testNegate() {
checkNodes("negateInt");
checkNodes("negateLong");
checkNodes("signExtractInt");
checkNodes("signExtractLong");
checkNodesOnlyUnsignedRightShift("negateInt");
checkNodesOnlyUnsignedRightShift("negateLong");
checkNodesOnlyUnsignedRightShift("signExtractInt");
checkNodesOnlyUnsignedRightShift("signExtractLong");
checkNodesNoNegate("negateNegate");
checkNodesNoNegate("negateNotDecrement");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

import java.io.Serializable;

import jdk.graal.compiler.test.SubprocessUtil;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;

import jdk.graal.compiler.test.SubprocessUtil;
import jdk.vm.ci.meta.JavaTypeProfile;
import jdk.vm.ci.meta.ProfilingInfo;
import jdk.vm.ci.meta.ResolvedJavaMethod;
Expand Down Expand Up @@ -196,7 +196,6 @@ public ProfilingInfoTest() {

@Test
public void testExceptionSeen() {
Assume.assumeTrue("GR-45918", Runtime.version().feature() < 21);
// NullPointerException
ProfilingInfo info = profile("nullPointerExceptionSnippet", 5);
Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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 jdk.graal.compiler.nodes.GraphState;
import jdk.graal.compiler.nodes.GraphState.GuardsStage;
import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.java.LoadFieldNode;
import jdk.graal.compiler.nodes.spi.CoreProviders;
import jdk.graal.compiler.phases.VerifyPhase;
import jdk.vm.ci.meta.MetaAccessProvider;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;

/**
* Verify that {@link GuardsStage} enums are encapsulated.
*/
public class VerifyGuardsStageUsages extends VerifyPhase<CoreProviders> {

@Override
public boolean checkContract() {
return false;
}

@Override
protected void verify(StructuredGraph graph, CoreProviders context) {
MetaAccessProvider metaAccess = context.getMetaAccess();
ResolvedJavaMethod caller = graph.method();

if (caller.getDeclaringClass().equals(metaAccess.lookupJavaType(GraphState.class))) {
return;
}
if (caller.getDeclaringClass().equals(metaAccess.lookupJavaType(GraphState.GuardsStage.class))) {
return;
}

String callerName = caller.format("%H.%n");

switch (callerName) {
case "jdk.graal.compiler.phases.common.GuardLoweringPhase.updateGraphState":
case "jdk.graal.compiler.replacements.arraycopy.ArrayCopySnippets.delayedCheckcastArraycopySnippet":
case "jdk.graal.compiler.replacements.arraycopy.ArrayCopySnippets.delayedExactArraycopyWithExpandedLoopSnippet":
case "jdk.graal.compiler.replacements.arraycopy.ArrayCopySnippets.delayedGenericArraycopySnippet":
// Exempted cases
return;
default:
}

final ResolvedJavaType typeGuardsStage = metaAccess.lookupJavaType(GraphState.GuardsStage.class);

for (LoadFieldNode t : graph.getNodes().filter(LoadFieldNode.class)) {
if (typeGuardsStage.equals(t.field().getDeclaringClass())) {
throw new VerificationError("Access to %s fields at callsite %s is prohibited. Use API methods provided in %s.",
typeGuardsStage.toJavaName(true),
caller.format("%H.%n(%p)"),
typeGuardsStage.toJavaName(true));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.lang.Runtime.Version;

import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.java.MethodCallTargetNode;
import jdk.graal.compiler.nodes.spi.CoreProviders;
import jdk.graal.compiler.phases.VerifyPhase;
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
import jdk.vm.ci.meta.MetaAccessProvider;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;

/**
* Verify that Graal fetches {@link Version#feature} only via {@link JavaVersionUtil}.
*/
public class VerifyRuntimeVersionFeature extends VerifyPhase<CoreProviders> {

@Override
public boolean checkContract() {
return false;
}

@Override
protected void verify(StructuredGraph graph, CoreProviders context) {
MetaAccessProvider metaAccess = context.getMetaAccess();
ResolvedJavaMethod caller = graph.method();

if ("jdk.graal.compiler.serviceprovider.JavaVersionUtil.<clinit>()".equals(caller.format("%H.%n(%p)"))) {
// JavaVersionUtil.JAVA_SPEC
return;
}

final ResolvedJavaType typeRuntimeVersion = metaAccess.lookupJavaType(Runtime.Version.class);

for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) {
ResolvedJavaMethod callee = t.targetMethod();
if (typeRuntimeVersion.equals(callee.getDeclaringClass()) && "feature".equals(callee.getName())) {
throw new VerificationError("Call to %s at callsite %s is prohibited, use JavaVersionUtil.JAVA_SPEC", callee.format("%H.%n(%p)"), caller.format("%H.%n(%p)"));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ protected void run(StructuredGraph graph, LowTierContext context) {
*/
public static final int SLEEP_SECONDS = 10;

/**
* Thread.sleep is using nanoTime and compilation alarm uses System.currenTimeMillis which is a
* different timer so there can be small imprecision. We allow this amount milliseconds total
* imprecision.
*/
public static final int IMPRECISION_DELTA = 100;

@Test
public void testTimeOutRetryToString() {
final double secondsToWait = 1D;
Expand All @@ -103,9 +96,7 @@ public void testTimeOutRetryToString() {
duration += c;
index++;
}
final double scaledSecondsToWait = CompilationAlarm.scaleExpirationPeriod(secondsToWait, opt);
assert Integer.parseInt(duration) >= (scaledSecondsToWait * 1000) -
IMPRECISION_DELTA : String.format("Must at least wait for 2000ms but waited %s error was %s", duration, message);
assert Integer.parseInt(duration) > 0 : String.format("Must at least wait some positive amount of time but waited %s error was %s", duration, message);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public class LibGraalCompilationDriver {
private final boolean multiThreaded;

/**
* Number of threads to use for multithreaded compilation. If 0, the value of
* {@code Runtime.getRuntime().availableProcessors()} is used instead.
* Number of threads to use for multithreaded compilation. If 0, a good default value is picked
* by {@link #getThreadCount()}.
*/
private final int numThreads;

Expand Down Expand Up @@ -694,7 +694,12 @@ private int getThreadCount() {
if (multiThreaded) {
threadCount = numThreads;
if (threadCount == 0) {
threadCount = Runtime.getRuntime().availableProcessors();
/*
* On very large machine there might be hundreds of processors and the compiler
* doesn't really scale well enough for that so limit the max number of threads. 32
* was picked as that seemed to scale well enough in testing.
*/
threadCount = Math.min(32, Runtime.getRuntime().availableProcessors());
}
}
return threadCount;
Expand Down
Loading

0 comments on commit cc01c00

Please sign in to comment.