-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8335221: Some C2 intrinsics incorrectly assume that type argument is compile-time constant #19918
Conversation
…compile-time constant
👋 Welcome back kvn! A progress list of the required criteria for merging this PR into |
@vnkozlov 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 36 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
|
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 to me.
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.
Only some style comments, otherwise, it looks good to me, too.
Were you able to reproduce this in mainline as well?
address stubAddr = nullptr; | ||
stubAddr = StubRoutines::select_array_partition_function(); |
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 be merged:
address stubAddr = nullptr; | |
stubAddr = StubRoutines::select_array_partition_function(); | |
address stubAddr = StubRoutines::select_array_partition_function(); |
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.
done
|
||
null_check(obj); | ||
// If obj is dead, only null-path is taken. | ||
if (stopped()) return 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.
Can you add braces here?
if (stopped()) return true; | |
if (stopped()) { | |
return 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.
done
const TypeInstPtr* elem_klass = gvn().type(elementType)->isa_instptr(); | ||
if (elem_klass == nullptr) { | ||
return false; // dead path (elementType->is_top()). | ||
} | ||
if (obj == nullptr || obj->is_top()) { | ||
return false; // dead path | ||
} | ||
// java_mirror_type() returns non-null for compile-time Class constants only. | ||
ciType* elem_type = elem_klass->java_mirror_type(); | ||
if (elem_type == nullptr) { | ||
return false; | ||
} | ||
BasicType bt = elem_type->basic_type(); | ||
// Disable the intrinsic if the CPU does not support SIMD sort | ||
if (!Matcher::supports_simd_sort(bt)) { | ||
return false; | ||
} | ||
address stubAddr = nullptr; | ||
stubAddr = StubRoutines::select_array_partition_function(); | ||
// stub not loaded | ||
if (stubAddr == nullptr) { | ||
return false; | ||
} | ||
// get the address of the array | ||
const TypeAryPtr* obj_t = _gvn.type(obj)->isa_aryptr(); | ||
if (obj_t == nullptr || obj_t->elem() == Type::BOTTOM ) { | ||
return false; // failed input validation | ||
} |
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.
The bailout code looks almost identical to the one in inline_array_sort()
. Can it somehow be shared?
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.
Good idea. I will try.
|
||
null_check(obj); | ||
// If obj is dead, only null-path is taken. | ||
if (stopped()) return 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.
if (stopped()) return true; | |
if (stopped()) { | |
return 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.
done
} | ||
// get the address of the array | ||
const TypeAryPtr* obj_t = _gvn.type(obj)->isa_aryptr(); | ||
if (obj_t == nullptr || obj_t->elem() == Type::BOTTOM ) { |
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.
if (obj_t == nullptr || obj_t->elem() == Type::BOTTOM ) { | |
if (obj_t == nullptr || obj_t->elem() == Type::BOTTOM) { |
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.
done
Moved common checks into new Tested locally |
|
||
// Common checks for array sorting intrinsics arguments. | ||
// Returns `true` if checks passed. | ||
bool LibraryCallKit::check_array_sort_arguments(Node* elementType, Node* obj, BasicType* bt) { |
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.
Thanks for doing the update, looks good! Just one small detail: You could use a reference here instead of a pointer. Then you can pass bt
in and modify it directly.
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.
Done.
/integrate |
Going to push as commit 166f9d9.
Your commit was automatically rebased without conflicts. |
Problems were found in some C2 intrinsics while testing Leyden Early Release.
inline_array_partition()
andinline_array_sort()
intrinsics incorrectly assume thatelementType
argument is always compile-time constant. Which is not true for Leyden (and in general) when constant folding optimization is switched off (or did not executed for particular type).Note, other intrinsics are very careful about that. For example, see
inline_Class_cast()
intrinsic.Add similar checks to
inline_array_partition()
andinline_array_sort()
.An other problem is that
null_check()
(which adds new control nodes to graph) was executed in these intrinsics before bailouts from intrinsic generation. We hit next assert if bailout happens:I moved
null_check()
after bailouts.An other issue with
null_check()
is it checks fornull
first argument which isClass
. It can't benull
because corresponding Java methods areprivate
and each call site passed<primitive_type>.class
as first argument.For example: DualPivotQuicksort.java#L260
On other hand there is no null check for passed array (second argument). I changed
null_check()
for array.These 2 intrinsics were added by JDK-8309130 in JDK 22.
Testing tier1-6, hs-stress, hs-xcomp
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19918/head:pull/19918
$ git checkout pull/19918
Update a local copy of the PR:
$ git checkout pull/19918
$ git pull https://git.openjdk.org/jdk.git pull/19918/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19918
View PR using the GUI difftool:
$ git pr show -t 19918
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19918.diff
Webrev
Link to Webrev Comment