Skip to content

Conversation

@fparain
Copy link
Collaborator

@fparain fparain commented Nov 18, 2025

Add some helper methods to test properties of layouts in a more reliable way.

Tested with Mach5, tier 1 to 3.

Fred


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-8371915: [lworld] LayoutKind enum should have helper methods (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1745

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 18, 2025

👋 Welcome back fparain! 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 18, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 18, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 18, 2025

Webrevs

props = (ArrayKlass::ArrayProperties)(ArrayKlass::ArrayProperties::NULL_RESTRICTED | ArrayKlass::ArrayProperties::NON_ATOMIC);
break;
case LayoutKind::NULLABLE_ATOMIC_FLAT:
props = ArrayKlass::ArrayProperties::NON_ATOMIC;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does NULLABLE_ATOMIC_FLAT produce NON_ATOMIC? Something, maybe just naming?, seems off here.

I know this is a refactoring of existing code and so has the same meaning but it doesn't make sense to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch!
I've copied/pasted this code when refactoring without verifying it.
It doesn't make sense to me either.
For LayoutKind::NULLABLE_ATOMIC_FLAT the method should return ArrayKlass::ArrayProperties::DEFAULT.
Let me fix this and run some tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No issue detected by testing.

public:
enum ArrayProperties : uint32_t {
DEFAULT = 0,
DEFAULT = 0, // NULLABLE and ATOMIC
Copy link
Contributor

Choose a reason for hiding this comment

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

Does DEFAULT also apply to arrays of oops? The name "DEFAULT" is slightly concerning if we're only talking about non-oop cases. I'd be tempted to call this NULLABLE_ATOMIC rather than DEFAULT

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

An array of oops (non-flat array) can be either DEFAULT or NULL_RESTRICTED.
DEFAULT is far from a perfect name, but it tries to reflect the fact that it is the semantic properties of arrays users get by default when creating an array, without using any special array creation API.

Copy link
Contributor

@DanHeidinga DanHeidinga 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

UNKNOWN = 5 // used for uninitialized fields of type LayoutKind
};

class LayoutKindHelper : AllStatic {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this would be nicer if LayoutKind was a class and these helpers were in that class and encapsulate the whole thing in LayoutKind, so the accessors could be lk->is_flat(), etc? less characters. The enum inside LayoutKind could be referenced as LayoutKind::Kind::REFERENCE if direct references to the value is needed. Other enum class types in the VM are used that way (like AccessFlags). Then also it wouldn't need a helper.

Copy link
Contributor

Choose a reason for hiding this comment

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

It might not be a good idea based on all the places that we read the LayoutKind enum values, in which case, never mind.

}
return props;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good refactoring. nit: I think the coding style has the break indented with the props = lines.

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

Labels

rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants