-
Notifications
You must be signed in to change notification settings - Fork 38
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
8345836: stable annotation documentation is incomplete #26
Conversation
👋 Welcome back jrose! A progress list of the required criteria for merging this PR into |
@rose00 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:
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 5 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
To avoid this situation, create a new branch for your changes and reset the
Then proceed to create a new pull request with |
Webrevs
|
Mailing list message from Alex Buckley on leyden-dev: Hi John, a few comments.
Saying "at most once" suggests that changing the value zero times is A+
(The phrase "stables values" should be "stable variables"; later, the I got a sense here that stable variables are the fundamental construct,
It's a little hard to figure out if "behavior" refers to the constant Alex On 12/9/2024 3:58 PM, John R Rose wrote: |
src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java
Outdated
Show resolved
Hide resolved
It might be worth mentioning that primitive types could be held in a wrapper class (rather than as a primitive value) if the default values are important to capture and constant-fold. Another thing that we could talk about when it comes to stable variables initialized outside |
src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java
Outdated
Show resolved
Hide resolved
* (the second value of the field) is used as the value of the field even after | ||
* the field value has changed (to a third value). | ||
* After constant folding, the compiler can make use of may aspects of | ||
* the object: Its dynamic type, its length (if it is an array), and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Its" -> "its". (no capital I needed)
src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java
Outdated
Show resolved
Hide resolved
Mailing list message from Alex Buckley on leyden-dev: Re: "A stable variable may be assigned its final value inside a class or "For example, declaring two stable fields of type {@code int} and {@code Before "As an extended behavior," please insert a heading "Array-typed Before "As very simple example", please insert a heading "Constant Before "Fields which are declared {@code final}", please insert a Please consider adding further headings. Alex On 12/11/2024 1:36 PM, John R Rose wrote: |
@rose00 Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
For easier review, here is a rendered version of the most recent changes. |
Mailing list message from Alex Buckley on leyden-dev: First paragraph: Both "initial default value" and "default initial value" appear, and I "its initial default (null or zero) value" "When the first value is stored into the field (assuming it is not a "Or is the user waiting until later to assign another value to the "The VM does not systematically record stores of a default null (or In the Example section: - The phrase "stable value" has crept in. - Is a _value_ constant-foldable? Or a _variable_? I think the latter. - The "As a very simple example ..." paragraph is weird, coming after so - The final paragraph about "mutually exclusive" and "never be part of Alex On 12/12/2024 1:03 AM, John R Rose wrote: |
@rose00 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
* to assume that no more significant changes will occur. This in | ||
* turn enables the VM to optimize uses of the stable variable, treating | ||
* them as constant values. This behavior is a useful building block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This in turn enables the VM to optimize uses of the stable variable, treating them as constant values.
A mistake I often see people make, is thinking that @Stable
will always allow the JIT to directly use the value of an instance field. But, this of course depends on the instance holding the field being a constant as well. I feel like this could be stated more explicitly in this text.
Maybe something along the lines of: An instance field load operation has as input an object instance, and as output the value of a particular field. There are two requirements for constant folding such a load operation: 1) the object instance is a constant. 2) the field's value will not change in the future. The @Stable
annotation influences only the second condition. It is the responsibility of the user of this annotation to make sure that a load operation on a field annotated with @Stable
has a constant object instance as input, if constant folding of the load operation is desired as a result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
The javadoc for jdk.internal.vm.annotation.Stable is incomplete.
The existing documentation gives an over-simple user model,
and does not explain how it is implemented.
Proposed new documentation will detail how the annotation
is implemented, and how it may be used correctly.
The improved documentation will makes it easier for JDK programmers
to use the annotation more aggressively, and more confidently.
This is a first cut. Please comment…
Progress
Warning
8345836: stable annotation documentation is incomplete
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/leyden.git pull/26/head:pull/26
$ git checkout pull/26
Update a local copy of the PR:
$ git checkout pull/26
$ git pull https://git.openjdk.org/leyden.git pull/26/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26
View PR using the GUI difftool:
$ git pr show -t 26
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/leyden/pull/26.diff
Using Webrev
Link to Webrev Comment