Skip to content

Commit

Permalink
Merge pull request #20656 from theresa-m/fix_20386
Browse files Browse the repository at this point in the history
Use migrated value classes in Valhalla functional tests
  • Loading branch information
hangshao0 authored Dec 4, 2024
2 parents 4f06ea8 + a4e21b6 commit f8939d1
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 14 deletions.
9 changes: 9 additions & 0 deletions test/functional/Valhalla/playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
-Xint -Xdump:system+java+snap:events=systhrow,filter=java/lang/LinkageError,msg_filter=*Triangle2D* --enable-preview \
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports java.base/jdk.internal.value=ALL-UNNAMED \
--patch-module java.base=$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar \
-cp $(Q)$(LIB_DIR)$(D)asm.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)ValhallaTests.jar$(Q) \
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames ValueTypeTests \
-groups $(TEST_GROUP) \
Expand Down Expand Up @@ -76,6 +77,7 @@
-Xdump:system+java+snap:events=systhrow,filter=java/lang/LinkageError,msg_filter=*Triangle2D* --enable-preview \
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports java.base/jdk.internal.value=ALL-UNNAMED \
--patch-module java.base=$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar \
-cp $(Q)$(LIB_DIR)$(D)asm.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)ValhallaTests.jar$(Q) \
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames ValueTypeTests \
-groups $(TEST_GROUP) \
Expand Down Expand Up @@ -113,6 +115,7 @@
-Xint --enable-preview \
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports java.base/jdk.internal.value=ALL-UNNAMED \
--patch-module java.base=$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar \
-cp $(Q)$(LIB_DIR)$(D)asm.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)ValhallaTests.jar$(Q) \
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames ValueTypeArrayTests \
-groups $(TEST_GROUP) \
Expand Down Expand Up @@ -165,6 +168,7 @@
--enable-preview \
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports java.base/jdk.internal.value=ALL-UNNAMED \
--patch-module java.base=$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar \
-cp $(Q)$(LIB_DIR)$(D)asm.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)ValhallaTests.jar$(Q) \
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames ValueTypeArrayTests \
-groups $(TEST_GROUP) \
Expand Down Expand Up @@ -196,6 +200,7 @@
-Xint --enable-preview \
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports java.base/jdk.internal.value=ALL-UNNAMED \
--patch-module java.base=$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar \
-cp $(Q)$(LIB_DIR)$(D)asm.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)ValhallaTests.jar$(Q) \
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames ValueTypeUnsafeTests \
-groups $(TEST_GROUP) \
Expand Down Expand Up @@ -237,6 +242,7 @@
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
--enable-preview \
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
--patch-module java.base=$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar \
-cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)ValhallaTests.jar$(Q) \
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames ValueTypeOptTests \
-groups $(TEST_GROUP) \
Expand Down Expand Up @@ -280,6 +286,7 @@
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
--enable-preview \
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
--patch-module java.base=$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar \
-cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)ValhallaTests.jar$(Q) \
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames NullRestrictedTypeOptTests \
-groups $(TEST_GROUP) \
Expand Down Expand Up @@ -313,6 +320,7 @@
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
--enable-preview \
--add-exports java.base/jdk.internal.value=ALL-UNNAMED \
--patch-module java.base=$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar \
-cp $(Q)$(LIB_DIR)$(D)asm.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)ValhallaTests.jar$(Q) \
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames ValhallaAttributeTests \
-groups $(TEST_GROUP) \
Expand Down Expand Up @@ -363,6 +371,7 @@
--enable-preview \
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports java.base/jdk.internal.value=ALL-UNNAMED \
--patch-module java.base=$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar \
-cp $(Q)$(LIB_DIR)$(D)asm.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)ValhallaTests.jar$(Q) \
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames ValueTypeSystemArraycopyTests \
-groups $(TEST_GROUP) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,14 @@ public static Class<?> generateVerifiableValueClass(String name, String[] fields
return generator.defineClass(name, bytes, 0, bytes.length);
}

