Skip to content

Conversation

@fandreuz
Copy link
Contributor

@fandreuz fandreuz commented Sep 16, 2025

#23782 (JDK-8315488) removed several vmStructs fields. A small subset was used in Async-Profiler:

CiEnv* _env
CompileTask* _task
ciMethod* _method

I propose a small patch to bring them back. It helps third-party tools in building useful features on the JDK. For example, Async-Profiler uses these fields to display the current method being compiled in a compiler thread.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8367689: Revert removal of several compilation-related vmStructs fields (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27318/head:pull/27318
$ git checkout pull/27318

Update a local copy of the PR:
$ git checkout pull/27318
$ git pull https://git.openjdk.org/jdk.git pull/27318/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27318

View PR using the GUI difftool:
$ git pr show -t 27318

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27318.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 16, 2025

👋 Welcome back fandreuzzi! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 16, 2025

@fandreuz This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8367689: Revert removal of several compilation-related vmStructs fields

Reviewed-by: kevinw, coleenp

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 37 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@coleenp, @kevinjwalls) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk
Copy link

openjdk bot commented Sep 16, 2025

@fandreuz The following labels will be automatically applied to this pull request:

  • graal
  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org rfr Pull request is ready for review labels Sep 16, 2025
@mlbridge
Copy link

mlbridge bot commented Sep 16, 2025

Webrevs

@fandreuz fandreuz marked this pull request as draft September 16, 2025 18:45
@openjdk openjdk bot removed the rfr Pull request is ready for review label Sep 16, 2025
\
nonstatic_field(CompilerThread, _env, ciEnv*) \
nonstatic_field(ciEnv, _task, CompileTask*) \
c2_nonstatic_field(Compile, _method, ciMethod*) \
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be really easy for someone to notice that these aren't used and delete them again, and it's unfortunate that this macro has to be propagated throughout all the vmStructs macros. I can see some external tool needing CompilerThread env and ciEnv task (the current compile task) but maybe this can not need Compile::_method?

Instead of adding the c2 macros, can you change the code to have:

COMPILER2_PRESENT(nontstatic_field(Compile, _method, ciMethod*))
COMPILER2_PRESENT(declare_toplevel_type(Compile))
etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment that these fields are needed.

Copy link
Contributor Author

@fandreuz fandreuz Sep 16, 2025

Choose a reason for hiding this comment

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

I can see some external tool needing CompilerThread env and ciEnv task (the current compile task) but maybe this can not need Compile::_method?

This is how we use Compile::_method in Async-Profiler:

VMMethod* compiledMethod() {
    const char* env = *(const char**) at(_comp_env_offset);
    if (env != NULL) {
        const char* task = *(const char**) (env + _comp_task_offset);
        if (task != NULL) {
            return *(VMMethod**) (task + _comp_method_offset);
        }
    }
    return NULL;
}

so we can get a jmethodID to the method being compiled. That's the only use case we have for these fields.

Copy link

Choose a reason for hiding this comment

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

@coleenp Good catch, thanks. Compile::_method is redundant, indeed. CompileTask::_method is what async-profiler needs, but it's still in place.
@fandreuz I think this PR can do without platform-dependent changes.

For the context, it's this feature that embeds method name of the current compile task right in the C1/C2 stack traces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks. Compile::_method is redundant,

I see, thanks! 3a263b3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this PR can do without platform-dependent changes.

Right, many things turned out to be unnecessary. Thanks

@fandreuz fandreuz marked this pull request as ready for review September 16, 2025 22:19
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 16, 2025
Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

Oh that is much better! Thanks.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 16, 2025
@fandreuz
Copy link
Contributor Author

static_field(VMRegImpl, stack0, VMReg) \
\
/**************/ \
/* CI (NOTE: these fields should not be removed, they can be used by external tools) */ \
Copy link
Member

Choose a reason for hiding this comment

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

Can you also clarify what "external tools" are in the comment so that when/if those external tools stop using them, we can re-evaluate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean I should explicitly mention Async-Profiler?

