Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove flattening flag from nullable arrays #20250

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

theresa-m
Copy link
Contributor

@theresa-m theresa-m commented Sep 27, 2024

Update ValueTypeUnsafeTests tests to use flattenable array.
Update ValueTypeSystemArraycopyTests to test System.arrayCopy
between nullable and null-restricted arrays.

Fixes: #20223
Fixes: #20253

@theresa-m
Copy link
Contributor Author

@a7ehuo can you review the tests on this change?

Copy link
Contributor

@a7ehuo a7ehuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test update looks good to me. Thank you very much for the change @theresa-m!

@theresa-m theresa-m marked this pull request as draft October 1, 2024 16:13
@theresa-m theresa-m force-pushed the arraystore_nr branch 3 times, most recently from 38e1116 to 58cb366 Compare October 1, 2024 16:31
@theresa-m theresa-m marked this pull request as ready for review October 1, 2024 17:12
@theresa-m theresa-m changed the title Allow arrayCopy between null-restricted and nullable Remove flattening flag from nullable arrays Oct 1, 2024
Update ValueTypeUnsafeTests  tests to use flattenable array.
Update ValueTypeSystemArraycopyTests to test System.arrayCopy
between nullable and null-restricted arrays.

Signed-off-by: Theresa Mammarella <Theresa.T.Mammarella@ibm.com>
@theresa-m theresa-m marked this pull request as draft October 2, 2024 14:17
@theresa-m theresa-m force-pushed the arraystore_nr branch 2 times, most recently from d45e43f to d2eab92 Compare October 2, 2024 15:51
@theresa-m theresa-m marked this pull request as ready for review October 2, 2024 15:53
@hangshao0
Copy link
Contributor

@a7ehuo can you review the tests on this change?

There are some new changes to the test, could you review again ? @a7ehuo

Copy link
Contributor

@a7ehuo a7ehuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the update! Sorry I just realized I missed a few things in my first review. They are minor comments

Comment on lines 124 to 141
nullRestrictedVtArrayDst[i] = new SomeValueClass(i*5);
nullRestrictedVtArraySrc[i] = new SomeValueClass(i*6);

ifIdArrayDst[i] = new SomeIdentityClass(i*7);
ifIdArraySrc[i] = new SomeIdentityClass(i*8);

ifVtArrayDst[i] = new SomeValueClass(i*9);
ifVtArraySrc[i] = new SomeValueClass(i*10);

ifPrimitiveVtArrayDst[i] = new SomePrimitiveValueClass(i*11);
ifPrimitiveVtArraySrc[i] = new SomePrimitiveValueClass(i*12);
ifNullRestrictedVtArrayDst[i] = new SomeValueClass(i*11);
ifNullRestrictedVtArraySrc[i] = new SomeValueClass(i*12);

ifArray1[i] = new SomeIdentityClass(i*13);
ifArray2[i] = new SomeValueClass(i*14);
ifArray3[i] = new SomePrimitiveValueClass(i*15);
ifArray3[i] = new SomeValueClass(i*15);

nullRestrictedVtArrayDst[i] = new SomeValueClass(i*16);
nullRestrictedVtArraySrc[i] = new SomeValueClass(i*17);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullRestrictedVtArrayDst[i] and nullRestrictedVtArraySrc[i] are now being initialized twice: line 124/125 and line 140/141. I think only one set of initialization is required

Comment on lines +838 to +839
initArrays();
testVTVT(vtArraySrc, nullRestrictedVtArrayDst);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To properly test the interpreter and the JIT, these two lines need to run twice since a lot of JIT options include count=1. Running it once won't get testVTVT method compiled. And the result should be checked to make sure the array element data is copied correctly.

Maybe something like below

	@Test(priority=1)
	static public void testSystemArrayCopy27() throws Throwable {
		initArrays();
		testVTVT(vtArraySrc, nullRestrictedVtArrayDst);
		checkResults(vtArraySrc, nullRestrictedVtArrayDst);

		initArrays();
		testVTVT(vtArraySrc, nullRestrictedVtArrayDst);
		checkResults(vtArraySrc, nullRestrictedVtArrayDst);
	}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or use the attribute @Test(priority=1,invocationCount=2), if the test has the -Xjit:count=1,disableAsyncCompilation option specified.

Comment on lines +844 to +845
initArrays();
testVTVT(nullRestrictedVtArraySrc, vtArrayDst);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as the above

	@Test(priority=1)
	static public void testSystemArrayCopy28() throws Throwable {
		initArrays();
		testVTVT(nullRestrictedVtArraySrc, vtArrayDst);
		checkResults(nullRestrictedVtArraySrc, vtArrayDst);

		initArrays();
		testVTVT(nullRestrictedVtArraySrc, vtArrayDst);
		checkResults(nullRestrictedVtArraySrc, vtArrayDst);
	}

Comment on lines +850 to +851
initArraysToCopyNullToNullRestrictedArray();
testVTVT(vtArraySrc, nullRestrictedVtArrayDst);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To properly test the interpreter and the JIT, these two lines need to run twice. Maybe something like below

	@Test(priority=1)
	static public void testSystemArrayCopy29() throws Throwable {
		try { 
		   initArraysToCopyNullToNullRestrictedArray();
		   testVTVT(vtArraySrc, nullRestrictedVtArrayDst); // First time invoke the interpreter
		} catch (java.lang.ArrayStoreException ase1) {
			try {
		      initArraysToCopyNullToNullRestrictedArray();
		      testVTVT(vtArraySrc, nullRestrictedVtArrayDst); // Second time JIT'd method 
			} catch (java.lang.ArrayStoreException ase2) {
				// pass
				return;
			}
		}

		Assert.fail("Expect a ArrayStoreException. No exception or wrong kind of exception thrown");
	}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we sometimes adjust the @Test attribute to run the test method twice, so methods will be compiled the second time if the test is accompanied by the -Xjit:count=1,disableAsyncCompilation option.

@Test(priority=1,invocationCount=2)

Comment on lines 772 to 776
checkResults(vtArraySrc, nullRestrictedVtArrayDst);

initArrays();
testVTVT(vtArraySrc, nullRestrictedVtArrayDst);
checkResults(vtArraySrc, nullRestrictedVtArrayDst);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use Henry's suggestion, #20250 (comment) instead of copying/paste the code twice like I initially suggested?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment applies to testSystemArrayCopy28 and testSystemArrayCopy29 as well

Signed-off-by: Theresa Mammarella <Theresa.T.Mammarella@ibm.com>
@theresa-m theresa-m requested a review from a7ehuo October 3, 2024 17:59
@theresa-m theresa-m added comp:vm comp:test project:valhalla Used to track Project Valhalla related work labels Oct 3, 2024
Copy link
Contributor

@a7ehuo a7ehuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the update on the test file!

@hangshao0
Copy link
Contributor

Jenkins test sanity,extended zlinuxval jdknext

@hangshao0
Copy link
Contributor

Jenkins compile amac jdk23

@hangshao0
Copy link
Contributor

The sanity.openjdk failure is not related to this change.

@hangshao0 hangshao0 merged commit 08b63fa into eclipse-openj9:master Oct 4, 2024
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:test comp:vm project:valhalla Used to track Project Valhalla related work
Projects
None yet
4 participants