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

Value type null-restricted array support #19911

Merged
merged 3 commits into from
Sep 3, 2024

Conversation

theresa-m
Copy link
Contributor

@theresa-m theresa-m commented Jul 23, 2024

Please note this pull request adds support to create a null-restricted array but not a flattened array. That will come in a later change.

Related: #17340
Fixes: #19460

After these changes:

@theresa-m theresa-m added comp:vm project:valhalla Used to track Project Valhalla related work labels Jul 23, 2024
@theresa-m theresa-m force-pushed the nr_array branch 2 times, most recently from 9c741db to bf4b5b3 Compare July 23, 2024 20:38
@theresa-m theresa-m marked this pull request as ready for review July 24, 2024 13:35
@theresa-m theresa-m requested a review from hangshao0 July 24, 2024 13:35
runtime/j9vm/javanextvmi.cpp Outdated Show resolved Hide resolved
runtime/oti/j9nonbuilder.h Outdated Show resolved Hide resolved
runtime/vm/createramclass.cpp Outdated Show resolved Hide resolved
@hangshao0
Copy link
Contributor

Before continue reviewing this, I am wondering if it is easier to add an new function
internalCreateArrayClassWithOptions(J9VMThread* vmThread, J9ROMArrayClass* romClass, J9Class* elementClass, UDATA options) (The existing internalCreateArrayClass() becomes a special case that passed in options is 0) and call this function in JVM_NewNullRestrictedArray with a new option flag J9_FINDCLASS_FLAG_CLASS_OPTION_NULL_RESTRICTED_ARRAY indicating it is creating a null restricted array.

runtime/vm/createramclass.cpp Outdated Show resolved Hide resolved
runtime/vm/createramclass.cpp Outdated Show resolved Hide resolved
runtime/vm/createramclass.cpp Outdated Show resolved Hide resolved
runtime/vm/createramclass.cpp Outdated Show resolved Hide resolved
runtime/vm/createramclass.cpp Outdated Show resolved Hide resolved
runtime/vm/createramclass.cpp Outdated Show resolved Hide resolved
runtime/oti/j9nonbuilder.h Outdated Show resolved Hide resolved
@hangshao0
Copy link
Contributor

hangshao0 commented Jul 24, 2024

Before continue reviewing this, I am wondering if it is easier to add an new function
internalCreateArrayClassWithOptions(J9VMThread* vmThread, J9ROMArrayClass* romClass, J9Class* elementClass, UDATA options) (The existing internalCreateArrayClass() becomes a special case that passed in options is 0) and call this function in JVM_NewNullRestrictedArray with a new option flag J9_FINDCLASS_FLAG_CLASS_OPTION_NULL_RESTRICTED_ARRAY indicating it is creating a null restricted array.

The reason for this is to see if we can minimize the change in createramclass.cpp and do not need special handling of pushing/poping the protectionDomain and class loading stack. The nullable J9arrayClass and null restricted J9arrayClass can be created separately, one in each internalCreateArrayClass*() call.

@theresa-m
Copy link
Contributor Author

Before continue reviewing this, I am wondering if it is easier to add an new function
internalCreateArrayClassWithOptions(J9VMThread* vmThread, J9ROMArrayClass* romClass, J9Class* elementClass, UDATA options) (The existing internalCreateArrayClass() becomes a special case that passed in options is 0) and call this function in JVM_NewNullRestrictedArray with a new option flag J9_FINDCLASS_FLAG_CLASS_OPTION_NULL_RESTRICTED_ARRAY indicating it is creating a null restricted array.

The reason for this is to see if we can minimize the change in createramclass.cpp and do not need special handling of pushing/poping the protectionDomain and class loading stack. The nullable J9arrayClass and null restricted J9arrayClass can be created separately, one in each internalCreateArrayClass*() call.

I agree this approach may be cleaner, I'll give it a try and look over the review comments that are still applicable.

Copy link
Contributor

@ThanHenderson ThanHenderson left a comment

Choose a reason for hiding this comment

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

Just a few formatting comments.

runtime/j9vm/javanextvmi.cpp Outdated Show resolved Hide resolved
runtime/j9vm/javanextvmi.cpp Outdated Show resolved Hide resolved
runtime/vm/createramclass.cpp Show resolved Hide resolved
@hangshao0
Copy link
Contributor

The following GC code need to be updated, so that GC scan is able to find the new null restricted array class:

GC_ClassArrayClassSlotIterator::nextSlot()

GC_ClassLoaderClassesIterator::nextClass()

We provide helpers to JIT in cnathelper.cpp. I see functions there are still using J9_IS_J9CLASS_PRIMITIVE_VALUETYPE and throw NPE if null is stored to null restricted array. They need to be updated to check the null restricted array and throw ASE.
cnathelper.cpp can be changed in another PR, and you may not be able to update some of them without JIT changing there code to pass you the nullRestrictedArrayClass.

@theresa-m
Copy link
Contributor Author

theresa-m commented Aug 1, 2024

The JIT updates should be covered by #19913.
Discussed in slack, I will update cnathelper.cpp and check if the referenced issue can be closed.

I'll take a look at the GC code.

runtime/codert_vm/cnathelp.cpp Outdated Show resolved Hide resolved
runtime/codert_vm/cnathelp.cpp Outdated Show resolved Hide resolved
runtime/gc_structs/ClassArrayClassSlotIterator.cpp Outdated Show resolved Hide resolved
runtime/gc_structs/ClassArrayClassSlotIterator.cpp Outdated Show resolved Hide resolved
runtime/gc_structs/ClassLoaderClassesIterator.cpp Outdated Show resolved Hide resolved
@hangshao0 hangshao0 requested a review from dmitripivkine August 2, 2024 19:32
@hangshao0
Copy link
Contributor

