Skip to content
This repository has been archived by the owner. It is now read-only.

JDK-8225667: Clarify the behavior of System::gc w.r.t. reference processing #183

Closed
wants to merge 2 commits into from

Conversation

mlchung
Copy link
Member

@mlchung mlchung commented Jun 30, 2021

This spec clarification is a follow-up to JDK-8224760 w.r.t. reference processing. Since there is no guarantee for any memory reclamation by the invocation of System::gc, the spec should also clarify that there is no guarantee in determining the change of reachability of any objects or any particular number of Reference objects be enqueued and cleared.

CSR:
https://bugs.openjdk.java.net/browse/JDK-8269690


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8225667: Clarify the behavior of System::gc w.r.t. reference processing

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk17 pull/183/head:pull/183
$ git checkout pull/183

Update a local copy of the PR:
$ git checkout pull/183
$ git pull https://git.openjdk.java.net/jdk17 pull/183/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 183

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk17/pull/183.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 30, 2021

👋 Welcome back mchung! 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 openjdk bot added the rfr label Jun 30, 2021
@openjdk
Copy link

openjdk bot commented Jun 30, 2021

@mlchung 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 core-libs label Jun 30, 2021
@mlbridge
Copy link

mlbridge bot commented Jun 30, 2021

Webrevs

@openjdk
Copy link

openjdk bot commented Jun 30, 2021

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

8225667: Clarify the behavior of System::gc w.r.t. reference processing

Reviewed-by: rriggs, kbarrett, tschatzl

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 15 new commits pushed to the master branch:

  • 54dd510: 8269704: Typo in j.t.Normalizer.normalize()
  • a8385fe: 8269354: javac crashes when processing parenthesized pattern in instanceof
  • c16d1fc: 8269285: Crash/miscompile in CallGenerator::for_method_handle_inline after JDK-8191998
  • ad27d9b: 8269088: C2 fails with assert(!n->is_Store() && !n->is_LoadStore()) failed: no node with a side effect
  • c67a7b0: 8269230: C2: main loop in micro benchmark never executed
  • 962f1c1: 8262886: javadoc generates broken links with {@inheritdoc}
  • f7ffd58: 8267602: [macos] [lanai] java/awt/PrintJob/Text/stringwidth.sh doesn't exit on cancelling print dialog
  • 4930ae9: 8268592: JDK-8262891 causes an NPE in Lint.augment
  • 9ac63a6: 8262841: Clarify the behavior of PhantomReference::refersTo
  • aba6c55: 8269703: ProblemList vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/TestDescription.java on Windows-X64 with -Xcomp
  • ... and 5 more: https://git.openjdk.java.net/jdk17/compare/be0ac92e186c7b2845e251ce56204a2378f76976...master

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 ready label Jun 30, 2021
src/java.base/share/classes/java/lang/Runtime.java Outdated Show resolved Hide resolved
src/java.base/share/classes/java/lang/System.java Outdated Show resolved Hide resolved
Copy link
Contributor

@kimbarrett kimbarrett left a comment

Looks good.

* There is also no guarantee that this effort will determine
* the change of reachability in any particular number of objects,
* or that any particular number of {@link java.lang.ref.Reference Reference}
* objects will be cleared and enqueued.
* <p>
Copy link
Contributor

@plevart plevart Jul 2, 2021

Choose a reason for hiding this comment

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

Hi Mandy,
I'm not a native speaker so this might be wrong thinking: The word "determine" feels to me like saying "cause". But running System.gc never actually causes the change of reachability (well it does, when the Reference object is cleared, the reachability of referent changes from Weakly/Softly/Phantom-reachable to unreachable, but I don't think you had that in mind. Or did you?). What would you say about using word "detect" instead? Please others, do say if my thinking is wrong...

Copy link
Contributor

@plevart plevart Jul 2, 2021

Choose a reason for hiding this comment

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

Well, "determine" seems to have both meanings:
https://www.google.com/search?q=determine
So by the 2nd meaning, it is good.

Copy link
Contributor

@plevart plevart Jul 2, 2021

Choose a reason for hiding this comment

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

... and considering the "Schrödinger's cat", even the 1st interpretation is correct. You can't know whether the cat is dead or not until you "determine" it's death. This does not mean that you killed it though.

Copy link
Member Author

@mlchung mlchung Jul 2, 2021

Choose a reason for hiding this comment

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

I think "determine" sounds right to me. "detect" is another possibility but does not apply well in "this effort" as the subject. This is another way to explain it.

During the execution, there are a number of reachability decision points. At each reachability decision point, the references are checked. GC determines if the reachability of the referent has changed to the value corresponding to the type of the reference (softly weakly, or phantom reachable), then it clears and enqueues the reference.

@mlchung
Copy link
Member Author

mlchung commented Jul 6, 2021

/integrate

@openjdk
Copy link

openjdk bot commented Jul 6, 2021

Going to push as commit 3a69024.
Since your change was applied there have been 33 commits pushed to the master branch:

  • 2b20778: 8269568: JVM crashes when running VectorMask query tests
  • 0f4e07b: 8269661: JNI_GetStringCritical does not lock char array
  • df1364b: 8269575: C2: assert(false) failed: graph should be schedulable after JDK-8252372
  • 6d8fc72: 8268883: C2: assert(false) failed: unscheduable graph
  • 4ad8b04: 8268369: SIGSEGV in PhaseCFG::implicit_null_check due to missing null check
  • 5b8e1a2: 8266595: jdk/jfr/jcmd/TestJcmdDump.java with slowdebug bits fails with AttachNotSupportedException
  • e14801c: 8269668: [aarch64] java.library.path not including /usr/lib64
  • 97e0e9e: 8268775: Password is being converted to String in AccessibleJPasswordField
  • 1c18f91: 8269768: JFR Terminology Refresh
  • 6f0e8e7: 8269775: compiler/codegen/ClearArrayTest.java failed with "assert(false) failed: bad AD file"
  • ... and 23 more: https://git.openjdk.java.net/jdk17/compare/be0ac92e186c7b2845e251ce56204a2378f76976...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jul 6, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jul 6, 2021
@openjdk
Copy link

openjdk bot commented Jul 6, 2021

@mlchung Pushed as commit 3a69024.

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core-libs integrated
5 participants