8346609: Improve MemorySegment.toString#22826
8346609: Improve MemorySegment.toString#22826minborg wants to merge 8 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back pminborg! A progress list of the required criteria for merging this PR into |
|
@minborg 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 6 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 |
Webrevs
|
JornVernee
left a comment
There was a problem hiding this comment.
I'm not sure if all this information is useful to have in the toString output. I'll note that all of this information is publicly accessible through the MermorySegment interface aswell, so could be printed with additional print statements. Except for confined-ness, which is exposed through isAccessibleBy instead, since confined-ness is not a property of memory segments, but of arenas (and I don't think we should expose it directly like this).
Subjectively, I think the things that are reasonable to expose in the toString output are the things that are already exposed today: the heap base, address/offset, and size. I would find it reasonable to add isAlive=true/false to that, but it's not a property of the MS itself, but of the scope that it is attached to, so I'm not sure. But, read-only, and mapped are things I don't think are relevant often enough to include.
If you want a complete overview of the properties of the object, I think what you really want is a debugger :)
And even for liveness, the fact that this info could be updated concurrently makes it a bit hard to capture in the toString output - e.g. "was alive when printed" :-) |
| return "MemorySegment{ " + | ||
| heapBase().map(hb -> "heapBase: " + hb + ", ").orElse("") + | ||
| "address: " + Utils.toHexString(address()) + | ||
| heapBase().map(hb -> "heapBase: " + hb).orElse(isMapped() ? "mapped" : "native") + |
There was a problem hiding this comment.
This is not correct. Heap base can be empty for read-only segments.
Have we considered printing one of:
- HeapMemorySegment
- NativeMemorySegment
- MappedMemorySegment
E.g. add the heap/native/mapped as part of the "class" qualifier, before the { ? That seems more readable (of course the drawback is that it might suggest that these classes exist somewhere, which they don't.
A possible compromise would be:
MemorySegment{ kind: heap/native/mapped, [heapBase: xyz ], address: xyz, size: xyz}
This is consistent with the terminology found in the javadoc:
There are two kinds of memory segments: ...
| return "MemorySegment{ " + | ||
| heapBase().map(hb -> "heapBase: " + hb).orElse(isMapped() ? "mapped" : "native") + | ||
| final String kind; | ||
| if (this instanceof HeapMemorySegmentImpl) { |
There was a problem hiding this comment.
could also be a "virtual" method
|
/integrate |
|
Going to push as commit c8a9dd3.
Your commit was automatically rebased without conflicts. |
This PR proposes to improve the current
MemorySegment.toString()method from:MemorySegment{ address: 0x60000264c540, byteSize: 8 }to
MemorySegment{ native, address: 0x60000264c540, byteSize: 8}Tests passes tier1-tier3
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22826/head:pull/22826$ git checkout pull/22826Update a local copy of the PR:
$ git checkout pull/22826$ git pull https://git.openjdk.org/jdk.git pull/22826/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22826View PR using the GUI difftool:
$ git pr show -t 22826Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22826.diff
Using Webrev
Link to Webrev Comment