< prev index next >

src/hotspot/share/opto/graphKit.cpp

Print this page
rev 55127 : 8223351: [lworld] Primary mirror and nullable mirror for inline type
Reviewed-by: tbd


3384   }
3385 }
3386 
3387 // Deoptimize if 'ary' is a null-free value type array and 'val' is null
3388 void GraphKit::gen_value_array_null_guard(Node* ary, Node* val, int nargs) {
3389   assert(EnableValhalla, "should only be used if value types are enabled");
3390   const Type* val_t = _gvn.type(val);
3391   if (val->is_ValueType() || !TypePtr::NULL_PTR->higher_equal(val_t)) {
3392     return; // Never null
3393   }
3394   RegionNode* region = new RegionNode(3);
3395   Node* null_ctl = top();
3396   null_check_oop(val, &null_ctl);
3397   if (null_ctl != top()) {
3398     PreserveJVMState pjvms(this);
3399     set_control(null_ctl);
3400     // Get array element mirror and corresponding value mirror
3401     Node* array_type_mirror = load_mirror_from_klass(load_object_klass(ary));
3402     Node* elem_mirror_adr = basic_plus_adr(array_type_mirror, java_lang_Class::component_mirror_offset_in_bytes());
3403     Node* elem_mirror = access_load_at(array_type_mirror, elem_mirror_adr, _gvn.type(elem_mirror_adr)->is_ptr(), TypeInstPtr::MIRROR, T_OBJECT, IN_HEAP);
3404     Node* value_mirror_adr = basic_plus_adr(elem_mirror, java_lang_Class::value_mirror_offset_in_bytes());
3405     Node* value_mirror = access_load_at(elem_mirror, value_mirror_adr, _gvn.type(value_mirror_adr)->is_ptr(), TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR), T_OBJECT, IN_HEAP);
3406     // Deoptimize if elem_mirror == value_mirror => null-free array
3407     Node* cmp = _gvn.transform(new CmpPNode(elem_mirror, value_mirror));
3408     Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne));
3409     { BuildCutout unless(this, bol, PROB_MAX);
3410       inc_sp(nargs);
3411       uncommon_trap(Deoptimization::Reason_null_check,
3412                     Deoptimization::Action_none);
3413     }
3414     region->init_req(1, control());
3415   }
3416   region->init_req(2, control());
3417   set_control(_gvn.transform(region));
3418   record_for_igvn(region);
3419 }
3420 
3421 Node* GraphKit::load_lh_array_tag(Node* kls) {
3422   Node* lhp = basic_plus_adr(kls, in_bytes(Klass::layout_helper_offset()));
3423   Node* layout_val = make_load(NULL, lhp, TypeInt::INT, T_INT, MemNode::unordered);
3424   return _gvn.transform(new RShiftINode(layout_val, intcon(Klass::_lh_array_tag_shift)));
3425 }
3426 
3427 


4032         }
4033       }
4034       storage_properties = MakeConX(props.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift));
4035     }
4036   }
4037 
4038   if (EnableValhalla && (elem == NULL || (elem_klass != NULL && elem_klass->is_java_lang_Object() && !ary_type->klass_is_exact()))) {
4039     // Array type is not known, compute default value and storage properties for initialization.
4040     assert(raw_default_value == NULL && storage_properties == NULL, "shouldn't be set yet");
4041     assert(elem_mirror != NULL, "should not be null");
4042 
4043     Node* r = new RegionNode(4);
4044     raw_default_value = new PhiNode(r, TypeX_X);
4045     storage_properties = new PhiNode(r, TypeX_X);
4046 
4047     Node* empty     = MakeConX(ArrayStorageProperties::empty.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift));
4048     Node* null_free = MakeConX(ArrayStorageProperties::null_free.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift));
4049     Node* flat      = MakeConX(ArrayStorageProperties::flattened_and_null_free.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift));
4050 
4051     // Check if element mirror is a value mirror
4052     Node* p = basic_plus_adr(elem_mirror, java_lang_Class::value_mirror_offset_in_bytes());
4053     Node* value_mirror = access_load_at(elem_mirror, p, _gvn.type(p)->is_ptr(), TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR), T_OBJECT, IN_HEAP);
4054     Node* cmp = _gvn.transform(new CmpPNode(elem_mirror, value_mirror));
4055     Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq));
4056     IfNode* iff = create_and_map_if(control(), bol, PROB_FAIR, COUNT_UNKNOWN);
4057 
4058     // Not a value mirror but a box mirror or not a value type array, initialize with all zero
4059     r->init_req(1, _gvn.transform(new IfFalseNode(iff)));
4060     raw_default_value->init_req(1, MakeConX(0));
4061     storage_properties->init_req(1, empty);
4062 
4063     // Value mirror (= null-free), check if flattened
4064     set_control(_gvn.transform(new IfTrueNode(iff)));
4065     cmp = gen_lh_array_test(klass_node, Klass::_lh_array_tag_vt_value);
4066     bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq));
4067     iff = create_and_map_if(control(), bol, PROB_FAIR, COUNT_UNKNOWN);
4068 
4069     // Flattened, initialize with all zero
4070     r->init_req(2, _gvn.transform(new IfTrueNode(iff)));
4071     raw_default_value->init_req(2, MakeConX(0));
4072     storage_properties->init_req(2, flat);
4073 
4074     // Non-flattened, initialize with the default value




