Skip to content

Conversation

@Arraying
Copy link
Member

@Arraying Arraying commented Nov 25, 2025

Hi all,

This removes the EnableValhalla in favour of the --enable-preview flag. Concretely:

  • I've replaced most of the EnableValhalla checks with Arguments::is_valhalla_enabled().
  • Some checks were redundant and could be removed entirely.
  • I've made the EnableValhalla flag obsolete.
  • Some tests had to be updated.

This greatly changes the semantics of tests. I've refined some test groups to make it easier.

Testing: tiers 1-4.


Progress

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

Issue

  • JDK-8371357: [lworld] Remove EnableValhalla (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1759

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1759.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 25, 2025

👋 Welcome back phubner! A progress list of the required criteria for merging this PR into lworld 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 Nov 25, 2025

@Arraying 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:

8371357: [lworld] Remove EnableValhalla

Reviewed-by: coleenp, stefank, dcubed

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 4 new commits pushed to the lworld 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.

➡️ To integrate this PR with the above commit message to the lworld branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title 8371357 8371357: [lworld] Remove EnableValhalla Nov 25, 2025
@Arraying Arraying force-pushed the JDK-8371357 branch 3 times, most recently from a44154d to d671584 Compare November 28, 2025 16:14
@openjdk
Copy link

openjdk bot commented Dec 11, 2025

@Arraying this pull request can not be integrated into lworld due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8371357
git fetch https://git.openjdk.org/valhalla.git lworld
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge lworld"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Dec 11, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Dec 11, 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.

Except for EnableValhalla legacy comments that I think should be removed, this looks reasonable on it's own. Does it pass our existing tier1-4 testing without updating problem lists ?

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Dec 12, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Dec 12, 2025
Copy link
Member

@stefank stefank left a comment

Choose a reason for hiding this comment

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

Not a full review, but I think this looks good. If this is accepted you'll have to add includes of arguments.hpp to all places where you have added a call to is_valhalla_enabled().

@mlbridge
Copy link

mlbridge bot commented Dec 12, 2025

Webrevs

@dholmes-ora
Copy link
Member

is_valhalla_enabled

As Ioi suggested in the mainline argument.hpp PR shouldn't this be something more specific to what is actually being enabled in this preview release e.g. valueTypesConfig.hpp which defines value_types_enabled or some such? IIUC for this release we are talking about JEP-401 features that are opted into when --enable-preview is added. But for the next release I assume there could be additional JEPs with 401 still also in preview - so is_valhalla_enabled is somewhat vague and doesn't identify what aspect of Valhalla a piece of code relates to.

@Arraying
Copy link
Member Author

is_valhalla_enabled

As Ioi suggested in the mainline argument.hpp PR shouldn't this be something more specific to what is actually being enabled in this preview release e.g. valueTypesConfig.hpp which defines value_types_enabled or some such? IIUC for this release we are talking about JEP-401 features that are opted into when --enable-preview is added. But for the next release I assume there could be additional JEPs with 401 still also in preview - so is_valhalla_enabled is somewhat vague and doesn't identify what aspect of Valhalla a piece of code relates to.

is_valhalla_enabled currently guards JEP 401 and JEP draft strict field init. It's supposed to be a drop-in replacement for --enable-preview such that when reading code, it becomes clear that this is a Valhalla-related feature (and not some special EP handling in e.g., AOT). I agree that this may become ambiguous if there are multiple Valhalla JEPs in preview that offer distinct language-level features. I am moving the function to its own config, I'll see what I can do.

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.

This seems fine to me with or without a one line include file for is_valhalla_enabled() to test Arguments::enable_preview() or any other change for future preview or valhalla related features. I think we can fix that for the specific situations when it happens.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 15, 2025
Copy link
Member

@stefank stefank left a comment

Choose a reason for hiding this comment

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

Looks good minus one nit.

Node* proto_adr = phase->transform(new AddPNode(klass_node, klass_node, phase->MakeConX(in_bytes(Klass::prototype_header_offset()))));
mark_node = LoadNode::make(*phase, control, mem, proto_adr, TypeRawPtr::BOTTOM, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
if (EnableValhalla) {
// EnavleValhalla legacy
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// EnavleValhalla legacy

Copy link
Member Author

Choose a reason for hiding this comment

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

Good shout, I missed that thanks.

@Arraying
Copy link
Member Author

Thanks for the feedback, everyone. After a face-to-face discussion, we decided this shape (without explicit feature granularity or its own file) is sufficient for our current needs. Sole --enable-preview for Valhalla is a large change that will be delivered incrementally. This is only the start, and many subsequent changes depend on this change. I've filed a follow-up RFE https://bugs.openjdk.org/browse/JDK-8373694, where we can devote more (non-blocking) time and discussion towards how a better way of checking may look. Ideally, @stefank's mainline changes will have made it into lworld by then too.

Copy link
Member

@dcubed-ojdk dcubed-ojdk left a comment

Choose a reason for hiding this comment

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

Generally looks good. I posted one comment where I think a logical expression is backwards.

Comment on lines -210 to -213
static bool is_valhalla_preview() {
return Arguments::enable_preview() && EnableValhalla;
}

Copy link
Member

Choose a reason for hiding this comment

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

Does this file still need to include arguments.hpp? I'm not seeing anymore calls into Arguments::foo.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, I'll get rid of it.

Comment on lines 176 to 175
bool _has_valhalla_patched_classes; // Is this archived dumped with --enable-preview -XX:+EnableValhalla?
bool _has_valhalla_patched_classes; // Is this archived dumped with --enable-preview
Copy link
Member

Choose a reason for hiding this comment

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

Nit: dropped the ? at the end of the comment.

Comment on lines 6147 to 6148
// Determining is the class allows tearing or not (default is not)
if (EnableValhalla && !_access_flags.is_identity_class()) {
if (Arguments::is_valhalla_enabled() && !_access_flags.is_identity_class()) {
Copy link
Member

Choose a reason for hiding this comment

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

Typo: L6147 (baseline): s/is the/if the/

// Given a type, return true if elements of that type must be aligned to 64-bit.
static bool element_type_should_be_aligned(BasicType type) {
if (EnableValhalla && type == T_FLAT_ELEMENT) {
if (type == T_FLAT_ELEMENT) {
Copy link
Member

Choose a reason for hiding this comment

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

You don't need EnableValhalla or Arguments::is_valhalla_enabled() as long as all callers
of element_type_should_be_aligned() only pass known valid BasicType values. If any caller
passes a non-valid BasicType value as part of a "probing call", then a call with a value that
happens to match T_FLAT_ELEMENT by a VM with Arguments::is_valhalla_enabled() == false
will return true unexpectedly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this should be fine because T_FLAT_ELEMENT is hardcoded to 15 regardless of if Valhalla/preview is enabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

Testing until tier 4 also shows no issue, so I think I'm confident enough to leave it as is. Unless someone from compiler has any insights?

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, a follow-up could add an assert in this branch that we are indeed running with value classes.

// instance state
static const int age_bits = 4;
// EnableValhalla: static prototype header bits (fast path instead of klass layout_helper)
// prototype header bits (fast path instead of klass layout_helper)
Copy link
Member

Choose a reason for hiding this comment

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

Why drop the word static in the comment here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Static prototypes were part of an older model that no longer exists.

Comment on lines 4009 to 4006
if (!EnableValhalla || (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces)) {
if (is_valhalla_enabled() || (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces)) {
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm... The original logic is !EnableValhalla so shouldn't this be: !is_valhalla_enabled()?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. Good spot!

@jsikstro
Copy link
Member

Now that we're not using EnableValhalla, which was in runtime/globals.hpp, there are several includes of runtime/globals.hpp which have been added over the years in the lworld branch that don't need to be added anymore.

I don't see an issue with including runtime/globals.hpp unnecessarily, just pointing it out.

@Arraying
Copy link
Member Author

Now that we're not using EnableValhalla, which was in runtime/globals.hpp, there are several includes of runtime/globals.hpp which have been added over the years in the lworld branch that don't need to be added anymore.

I don't see an issue with including runtime/globals.hpp unnecessarily, just pointing it out.

Good idea. I've added it to the follow up RFE where we are doing cleanups already.

@dcubed-ojdk
Copy link
Member

I re-reviewed the changes from v02 -> v05 and they look good.

Copy link
Member

@dcubed-ojdk dcubed-ojdk left a comment

Choose a reason for hiding this comment

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

Thumbs up.

@Arraying
Copy link
Member Author

Thanks all for the diligent feedback and reviews.
/integrate

@openjdk
Copy link

openjdk bot commented Dec 17, 2025

Going to push as commit 59a270d.
Since your change was applied there have been 7 commits pushed to the lworld branch:

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 17, 2025

@Arraying Pushed as commit 59a270d.

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

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

Labels

integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

6 participants