8381854: [lworld] Add acmp maps test to the FieldLayoutAnalyzer#2312
8381854: [lworld] Add acmp maps test to the FieldLayoutAnalyzer#2312fparain wants to merge 4 commits intoopenjdk:lworldfrom
Conversation
|
👋 Welcome back fparain! A progress list of the required criteria for merging this PR into |
|
@fparain 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 13 new commits pushed to the
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 |
Webrevs
|
Arraying
left a comment
There was a problem hiding this comment.
Thanks for this change. This is a valuable thing to have in our test, and I think the logic of using a bitmap to check for overlaps makes a lot of sense. I've left some code feedback and potential future ideas.
| } | ||
| // Non-oop acmp map <offset,size>: <12,1> <16,4> ... | ||
| Asserts.assertTrue(lo.getCurrentLine().startsWith("Non-oop acmp map <offset,size>"), lo.getCurrentLine()); | ||
| String[] acmp_nonoop_line = lo.getCurrentLine().split("\\s+"); |
There was a problem hiding this comment.
May be worth doing a .trim() before splitting by whitespace, it's good practice so we don't end up with any surprises, especially since our output has trailing spaces at the moment.
There was a problem hiding this comment.
The expression used to split the line takes care of removing consecutive whitespaces and trailing whitespaces.
| for (ClassLayout layout : layouts) { | ||
| if (!layout.isValue) continue; | ||
| System.out.println("Checking acmp map of class " + layout.name); | ||
| boolean[] acmpBitMap = new boolean[layout.instanceSize]; |
There was a problem hiding this comment.
If I understand the format properly, it could be a nice addition to verify that the leftover false regions in the bitmap correspond to the padding BlockType.
There was a problem hiding this comment.
false regions could be padding, or empty, or reserved, in fact all block types that are not real basic types or the null marker.
There was a problem hiding this comment.
Good point.
Right now, we are testing that what we get from the acmp map is correct (i.e., fields do not overlap). I think it would be valuable to test (perhaps a follow-up) from the opposite angle as well: is everything that's not in the acmp map accounted for? Are there any unexpected leftover areas?
For instance, let's say that we introduce a bug which forgets to include a field in the acmp map. We end up with a bitmap of e.g. length 5, and the (faulty) acmp map says there are fields in indices 1, 2, and 4. After the test is run, the bitmap looks as follows:
[F | T | T | F | T]
We know that index 1 corresponds to padding, so we mark that as T as well. We have no empty, reserved, etc. blocks. The final bitmap looks as follows:
[T | T | T | F | T]
At this point, the bitmap should only be truthy. If we add an assertion, that will fail. It turns out, index 3 corresponds to the region that got skipped during the (faulty) acmp map creation. By looking at what's left, we ensure nothing is left out by accident.
Does any of that make sense? 😅
There was a problem hiding this comment.
I don't really understand your point. The acmp_map must contain all the segments that are relevant for a substitutability test, and only the segments that are relevant, so padding areas must not be in the map. The new test reconstructs a map of the relevant segments using the field information, and then compare this reconstructed map with the VM generated map. At line 834, the test checks that at each index, the two maps are consistent, they must agree that either it is a relevant area or it is not. If the VM generated acmp_map is missing a field area, this field area will show up in the reconstructed map, and the test will detect the mismatch.
There was a problem hiding this comment.
so padding areas must not be in the map.
Not in the acmp map, but I was under the impression that FieldLayoutAnalyzer has this information. What I'm suggesting combines existing generic layout tests with the new acmp bitmap test.
this field area will show up in the reconstructed map
That's a good point (or maybe my example was just bad).
To summarize, I'm suggesting something along the lines of:
- Get the field layout of value class
X. Save all of theFieldBlocks asblocks. - Create a bitmap that spans the whole field layout region (I think we already do this right now).
- Get the acmp maps, set the bitmap indices to
trueand ensure no collisions (we are doing this already). - Iterate through every block
binblocks:- If we haven't seen
b's type yet in the acmp maps (e.g., we already marked the null marker, so skip that:- Ensure the corresponding bitmap index is
falseand then set totrue.
- Ensure the corresponding bitmap index is
- If we haven't seen
- Iterate through the bitmap at every index
i:- Ensure that the value at index
iistrue. If not, we've "lost" something in some part of our bookkeeping.
- Ensure that the value at index
I hope that explains the idea a bit better. Thoughts?
There was a problem hiding this comment.
As we discussed off-line, this is a different kind of verification unrelated to acmp_maps. This should be addressed in a different PR.
matias9927
left a comment
There was a problem hiding this comment.
Change looks good! Just some cosmetic comments
|
Thanks @Arraying @matias9927 for the reviews. |
|
Going to push as commit 8997310.
Your commit was automatically rebased without conflicts. |
Add acmp_maps verification to the FieldLayoutAnalyzer.
The FieldLayoutAnalyzer recomputes the memory segments used by fields from the available layout descriptions, and compare the results to the acmp_maps computed by the JVM.
The verification is automatically performed for all tests calling the
check()method of the FieldLayoutAnalyzer (like the ValueRandomLayoutTest.java).Tested repeatedly with ValueRandomLayoutTest.java on Mach5.
Thanks,
Fred
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/2312/head:pull/2312$ git checkout pull/2312Update a local copy of the PR:
$ git checkout pull/2312$ git pull https://git.openjdk.org/valhalla.git pull/2312/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2312View PR using the GUI difftool:
$ git pr show -t 2312Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/2312.diff
Using Webrev
Link to Webrev Comment