< prev index next >

src/hotspot/share/opto/parse2.cpp

Print this page




 213   Node* ary = pop();        // The array itself
 214 
 215   const TypeAryPtr* ary_t = _gvn.type(ary)->is_aryptr();
 216   if (bt == T_OBJECT) {
 217     const TypeOopPtr* elemptr = elemtype->make_oopptr();
 218     const Type* val_t = _gvn.type(cast_val);
 219     if (elemtype->isa_valuetype() != NULL) {
 220       C->set_flattened_accesses();
 221       // Store to flattened value type array
 222       if (!cast_val->is_ValueType()) {
 223         inc_sp(3);
 224         cast_val = null_check(cast_val);
 225         if (stopped()) return;
 226         dec_sp(3);
 227         cast_val = ValueTypeNode::make_from_oop(this, cast_val, elemtype->value_klass());
 228       }
 229       cast_val->as_ValueType()->store_flattened(this, ary, adr);
 230       return;
 231     } else if (elemptr->is_valuetypeptr() && !elemptr->maybe_null()) {
 232       // Store to non-flattened but flattenable value type array (elements can never be null)
 233       if (!cast_val->is_ValueType()) {
 234         inc_sp(3);
 235         cast_val = null_check(cast_val);
 236         if (stopped()) return;
 237         dec_sp(3);
 238       }
 239     } else if (elemptr->can_be_value_type() && !ary_t->klass_is_exact() &&
 240                (cast_val->is_ValueType() || val_t == TypePtr::NULL_PTR || val_t->is_oopptr()->can_be_value_type())) {
 241       // Cannot statically determine if array is flattened or null-free, emit runtime checks
 242       ciValueKlass* vk = NULL;
 243       // Try to determine the value klass
 244       if (cast_val->is_ValueType()) {
 245         vk = val_t->value_klass();
 246       } else if (elemptr->is_valuetypeptr()) {
 247         vk = elemptr->value_klass();
 248       }
 249       if (!ary_t->is_not_flat() && (vk == NULL || vk->flatten_array())) {
 250         // Array might be flattened
 251         assert(ValueArrayFlatten && !ary_t->is_not_null_free(), "a null-ok array can't be flattened");
 252         IdealKit ideal(this);
 253         Node* kls = load_object_klass(ary);
 254         Node* layout_val = load_lh_array_tag(kls);
 255         ideal.if_then(layout_val, BoolTest::ne, intcon(Klass::_lh_array_tag_vt_value));
 256         {
 257           // non-flattened
 258           sync_kit(ideal);
 259           gen_value_array_null_guard(ary, cast_val, 3);
 260           const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(bt);
 261           elemtype = ary_t->elem()->make_oopptr();
 262           access_store_at(ary, adr, adr_type, cast_val, elemtype, bt, MO_UNORDERED | IN_HEAP | IS_ARRAY, false, false);
 263           ideal.sync_kit(this);
 264         }
 265         ideal.else_();
 266         {
 267           // flattened
 268           if (!cast_val->is_ValueType() && TypePtr::NULL_PTR->higher_equal(val_t)) {
 269             // Add null check
 270             sync_kit(ideal);
 271             Node* null_ctl = top();
 272             cast_val = null_check_oop(cast_val, &null_ctl);
 273             if (null_ctl != top()) {
 274               PreserveJVMState pjvms(this);
 275               inc_sp(3);
 276               set_control(null_ctl);
 277               uncommon_trap(Deoptimization::Reason_null_check, Deoptimization::Action_none);
 278               dec_sp(3);
 279             }
 280             ideal.sync_kit(this);
 281           }
 282           if (vk != NULL && !stopped()) {
 283             // Element type is known, cast and store to flattened representation
 284             sync_kit(ideal);
 285             assert(vk->flatten_array(), "must be flattenable");
 286             assert(elemptr->maybe_null(), "must be nullable");
 287             ciArrayKlass* array_klass = ciArrayKlass::make(vk, /* never_null */ true);
 288             const TypeAryPtr* arytype = TypeOopPtr::make_from_klass(array_klass)->isa_aryptr();




 213   Node* ary = pop();        // The array itself
 214 
 215   const TypeAryPtr* ary_t = _gvn.type(ary)->is_aryptr();
 216   if (bt == T_OBJECT) {
 217     const TypeOopPtr* elemptr = elemtype->make_oopptr();
 218     const Type* val_t = _gvn.type(cast_val);
 219     if (elemtype->isa_valuetype() != NULL) {
 220       C->set_flattened_accesses();
 221       // Store to flattened value type array
 222       if (!cast_val->is_ValueType()) {
 223         inc_sp(3);
 224         cast_val = null_check(cast_val);
 225         if (stopped()) return;
 226         dec_sp(3);
 227         cast_val = ValueTypeNode::make_from_oop(this, cast_val, elemtype->value_klass());
 228       }
 229       cast_val->as_ValueType()->store_flattened(this, ary, adr);
 230       return;
 231     } else if (elemptr->is_valuetypeptr() && !elemptr->maybe_null()) {
 232       // Store to non-flattened but flattenable value type array (elements can never be null)
 233       if (!cast_val->is_ValueType() && val_t->maybe_null()) {
 234         inc_sp(3);
 235         cast_val = null_check(cast_val);
 236         if (stopped()) return;
 237         dec_sp(3);
 238       }
 239     } else if (elemptr->can_be_value_type() && !ary_t->klass_is_exact() &&
 240                (cast_val->is_ValueType() || val_t == TypePtr::NULL_PTR || val_t->is_oopptr()->can_be_value_type())) {
 241       // Cannot statically determine if array is flattened or null-free, emit runtime checks
 242       ciValueKlass* vk = NULL;
 243       // Try to determine the value klass
 244       if (cast_val->is_ValueType()) {
 245         vk = val_t->value_klass();
 246       } else if (elemptr->is_valuetypeptr()) {
 247         vk = elemptr->value_klass();
 248       }
 249       if (!ary_t->is_not_flat() && (vk == NULL || vk->flatten_array())) {
 250         // Array might be flattened
 251         assert(ValueArrayFlatten && !ary_t->is_not_null_free(), "a null-ok array can't be flattened");
 252         IdealKit ideal(this);
 253         Node* kls = load_object_klass(ary);
 254         Node* layout_val = load_lh_array_tag(kls);
 255         ideal.if_then(layout_val, BoolTest::ne, intcon(Klass::_lh_array_tag_vt_value));
 256         {
 257           // non-flattened
 258           sync_kit(ideal);
 259           gen_value_array_null_guard(ary, cast_val, 3);
 260           const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(bt);
 261           elemtype = ary_t->elem()->make_oopptr();
 262           access_store_at(ary, adr, adr_type, cast_val, elemtype, bt, MO_UNORDERED | IN_HEAP | IS_ARRAY, false, false);
 263           ideal.sync_kit(this);
 264         }
 265         ideal.else_();
 266         {
 267           // flattened
 268           if (!cast_val->is_ValueType() && val_t->maybe_null()) {
 269             // Add null check
 270             sync_kit(ideal);
 271             Node* null_ctl = top();
 272             cast_val = null_check_oop(cast_val, &null_ctl);
 273             if (null_ctl != top()) {
 274               PreserveJVMState pjvms(this);
 275               inc_sp(3);
 276               set_control(null_ctl);
 277               uncommon_trap(Deoptimization::Reason_null_check, Deoptimization::Action_none);
 278               dec_sp(3);
 279             }
 280             ideal.sync_kit(this);
 281           }
 282           if (vk != NULL && !stopped()) {
 283             // Element type is known, cast and store to flattened representation
 284             sync_kit(ideal);
 285             assert(vk->flatten_array(), "must be flattenable");
 286             assert(elemptr->maybe_null(), "must be nullable");
 287             ciArrayKlass* array_klass = ciArrayKlass::make(vk, /* never_null */ true);
 288             const TypeAryPtr* arytype = TypeOopPtr::make_from_klass(array_klass)->isa_aryptr();


< prev index next >