@dmitripivkine I added you to review the GC change here.

The change here is to support value type which could have 2 types of arrays. One allows its element to be null, one does not allow its element to be null (null restricted array). A new field nullRestrictedArrayClass is added in J9Class. (Note nullRestrictedArrayClass can only be 1D array).

Copy link
Contributor

@keithc-ca keithc-ca left a comment

Choose a reason for hiding this comment

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

In the files changed by this pull request, there are still several occurrences of "null restricted" that should be "null-restricted".

Please also address the line-end check failure.

@theresa-m
Copy link
Contributor Author

In the files changed by this pull request, there are still several occurrences of "null restricted" that should be "null-restricted".

I think they have all been fixed in the code and commit messages. Which others are you seeing?

- create a null-restricted array field for every RAM class if one
 doesn't exist when a null-restricted array is created
- implement JVM_IsNullRestrictedArray and JVM_NewNullRestrictedArray
- Update exception thrown when null is set to a null-restricted array
 from NullPointerException to ArrayStoreException as described in
 https://openjdk.org/jeps/8316779

Signed-off-by: Theresa Mammarella <[email protected]>
@keithc-ca
Copy link
Contributor

Which others are you seeing

  • vm_api.h - lines 2715, 2719, 2823, etc.
  • BytecodeInterpreter.hpp - line 8585 and missing comma on line 8584
  • ValueTypeHelpers.hpp - lines 193, 197
  • ValueTypeTest.java - lines 196, 1804, 2262

@theresa-m
Copy link
Contributor Author

Which others are you seeing

  • vm_api.h - lines 2715, 2719, 2823, etc.
  • BytecodeInterpreter.hpp - line 8585 and missing comma on line 8584
  • ValueTypeHelpers.hpp - lines 193, 197
  • ValueTypeTest.java - lines 196, 1804, 2262

Do you mind if I do this as a separate pull requests? This is out of scope of the current change since none of those code sections are being modified.

@keithc-ca
Copy link
Contributor

do this as a separate pull request

That is fine with me, but, I'd like to see those changes ready to go, perhaps even before this is merged (so it does not get forgotten).

@theresa-m
Copy link
Contributor Author

Okay. I have fixed the remaining cases in #20085

@keithc-ca
Copy link
Contributor

Jenkins test sanity aarch64_linux_vt_standard,s390x_linux

@keithc-ca
Copy link
Contributor

Jenkins test sanity aarch64_linux_vt_standard,s390x_linux jdknext

@hangshao0
Copy link
Contributor

Jenkins test sanity,extended zlinuxval jdknext

@theresa-m
Copy link
Contributor Author

I'm looking at the test failures.

The purpose of this change is to keep value type
command line tests passing until they are updated
and the vm fully enables flattening of null-restricted
arrays.

Signed-off-by: Theresa Mammarella <[email protected]>
@theresa-m
Copy link
Contributor Author

theresa-m commented Aug 30, 2024

  1. For the sanity failures many of them seem to already exist. I ran sanity tests for a value types build on the master branch and similar failures occurred. https://hyc-runtimes-jenkins.swg-devops.com/view/OpenJ9%20-%20Personal/job/Pipeline-Build-Test-Personal/23714/
    I'm not sure where that started since the valhalla nightly builds don't run full sanity tests, I will need to do more testing.

  2. I pushed a second commit to fix the extended failures. The tests are currently written to use arrayClass so to keep them passing both arrayClass and nullRestrictedArrayClass can have the J9ClassIsFlattened set for now. The purpose of this pull request was to add support for null-restricted arrays without flattening support. I have a draft pull request Null-restricted array flattening and test fix up #19995 that will address flattening where I update the value type command line tests and will stop setting J9ClassIsFlattened for arrayClass.

failing pr build links so they aren't lost:
https://openj9-jenkins.osuosl.org/job/PullRequest-OpenJ9/5985/
https://openj9-jenkins.osuosl.org/job/Test_openjdknext_j9_sanity.functional_aarch64_linux_vt_standard_Personal/8/
https://openj9-jenkins.osuosl.org/job/Test_openjdknext_j9_sanity.functional_s390x_linux_Personal/62/
https://openj9-jenkins.osuosl.org/job/Test_openjdkValhalla_j9_extended.functional_s390x_linux_valhalla_Personal/27/
https://openj9-jenkins.osuosl.org/job/Test_openjdkValhalla_j9_sanity.functional_s390x_linux_valhalla_Personal/29/

@hangshao0
Copy link
Contributor

Jenkins test sanity,extended zlinuxval jdknext

@hangshao0
Copy link
Contributor

Jenkins compile amac jdknext

Signed-off-by: Theresa Mammarella <[email protected]>
@theresa-m
Copy link
Contributor Author

The failures in ValueTypeTestsJIT are related to 42393ff and array flattening. I have disabled them for now since there is more work to be done to flatten arrays in #19995

@hangshao0
Copy link
Contributor

Jenkins test sanity,extended zlinuxval jdknext

@hangshao0 hangshao0 merged commit c28eae6 into eclipse-openj9:master Sep 3, 2024
6 checks passed
@pshipton
Copy link
Member

pshipton commented Sep 4, 2024

I believe this is causing hangs in testing. I'll revert it while we investigate.

@pshipton
Copy link
Member

pshipton commented Sep 4, 2024

Reverted via #20109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:vm project:valhalla Used to track Project Valhalla related work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add implementation for new JNI functions in Valhalla
7 participants