-
Notifications
You must be signed in to change notification settings - Fork 137
8372700: [lworld] compiler/c2/irTests/stable/* fail with --enable-preview #1826
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
base: lworld
Are you sure you want to change the base?
Conversation
|
👋 Welcome back mchevalier! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
@marc-chevalier this pull request can not be integrated into git checkout JDK-8372700
git fetch https://git.openjdk.org/valhalla.git lworld
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge lworld"
git push |
TobiHartmann
left a comment
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.
I had a first quick look at this and left a few comments. Will do a full review after vacation.
I assume the folding should also work for arrays with different layouts, right? I think we need tests for all of them, i.e. all ValueClass.new*Array() variants.
|
|
||
| // Constant value of the null marker. | ||
| ciConstant ciInstance::null_marker_value() { | ||
| if (!klass()->is_inlinetype()) { |
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.
Should this be an assert?
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.
Matter of point of view. I prefer to have the semantics
if inlinetype => get the null marker
else return invalid constant (since it doesn't make sense).
rather than
check is inline type
get null marker
At call site, in the first case, I need to
nm = inst->null_marker_value();
nm is true? (might be false or invalid)
in the second, I need to do
is inst an inline type?
if so, nm = inst->null_marker_value();
nm is true? (might be false, but not invalid)
I prefer the first pattern, it's rather safer, and I think a lot of the code involving ciConstant have this behavior of "you get the constant if I can, otherwise, you get invalid".
| @IR(counts = { IRNode.LOAD, ">0" }) | ||
| @IR(failOn = { IRNode.MEMBAR }) | ||
| @IR(applyIf = {"enable-valhalla", "false"}, failOn = { IRNode.MEMBAR }) | ||
| @IR(applyIf = {"enable-valhalla", "true"}, counts = { IRNode.MEMBAR, ">0" }) |
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 needs a comment explaining why barriers are sometimes observed.
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.
I agree. The problem is that you told me it's expected, but I forgot the reason.
test/hotspot/jtreg/compiler/c2/irTests/stable/StableRefPlainTest.java
Outdated
Show resolved
Hide resolved
test/hotspot/jtreg/compiler/c2/irTests/stable/StableRefPlainTest.java
Outdated
Show resolved
Hide resolved
| return ciConstant(T_BOOLEAN, elem); | ||
| } | ||
|
|
||
| ciConstant ciFlatArray::check_constant_null_marker_cache(int off) { |
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.
Do we really need a cache here?
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.
Maybe? I read
valhalla/src/hotspot/share/ci/ciObject.hpp
Lines 62 to 63 in 69399ce
| // Cache constant value lookups to ensure that consistent values are observed during compilation. | |
| class ConstantValue { |
and
valhalla/src/hotspot/share/ci/ciObject.cpp
Lines 173 to 175 in 69399ce
| // Cache constant value lookups to ensure that consistent values are observed | |
| // during compilation because fields may be (re-)initialized concurrently. | |
| ciConstant ciObject::check_constant_value_cache(int off, BasicType bt) { |
It seems to be more a correctness thing than a performance matter. It couldn't see why I wouldn't have a similar risk.
Flat accesses to a stable value can be expanded in a non-atomic way if the stable field is already initialized since they are read-only at this point. That allows to make more optimizations, and in particular to replace the access by a constant if it's known at compilation time.
There are 2 cases. First, flat stable non-array field. In this case, the value is known to be stable if the value is non-null, that is if the null-marker of the said field is 1. If we can find that the null marker has a constant value that is non zero, we expand non-atomically. That is done by finding the field we are trying to get from the offset. From the field, we can find the offset of the null marker, and then the null marker
ciField, allowing to fetch its value if the holder is known to be a constant oop.The other case is stable flat array. In this case, we need to find index of the containing element of the array, then with the offset, we can find the field we are trying to get. Finding the null marker here is a bit more tricky. Let's say we have
the null marker for
vis somewhat a field ofC, as well asv.x. So I can just usefield_valueto get the null marker. But inMyValue[], there isn't a single field for the null marker, but one "field" for each cell of the array, and there isn't a nice containing type in which it lives. The only way to get each piece of the array is by index (or offset). So, I needed specialized functions to access the null marker of a cell given the index/offset.I also had to implement of bit of accessors for
ciFlatArray. First, implementelement_value_by_offsetinciFlatArraysince the implementation ofciArray(super-class) was used, which computes the index from the provided offset, assuming a size of elements that doesn't take flattening into account as it used only the basic type, and not the layout helper. But also helpers to get a field of the flattened value class in a cell, to allow constant folding to get the constant value in an array.The last part of the puzzle, necessary to make constant folding happen (see
Type::make_constant_from_field), is to say that a field of a flattened inline type field is constant if the containing field if constant. In the words of the previous example, that meansxis constant inCifvis strict and final (already there), or ifvis constant itself. That matches what we do invoid ciField::initialize_from(fieldDescriptor* fd):valhalla/src/hotspot/share/ci/ciField.cpp
Line 341 in 26b7640
Thanks,
Marc
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1826/head:pull/1826$ git checkout pull/1826Update a local copy of the PR:
$ git checkout pull/1826$ git pull https://git.openjdk.org/valhalla.git pull/1826/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1826View PR using the GUI difftool:
$ git pr show -t 1826Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1826.diff
Using Webrev
Link to Webrev Comment