4166 elem_klass = ary_klass->element_klass(); 4167 4168 ArrayStorageProperties props = ary_klass->storage_properties(); 4169 if (!props.is_empty() && elem_klass->is_valuetype()) { 4170 if (props.is_null_free() && !props.is_flattened()) { 4171 default_value = ValueTypeNode::default_oop(gvn(), elem_klass->as_value_klass()); 4172 if (elem->isa_narrowoop()) { 4173 default_value = _gvn.transform(new EncodePNode(default_value, elem)); 4174 raw_default_value = raw_default_for_coops(default_value, *this); 4175 } else { 4176 raw_default_value = _gvn.transform(new CastP2XNode(control(), default_value)); 4177 } 4178 } 4179 storage_properties = MakeConX(props.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift)); 4180 } 4181 } 4182 4183 if (EnableValhalla && (elem == NULL || (elem_klass != NULL && (elem_klass->is_java_lang_Object() || elem_klass->is_valuetype()) && 4184 !ary_type->klass_is_exact()))) { 4185 // Array type is not known, compute default value and storage properties for initialization. 4186 assert(raw_default_value == NULL && storage_properties == NULL, "shouldn't be set yet"); 4187 assert(elem_mirror != NULL, "should not be null"); 4188 4189 Node* r = new RegionNode(4); 4190 raw_default_value = new PhiNode(r, TypeX_X); 4191 storage_properties = new PhiNode(r, TypeX_X); 4192 4193 Node* empty = MakeConX(ArrayStorageProperties::empty.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift)); 4194 Node* null_free = MakeConX(ArrayStorageProperties::null_free.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift)); 4195 Node* flat = MakeConX(ArrayStorageProperties::flattened_and_null_free.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift)); 4196 4197 // Check if element mirror is a value mirror 4198 IfNode* iff = create_and_map_if(control(), is_value_mirror(elem_mirror), PROB_FAIR, COUNT_UNKNOWN); 4199 4200 // Not a value mirror but a box mirror or not a value type array, initialize with all zero 4201 r->init_req(1, _gvn.transform(new IfFalseNode(iff))); 4202 raw_default_value->init_req(1, MakeConX(0)); 4203 storage_properties->init_req(1, empty); 4204 4205 // Value mirror (= null-free), check if flattened 4206 set_control(_gvn.transform(new IfTrueNode(iff))); 4207 Node* cmp = gen_lh_array_test(klass_node, Klass::_lh_array_tag_vt_value); 4208 Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq)); 4209 iff = create_and_map_if(control(), bol, PROB_FAIR, COUNT_UNKNOWN); 4210 4211 // Flattened, initialize with all zero 4212 r->init_req(2, _gvn.transform(new IfTrueNode(iff))); 4213 raw_default_value->init_req(2, MakeConX(0)); 4214 storage_properties->init_req(2, flat); 4215 4216 // Non-flattened, initialize with the default value 4217 set_control(_gvn.transform(new IfFalseNode(iff))); 4218 Node* p = basic_plus_adr(klass_node, in_bytes(ArrayKlass::element_klass_offset())); 4219 Node* eklass = _gvn.transform(LoadKlassNode::make(_gvn, control(), immutable_memory(), p, TypeInstPtr::KLASS)); 4220 Node* adr_fixed_block_addr = basic_plus_adr(eklass, in_bytes(InstanceKlass::adr_valueklass_fixed_block_offset())); 4221 Node* adr_fixed_block = make_load(control(), adr_fixed_block_addr, TypeRawPtr::NOTNULL, T_ADDRESS, MemNode::unordered); 4222 Node* default_value_offset_addr = basic_plus_adr(adr_fixed_block, in_bytes(ValueKlass::default_value_offset_offset())); 4223 Node* default_value_offset = make_load(control(), default_value_offset_addr, TypeInt::INT, T_INT, MemNode::unordered); 4224 Node* default_value_addr = basic_plus_adr(elem_mirror, ConvI2X(default_value_offset)); 4225 Node* val = access_load_at(elem_mirror, default_value_addr, _gvn.type(default_value_addr)->is_ptr(), TypeInstPtr::BOTTOM, T_OBJECT, IN_HEAP); 4226 if (UseCompressedOops) { 4227 val = _gvn.transform(new EncodePNode(val, elem)); 4228 val = raw_default_for_coops(val, *this); 4229 } else { 4230 val = _gvn.transform(new CastP2XNode(control(), val)); 4231 } 4232 r->init_req(3, control()); 4233 raw_default_value->init_req(3, val); 4234 storage_properties->init_req(3, null_free); 4235 4236 set_control(_gvn.transform(r)); 4237 raw_default_value = _gvn.transform(raw_default_value); 4238 storage_properties = _gvn.transform(storage_properties); 4239 } 4240 4241 // Create the AllocateArrayNode and its result projections 4242 AllocateArrayNode* alloc = new AllocateArrayNode(C, AllocateArrayNode::alloc_type(TypeInt::INT), 4243 control(), mem, i_o(), 4244 size, klass_node, 4245 initial_slow_test, 4246 length, default_value, 4247 raw_default_value, 4248 storage_properties); 4249 4250 // Cast to correct type. Note that the klass_node may be constant or not, 4251 // and in the latter case the actual array type will be inexact also. 4252 // (This happens via a non-constant argument to inline_native_newArray.) 4253 // In any case, the value of klass_node provides the desired array type. 4254 const TypeInt* length_type = _gvn.find_int_type(length); 4255 if (ary_type->isa_aryptr() && length_type != NULL) { 4256 // Try to get a better type than POS for the size 4257 ary_type = ary_type->is_aryptr()->cast_to_size(length_type); 4258 } | 4166 elem_klass = ary_klass->element_klass(); 4167 4168 ArrayStorageProperties props = ary_klass->storage_properties(); 4169 if (!props.is_empty() && elem_klass->is_valuetype()) { 4170 if (props.is_null_free() && !props.is_flattened()) { 4171 default_value = ValueTypeNode::default_oop(gvn(), elem_klass->as_value_klass()); 4172 if (elem->isa_narrowoop()) { 4173 default_value = _gvn.transform(new EncodePNode(default_value, elem)); 4174 raw_default_value = raw_default_for_coops(default_value, *this); 4175 } else { 4176 raw_default_value = _gvn.transform(new CastP2XNode(control(), default_value)); 4177 } 4178 } 4179 storage_properties = MakeConX(props.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift)); 4180 } 4181 } 4182 4183 if (EnableValhalla && (elem == NULL || (elem_klass != NULL && (elem_klass->is_java_lang_Object() || elem_klass->is_valuetype()) && 4184 !ary_type->klass_is_exact()))) { 4185 // Array type is not known, compute default value and storage properties for initialization. 4186 assert(default_value == NULL && raw_default_value == NULL && storage_properties == NULL, "shouldn't be set yet"); 4187 assert(elem_mirror != NULL, "should not be null"); 4188 4189 Node* r = new RegionNode(4); 4190 default_value = new PhiNode(r, TypeInstPtr::BOTTOM); 4191 storage_properties = new PhiNode(r, TypeX_X); 4192 4193 Node* empty = MakeConX(ArrayStorageProperties::empty.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift)); 4194 Node* null_free = MakeConX(ArrayStorageProperties::null_free.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift)); 4195 Node* flat = MakeConX(ArrayStorageProperties::flattened_and_null_free.encode<NOT_LP64(jint) LP64_ONLY(jlong)>(props_shift)); 4196 4197 // Check if element mirror is a value mirror 4198 IfNode* iff = create_and_map_if(control(), is_value_mirror(elem_mirror), PROB_FAIR, COUNT_UNKNOWN); 4199 4200 // Not a value mirror but a box mirror or not a value type array, initialize with all zero 4201 r->init_req(1, _gvn.transform(new IfFalseNode(iff))); 4202 default_value->init_req(1, null()); 4203 storage_properties->init_req(1, empty); 4204 4205 // Value mirror (= null-free), check if flattened 4206 set_control(_gvn.transform(new IfTrueNode(iff))); 4207 Node* cmp = gen_lh_array_test(klass_node, Klass::_lh_array_tag_vt_value); 4208 Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq)); 4209 iff = create_and_map_if(control(), bol, PROB_FAIR, COUNT_UNKNOWN); 4210 4211 // Flattened, initialize with all zero 4212 r->init_req(2, _gvn.transform(new IfTrueNode(iff))); 4213 default_value->init_req(2, null()); 4214 storage_properties->init_req(2, flat); 4215 4216 // Non-flattened, initialize with the default value 4217 set_control(_gvn.transform(new IfFalseNode(iff))); 4218 Node* p = basic_plus_adr(klass_node, in_bytes(ArrayKlass::element_klass_offset())); 4219 Node* eklass = _gvn.transform(LoadKlassNode::make(_gvn, control(), immutable_memory(), p, TypeInstPtr::KLASS)); 4220 Node* adr_fixed_block_addr = basic_plus_adr(eklass, in_bytes(InstanceKlass::adr_valueklass_fixed_block_offset())); 4221 Node* adr_fixed_block = make_load(control(), adr_fixed_block_addr, TypeRawPtr::NOTNULL, T_ADDRESS, MemNode::unordered); 4222 Node* default_value_offset_addr = basic_plus_adr(adr_fixed_block, in_bytes(ValueKlass::default_value_offset_offset())); 4223 Node* default_value_offset = make_load(control(), default_value_offset_addr, TypeInt::INT, T_INT, MemNode::unordered); 4224 Node* default_value_addr = basic_plus_adr(elem_mirror, ConvI2X(default_value_offset)); 4225 Node* val = access_load_at(elem_mirror, default_value_addr, _gvn.type(default_value_addr)->is_ptr(), TypeInstPtr::BOTTOM, T_OBJECT, IN_HEAP); 4226 r->init_req(3, control()); 4227 default_value->init_req(3, val); 4228 storage_properties->init_req(3, null_free); 4229 4230 set_control(_gvn.transform(r)); 4231 default_value = _gvn.transform(default_value); 4232 storage_properties = _gvn.transform(storage_properties); 4233 if (UseCompressedOops) { 4234 default_value = _gvn.transform(new EncodePNode(default_value, default_value->bottom_type()->make_narrowoop())); 4235 raw_default_value = raw_default_for_coops(default_value, *this); 4236 } else { 4237 raw_default_value = _gvn.transform(new CastP2XNode(control(), default_value)); 4238 } 4239 } 4240 4241 // Create the AllocateArrayNode and its result projections 4242 AllocateArrayNode* alloc = new AllocateArrayNode(C, AllocateArrayNode::alloc_type(TypeInt::INT), 4243 control(), mem, i_o(), 4244 size, klass_node, 4245 initial_slow_test, 4246 length, default_value, 4247 raw_default_value, 4248 storage_properties); 4249 4250 // Cast to correct type. Note that the klass_node may be constant or not, 4251 // and in the latter case the actual array type will be inexact also. 4252 // (This happens via a non-constant argument to inline_native_newArray.) 4253 // In any case, the value of klass_node provides the desired array type. 4254 const TypeInt* length_type = _gvn.find_int_type(length); 4255 if (ary_type->isa_aryptr() && length_type != NULL) { 4256 // Try to get a better type than POS for the size 4257 ary_type = ary_type->is_aryptr()->cast_to_size(length_type); 4258 } |