@kevinjwalls
Copy link
Contributor

kevinjwalls commented Sep 17, 2025

We should clarify:
These fields are not a public interface, but the JVM has to maintain them due to other software's expectations?

Async-Profiler is great, but is this change the right solution? Are there other fields which other software would have liked to stay around, and what else can not be removed?

Curious how did Async-Profiler break when these are removed? Is it a crash that Async-Profiler needs to workaround, or is there less information in the collected profile.

@apangin
Copy link

apangin commented Sep 17, 2025

@kevinjwalls Right, VMStructs is not a public supported interface, the JVM is not obliged to maintain it. Yet, some external tools (async-profiler and eBPF based profilers) softly rely on that in the lack of standard supported alternatives. At the same time, we are improving OpenJDK built-in capabilities that can eventually serve as such an alternative. A recent example is JEP 509: JFR CPU-Time Profiling. It's still a long path until JFR or other built-in tools can satisfy today's demand; in the meantime, VMStructs provides a temporary solution.

VMStructs is a reasonable trade-off, very cheap from the maintenance perspective as opposed to AsyncGetCallTrace (async-profiler no longer depends on the latter). To emphasize, we do not expect others to maintain VM structures that async-profiler relies on, that is our (profiler + Corretto) responsibility. Infrequent changes will be small, localized and safe, like in this PR.

As for the question how async-profiler breaks: if it is an optional feature (like here), it gracefully reduces functionality. Async-profiler attempts to detect essential VM changes and fail fast to prevent from crashing at runtime.

@kevinjwalls
Copy link
Contributor

Thanks @apangin Andrei

I thought we should be open and explicit about this, good to have that exchange in the review. Async-Profiler knew what it was getting into. 8-)

In the comment being added above, what is it appropriate to say...

Saying "should not removed... they can be used by external tools" as an instruction seems like an overreach. Maybe more like:

"These CI fields are retained in VMStructs for the benefit of external tools, to ease their migration to a future alternative."

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Sep 17, 2025
/* CI (NOTE: these CI fields are retained in VMStructs for the benefit of external tools, */ \
/* to ease their migration to a future alternative. */ \
/******************************************************************************************/ \
\
Copy link
Contributor

Choose a reason for hiding this comment

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

oops just a missing close ), but yes other than that I think we're done 8-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed in d7c4db0

Copy link
Contributor

@kevinjwalls kevinjwalls left a comment

Choose a reason for hiding this comment

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

OK, thanks!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 18, 2025
@fandreuz
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Sep 18, 2025
@openjdk
Copy link

openjdk bot commented Sep 18, 2025

@fandreuz
Your change (at version d7c4db0) is now ready to be sponsored by a Committer.

@kevinjwalls
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Sep 18, 2025

Going to push as commit 4c5e901.
Since your change was applied there have been 37 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 18, 2025
@openjdk openjdk bot closed this Sep 18, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Sep 18, 2025
@openjdk
Copy link

openjdk bot commented Sep 18, 2025

@kevinjwalls @fandreuz Pushed as commit 4c5e901.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@fandreuz
Copy link
Contributor Author

/backport jdk25u

@openjdk
Copy link

openjdk bot commented Sep 18, 2025

@fandreuz the backport was successfully created on the branch backport-fandreuz-4c5e901c-master in my personal fork of openjdk/jdk25u. To create a pull request with this backport targeting openjdk/jdk25u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 4c5e901c from the openjdk/jdk repository.

The commit being backported was authored by Francesco Andreuzzi on 18 Sep 2025 and was reviewed by Kevin Walls and Coleen Phillimore.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk25u:

$ git fetch https://github.com/openjdk-bots/jdk25u.git backport-fandreuz-4c5e901c-master:backport-fandreuz-4c5e901c-master
$ git checkout backport-fandreuz-4c5e901c-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk25u.git backport-fandreuz-4c5e901c-master

⚠️ @fandreuz You are not yet a collaborator in my fork openjdk-bots/jdk25u. An invite will be sent out and you need to accept it before you can proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

5 participants