@@ -156,19 +156,18 @@ void Parse::array_store_check() {
156
156
int klass_offset = oopDesc::klass_offset_in_bytes ();
157
157
Node* p = basic_plus_adr ( ary, ary, klass_offset );
158
158
// 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));
160
160
// Get the array klass
161
161
const TypeKlassPtr *tak = _gvn.type (array_klass)->is_klassptr ();
162
162
163
163
// The type of array_klass is usually INexact array-of-oop. Heroically
164
164
// cast array_klass to EXACT array and uncommon-trap if the cast fails.
165
165
// Make constant out of the inexact array klass, but use it only if the cast
166
166
// 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 ()) {
172
171
// Regarding the fourth condition in the if-statement from above:
173
172
//
174
173
// If the compiler has determined that the type of array 'ary' (represented
@@ -190,16 +189,12 @@ void Parse::array_store_check() {
190
189
//
191
190
// See issue JDK-8057622 for details.
192
191
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 ();
199
194
if (extak->exact_klass (true ) != nullptr ) {
200
195
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));
203
198
Node* ctrl= control ();
204
199
{ BuildCutout unless (this , bol, PROB_MAX);
205
200
uncommon_trap (Deoptimization::Reason_array_check,
@@ -210,7 +205,7 @@ void Parse::array_store_check() {
210
205
set_control (ctrl); // Then Don't Do It, just fall into the normal checking
211
206
} else { // Cast array klass to exactness:
212
207
// Use the exact constant value we know it is.
213
- replace_in_map (array_klass,con);
208
+ replace_in_map (array_klass, con);
214
209
CompileLog* log = C->log ();
215
210
if (log != nullptr ) {
216
211
log ->elem (" cast_up reason='monomorphic_array' from='%d' to='(exact)'" ,
@@ -225,12 +220,9 @@ void Parse::array_store_check() {
225
220
226
221
// Extract the array element class
227
222
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" );
234
226
235
227
// Check (the hard way) and throw if not a subklass.
236
228
// Result is ignored, we just need the CFG effects.
0 commit comments