public static Class<?> generateRefClass(String name) throws Throwable {
ClassConfiguration classConfig = new ClassConfiguration(name, new String[0]);
classConfig.setIsReference(true);

byte[] bytes = generateClass(classConfig);
return generator.defineClass(name, bytes, 0, bytes.length);
}

public static Class<?> generateRefClass(String name, String[] fields) throws Throwable {
ClassConfiguration classConfig = new ClassConfiguration(name, fields);
classConfig.setIsReference(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1007,8 +1007,7 @@ static public void testSynchMethodsOnRefTypes() throws Throwable {
*/
@Test(priority=1)
static public void testMonitorExitWithRefType() throws Throwable {
int x = 1;
Object refType = (Object) x;
Object refType = new Object();

String[] fields = {"longField:J"};
Class<?> testMonitorExitWithRefType = ValueTypeGenerator.generateRefClass("TestMonitorExitWithRefType", fields);
Expand All @@ -1028,8 +1027,7 @@ static public void testMonitorExitWithRefType() throws Throwable {
*/
@Test(priority=1)
static public void testMonitorEnterAndExitWithRefType() throws Throwable {
int x = 2;
Object refType = (Object) x;
Object refType = new Object();

String[] fields = {"longField:J"};
Class<?> testMonitorEnterAndExitWithRefType = ValueTypeGenerator.generateRefClass("TestMonitorEnterAndExitWithRefType", fields);
Expand All @@ -1041,6 +1039,33 @@ static public void testMonitorEnterAndExitWithRefType() throws Throwable {
}
}

@Test(priority=1)
static public void testMigratedValueClasses() {
Integer a = new Integer(1);
Integer b = new Integer(1);

Assert.assertTrue(a.getClass().isValue(),
"java/lang/Integer should be migrated to a value class.");
Assert.assertTrue(a.hashCode() == b.hashCode(),
"Two objects of value type classes with the same values should have the same hash code.");
Assert.assertTrue(a == b,
"Two objects of value type classes with the same values should be equal.");
}

@Test(priority=1)
static public void testMigratedValueClassesMonitorEnterAndExit() throws Throwable {
Integer i = new Integer(1);
Object refType = (Object)i;

Class<?> testMigratedValueClassesMonitorEnterAndExit = ValueTypeGenerator.generateRefClass("TestMigratedValueClassesMonitorEnterAndExit");
MethodHandle monitorEnterAndExitWithRefType = lookup.findStatic(testMigratedValueClassesMonitorEnterAndExit, "testMonitorEnterAndExitWithRefType", MethodType.methodType(void.class, Object.class));
try {
monitorEnterAndExitWithRefType.invoke(refType);
fail("Synchronization attempts on migrated value classes should fail.");
} catch (IdentityException e) {
}
}

/*
* Create a valueType with three valueType members
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
<!DOCTYPE suite SYSTEM "cmdlinetester.dtd">

<suite id="J9 Value Type ddr test with flattening enabled" timeout="600">
<variable name="ARGS" value="--enable-preview -XX:ValueTypeFlatteningThreshold=999999 -XX:+EnableArrayFlattening -Xverify:none --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED" />
<variable name="ARGS" value="--enable-preview -XX:ValueTypeFlatteningThreshold=999999 -XX:+EnableArrayFlattening -Xverify:none --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED --patch-module java.base=$MIGRATEDVALUECLASSJAR$" />
<variable name="JARS" value="-cp $ASMJAR$$CPDL$$JCOMMANDERJAR$$CPDL$$TESTNGJAR$$CPDL$$VALUETYPEJAR$" />
<variable name="PROGRAM" value="org.openj9.test.lworld.DDRBackfillLayoutTest" />
<variable name="DUMPFILE" value="j9core.dmp" />
Expand Down Expand Up @@ -118,7 +118,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
<input>!fj9object $flatSingleBackfillInstanceO$</input>
<input>quit</input>
</command>
<output regex="no" type="success" showMatch="yes">I value = 0xEEFFEEFF (offset = 4) (java/lang/Integer)</output>
<output regex="no" type="success" showMatch="yes">I value = 0xEEFFEEFF (offset = 0) (java/lang/Integer)</output>
<output regex="no" type="failure">Problem running command</output>
</test>

Expand Down Expand Up @@ -162,7 +162,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
<input>!fj9object $objectBackfillInstanceO$</input>
<input>quit</input>
</command>
<output regex="no" type="success" showMatch="yes">I value = 0xEEFFEEFF (offset = 4) (java/lang/Integer)</output>
<output regex="no" type="success" showMatch="yes">I value = 0xEEFFEEFF (offset = 0) (java/lang/Integer)</output>
<output regex="no" type="failure">Problem running command</output>
</test>

Expand Down Expand Up @@ -236,7 +236,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
<input>!fj9object $flatUnAlignedSingleBackfillInstanceO$</input>
<input>quit</input>
</command>
<output regex="no" type="success" showMatch="yes">I value = 0xEEFFEEFF (offset = 4) (java/lang/Integer)</output>
<output regex="no" type="success" showMatch="yes">I value = 0xEEFFEEFF (offset = 0) (java/lang/Integer)</output>
<output regex="no" type="failure">Problem running command</output>
</test>

Expand Down Expand Up @@ -355,7 +355,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
<input>!fj9object $singleBackfillInstanceO$</input>
<input>quit</input>
</command>
<output regex="no" type="success" showMatch="yes">I value = 0xEEFFEEFF (offset = 4) (java/lang/Integer)</output>
<output regex="no" type="success" showMatch="yes">I value = 0xEEFFEEFF (offset = 0) (java/lang/Integer)</output>
<output regex="no" type="failure">Problem running command</output>
</test>

Expand Down Expand Up @@ -388,7 +388,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
<input>!fj9object $objectBackfillInstance2O$</input>
<input>quit</input>
</command>
<output regex="no" type="success" showMatch="yes">I value = 0xEEFFEEFF (offset = 4) (java/lang/Integer)</output>
<output regex="no" type="success" showMatch="yes">I value = 0xEEFFEEFF (offset = 0) (java/lang/Integer)</output>
<output regex="no" type="failure">Problem running command</output>
</test>

Expand All @@ -399,7 +399,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
<input>quit</input>
</command>
<output regex="no" type="success" showMatch="yes" regex="yes" javaUtilPattern="yes">J l2 = 0x11551155AAEEAAEE \(offset = 12\) \(.*ValueTypeDoubleLong\)</output>
<output regex="no" type="success" showMatch="yes" regex="yes" javaUtilPattern="yes">l \(offset = 4\) \(.*ValueTypeLong\)</output>
<output regex="no" type="success" showMatch="yes" regex="yes" javaUtilPattern="yes">l \(offset = 0\) \(.*ValueTypeLong\)</output>
<output regex="no" type="success" showMatch="yes" regex="yes" javaUtilPattern="yes">\// \(.*ValueTypeDoubleLong\)</output>
<output regex="no" type="failure">Problem running command</output>
</test>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<!DOCTYPE suite SYSTEM "cmdlinetester.dtd">

<suite id="J9 Value Type ddr test with flattening enabled" timeout="600">
<variable name="ARGS" value="-Xint --enable-preview -XX:ValueTypeFlatteningThreshold=999999 -XX:+EnableArrayFlattening -Xverify:none --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED" />
<variable name="ARGS_NOCR" value="-Xint --enable-preview -Xnocompressedrefs -XX:ValueTypeFlatteningThreshold=999999 -XX:+EnableArrayFlattening -Xverify:none --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED" />
<variable name="ARGS" value="-Xint --enable-preview -XX:ValueTypeFlatteningThreshold=999999 -XX:+EnableArrayFlattening -Xverify:none --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED --patch-module java.base=$MIGRATEDVALUECLASSJAR$" />
<variable name="ARGS_NOCR" value="-Xint --enable-preview -Xnocompressedrefs -XX:ValueTypeFlatteningThreshold=999999 -XX:+EnableArrayFlattening -Xverify:none --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED --patch-module java.base=$MIGRATEDVALUECLASSJAR$" />
<variable name="JARS" value="-cp $ASMJAR$$CPDL$$JCOMMANDERJAR$$CPDL$$TESTNGJAR$$CPDL$$VALUETYPEJAR$" />
<variable name="PROGRAM" value="org.openj9.test.lworld.DDRValueTypeTest" />
<variable name="DUMPFILE" value="j9core.dmp" />
Expand Down
4 changes: 4 additions & 0 deletions test/functional/cmdLineTests/valuetypeddrtests/playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
-DJCOMMANDERJAR=$(Q)$(LIB_DIR)$(D)jcommander.jar$(Q) \
-DTESTNGJAR=$(Q)$(LIB_DIR)$(D)testng.jar$(Q) \
-DVALUETYPEJAR=$(Q)$(JVM_TEST_ROOT)$(D)functional$(D)Valhalla$(D)ValhallaTests.jar$(Q) \
-DMIGRATEDVALUECLASSJAR=$(Q)$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar$(Q) \
-DCPDL=$(Q)$(P)$(Q) \
-jar $(CMDLINETESTER_JAR) \
-config $(Q)$(TEST_RESROOT)$(D)flattenedvaluetypeddrtests.xml$(Q) \
Expand Down Expand Up @@ -78,6 +79,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
-DJCOMMANDERJAR=$(Q)$(LIB_DIR)$(D)jcommander.jar$(Q) \
-DTESTNGJAR=$(Q)$(LIB_DIR)$(D)testng.jar$(Q) \
-DVALUETYPEJAR=$(Q)$(JVM_TEST_ROOT)$(D)functional$(D)Valhalla$(D)ValhallaTests.jar$(Q) \
-DMIGRATEDVALUECLASSJAR=$(Q)$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar$(Q) \
-DCPDL=$(Q)$(P)$(Q) \
-jar $(CMDLINETESTER_JAR) \
-config $(Q)$(TEST_RESROOT)$(D)unflattenedvaluetypeddrtests.xml$(Q) \
Expand Down Expand Up @@ -118,6 +120,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
-DJCOMMANDERJAR=$(Q)$(LIB_DIR)$(D)jcommander.jar$(Q) \
-DTESTNGJAR=$(Q)$(LIB_DIR)$(D)testng.jar$(Q) \
-DVALUETYPEJAR=$(Q)$(JVM_TEST_ROOT)$(D)functional$(D)Valhalla$(D)ValhallaTests.jar$(Q) \
-DMIGRATEDVALUECLASSJAR=$(Q)$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar$(Q) \
-DCPDL=$(Q)$(P)$(Q) \
-jar $(CMDLINETESTER_JAR) \
-config $(Q)$(TEST_RESROOT)$(D)flattened32bitRefBackfillTest.xml$(Q) \
Expand Down Expand Up @@ -158,6 +161,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
-DJCOMMANDERJAR=$(Q)$(LIB_DIR)$(D)jcommander.jar$(Q) \
-DTESTNGJAR=$(Q)$(LIB_DIR)$(D)testng.jar$(Q) \
-DVALUETYPEJAR=$(Q)$(JVM_TEST_ROOT)$(D)functional$(D)Valhalla$(D)ValhallaTests.jar$(Q) \
-DMIGRATEDVALUECLASSJAR=$(Q)$(TEST_JDK_HOME)$(D)lib$(D)valueclasses$(D)java.base-valueclasses.jar$(Q) \
-DCPDL=$(Q)$(P)$(Q) \
-jar $(CMDLINETESTER_JAR) \
-config $(Q)$(TEST_RESROOT)$(D)flattened32bitRefBackfillTest.xml$(Q) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<!DOCTYPE suite SYSTEM "cmdlinetester.dtd">

<suite id="J9 Value Type ddr test with flattening disabled" timeout="600">
<variable name="ARGS" value="--enable-preview -Xint -Xverify:none --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED" />
<variable name="ARGS" value="--enable-preview -Xint -Xverify:none --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED --patch-module java.base=$MIGRATEDVALUECLASSJAR$" />
<variable name="JARS" value="-cp $ASMJAR$$CPDL$$JCOMMANDERJAR$$CPDL$$TESTNGJAR$$CPDL$$VALUETYPEJAR$" />
<variable name="PROGRAM" value="org.openj9.test.lworld.DDRValueTypeTest" />
<variable name="DUMPFILE" value="j9core.dmp" />
Expand Down

0 comments on commit f8939d1

Please sign in to comment.