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

Make static final field folding more aggressive #19699

Merged
merged 4 commits into from
Jun 27, 2024

Conversation

jdmpapin
Copy link
Contributor

  • Add dontFoldStaticFinalFields={} JIT option
  • Add missing newline to an IL generator log message
  • Expand Java 17+ aggressive SFFF from VarHandle to all types
  • Fold primitive-typed static final fields more aggressively

This depends on eclipse/omr#7376

@jdmpapin jdmpapin added comp:jit depends:omr comp:jitserver Artifacts related to JIT-as-a-Service project project:MH Used to track Method Handles related work labels Jun 13, 2024
@jdmpapin jdmpapin requested a review from dsouzai as a code owner June 13, 2024 16:10
@jdmpapin jdmpapin requested review from vijaysun-omr and removed request for dsouzai June 18, 2024 16:39
@jdmpapin
Copy link
Contributor Author

@vijaysun-omr, would you mind reviewing?

@vijaysun-omr
Copy link
Contributor

@mpirvu since this includes some JIT server relevant changes

@vijaysun-omr
Copy link
Contributor

Jenkins test sanity.functional all jdk11,jdk17

@mpirvu mpirvu self-requested a review June 20, 2024 14:51
@jdmpapin
Copy link
Contributor Author

Builds failed because eclipse/omr#7376 hadn't (and still hasn't) promoted

This can be used to prevent constant folding a specified set of static
final fields for debugging purposes or as a workaround.

Whenever the JIT attempts to fold a static final field, if this option
is set, it checks whether the glob pattern ("simple regex") matches
<class>.<field>:<sig>, e.g.

    java/util/AraryList.EMPTY_ELEMENTDATA:[Ljava/lang/Object;

If it matches, then the static final field is not folded.
Starting in Java 17, it is no longer possible to remove the final
attribute of a field to make it writable via reflection, and in classes
with version 53 and later, putstatic can write to static final fields
only during class initialization.

With this justification, the JIT compiler has been treating static final
fields with declared type VarHandle as reliable for folding (if declared
in a suitable class).

But the justification applies regardless of the declared type of the
static final field, so with this commit, so too will the folding.
Whenever the compiler attempts to fold a static final field (that hasn't
been explicitly allowlisted somehow), it will now determine whether the
declaring class contains a putstatic instruction that could modify one
of its static final fields outside of <clinit>. The presence of such a
putstatic instruction prevents folding, but it should be extremely rare,
since javac doesn't generate any.

We can assume JCL classes won't attempt to store to static final fields
outside of <clinit>, and classes with class file version 53 or later
won't succeed even if they do attempt it. Other classes, i.e. non-JCL
classes with version 52 or earlier, will have their bytecode scanned.

If no putstatic instruction interferes, all primitive-typed static final
fields will now be folded without any runtime assumption. If the field
could potentially be modified later, e.g. using some reflection hack or
Unsafe, the compiled code is not required to see the new value. This is
also true of references, but due to limitations in the JIT's handling of
known objects, those still require runtime assumptions if there is any
possibility they will be modified later.

Later on, when it becomes possible to treat reference-typed static final
fields the same way, it should be possible to entirely eliminate guarded
static final field folding.
@jdmpapin
Copy link
Contributor Author

Updated to check for System before getting the name and signature and to override setAlreadyScannedForFinalPutstatic() in the client persistent class info

@vijaysun-omr
Copy link
Contributor

@mpirvu are you good with the changes Devin made ? If so, I will run tests again.

Copy link
Contributor

@mpirvu mpirvu left a comment

Choose a reason for hiding this comment

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

LGTM

@vijaysun-omr
Copy link
Contributor

Jenkins test sanity.functional all jdk11,jdk17

@jdmpapin
Copy link
Contributor Author

It looks like eclipse/omr#7376 still hadn't promoted when the PR builds were last restarted. But it has promoted by now, so I'll restart them again

Jenkins test sanity.functional all jdk11,jdk17

@jdmpapin
Copy link
Contributor Author

Still some checks in progress, but the finished ones have all succeeded. Adding the same tests but with JITServer

Jenkins test sanity plinuxjit,xlinuxjit jdk11,jdk17

@vijaysun-omr
Copy link
Contributor

Jenkins test sanity plinuxjit jdk11,jdk17

@vijaysun-omr
Copy link
Contributor

Jenkins test sanity xlinuxjit jdk17

@jdmpapin
Copy link
Contributor Author

jdmpapin commented Jun 27, 2024

Both of the aborted PPCLE builds just failed to run:

Still waiting to schedule task
All nodes of label ‘ci.role.build&&hw.arch.ppc64le&&sw.os.cent.7’ are offline
Cancelling nested steps due to timeout

In the console output, ci.role.build&&... links to a list, and it appears that there are now matching nodes online

Jenkins test sanity plinuxjit jdk11,jdk17

@jdmpapin
Copy link
Contributor Author

jdmpapin commented Jun 27, 2024

Same problem. I see now that there's an ongoing problem with the PPC64LE server, and Linux PPC64LE seems to have been excluded from "all" - here the only builds on that platform are the ones that were explicitly launched for plinuxjit

At this point we could run zlinuxjit, or we could say that xlinuxjit was enough testing for JITServer

@mpirvu
Copy link
Contributor

mpirvu commented Jun 27, 2024

I think that xlinuxjit is sufficient

@vijaysun-omr
Copy link
Contributor

Merging based on the comments above. Reviews were done some days back.

@vijaysun-omr vijaysun-omr merged commit 22eaa4d into eclipse-openj9:master Jun 27, 2024
34 of 37 checks passed
@pshipton
Copy link
Member

There are no available plinux machines to build on, and no outlook for getting any. You'll need to run an internal build for this platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:jit comp:jitserver Artifacts related to JIT-as-a-Service project depends:omr project:MH Used to track Method Handles related work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants