-
Notifications
You must be signed in to change notification settings - Fork 6.3k
8339526: C2: store incorrectly removed for clone() transformed to series of loads/stores #27604
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: master
Are you sure you want to change the base?
Conversation
👋 Welcome back roland! A progress list of the required criteria for merging this PR into |
@rwestrel 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 424 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 |
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.
That looks reasonable to me.
} | ||
} | ||
|
||
static A field; |
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.
Can you move the field up to the other field?
// At parse time, exact type of the object to clone was not known. That inexact type was captured by the CheckCastPP | ||
// of the newly allocated cloned object (in dest). Exact type is now known (in src), but type for the cloned object | ||
// (dest) was not updated. When copying fields below, Store nodes may write to offsets for fields that don't exist in | ||
// the inexact class. The stores would then be assigned an incorrect slice. |
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.
// At parse time, exact type of the object to clone was not known. That inexact type was captured by the CheckCastPP | |
// of the newly allocated cloned object (in dest). Exact type is now known (in src), but type for the cloned object | |
// (dest) was not updated. When copying fields below, Store nodes may write to offsets for fields that don't exist in | |
// the inexact class. The stores would then be assigned an incorrect slice. | |
// At parse time, the exact type of the object to clone was not known. That inexact type was captured by the CheckCastPP | |
// of the newly allocated cloned object (in dest). The exact type is now known (in src), but the type for the cloned object | |
// (dest) was not updated. When copying the fields below, Store nodes may write to offsets for fields that don't exist in | |
// the inexact class. The stores would then be assigned an incorrect slice. |
In the
test1()
method of the test case:inlined2()
callsclone()
for an object loaded from fieldfield
that has inexact type
A
at parse time. The intrinsic forclone()
inserts an
Allocate
and anArrayCopy
nodes. When igvn runs, theload of
field
is optimized out because it reads back a newlyallocated
B
written tofield
in the same method.ArrayCopy
cannow be optimized because the type of its
src
input is known. Thetype of its
dest
input is theCheckCastPP
from the allocation ofthe cloned object created at parse time. That one has type
A
. Aseries of
Load
s/Store
s are created to copy the fields of classB
from
src
(of typeB
) todest
of (typeA
).Writting to
dest
with offsets for fields that don't exist inA
,causes this code in
Compile::flatten_alias_type()
:to assign it some slice that doesn't match the one that's used at the
same offset in
B
.That causes an assert in
ArrayCopyNode::try_clone_instance()
tofire. With a release build, execution proceeds.
test1()
also has anon escaping allocation. That one causes EA to run and
ConnectionGraph::split_unique_types()
to move the store to the nonescaping allocation to a new slice. In the process, when it iterates
over
MergeMem
nodes, it notices the stores added byArrayCopyNode::try_clone_instance()
, finds that some are not on theright slice, tries to move them to the correct slice (expecting they
are from a non escaping EA). That causes some of the
Store
s to bedisconnected. When the resulting code runs, execution fails as some
fields are not copied.
The fix I propose is to skip
ArrayCopyNode::try_clone_instance()
when
src
anddest
classes don't match as this seems like a rareenough corner case.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27604/head:pull/27604
$ git checkout pull/27604
Update a local copy of the PR:
$ git checkout pull/27604
$ git pull https://git.openjdk.org/jdk.git pull/27604/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27604
View PR using the GUI difftool:
$ git pr show -t 27604
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27604.diff
Using Webrev
Link to Webrev Comment