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

Null-restricted checks for jitCheckCastForArrayStore #20331

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theresa-m
Copy link
Contributor

Related to #20184 and #18157

fyi @a7ehuo this is what I was thinking for jitCheckCastForArrayStore if the jit can pass in the array class rather than the base class.

@theresa-m theresa-m added comp:vm project:valhalla Used to track Project Valhalla related work labels Oct 11, 2024
@@ -1490,17 +1490,19 @@ old_fast_jitCheckCastForArrayStore(J9VMThread *currentThread)
{
void *slowPath = NULL;
OLD_JIT_HELPER_PROLOGUE(2);
DECLARE_JIT_CLASS_PARM(castClass, 1);
DECLARE_JIT_CLASS_PARM(castClassArray, 1); // <-- castClassArray should be the array class, not its base class
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering when VT is not enabled, it should still be checking the component class but if VT is enabled, it will check the array class. I don't have a strong preference either way. @hzongaro What do you think?

jitCheckCastForArrayStore is currently only used at one place in EA fixupFieldAccessForNonContiguousAllocation. If checking array class here regardless of if VT is enabled or not, it will require a coordinated merge with the JIT change so that it doesn't break the functionality for non-VT build. But the change here is cleaner without having to consider if VT is enabled or not.

Copy link
Member

Choose a reason for hiding this comment

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

@a7ehuo - Good catch! Escape Analysis is using the class that was specified on an anewarray operation, so it will need to get the corresponding array class instead. And in order for EA to stack allocate non-nullable arrays, it will need to recognize calls to ValueClass.newArrayInstance(NullRestrictedCheckedType.of(myself),...).

I'll take a look at implementing those changes. . . .

Copy link
Member

@hzongaro hzongaro left a comment

Choose a reason for hiding this comment

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

Just spotted a few things you almost certainly would have uncovered once you were able to run testing on these changes. . . .

runtime/codert_vm/cnathelp.cpp Outdated Show resolved Hide resolved
runtime/codert_vm/cnathelp.cpp Outdated Show resolved Hide resolved
runtime/codert_vm/cnathelp.cpp Outdated Show resolved Hide resolved
runtime/codert_vm/cnathelp.cpp Outdated Show resolved Hide resolved
@hzongaro
Copy link
Member

@theresa-m, I have prototyped the changes to Escape Analysis that would be required for your changes to jitCheckCastForArrayStore if you would like to try them together. You can cherry-pick this commit from my repository: hzongaro@5da68f8

@theresa-m
Copy link
Contributor Author

theresa-m commented Oct 23, 2024

Thanks @hzongaro ! It won't be possible to fully test this until #19764 is in place. I will try it out and at least make sure nothing new is failing.

edit: Valhalla sanity tests are passing with this and Henry's change.

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.

4 participants