Skip to content

8380764: Vector classes should have @ValueBased#30392

Closed
YaSuenag wants to merge 2 commits into
openjdk:masterfrom
YaSuenag:vector-valuebased
Closed

8380764: Vector classes should have @ValueBased#30392
YaSuenag wants to merge 2 commits into
openjdk:masterfrom
YaSuenag:vector-valuebased

Conversation

@YaSuenag
Copy link
Copy Markdown
Member

@YaSuenag YaSuenag commented Mar 24, 2026

According to Javadoc of jdk.incubator.vector.Vector, vector classes are declared as value based class. However all vector classes (e.g. IntVector256) do not have @jdk.internal.ValueBased, so DiagnoseSyncOnValueBasedClasses does not affect if vector object are used as a monitor.

This PR fixes all of final classes of vector, but most of files were generated by gen-src.sh. Essense of this PR is a chenge for X-VectorBits.java.template.
After this change, we can see following logs if -XX:DiagnoseSyncOnValueBasedClasses is set and vector class is used as monitor object.

$ java --add-modules jdk.incubator.vector -XX:DiagnoseSyncOnValueBasedClasses=2  ValueBaseLock
WARNING: Using incubator modules: jdk.incubator.vector
[0.453s][info][valuebasedclasses] Synchronizing on object 0x00000000823b1258 of klass jdk.incubator.vector.IntVector256
[0.453s][info][valuebasedclasses]       at ValueBaseLock.run(ValueBaseLock.java:9)
[0.453s][info][valuebasedclasses]       - locked <0x00000000823b1258> (a jdk.incubator.vector.IntVector256)
[0.453s][info][valuebasedclasses]       at java.lang.Thread.runWith(java.base@27-internal/Thread.java:1540)
[0.453s][info][valuebasedclasses]       at java.lang.Thread.run(java.base@27-internal/Thread.java:1527)

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-8380764: Vector classes should have @ValueBased (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30392

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Mar 24, 2026

👋 Welcome back ysuenaga! 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
Copy Markdown

openjdk Bot commented Mar 24, 2026

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

8380764: Vector classes should have @ValueBased

Reviewed-by: liach

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 24 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.

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

@openjdk openjdk Bot added the core-libs core-libs-dev@openjdk.org label Mar 24, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Mar 24, 2026

@YaSuenag The following label will be automatically applied to this pull request:

  • core-libs

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

@openjdk openjdk Bot added the rfr Pull request is ready for review label Mar 24, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented Mar 24, 2026

Webrevs

@liach
Copy link
Copy Markdown
Member

liach commented Mar 24, 2026

Re-@ValueBased:

  1. We need such an excerpt in every immediately annotated classes:
 * <p>This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
 * class; programmers should treat instances that are
 * {@linkplain #equals(Object) equal} as interchangeable and should not
 * use instances for synchronization, or unpredictable behavior may
 * occur. For example, in a future release, synchronization may fail.
  1. VectorMask and VectorShuffle should be marked so too.

@YaSuenag
Copy link
Copy Markdown
Member Author

VectorMask and VectorShuffle should be marked so too.

Good catch! I added @ValueBased to all of VectorMask and VectorShuffle implementations, and re-run gen-src.sh.

We need such an excerpt in every immediately annotated classes:

Indeed.
AFAICS following classes (or their final implementations) should have @ValueBased. Most of classes are FFM related classes, but I haven't yet find out what should be treated.

java.base/share/classes/java/lang/foreign/AddressLayout.java
java.base/share/classes/java/lang/foreign/FunctionDescriptor.java
java.base/share/classes/java/lang/foreign/GroupLayout.java
java.base/share/classes/java/lang/foreign/MemoryLayout.java
java.base/share/classes/java/lang/foreign/PaddingLayout.java
java.base/share/classes/java/lang/foreign/SequenceLayout.java
java.base/share/classes/java/lang/foreign/StructLayout.java
java.base/share/classes/java/lang/foreign/UnionLayout.java
java.base/share/classes/java/lang/foreign/ValueLayout.java
java.base/share/classes/java/lang/foreign/MemorySegment.java
java.base/share/classes/java/lang/foreign/Linker.java
java.base/share/classes/java/util/HexFormat.java
java.base/share/classes/jdk/internal/foreign/FunctionDescriptorImpl.java
java.base/share/classes/jdk/internal/foreign/layout/ValueLayouts.java

Copy link
Copy Markdown
Member

@liach liach left a comment

Choose a reason for hiding this comment

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

Looks reasonable. For ffm layouts and hex format, please create one jbs issue for each VBC addition.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Mar 25, 2026
@YaSuenag
Copy link
Copy Markdown
Member Author

@liach Thanks for your review!
I filed JDK-8380955 ( #30443 ) for FFM, and JDK-8380956 ( #30444 ) for HexFormat. I hope they could have the review.

/integrate

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Mar 26, 2026

Going to push as commit 960161d.
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 Mar 26, 2026
@openjdk openjdk Bot closed this Mar 26, 2026
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 26, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Mar 26, 2026

@YaSuenag Pushed as commit 960161d.

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

@YaSuenag YaSuenag deleted the vector-valuebased branch March 26, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

2 participants