Skip to content

Conversation

@stefank
Copy link
Member

@stefank stefank commented Apr 4, 2024

We have a few places that uses the terms KlassObj and klassOop when referring to Klasses. This is old code from before the PermGen removal, when Klasses also were Java objects.

These names tripped me up when I was reading the heap heapInspection.cpp and first though we were mixing the klass mirror objects and klass pointers in the hash code calculation:

   // An aligned reference address (typically the least
   // address in the perm gen) used for hashing klass
   // objects.
   HeapWord* _ref;
...
_ref = (HeapWord*) Universe::boolArrayKlassObj();
...
uint KlassInfoTable::hash(const Klass* p) {
  return (uint)(((uintptr_t)p - (uintptr_t)_ref) >> 2);
}

I propose that we rename these functions (and stop casting the Klass* to a (HeapWord*)).

Tested with serviceability/dcmd/gc/ClassHistogramTest.java but will run this through our lower tiers.


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-8329655: Cleanup KlassObj and klassOop names after the PermGen removal (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18618

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 4, 2024

👋 Welcome back stefank! 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

openjdk bot commented Apr 4, 2024

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

8329655: Cleanup KlassObj and klassOop names after the PermGen removal

Reviewed-by: rkennke, coleenp

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

  • 21867c9: 8313332: Simplify lazy jmethodID cache in InstanceKlass
  • b9da140: 8329594: G1: Consistent Titles to Thread Work Items.
  • a169c06: 8329580: Parallel: Remove VerifyObjectStartArray

Please see this link for an up-to-date comparison between the source branch of this pull request and 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 changed the title 8329655: Cleanup KlassObj and klassOop names after the PermGen removal 8329655: Cleanup KlassObj and klassOop names after the PermGen removal Apr 4, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 4, 2024
@openjdk
Copy link

openjdk bot commented Apr 4, 2024

@stefank The following labels will be automatically applied to this pull request:

  • graal
  • hotspot
  • serviceability

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

@openjdk openjdk bot added graal graal-dev@openjdk.org serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Apr 4, 2024
@mlbridge
Copy link

mlbridge bot commented Apr 4, 2024

Webrevs

Copy link
Contributor

@rkennke rkennke left a comment

Choose a reason for hiding this comment

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

This is a useful change, it has tripped me up a couple of times, too. Change mostly looks good, just a few minor suggestions.


ldrw(scan_temp, Address(recv_klass, Klass::vtable_length_offset()));

// %%% Could store the aligned, prescaled offset in the klassoop.
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated, but what's the point of the %%% in all those comments? Might want to remove that, while you're there.

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 it is an old-style TODO. I'm considering if we shouldn't just remove these comments. What do people think about that?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not even sure what they want to say, really. Should be good to remove, and if anybody can make sense of it, record an issue in the bug-tracker?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. I removed the %%%. I'll wait a little bit to see if someone else wants to keep them for some reason, if not, I'll remove them.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think leaving these comments without the %%% seems fine. Describing this idea in a CR is a lot more difficult than seeing it in context as commentary, and unless the enhancement has other motivation, it won't be picked up. Leaving the comment as a clue seems useful.

KlassInfoTable::KlassInfoTable(bool add_all_classes) {
_size_of_instances_in_words = 0;
_ref = (HeapWord*) Universe::boolArrayKlassObj();
_ref = (uintptr_t) Universe::boolArrayKlass();
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems weird (non-obvious) to cast to uintptr_t here. I see it is only used in KlassInfoTable::hash(), which is weird, too. I am not sure that this even does a useful hashing. Might be worth to get rid of the whole thing and use the fastHash stuff that @rose00 proposed for Lilliput. Perhaps in a follow-up. I'd probably either cast to void* or Klass*, or cast to uintptr_t as you did and remove the unnecessary cast in ::hash().

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 agree. I'll start by removing the redundant cast in ::hash().

Copy link
Contributor

@rkennke rkennke left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good to me, now.

Roman

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 4, 2024
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 is good. The Obj was confusing.


ldrw(scan_temp, Address(recv_klass, Klass::vtable_length_offset()));

// %%% Could store the aligned, prescaled offset in the klassoop.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think leaving these comments without the %%% seems fine. Describing this idea in a CR is a lot more difficult than seeing it in context as commentary, and unless the enhancement has other motivation, it won't be picked up. Leaving the comment as a clue seems useful.

size_t _size_of_instances_in_words;

// An aligned reference address (typically the least
// address in the perm gen) used for hashing klass
Copy link
Contributor

Choose a reason for hiding this comment

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

Rats I missed this.

@stefank
Copy link
Member Author

stefank commented Apr 5, 2024

Thanks for the reviews!
/integrate

@openjdk
Copy link

openjdk bot commented Apr 5, 2024

Going to push as commit 71d48bc.
Since your change was applied there have been 21 commits pushed to the master branch:

  • b71acc7: 8329089: Empty immutable list throws the wrong exception type for remove(first | last) operations
  • 1131bb7: 8329261: G1: interpreter post-barrier x86 code asserts index size of wrong buffer
  • 6bc6392: 8329201: C2: Replace TypeInterfaces::intersection_with() + eq() with contains()
  • 9da5170: 8327978: C2 SuperWord: Fix compilation time regression in dependency graph traversal after JDK-8325651
  • c1cfb43: 8329109: Threads::print_on() tries to print CPU time for terminated GC threads
  • 5860a48: 8329624: Add visitors for preview language features
  • 0b01144: 8329720: Gtest failure printing markword after JDK-8325303
  • 34f7974: 8325303: Replace markWord.is_neutral() with markWord.is_unlocked()
  • 27cfcef: 8329651: TestLibGraal.java crashes with assert(_stack_base != nullptr)
  • e1183ac: 8329703: Remove unused apple.jpeg file from SwingSet2 demo
  • ... and 11 more: https://git.openjdk.org/jdk/compare/8efd7aa6c1671fa7d40c5c43bed140a493cfcf72...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Apr 5, 2024

@stefank Pushed as commit 71d48bc.

💡 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

graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

3 participants