< prev index next >

src/hotspot/share/opto/graphKit.cpp

Print this page

1254   }
1255   Node* conv = _gvn.transform( new ConvI2LNode(offset));
1256   Node* mask = _gvn.transform(ConLNode::make((julong) max_juint));
1257   return _gvn.transform( new AndLNode(conv, mask) );
1258 }
1259 
1260 Node* GraphKit::ConvL2I(Node* offset) {
1261   // short-circuit a common case
1262   jlong offset_con = find_long_con(offset, (jlong)Type::OffsetBot);
1263   if (offset_con != (jlong)Type::OffsetBot) {
1264     return intcon((int) offset_con);
1265   }
1266   return _gvn.transform( new ConvL2INode(offset));
1267 }
1268 
1269 //-------------------------load_object_klass-----------------------------------
1270 Node* GraphKit::load_object_klass(Node* obj) {
1271   // Special-case a fresh allocation to avoid building nodes:
1272   Node* akls = AllocateNode::Ideal_klass(obj, &_gvn);
1273   if (akls != nullptr)  return akls;
1274   Node* k_adr = basic_plus_adr(obj, oopDesc::klass_offset_in_bytes());
1275   return _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), k_adr, TypeInstPtr::KLASS));
1276 }
1277 
1278 //-------------------------load_array_length-----------------------------------
1279 Node* GraphKit::load_array_length(Node* array) {
1280   // Special-case a fresh allocation to avoid building nodes:
1281   AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(array);
1282   Node *alen;
1283   if (alloc == nullptr) {
1284     Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes());
1285     alen = _gvn.transform( new LoadRangeNode(nullptr, immutable_memory(), r_adr, TypeInt::POS));
1286   } else {
1287     alen = array_ideal_length(alloc, _gvn.type(array)->is_oopptr(), false);
1288   }
1289   return alen;
1290 }
1291 
1292 Node* GraphKit::array_ideal_length(AllocateArrayNode* alloc,
1293                                    const TypeOopPtr* oop_type,
1294                                    bool replace_length_in_map) {

3725   InitializeNode* init = insert_mem_bar_volatile(Op_Initialize, rawidx,
3726                                                  rawoop)->as_Initialize();
3727   assert(alloc->initialization() == init,  "2-way macro link must work");
3728   assert(init ->allocation()     == alloc, "2-way macro link must work");
3729   {
3730     // Extract memory strands which may participate in the new object's
3731     // initialization, and source them from the new InitializeNode.
3732     // This will allow us to observe initializations when they occur,
3733     // and link them properly (as a group) to the InitializeNode.
3734     assert(init->in(InitializeNode::Memory) == malloc, "");
3735     MergeMemNode* minit_in = MergeMemNode::make(malloc);
3736     init->set_req(InitializeNode::Memory, minit_in);
3737     record_for_igvn(minit_in); // fold it up later, if possible
3738     Node* minit_out = memory(rawidx);
3739     assert(minit_out->is_Proj() && minit_out->in(0) == init, "");
3740     int mark_idx = C->get_alias_index(oop_type->add_offset(oopDesc::mark_offset_in_bytes()));
3741     // Add an edge in the MergeMem for the header fields so an access to one of those has correct memory state.
3742     // Use one NarrowMemProjNode per slice to properly record the adr type of each slice. The Initialize node will have
3743     // multiple projections as a result.
3744     set_memory(_gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(mark_idx))), mark_idx);
3745     int klass_idx = C->get_alias_index(oop_type->add_offset(oopDesc::klass_offset_in_bytes()));
3746     set_memory(_gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(klass_idx))), klass_idx);
3747     if (oop_type->isa_aryptr()) {
3748       const TypePtr* telemref = oop_type->add_offset(Type::OffsetBot);
3749       int            elemidx  = C->get_alias_index(telemref);
3750       hook_memory_on_init(*this, elemidx, minit_in, _gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(elemidx))));
3751     } else if (oop_type->isa_instptr()) {
3752       ciInstanceKlass* ik = oop_type->is_instptr()->instance_klass();
3753       for (int i = 0, len = ik->nof_nonstatic_fields(); i < len; i++) {
3754         ciField* field = ik->nonstatic_field_at(i);
3755         if (field->offset_in_bytes() >= TrackedInitializationLimit * HeapWordSize)
3756           continue;  // do not bother to track really large numbers of fields
3757         // Find (or create) the alias category for this field:
3758         int fieldidx = C->alias_type(field)->index();
3759         hook_memory_on_init(*this, fieldidx, minit_in, _gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(fieldidx))));
3760       }
3761     }
3762   }
3763 
3764   // Cast raw oop to the real thing...
3765   Node* javaoop = new CheckCastPPNode(control(), rawoop, oop_type);

