-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8323682: C2: guard check is not generated in Arrays.copyOfRange intrinsic when allocation is eliminated by EA #18472
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
Conversation
👋 Welcome back dlunden! A progress list of the required criteria for merging this PR into |
@dlunde 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 116 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@TobiHartmann, @vnkozlov) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
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 good to me.
@@ -4391,7 +4393,7 @@ bool LibraryCallKit::inline_array_copyOf(bool is_copyOfRange) { | |||
if (!stopped()) { | |||
newcopy = new_array(klass_node, length, 0); // no arguments to push | |||
|
|||
ArrayCopyNode* ac = ArrayCopyNode::make(this, true, original, start, newcopy, intcon(0), moved, true, false, | |||
ArrayCopyNode* ac = ArrayCopyNode::make(this, true, original, start, newcopy, intcon(0), moved, true, true, |
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.
Note: we can now specify true
for the argument has_negative_length_guard
.
@@ -1266,7 +1266,7 @@ void PhaseMacroExpand::expand_arraycopy_node(ArrayCopyNode *ac) { | |||
generate_arraycopy(ac, alloc, &ctrl, merge_mem, &io, | |||
adr_type, T_OBJECT, | |||
src, src_offset, dest, dest_offset, length, | |||
true, !ac->is_copyofrange()); |
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.
We cannot use this anymore, since we then ignore the has_negative_length_guard
for copyOfRange
(and generate the negative length guard twice).
generate_negative_guard(start, bailout, &start); | ||
generate_negative_guard(end, bailout, &end); |
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 think we need this check to avoid underflow in integer expression (end - start): (min_int - 1) == max_int
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.
OK, I see. Thanks, I readded the end
guard.
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.
Looks good.
Thanks for the reviews @TobiHartmann and @vnkozlov. Please sponsor! /integrate |
/sponsor |
Going to push as commit 92f5c0b.
Your commit was automatically rebased without conflicts. |
@TobiHartmann @dlunde Pushed as commit 92f5c0b. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Issue Summary
The library intrinsic
_copyOfRange
does not add a guard for start indices that are larger than the length of the source arrays. Macro expansion ofArrayCopy
nodes later adds such a guard, but in certain situations escape analysis may result in removing theArrayCopy
node before it is expanded. The result is incorrect behavior of the compiled program (as the missing guard may have relevant side effects, such as throwing an exception).Changeset
Testing
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18472/head:pull/18472
$ git checkout pull/18472
Update a local copy of the PR:
$ git checkout pull/18472
$ git pull https://git.openjdk.org/jdk.git pull/18472/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18472
View PR using the GUI difftool:
$ git pr show -t 18472
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18472.diff
Webrev
Link to Webrev Comment