-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8348411: C2: Remove the control input of LoadKlassNode and LoadNKlassNode #23274
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
Changes from 1 commit
79cf199
ff924de
c676188
175232a
7c2b595
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,42 +164,35 @@ void Parse::array_store_check() { | |
| // cast array_klass to EXACT array and uncommon-trap if the cast fails. | ||
| // Make constant out of the inexact array klass, but use it only if the cast | ||
| // succeeds. | ||
| bool always_see_exact_class = false; | ||
| if (MonomorphicArrayCheck | ||
| && !too_many_traps(Deoptimization::Reason_array_check) | ||
| && !tak->klass_is_exact() | ||
| if (MonomorphicArrayCheck && !too_many_traps(Deoptimization::Reason_array_check) && !tak->klass_is_exact() | ||
| && tak != TypeInstKlassPtr::OBJECT) { | ||
| // Regarding the fourth condition in the if-statement from above: | ||
| // | ||
| // If the compiler has determined that the type of array 'ary' (represented | ||
| // by 'array_klass') is java/lang/Object, the compiler must not assume that | ||
| // the array 'ary' is monomorphic. | ||
| // | ||
| // If 'ary' were of type java/lang/Object, this arraystore would have to fail, | ||
| // because it is not possible to perform a arraystore into an object that is not | ||
| // a "proper" array. | ||
| // | ||
| // Therefore, let's obtain at runtime the type of 'ary' and check if we can still | ||
| // successfully perform the store. | ||
| // | ||
| // The implementation reasons for the condition are the following: | ||
| // | ||
| // java/lang/Object is the superclass of all arrays, but it is represented by the VM | ||
| // as an InstanceKlass. The checks generated by gen_checkcast() (see below) expect | ||
| // 'array_klass' to be ObjArrayKlass, which can result in invalid memory accesses. | ||
| // | ||
| // See issue JDK-8057622 for details. | ||
|
|
||
| always_see_exact_class = true; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it ok to remove this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only use of this is to decide if we need to attach a control input to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, thanks! |
||
| // (If no MDO at all, hope for the best, until a trap actually occurs.) | ||
|
|
||
| // Make a constant out of the inexact array klass | ||
| const TypeKlassPtr *extak = tak->cast_to_exactness(true); | ||
|
|
||
| // Regarding the fourth condition in the if-statement from above: | ||
| // | ||
| // If the compiler has determined that the type of array 'ary' (represented | ||
| // by 'array_klass') is java/lang/Object, the compiler must not assume that | ||
| // the array 'ary' is monomorphic. | ||
| // | ||
| // If 'ary' were of type java/lang/Object, this arraystore would have to fail, | ||
| // because it is not possible to perform a arraystore into an object that is not | ||
| // a "proper" array. | ||
| // | ||
| // Therefore, let's obtain at runtime the type of 'ary' and check if we can still | ||
| // successfully perform the store. | ||
| // | ||
| // The implementation reasons for the condition are the following: | ||
| // | ||
| // java/lang/Object is the superclass of all arrays, but it is represented by the VM | ||
| // as an InstanceKlass. The checks generated by gen_checkcast() (see below) expect | ||
| // 'array_klass' to be ObjArrayKlass, which can result in invalid memory accesses. | ||
| // | ||
| // See issue JDK-8057622 for details. | ||
|
|
||
| // Make a constant out of the exact array klass | ||
| const TypeAryKlassPtr* extak = tak->cast_to_exactness(true)->is_aryklassptr(); | ||
| if (extak->exact_klass(true) != nullptr) { | ||
| Node* con = makecon(extak); | ||
| Node* cmp = _gvn.transform(new CmpPNode( array_klass, con )); | ||
| Node* bol = _gvn.transform(new BoolNode( cmp, BoolTest::eq )); | ||
| Node* cmp = _gvn.transform(new CmpPNode(array_klass, con)); | ||
| Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq)); | ||
| Node* ctrl= control(); | ||
| { BuildCutout unless(this, bol, PROB_MAX); | ||
| uncommon_trap(Deoptimization::Reason_array_check, | ||
|
|
@@ -210,7 +203,7 @@ void Parse::array_store_check() { | |
| set_control(ctrl); // Then Don't Do It, just fall into the normal checking | ||
| } else { // Cast array klass to exactness: | ||
| // Use the exact constant value we know it is. | ||
| replace_in_map(array_klass,con); | ||
| replace_in_map(array_klass, con); | ||
| CompileLog* log = C->log(); | ||
| if (log != nullptr) { | ||
| log->elem("cast_up reason='monomorphic_array' from='%d' to='(exact)'", | ||
|
|
||
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'd also turn
tak != TypeInstKlassPtr::OBJECTintotak->isa_aryklassptr()to stress the intention.(Please, keep the original formatting 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.
Done, I assume you meant the formatting of the comment below, right?
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.
No, I referred to the original shape of the condition (1 check per line). IMO it is easier to follow.