@@ -156,19 +156,18 @@ void Parse::array_store_check() {
156156 int klass_offset = oopDesc::klass_offset_in_bytes ();
157157 Node* p = basic_plus_adr ( ary, ary, klass_offset );
158158 // p's type is array-of-OOPS plus klass_offset
159- Node* array_klass = _gvn.transform (LoadKlassNode::make (_gvn, nullptr , immutable_memory (), p, TypeInstPtr::KLASS));
159+ Node* array_klass = _gvn.transform (LoadKlassNode::make (_gvn, immutable_memory (), p, TypeInstPtr::KLASS));
160160 // Get the array klass
161161 const TypeKlassPtr *tak = _gvn.type (array_klass)->is_klassptr ();
162162
163163 // The type of array_klass is usually INexact array-of-oop. Heroically
164164 // cast array_klass to EXACT array and uncommon-trap if the cast fails.
165165 // Make constant out of the inexact array klass, but use it only if the cast
166166 // succeeds.
167- bool always_see_exact_class = false ;
168- if (MonomorphicArrayCheck
169- && !too_many_traps (Deoptimization::Reason_array_check)
170- && !tak->klass_is_exact ()
171- && tak != TypeInstKlassPtr::OBJECT) {
167+ if (MonomorphicArrayCheck &&
168+ !too_many_traps (Deoptimization::Reason_array_check) &&
169+ !tak->klass_is_exact () &&
170+ tak->isa_aryklassptr ()) {
172171 // Regarding the fourth condition in the if-statement from above:
173172 //
174173 // If the compiler has determined that the type of array 'ary' (represented
@@ -190,16 +189,12 @@ void Parse::array_store_check() {
190189 //
191190 // See issue JDK-8057622 for details.
192191
193- always_see_exact_class = true ;
194- // (If no MDO at all, hope for the best, until a trap actually occurs.)
195-
196- // Make a constant out of the inexact array klass
197- const TypeKlassPtr *extak = tak->cast_to_exactness (true );
198-
192+ // Make a constant out of the exact array klass
193+ const TypeAryKlassPtr* extak = tak->cast_to_exactness (true )->is_aryklassptr ();
199194 if (extak->exact_klass (true ) != nullptr ) {
200195 Node* con = makecon (extak);
201- Node* cmp = _gvn.transform (new CmpPNode ( array_klass, con ));
202- Node* bol = _gvn.transform (new BoolNode ( cmp, BoolTest::eq ));
196+ Node* cmp = _gvn.transform (new CmpPNode (array_klass, con));
197+ Node* bol = _gvn.transform (new BoolNode (cmp, BoolTest::eq));
203198 Node* ctrl= control ();
204199 { BuildCutout unless (this , bol, PROB_MAX);
205200 uncommon_trap (Deoptimization::Reason_array_check,
@@ -210,7 +205,7 @@ void Parse::array_store_check() {
210205 set_control (ctrl); // Then Don't Do It, just fall into the normal checking
211206 } else { // Cast array klass to exactness:
212207 // Use the exact constant value we know it is.
213- replace_in_map (array_klass,con);
208+ replace_in_map (array_klass, con);
214209 CompileLog* log = C->log ();
215210 if (log != nullptr ) {
216211 log->elem (" cast_up reason='monomorphic_array' from='%d' to='(exact)'" ,
@@ -225,12 +220,9 @@ void Parse::array_store_check() {
225220
226221 // Extract the array element class
227222 int element_klass_offset = in_bytes (ObjArrayKlass::element_klass_offset ());
228- Node *p2 = basic_plus_adr (array_klass, array_klass, element_klass_offset);
229- // We are allowed to use the constant type only if cast succeeded. If always_see_exact_class is true,
230- // we must set a control edge from the IfTrue node created by the uncommon_trap above to the
231- // LoadKlassNode.
232- Node* a_e_klass = _gvn.transform (LoadKlassNode::make (_gvn, always_see_exact_class ? control () : nullptr ,
233- immutable_memory (), p2, tak));
223+ Node* p2 = basic_plus_adr (array_klass, array_klass, element_klass_offset);
224+ Node* a_e_klass = _gvn.transform (LoadKlassNode::make (_gvn, immutable_memory (), p2, tak));
225+ assert (array_klass->is_Con () == a_e_klass->is_Con () || StressReflectiveCode, " a constant array type must come with a constant element type" );
234226
235227 // Check (the hard way) and throw if not a subklass.
236228 // Result is ignored, we just need the CFG effects.
0 commit comments