3384   }
3385 }
3386 
3387 // Deoptimize if 'ary' is a null-free value type array and 'val' is null
3388 void GraphKit::gen_value_array_null_guard(Node* ary, Node* val, int nargs) {
3389   assert(EnableValhalla, "should only be used if value types are enabled");
3390   const Type* val_t = _gvn.type(val);
3391   if (val->is_ValueType() || !TypePtr::NULL_PTR->higher_equal(val_t)) {
3392     return; // Never null
3393   }
3394   RegionNode* region = new RegionNode(3);
3395   Node* null_ctl = top();
3396   null_check_oop(val, &null_ctl);
3397   if (null_ctl != top()) {
3398     PreserveJVMState pjvms(this);
3399     set_control(null_ctl);
3400     // Get array element mirror and corresponding value mirror
3401     Node* array_type_mirror = load_mirror_from_klass(load_object_klass(ary));
3402     Node* elem_mirror_adr = basic_plus_adr(array_type_mirror, java_lang_Class::component_mirror_offset_in_bytes());
3403     Node* elem_mirror = access_load_at(array_type_mirror, elem_mirror_adr, _gvn.type(elem_mirror_adr)->is_ptr(), TypeInstPtr::MIRROR, T_OBJECT, IN_HEAP);
3404     Node* inline_mirror_adr = basic_plus_adr(elem_mirror, java_lang_Class::inline_mirror_offset_in_bytes());
3405     Node* inline_mirror = access_load_at(elem_mirror, inline_mirror_adr, _gvn.type(inline_mirror_adr)->is_ptr(), TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR), T_OBJECT, IN_HEAP);
3406     // Deoptimize if elem_mirror == inline_mirror => null-free array
3407     Node* cmp = _gvn.transform(new CmpPNode(elem_mirror, inline_mirror));
3408     Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne));
3409     { BuildCutout unless(this, bol, PROB_MAX);
3410       inc_sp(nargs);
3411       uncommon_trap(Deoptimization::Reason_null_check,
3412                     Deoptimization::Action_none);
3413     }
3414     region->init_req(1, control());
3415   }
3416   region->init_req(2, control());
3417   set_control(_gvn.transform(region));
3418   record_for_igvn(region);
3419 }
3420 
3421 Node* GraphKit::load_lh_array_tag(Node* kls) {
3422   Node* lhp = basic_plus_adr(kls, in_bytes(Klass::layout_helper_offset()));
3423   Node* layout_val = make_load(NULL, lhp, TypeInt::INT, T_INT, MemNode::unordered);
3424   return _gvn.transform(new RShiftINode(layout_val, intcon(Klass::_lh_array_tag_shift)));
3425 }
3426 
3427 


4032         }
4033       }
4034       storage_properties = MakeConX(props.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift));
4035     }
4036   }
4037 
4038   if (EnableValhalla && (elem == NULL || (elem_klass != NULL && elem_klass->is_java_lang_Object() && !ary_type->klass_is_exact()))) {
4039     // Array type is not known, compute default value and storage properties for initialization.
4040     assert(raw_default_value == NULL && storage_properties == NULL, "shouldn't be set yet");
4041     assert(elem_mirror != NULL, "should not be null");
4042 
4043     Node* r = new RegionNode(4);
4044     raw_default_value = new PhiNode(r, TypeX_X);
4045     storage_properties = new PhiNode(r, TypeX_X);
4046 
4047     Node* empty     = MakeConX(ArrayStorageProperties::empty.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift));
4048     Node* null_free = MakeConX(ArrayStorageProperties::null_free.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift));
4049     Node* flat      = MakeConX(ArrayStorageProperties::flattened_and_null_free.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift));
4050 
4051     // Check if element mirror is a value mirror
4052     Node* p = basic_plus_adr(elem_mirror, java_lang_Class::inline_mirror_offset_in_bytes());
4053     Node* inline_mirror = access_load_at(elem_mirror, p, _gvn.type(p)->is_ptr(), TypeInstPtr::MIRROR, T_OBJECT, IN_HEAP);
4054     Node* cmp = _gvn.transform(new CmpPNode(elem_mirror, inline_mirror));
4055     Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq));
4056     IfNode* iff = create_and_map_if(control(), bol, PROB_FAIR, COUNT_UNKNOWN);
4057 
4058     // Not a value mirror but a box mirror or not a value type array, initialize with all zero
4059     r->init_req(1, _gvn.transform(new IfFalseNode(iff)));
4060     raw_default_value->init_req(1, MakeConX(0));
4061     storage_properties->init_req(1, empty);
4062 
4063     // Value mirror (= null-free), check if flattened
4064     set_control(_gvn.transform(new IfTrueNode(iff)));
4065     cmp = gen_lh_array_test(klass_node, Klass::_lh_array_tag_vt_value);
4066     bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq));
4067     iff = create_and_map_if(control(), bol, PROB_FAIR, COUNT_UNKNOWN);
4068 
4069     // Flattened, initialize with all zero
4070     r->init_req(2, _gvn.transform(new IfTrueNode(iff)));
4071     raw_default_value->init_req(2, MakeConX(0));
4072     storage_properties->init_req(2, flat);
4073 
4074     // Non-flattened, initialize with the default value


< prev index next >