-
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 all commits
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 |
|---|---|---|
|
|
@@ -156,19 +156,18 @@ void Parse::array_store_check() { | |
| int klass_offset = oopDesc::klass_offset_in_bytes(); | ||
| Node* p = basic_plus_adr( ary, ary, klass_offset ); | ||
| // p's type is array-of-OOPS plus klass_offset | ||
| Node* array_klass = _gvn.transform(LoadKlassNode::make(_gvn, nullptr, immutable_memory(), p, TypeInstPtr::KLASS)); | ||
| Node* array_klass = _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS)); | ||
| // Get the array klass | ||
| const TypeKlassPtr *tak = _gvn.type(array_klass)->is_klassptr(); | ||
|
|
||
| // The type of array_klass is usually INexact array-of-oop. Heroically | ||
| // 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() | ||
| && tak != TypeInstKlassPtr::OBJECT) { | ||
| if (MonomorphicArrayCheck && | ||
| !too_many_traps(Deoptimization::Reason_array_check) && | ||
| !tak->klass_is_exact() && | ||
| tak->isa_aryklassptr()) { | ||
| // Regarding the fourth condition in the if-statement from above: | ||
| // | ||
| // If the compiler has determined that the type of array 'ary' (represented | ||
|
|
@@ -190,16 +189,12 @@ void Parse::array_store_check() { | |
| // | ||
| // 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); | ||
|
|
||
| // 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 +205,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)'", | ||
|
|
@@ -225,12 +220,9 @@ void Parse::array_store_check() { | |
|
|
||
| // Extract the array element class | ||
| int element_klass_offset = in_bytes(ObjArrayKlass::element_klass_offset()); | ||
| Node *p2 = basic_plus_adr(array_klass, array_klass, element_klass_offset); | ||
| // We are allowed to use the constant type only if cast succeeded. If always_see_exact_class is true, | ||
| // we must set a control edge from the IfTrue node created by the uncommon_trap above to the | ||
| // LoadKlassNode. | ||
| Node* a_e_klass = _gvn.transform(LoadKlassNode::make(_gvn, always_see_exact_class ? control() : nullptr, | ||
| immutable_memory(), p2, tak)); | ||
| Node* p2 = basic_plus_adr(array_klass, array_klass, element_klass_offset); | ||
| Node* a_e_klass = _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), p2, tak)); | ||
merykitty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert(array_klass->is_Con() == a_e_klass->is_Con() || StressReflectiveCode, "a constant array type must come with a constant element type"); | ||
|
|
||
| // Check (the hard way) and throw if not a subklass. | ||
| // Result is ignored, we just need the CFG effects. | ||
|
|
||
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 like an implicit
nullptrcheck. Not allowed by code style ;)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 quickly explain this change from
tak != TypeInstKlassPtr::OBJECTso I don't need to investigate myself, please?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.
But the verb here is
isaand we use these as aboola lot, though :/The bottom type of an array can be either
Objector an array of some kind, sotak != TypeInstKlassPtr::OBJECTis the same astak->isa_aryklassptr().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.
Ah great, thanks for the explanation!