1254   }
1255   Node* conv = _gvn.transform( new ConvI2LNode(offset));
1256   Node* mask = _gvn.transform(ConLNode::make((julong) max_juint));
1257   return _gvn.transform( new AndLNode(conv, mask) );
1258 }
1259 
1260 Node* GraphKit::ConvL2I(Node* offset) {
1261   // short-circuit a common case
1262   jlong offset_con = find_long_con(offset, (jlong)Type::OffsetBot);
1263   if (offset_con != (jlong)Type::OffsetBot) {
1264     return intcon((int) offset_con);
1265   }
1266   return _gvn.transform( new ConvL2INode(offset));
1267 }
1268 
1269 //-------------------------load_object_klass-----------------------------------
1270 Node* GraphKit::load_object_klass(Node* obj) {
1271   // Special-case a fresh allocation to avoid building nodes:
1272   Node* akls = AllocateNode::Ideal_klass(obj, &_gvn);
1273   if (akls != nullptr)  return akls;
1274   Node* k_adr = basic_plus_adr(obj, Type::klass_offset());
1275   return _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), k_adr, TypeInstPtr::KLASS));
1276 }
1277 
1278 //-------------------------load_array_length-----------------------------------
1279 Node* GraphKit::load_array_length(Node* array) {
1280   // Special-case a fresh allocation to avoid building nodes:
1281   AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(array);
1282   Node *alen;
1283   if (alloc == nullptr) {
1284     Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes());
1285     alen = _gvn.transform( new LoadRangeNode(nullptr, immutable_memory(), r_adr, TypeInt::POS));
1286   } else {
1287     alen = array_ideal_length(alloc, _gvn.type(array)->is_oopptr(), false);
1288   }
1289   return alen;
1290 }
1291 
1292 Node* GraphKit::array_ideal_length(AllocateArrayNode* alloc,
1293                                    const TypeOopPtr* oop_type,
1294                                    bool replace_length_in_map) {

3725   InitializeNode* init = insert_mem_bar_volatile(Op_Initialize, rawidx,
3726                                                  rawoop)->as_Initialize();
3727   assert(alloc->initialization() == init,  "2-way macro link must work");
3728   assert(init ->allocation()     == alloc, "2-way macro link must work");
3729   {
3730     // Extract memory strands which may participate in the new object's
3731     // initialization, and source them from the new InitializeNode.
3732     // This will allow us to observe initializations when they occur,
3733     // and link them properly (as a group) to the InitializeNode.
3734     assert(init->in(InitializeNode::Memory) == malloc, "");
3735     MergeMemNode* minit_in = MergeMemNode::make(malloc);
3736     init->set_req(InitializeNode::Memory, minit_in);
3737     record_for_igvn(minit_in); // fold it up later, if possible
3738     Node* minit_out = memory(rawidx);
3739     assert(minit_out->is_Proj() && minit_out->in(0) == init, "");
3740     int mark_idx = C->get_alias_index(oop_type->add_offset(oopDesc::mark_offset_in_bytes()));
3741     // Add an edge in the MergeMem for the header fields so an access to one of those has correct memory state.
3742     // Use one NarrowMemProjNode per slice to properly record the adr type of each slice. The Initialize node will have
3743     // multiple projections as a result.
3744     set_memory(_gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(mark_idx))), mark_idx);
3745     int klass_idx = C->get_alias_index(oop_type->add_offset(Type::klass_offset()));
3746     set_memory(_gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(klass_idx))), klass_idx);
3747     if (oop_type->isa_aryptr()) {
3748       const TypePtr* telemref = oop_type->add_offset(Type::OffsetBot);
3749       int            elemidx  = C->get_alias_index(telemref);
3750       hook_memory_on_init(*this, elemidx, minit_in, _gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(elemidx))));
3751     } else if (oop_type->isa_instptr()) {
3752       ciInstanceKlass* ik = oop_type->is_instptr()->instance_klass();
3753       for (int i = 0, len = ik->nof_nonstatic_fields(); i < len; i++) {
3754         ciField* field = ik->nonstatic_field_at(i);
3755         if (field->offset_in_bytes() >= TrackedInitializationLimit * HeapWordSize)
3756           continue;  // do not bother to track really large numbers of fields
3757         // Find (or create) the alias category for this field:
3758         int fieldidx = C->alias_type(field)->index();
3759         hook_memory_on_init(*this, fieldidx, minit_in, _gvn.transform(new NarrowMemProjNode(init, C->get_adr_type(fieldidx))));
3760       }
3761     }
3762   }
3763 
3764   // Cast raw oop to the real thing...
3765   Node* javaoop = new CheckCastPPNode(control(), rawoop, oop_type);
< prev index next >