Skip to content

Commit

Permalink
Automatic merge of master into galahad
Browse files Browse the repository at this point in the history
  • Loading branch information
OracleLabsAutomation committed Feb 20, 2025
2 parents 8681f4c + f59ed46 commit bb41ff7
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 77 deletions.
4 changes: 2 additions & 2 deletions ci_includes/publish-javadoc.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
local linux_amd64 = common.linux_amd64,

local javadoc_publisher = {
name: 'graal-publish-javadoc-' + utils.prefixed_jdk(self.jdk_version),
name: 'graal-publish-javadoc-' + self.jdk_name,
run+: [
["cd", "./sdk"],
["mx", "build"],
Expand Down Expand Up @@ -59,7 +59,7 @@
},

local all_builds = [
common.post_merge + linux_amd64 + common.labsjdk21 + javadoc_publisher,
common.post_merge + linux_amd64 + common.labsjdkLatest + javadoc_publisher,
],
// adds a "defined_in" field to all builds mentioning the location of this current file
builds:: utils.add_defined_in(all_builds, std.thisFile),
Expand Down
4 changes: 4 additions & 0 deletions compiler/mx.compiler/mx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@ def apply(self, config):
vmArgs.append('-Djdk.graal.TrackNodeSourcePosition=true')
vmArgs.append('-esa')

if '-JUnitMaxTestTime' not in mainClassArgs:
# The max time (in seconds) for any compiler unit test
mainClassArgs.extend(['-JUnitMaxTestTime', '300'])

# Always run unit tests without UseJVMCICompiler unless explicitly requested
if _get_XX_option_value(vmArgs, 'UseJVMCICompiler', None) is None:
vmArgs.append('-XX:-UseJVMCICompiler')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public void testBody() {

@Test
public void testInSubprocess() throws IOException, InterruptedException {
SubprocessTest.launchSubprocess(getClass(), this::testBody, "--enable-preview");
SubprocessTest.launchSubprocess(getClass(), currentUnitTestName(), this::testBody, "--enable-preview");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,16 @@ public abstract class SubprocessTest extends GraalCompilerTest {
* {@link Subprocess} instance describing the process after its successful termination.
*/
public SubprocessUtil.Subprocess launchSubprocess(Runnable runnable, String... args) throws InterruptedException, IOException {
return launchSubprocess(null, null, true, getClass(), null, runnable, args);
}

/**
* Like {@link #launchSubprocess(Runnable, String...)}, but with an extra {@code testSelector}
* to specify a specific test method to execute in the test class.
*/
public SubprocessUtil.Subprocess launchSubprocess(String testSelector, Runnable runnable, String... args) throws InterruptedException, IOException {
return launchSubprocess(null, null, true, getClass(), testSelector, runnable, args);
return launchSubprocess(null, null, true, getClass(), currentUnitTestName(), runnable, args);
}

public SubprocessUtil.Subprocess launchSubprocess(Predicate<String> vmArgsFilter, Runnable runnable, String... args) throws InterruptedException, IOException {
return launchSubprocess(null, vmArgsFilter, true, getClass(), null, runnable, args);
}

public static SubprocessUtil.Subprocess launchSubprocess(Class<? extends GraalCompilerTest> testClass, Runnable runnable, String... args) throws InterruptedException, IOException {
return launchSubprocess(null, null, true, testClass, null, runnable, args);
return launchSubprocess(null, vmArgsFilter, true, getClass(), currentUnitTestName(), runnable, args);
}

public static SubprocessUtil.Subprocess launchSubprocess(Predicate<List<String>> testPredicate, Predicate<String> vmArgsFilter, boolean expectNormalExit,
Class<? extends GraalCompilerTest> testClass, Runnable runnable, String... args)
public static SubprocessUtil.Subprocess launchSubprocess(Class<? extends GraalCompilerTest> testClass, String testSelector, Runnable runnable, String... args)
throws InterruptedException, IOException {
return launchSubprocess(testPredicate, vmArgsFilter, expectNormalExit, testClass, null, runnable, args);
return launchSubprocess(null, null, true, testClass, testSelector, runnable, args);
}

private static List<String> filter(List<String> args, Predicate<String> vmArgsFilter) {
Expand All @@ -102,6 +89,11 @@ private static List<String> filter(List<String> args, Predicate<String> vmArgsFi
return result;
}

/**
* Sentinel value meaning all tests in the specified test class are to be run.
*/
public static final String ALL_TESTS = "ALL_TESTS";

public boolean isRecursiveLaunch() {
return isRecursiveLaunch(getClass());
}
Expand Down Expand Up @@ -131,10 +123,8 @@ public static SubprocessUtil.Subprocess launchSubprocess(Predicate<List<String>>

List<String> mainClassAndArgs = new LinkedList<>();
mainClassAndArgs.add("com.oracle.mxtool.junit.MxJUnitWrapper");
String testName = testClass.getName();
if (testSelector != null) {
testName += "#" + testSelector;
}
assert testSelector != null : "must pass the name of the current unit test";
String testName = testSelector.equals(ALL_TESTS) ? testClass.getName() : testClass.getName() + "#" + testSelector;
mainClassAndArgs.add(testName);
boolean junitVerbose = getProcessCommandLine().contains("-JUnitVerbose");
if (junitVerbose) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static int accessVolatile1Snippet(A a) {

@Test
public void accessVolatile1() {
runTest("accessVolatile1", new A(12));
runTest(currentUnitTestName(), new A(12));
}

public void runTest(String baseName, Object... args) {
Expand Down Expand Up @@ -120,7 +120,7 @@ public void runTest(String baseName, Object... args) {
"-Dgraal.Dump=:5"};
}
try {
subprocess = launchSubprocess(baseName, run, vmArgs);
subprocess = launchSubprocess(run, vmArgs);
} catch (InterruptedException | IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static Object fieldReadBarrierSnippet(TestObject t) {

@Test
public void fieldReadBarrier() {
runTest("fieldReadBarrier", new TestObject());
runTest(new TestObject());
}

public static void fieldWriteBarrierSnippet(TestObject t, Object value) {
Expand All @@ -101,7 +101,7 @@ public static void fieldWriteBarrierSnippet(TestObject t, Object value) {

@Test
public void fieldWriteBarrier() {
runTest("fieldWriteBarrier", new TestObject(), "string");
runTest(new TestObject(), "string");
}

public static void volatileFieldWriteBarrierSnippet(TestObject t, Object value) {
Expand All @@ -110,7 +110,7 @@ public static void volatileFieldWriteBarrierSnippet(TestObject t, Object value)

@Test
public void volatileFieldWriteBarrier() {
runTest("volatileFieldWriteBarrier", new TestObject(), "string");
runTest(new TestObject(), "string");
}

public static void arrayWriteBarrierSnippet(Object[] t, Object value) {
Expand All @@ -119,7 +119,7 @@ public static void arrayWriteBarrierSnippet(Object[] t, Object value) {

@Test
public void arrayWriteBarrier() {
runTest("arrayWriteBarrier", new Object[1], "string");
runTest(new Object[1], "string");
}

public static void volatileArrayWriteBarrierSnippet(Object[] t, Object value) {
Expand All @@ -131,7 +131,7 @@ public static void volatileArrayWriteBarrierSnippet(Object[] t, Object value) {

@Test
public void volatileArrayWriteBarrier() {
runTest("volatileArrayWriteBarrier", new Object[1], "string");
runTest(new Object[1], "string");
}

public static void fieldWriteNullBarrierSnippet(TestObject t) {
Expand All @@ -140,7 +140,7 @@ public static void fieldWriteNullBarrierSnippet(TestObject t) {

@Test
public void fieldWriteNullBarrier() {
runTest("fieldWriteNullBarrier", new TestObject());
runTest(new TestObject());
}

public static void volatileFieldWriteNullBarrierSnippet(TestObject t) {
Expand All @@ -149,7 +149,7 @@ public static void volatileFieldWriteNullBarrierSnippet(TestObject t) {

@Test
public void volatileFieldWriteNullBarrier() {
runTest("volatileFieldWriteNullBarrier", new TestObject());
runTest(new TestObject());
}

public static void arrayWriteNullBarrierSnippet(Object[] t) {
Expand All @@ -158,7 +158,7 @@ public static void arrayWriteNullBarrierSnippet(Object[] t) {

@Test
public void arrayWriteNullBarrier() {
runTest("arrayWriteNullBarrier", new Object[]{new Object[1]});
runTest(new Object[]{new Object[1]});
}

public static Object valueCompareAndSwapBarrierSnippet(TestObject t1, Object value) {
Expand All @@ -174,7 +174,7 @@ public void valueCompareAndSwapBarrier() {
assertTrue(graph.getNodes().filter(ValueCompareAndSwapNode.class).isNotEmpty(), "expected ValueCompareAndSwapNode");
return true;
};
runTest("valueCompareAndSwapBarrier", nodePredicate, supply(TestObject::new), "string");
runTest(nodePredicate, supply(TestObject::new), "string");
}

public static boolean logicCompareAndSwapBarrierSnippet(TestObject t1, Object value) {
Expand All @@ -190,7 +190,7 @@ public void logicCompareAndSwapBarrier() {
assertTrue(graph.getNodes().filter(LogicCompareAndSwapNode.class).isNotEmpty(), "expected LogicCompareAndSwapNode");
return true;
};
runTest("logicCompareAndSwapBarrier", nodePredicate, supply(TestObject::new), "string");
runTest(nodePredicate, supply(TestObject::new), "string");
}

public static Object getAndSetBarrierSnippet(TestObject t1, Object value) {
Expand All @@ -206,7 +206,7 @@ public void getAndSetBarrier() {
assertTrue(graph.getNodes().filter(LoweredAtomicReadAndWriteNode.class).isNotEmpty(), "expected LoweredAtomicReadAndWriteNode");
return true;
};
runTest("getAndSetBarrier", nodePredicate, supply(TestObject::new), "string");
runTest(nodePredicate, supply(TestObject::new), "string");
}

public static boolean phantomRefersToBarrierSnippet(PhantomReference<Object> phantom, Object value) {
Expand All @@ -216,7 +216,7 @@ public static boolean phantomRefersToBarrierSnippet(PhantomReference<Object> pha
@Test
public void phantomRefersToBarrier() {
ReferenceQueue<Object> queue = new ReferenceQueue<>();
runTest("phantomRefersToBarrier", new PhantomReference<>("string", queue), "string");
runTest(new PhantomReference<>("string", queue), "string");
}

public static boolean weakRefersToBarrierSnippet(WeakReference<Object> weak, Object value) {
Expand All @@ -225,7 +225,7 @@ public static boolean weakRefersToBarrierSnippet(WeakReference<Object> weak, Obj

@Test
public void weakRefersToBarrier() {
runTest("weakRefersToBarrier", new WeakReference<>("string"), "string");
runTest(new WeakReference<>("string"), "string");
}

public static Object referenceGetBarrierSnippet(WeakReference<Object> weak) {
Expand All @@ -234,7 +234,7 @@ public static Object referenceGetBarrierSnippet(WeakReference<Object> weak) {

@Test
public void referenceGetBarrier() {
runTest("referenceGetBarrier", new WeakReference<>("string"));
runTest(new WeakReference<>("string"));
}

public static TestObject objectAllocationBarrierSnippet() {
Expand All @@ -243,7 +243,7 @@ public static TestObject objectAllocationBarrierSnippet() {

@Test
public void objectAllocationBarrier() {
runTest("objectAllocationBarrier");
runTest();
}

public static String stringAllocationBarrierSnippet() {
Expand All @@ -252,7 +252,7 @@ public static String stringAllocationBarrierSnippet() {

@Test
public void stringAllocationBarrier() {
runTest("stringAllocationBarrier");
runTest();
}

private static TestObject obj6 = new TestObject(6);
Expand All @@ -265,7 +265,7 @@ public static Object testuuvCAESnippet() {

@Test
public void testuuvCAE() {
runTest("testuuvCAE");
runTest();
}

public static Object threadHandleBarrierSnippet() {
Expand All @@ -274,7 +274,7 @@ public static Object threadHandleBarrierSnippet() {

@Test
public void threadHandleBarrier() {
runTest("threadHandleBarrier");
runTest();
}

@Override
Expand All @@ -286,11 +286,12 @@ protected void checkLowTierGraph(StructuredGraph graph) {

Predicate<StructuredGraph> graphPredicate;

public void runTest(String baseName, Object... args) {
runTest(baseName, null, args);
public void runTest(Object... args) {
runTest(null, args);
}

public void runTest(String baseName, Predicate<StructuredGraph> predicate, Object... args) {
public void runTest(Predicate<StructuredGraph> predicate, Object... args) {
String baseName = currentUnitTestName();
String snippetName = baseName + "Snippet";
String methodSpec = getClass().getName() + "::" + snippetName;
Method m = getMethod(snippetName);
Expand Down Expand Up @@ -350,7 +351,7 @@ public void runTest(String baseName, Predicate<StructuredGraph> predicate, Objec
"-XX:LogFile=" + logName};
}
try {
subprocess = launchSubprocess(baseName, run, vmArgs);
subprocess = launchSubprocess(run, vmArgs);
} catch (InterruptedException | IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import java.util.Collections;
import java.util.List;

import jdk.graal.compiler.core.test.SubprocessTest;
import org.junit.Test;

import jdk.graal.compiler.core.test.SubprocessTest;
import jdk.internal.vm.annotation.Contended;

@SuppressWarnings("unused")
Expand Down Expand Up @@ -70,12 +70,30 @@ public void runSubprocessTest(String... args) throws IOException, InterruptedExc
}, newArgs.toArray(new String[0]));
}

// Checkstyle: stop method name check
@Test
public void testG1() throws IOException, InterruptedException {
String[] sizes = {"-XX:G1HeapRegionSize=1M", "-XX:G1HeapRegionSize=2M", "-XX:G1HeapRegionSize=4M", "-XX:G1HeapRegionSize=8M"};
for (String size : sizes) {
runSubprocessTest("-XX:+UseG1GC", "-XX:+EnableContended", "-XX:-RestrictContended", "-Xmx128m", "-XX:ContendedPaddingWidth=8192", size);
}
public void testG1_1M() throws IOException, InterruptedException {
testG1("-XX:G1HeapRegionSize=1M");
}

@Test
public void testG1_2M() throws IOException, InterruptedException {
testG1("-XX:G1HeapRegionSize=2M");
}

@Test
public void testG1_4M() throws IOException, InterruptedException {
testG1("-XX:G1HeapRegionSize=4M");
}

@Test
public void testG1_8M() throws IOException, InterruptedException {
testG1("-XX:G1HeapRegionSize=9M");
}
// Checkstyle: resume method name check

public void testG1(String size) throws IOException, InterruptedException {
runSubprocessTest("-XX:+UseG1GC", "-XX:+EnableContended", "-XX:-RestrictContended", "-Xmx128m", "-XX:ContendedPaddingWidth=8192", size);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@
import java.lang.reflect.Constructor;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;

import com.oracle.truffle.api.impl.asm.Opcodes;

import jdk.graal.compiler.core.test.SubprocessTest;
import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
Expand All @@ -40,11 +47,6 @@
import jdk.graal.compiler.test.AddExports;
import jdk.internal.vm.annotation.Stable;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import org.junit.Assert;
import org.junit.Test;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;

/**
* Assert that a barrier is inserted at the end of a constructor that writes to Stable fields or if
Expand Down Expand Up @@ -89,7 +91,7 @@ public void checkAlwaysSafeConstructors() throws NoSuchMethodException {

@Test
public void runCheckStableWriteConstructors() throws IOException, InterruptedException {
launchSubprocess("runCheckStableWriteConstructors", this::checkStableWriteConstructors, "--add-opens=java.base/java.lang=ALL-UNNAMED");
launchSubprocess(this::checkStableWriteConstructors, "--add-opens=java.base/java.lang=ALL-UNNAMED");
}

private void checkStableWriteConstructors() {
Expand Down
Loading

0 comments on commit bb41ff7

Please sign in to comment.