4249 __ sync_kit(this); 4250 4251 Node* card_val_reload = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw); 4252 __ if_then(card_val_reload, BoolTest::ne, dirty_card); { 4253 g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf); 4254 } __ end_if(); 4255 } __ end_if(); 4256 } __ end_if(); 4257 } __ end_if(); 4258 } else { 4259 // Object.clone() instrinsic uses this path. 4260 g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf); 4261 } 4262 4263 // Final sync IdealKit and GraphKit. 4264 final_sync(ideal); 4265 } 4266 #undef __ 4267 4268 4269 4270 Node* GraphKit::load_String_offset(Node* ctrl, Node* str) { 4271 if (java_lang_String::has_offset_field()) { 4272 int offset_offset = java_lang_String::offset_offset_in_bytes(); 4273 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 4274 false, NULL, 0); 4275 const TypePtr* offset_field_type = string_type->add_offset(offset_offset); 4276 int offset_field_idx = C->get_alias_index(offset_field_type); 4277 return make_load(ctrl, 4278 basic_plus_adr(str, str, offset_offset), 4279 TypeInt::INT, T_INT, offset_field_idx, MemNode::unordered); 4280 } else { 4281 return intcon(0); 4282 } 4283 } 4284 4285 Node* GraphKit::load_String_length(Node* ctrl, Node* str) { 4286 if (java_lang_String::has_count_field()) { 4287 int count_offset = java_lang_String::count_offset_in_bytes(); 4288 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 4289 false, NULL, 0); 4290 const TypePtr* count_field_type = string_type->add_offset(count_offset); 4291 int count_field_idx = C->get_alias_index(count_field_type); 4292 return make_load(ctrl, 4293 basic_plus_adr(str, str, count_offset), 4294 TypeInt::INT, T_INT, count_field_idx, MemNode::unordered); 4295 } else { 4296 return load_array_length(load_String_value(ctrl, str)); 4297 } 4298 } 4299 4300 Node* GraphKit::load_String_value(Node* ctrl, Node* str) { 4301 int value_offset = java_lang_String::value_offset_in_bytes(); 4302 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 4303 false, NULL, 0); 4304 const TypePtr* value_field_type = string_type->add_offset(value_offset); 4305 const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull, 4306 TypeAry::make(TypeInt::CHAR,TypeInt::POS), 4307 ciTypeArrayKlass::make(T_CHAR), true, 0); 4308 int value_field_idx = C->get_alias_index(value_field_type); 4309 Node* load = make_load(ctrl, basic_plus_adr(str, str, value_offset), 4310 value_type, T_OBJECT, value_field_idx, MemNode::unordered); 4311 // String.value field is known to be @Stable. 4312 if (UseImplicitStableValues) { 4313 load = cast_array_to_stable(load, value_type); 4314 } 4315 return load; 4316 } 4317 4318 void GraphKit::store_String_offset(Node* ctrl, Node* str, Node* value) { 4319 int offset_offset = java_lang_String::offset_offset_in_bytes(); 4320 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 4321 false, NULL, 0); 4322 const TypePtr* offset_field_type = string_type->add_offset(offset_offset); 4323 int offset_field_idx = C->get_alias_index(offset_field_type); 4324 store_to_memory(ctrl, basic_plus_adr(str, offset_offset), 4325 value, T_INT, offset_field_idx, MemNode::unordered); 4326 } 4327 4328 void GraphKit::store_String_value(Node* ctrl, Node* str, Node* value) { 4329 int value_offset = java_lang_String::value_offset_in_bytes(); 4330 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 4331 false, NULL, 0); 4332 const TypePtr* value_field_type = string_type->add_offset(value_offset); 4333 4334 store_oop_to_object(ctrl, str, basic_plus_adr(str, value_offset), value_field_type, 4335 value, TypeAryPtr::CHARS, T_OBJECT, MemNode::unordered); 4336 } 4337 4338 void GraphKit::store_String_length(Node* ctrl, Node* str, Node* value) { 4339 int count_offset = java_lang_String::count_offset_in_bytes(); 4340 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 4341 false, NULL, 0); 4342 const TypePtr* count_field_type = string_type->add_offset(count_offset); 4343 int count_field_idx = C->get_alias_index(count_field_type); 4344 store_to_memory(ctrl, basic_plus_adr(str, count_offset), 4345 value, T_INT, count_field_idx, MemNode::unordered); 4346 } 4347 4348 Node* GraphKit::cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type) { 4349 // Reify the property as a CastPP node in Ideal graph to comply with monotonicity 4350 // assumption of CCP analysis. 4351 return _gvn.transform(new CastPPNode(ary, ary_type->cast_to_stable(true))); 4352 } | 4249 __ sync_kit(this); 4250 4251 Node* card_val_reload = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw); 4252 __ if_then(card_val_reload, BoolTest::ne, dirty_card); { 4253 g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf); 4254 } __ end_if(); 4255 } __ end_if(); 4256 } __ end_if(); 4257 } __ end_if(); 4258 } else { 4259 // Object.clone() instrinsic uses this path. 4260 g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf); 4261 } 4262 4263 // Final sync IdealKit and GraphKit. 4264 final_sync(ideal); 4265 } 4266 #undef __ 4267 4268 4269 Node* GraphKit::load_String_length(Node* ctrl, Node* str) { 4270 Node* len = load_array_length(load_String_value(ctrl, str)); 4271 Node* coder = load_String_coder(ctrl, str); 4272 // Divide length by 2 if coder is UTF16 4273 return _gvn.transform(new RShiftINode(len, coder)); 4274 } 4275 4276 Node* GraphKit::load_String_value(Node* ctrl, Node* str) { 4277 int value_offset = java_lang_String::value_offset_in_bytes(); 4278 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 4279 false, NULL, 0); 4280 const TypePtr* value_field_type = string_type->add_offset(value_offset); 4281 const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull, 4282 TypeAry::make(TypeInt::BYTE, TypeInt::POS), 4283 ciTypeArrayKlass::make(T_BYTE), true, 0); 4284 int value_field_idx = C->get_alias_index(value_field_type); 4285 Node* load = make_load(ctrl, basic_plus_adr(str, str, value_offset), 4286 value_type, T_OBJECT, value_field_idx, MemNode::unordered); 4287 // String.value field is known to be @Stable. 4288 if (UseImplicitStableValues) { 4289 load = cast_array_to_stable(load, value_type); 4290 } 4291 return load; 4292 } 4293 4294 Node* GraphKit::load_String_coder(Node* ctrl, Node* str) { 4295 if (java_lang_String::has_coder_field()) { 4296 if (!CompactStrings) { 4297 return intcon(java_lang_String::CODER_UTF16); 4298 } 4299 int coder_offset = java_lang_String::coder_offset_in_bytes(); 4300 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 4301 false, NULL, 0); 4302 const TypePtr* coder_field_type = string_type->add_offset(coder_offset); 4303 int coder_field_idx = C->get_alias_index(coder_field_type); 4304 return make_load(ctrl, basic_plus_adr(str, str, coder_offset), 4305 TypeInt::BYTE, T_BYTE, coder_field_idx, MemNode::unordered); 4306 } else { 4307 return intcon(0); // false 4308 } 4309 } 4310 4311 void GraphKit::store_String_value(Node* ctrl, Node* str, Node* value) { 4312 int value_offset = java_lang_String::value_offset_in_bytes(); 4313 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 4314 false, NULL, 0); 4315 const TypePtr* value_field_type = string_type->add_offset(value_offset); 4316 store_oop_to_object(ctrl, str, basic_plus_adr(str, value_offset), value_field_type, 4317 value, TypeAryPtr::BYTES, T_OBJECT, MemNode::unordered); 4318 } 4319 4320 void GraphKit::store_String_coder(Node* ctrl, Node* str, Node* value) { 4321 int coder_offset = java_lang_String::coder_offset_in_bytes(); 4322 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 4323 false, NULL, 0); 4324 const TypePtr* coder_field_type = string_type->add_offset(coder_offset); 4325 int coder_field_idx = C->get_alias_index(coder_field_type); 4326 store_to_memory(ctrl, basic_plus_adr(str, coder_offset), 4327 value, T_BYTE, coder_field_idx, MemNode::unordered); 4328 } 4329 4330 Node* GraphKit::compress_string(Node* src, Node* dst, Node* count) { 4331 assert(Matcher::match_rule_supported(Op_StrCompressedCopy), "Intrinsic not supported"); 4332 uint idx = C->get_alias_index(TypeAryPtr::BYTES); 4333 StrCompressedCopyNode* str = new StrCompressedCopyNode(control(), memory(idx), src, dst, count); 4334 Node* res_mem = _gvn.transform(new SCMemProjNode(str)); 4335 set_memory(res_mem, idx); 4336 return str; 4337 } 4338 4339 void GraphKit::inflate_string(Node* src, Node* dst, Node* count) { 4340 assert(Matcher::match_rule_supported(Op_StrInflatedCopy), "Intrinsic not supported"); 4341 uint idx = C->get_alias_index(TypeAryPtr::BYTES); 4342 StrInflatedCopyNode* str = new StrInflatedCopyNode(control(), memory(idx), src, dst, count); 4343 set_memory(_gvn.transform(str), idx); 4344 } 4345 4346 void GraphKit::inflate_string_slow(Node* src, Node* dst, Node* start, Node* count) { 4347 /** 4348 * int i_char = start; 4349 * for (int i_byte = 0; i_byte < count; i_byte++) { 4350 * dst[i_char++] = (char)(src[i_byte] & 0xff); 4351 * } 4352 */ 4353 add_predicate(); 4354 RegionNode* head = new RegionNode(3); 4355 head->init_req(1, control()); 4356 gvn().set_type(head, Type::CONTROL); 4357 record_for_igvn(head); 4358 4359 Node* i_byte = new PhiNode(head, TypeInt::INT); 4360 i_byte->init_req(1, intcon(0)); 4361 gvn().set_type(i_byte, TypeInt::INT); 4362 record_for_igvn(i_byte); 4363 4364 Node* i_char = new PhiNode(head, TypeInt::INT); 4365 i_char->init_req(1, start); 4366 gvn().set_type(i_char, TypeInt::INT); 4367 record_for_igvn(i_char); 4368 4369 Node* mem = PhiNode::make(head, memory(TypeAryPtr::BYTES), Type::MEMORY, TypeAryPtr::BYTES); 4370 gvn().set_type(mem, Type::MEMORY); 4371 record_for_igvn(mem); 4372 set_control(head); 4373 set_memory(mem, TypeAryPtr::BYTES); 4374 Node* ch = load_array_element(control(), src, i_byte, TypeAryPtr::BYTES); 4375 Node* st = store_to_memory(control(), array_element_address(dst, i_char, T_BYTE), 4376 AndI(ch, intcon(0xff)), T_CHAR, TypeAryPtr::BYTES, MemNode::unordered); 4377 4378 IfNode* iff = create_and_map_if(head, Bool(CmpI(i_byte, count), BoolTest::lt), PROB_FAIR, COUNT_UNKNOWN); 4379 head->init_req(2, IfTrue(iff)); 4380 mem->init_req(2, st); 4381 i_byte->init_req(2, AddI(i_byte, intcon(1))); 4382 i_char->init_req(2, AddI(i_char, intcon(2))); 4383 4384 set_control(IfFalse(iff)); 4385 set_memory(st, TypeAryPtr::BYTES); 4386 } 4387 4388 Node* GraphKit::cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type) { 4389 // Reify the property as a CastPP node in Ideal graph to comply with monotonicity 4390 // assumption of CCP analysis. 4391 return _gvn.transform(new CastPPNode(ary, ary_type->cast_to_stable(true))); 4392 } |