1197 }
1198 Node* conv = _gvn.transform( new ConvI2LNode(offset));
1199 Node* mask = _gvn.transform(ConLNode::make((julong) max_juint));
1200 return _gvn.transform( new AndLNode(conv, mask) );
1201 }
1202
1203 Node* GraphKit::ConvL2I(Node* offset) {
1204 // short-circuit a common case
1205 jlong offset_con = find_long_con(offset, (jlong)Type::OffsetBot);
1206 if (offset_con != (jlong)Type::OffsetBot) {
1207 return intcon((int) offset_con);
1208 }
1209 return _gvn.transform( new ConvL2INode(offset));
1210 }
1211
1212 //-------------------------load_object_klass-----------------------------------
1213 Node* GraphKit::load_object_klass(Node* obj) {
1214 // Special-case a fresh allocation to avoid building nodes:
1215 Node* akls = AllocateNode::Ideal_klass(obj, &_gvn);
1216 if (akls != nullptr) return akls;
1217 Node* k_adr = basic_plus_adr(obj, oopDesc::klass_offset_in_bytes());
1218 return _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), k_adr, TypeInstPtr::KLASS));
1219 }
1220
1221 //-------------------------load_array_length-----------------------------------
1222 Node* GraphKit::load_array_length(Node* array) {
1223 // Special-case a fresh allocation to avoid building nodes:
1224 AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(array);
1225 Node *alen;
1226 if (alloc == nullptr) {
1227 Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes());
1228 alen = _gvn.transform( new LoadRangeNode(nullptr, immutable_memory(), r_adr, TypeInt::POS));
1229 } else {
1230 alen = array_ideal_length(alloc, _gvn.type(array)->is_oopptr(), false);
1231 }
1232 return alen;
1233 }
1234
1235 Node* GraphKit::array_ideal_length(AllocateArrayNode* alloc,
1236 const TypeOopPtr* oop_type,
1237 bool replace_length_in_map) {
3629 InitializeNode* init = insert_mem_bar_volatile(Op_Initialize, rawidx,
3630 rawoop)->as_Initialize();
3631 assert(alloc->initialization() == init, "2-way macro link must work");
3632 assert(init ->allocation() == alloc, "2-way macro link must work");
3633 {
3634 // Extract memory strands which may participate in the new object's
3635 // initialization, and source them from the new InitializeNode.
3636 // This will allow us to observe initializations when they occur,
3637 // and link them properly (as a group) to the InitializeNode.
3638 assert(init->in(InitializeNode::Memory) == malloc, "");
3639 MergeMemNode* minit_in = MergeMemNode::make(malloc);
3640 init->set_req(InitializeNode::Memory, minit_in);
3641 record_for_igvn(minit_in); // fold it up later, if possible
3642 Node* minit_out = memory(rawidx);
3643 assert(minit_out->is_Proj() && minit_out->in(0) == init, "");
3644 int mark_idx = C->get_alias_index(oop_type->add_offset(oopDesc::mark_offset_in_bytes()));
3645 // Add an edge in the MergeMem for the header fields so an access to one of those has correct memory state.
3646 // Use one NarrowMemProjNode per slice to properly record the adr type of each slice. The Initialize node will have
3647 // multiple projections as a result.
3648 set_memory(_gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(mark_idx))), mark_idx);
3649 int klass_idx = C->get_alias_index(oop_type->add_offset(oopDesc::klass_offset_in_bytes()));
3650 set_memory(_gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(klass_idx))), klass_idx);
3651 if (oop_type->isa_aryptr()) {
3652 const TypePtr* telemref = oop_type->add_offset(Type::OffsetBot);
3653 int elemidx = C->get_alias_index(telemref);
3654 hook_memory_on_init(*this, elemidx, minit_in, _gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(elemidx))));
3655 } else if (oop_type->isa_instptr()) {
3656 ciInstanceKlass* ik = oop_type->is_instptr()->instance_klass();
3657 for (int i = 0, len = ik->nof_nonstatic_fields(); i < len; i++) {
3658 ciField* field = ik->nonstatic_field_at(i);
3659 if (field->offset_in_bytes() >= TrackedInitializationLimit * HeapWordSize)
3660 continue; // do not bother to track really large numbers of fields
3661 // Find (or create) the alias category for this field:
3662 int fieldidx = C->alias_type(field)->index();
3663 hook_memory_on_init(*this, fieldidx, minit_in, _gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(fieldidx))));
3664 }
3665 }
3666 }
3667
3668 // Cast raw oop to the real thing...
3669 Node* javaoop = new CheckCastPPNode(control(), rawoop, oop_type);
|
1197 }
1198 Node* conv = _gvn.transform( new ConvI2LNode(offset));
1199 Node* mask = _gvn.transform(ConLNode::make((julong) max_juint));
1200 return _gvn.transform( new AndLNode(conv, mask) );
1201 }
1202
1203 Node* GraphKit::ConvL2I(Node* offset) {
1204 // short-circuit a common case
1205 jlong offset_con = find_long_con(offset, (jlong)Type::OffsetBot);
1206 if (offset_con != (jlong)Type::OffsetBot) {
1207 return intcon((int) offset_con);
1208 }
1209 return _gvn.transform( new ConvL2INode(offset));
1210 }
1211
1212 //-------------------------load_object_klass-----------------------------------
1213 Node* GraphKit::load_object_klass(Node* obj) {
1214 // Special-case a fresh allocation to avoid building nodes:
1215 Node* akls = AllocateNode::Ideal_klass(obj, &_gvn);
1216 if (akls != nullptr) return akls;
1217 Node* k_adr = basic_plus_adr(obj, Type::klass_offset());
1218 return _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), k_adr, TypeInstPtr::KLASS));
1219 }
1220
1221 //-------------------------load_array_length-----------------------------------
1222 Node* GraphKit::load_array_length(Node* array) {
1223 // Special-case a fresh allocation to avoid building nodes:
1224 AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(array);
1225 Node *alen;
1226 if (alloc == nullptr) {
1227 Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes());
1228 alen = _gvn.transform( new LoadRangeNode(nullptr, immutable_memory(), r_adr, TypeInt::POS));
1229 } else {
1230 alen = array_ideal_length(alloc, _gvn.type(array)->is_oopptr(), false);
1231 }
1232 return alen;
1233 }
1234
1235 Node* GraphKit::array_ideal_length(AllocateArrayNode* alloc,
1236 const TypeOopPtr* oop_type,
1237 bool replace_length_in_map) {
3629 InitializeNode* init = insert_mem_bar_volatile(Op_Initialize, rawidx,
3630 rawoop)->as_Initialize();
3631 assert(alloc->initialization() == init, "2-way macro link must work");
3632 assert(init ->allocation() == alloc, "2-way macro link must work");
3633 {
3634 // Extract memory strands which may participate in the new object's
3635 // initialization, and source them from the new InitializeNode.
3636 // This will allow us to observe initializations when they occur,
3637 // and link them properly (as a group) to the InitializeNode.
3638 assert(init->in(InitializeNode::Memory) == malloc, "");
3639 MergeMemNode* minit_in = MergeMemNode::make(malloc);
3640 init->set_req(InitializeNode::Memory, minit_in);
3641 record_for_igvn(minit_in); // fold it up later, if possible
3642 Node* minit_out = memory(rawidx);
3643 assert(minit_out->is_Proj() && minit_out->in(0) == init, "");
3644 int mark_idx = C->get_alias_index(oop_type->add_offset(oopDesc::mark_offset_in_bytes()));
3645 // Add an edge in the MergeMem for the header fields so an access to one of those has correct memory state.
3646 // Use one NarrowMemProjNode per slice to properly record the adr type of each slice. The Initialize node will have
3647 // multiple projections as a result.
3648 set_memory(_gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(mark_idx))), mark_idx);
3649 int klass_idx = C->get_alias_index(oop_type->add_offset(Type::klass_offset()));
3650 set_memory(_gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(klass_idx))), klass_idx);
3651 if (oop_type->isa_aryptr()) {
3652 const TypePtr* telemref = oop_type->add_offset(Type::OffsetBot);
3653 int elemidx = C->get_alias_index(telemref);
3654 hook_memory_on_init(*this, elemidx, minit_in, _gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(elemidx))));
3655 } else if (oop_type->isa_instptr()) {
3656 ciInstanceKlass* ik = oop_type->is_instptr()->instance_klass();
3657 for (int i = 0, len = ik->nof_nonstatic_fields(); i < len; i++) {
3658 ciField* field = ik->nonstatic_field_at(i);
3659 if (field->offset_in_bytes() >= TrackedInitializationLimit * HeapWordSize)
3660 continue; // do not bother to track really large numbers of fields
3661 // Find (or create) the alias category for this field:
3662 int fieldidx = C->alias_type(field)->index();
3663 hook_memory_on_init(*this, fieldidx, minit_in, _gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(fieldidx))));
3664 }
3665 }
3666 }
3667
3668 // Cast raw oop to the real thing...
3669 Node* javaoop = new CheckCastPPNode(control(), rawoop, oop_type);
|