< prev index next >

src/hotspot/share/opto/macro.cpp

Print this page




 674   // Subtract the offset of the first field to account for the missing oop header
 675   offset -= vk->first_field_offset();
 676   // Create a new ValueTypeNode and retrieve the field values from memory
 677   ValueTypeNode* vt = ValueTypeNode::make_uninitialized(_igvn, vk)->as_ValueType();
 678   for (int i = 0; i < vk->nof_declared_nonstatic_fields(); ++i) {
 679     ciType* field_type = vt->field_type(i);
 680     int field_offset = offset + vt->field_offset(i);
 681     // Each value type field has its own memory slice
 682     adr_type = adr_type->with_field_offset(field_offset);
 683     Node* value = NULL;
 684     if (vt->field_is_flattened(i)) {
 685       value = value_type_from_mem(mem, ctl, field_type->as_value_klass(), adr_type, field_offset, alloc);
 686     } else {
 687       const Type* ft = Type::get_const_type(field_type);
 688       BasicType bt = field_type->basic_type();
 689       if (UseCompressedOops && !is_java_primitive(bt)) {
 690         ft = ft->make_narrowoop();
 691         bt = T_NARROWOOP;
 692       }
 693       value = value_from_mem(mem, ctl, bt, ft, adr_type, alloc);
 694       assert(value != NULL, "field value should not be null");
 695       if (ft->isa_narrowoop()) {
 696         assert(UseCompressedOops, "unexpected narrow oop");
 697         value = transform_later(new DecodeNNode(value, value->get_ptr_type()));
 698       }
 699     }

 700     vt->set_field_value(i, value);




 701   }
 702   return vt;
 703 }
 704 
 705 // Check the possibility of scalar replacement.
 706 bool PhaseMacroExpand::can_eliminate_allocation(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints) {
 707   //  Scan the uses of the allocation to check for anything that would
 708   //  prevent us from eliminating it.
 709   NOT_PRODUCT( const char* fail_eliminate = NULL; )
 710   DEBUG_ONLY( Node* disq_node = NULL; )
 711   bool  can_eliminate = true;
 712 
 713   Node* res = alloc->result_cast();
 714   const TypeOopPtr* res_type = NULL;
 715   if (res == NULL) {
 716     // All users were eliminated.
 717   } else if (!res->is_CheckCastPP()) {
 718     NOT_PRODUCT(fail_eliminate = "Allocation does not have unique CheckCastPP";)
 719     can_eliminate = false;
 720   } else {




 674   // Subtract the offset of the first field to account for the missing oop header
 675   offset -= vk->first_field_offset();
 676   // Create a new ValueTypeNode and retrieve the field values from memory
 677   ValueTypeNode* vt = ValueTypeNode::make_uninitialized(_igvn, vk)->as_ValueType();
 678   for (int i = 0; i < vk->nof_declared_nonstatic_fields(); ++i) {
 679     ciType* field_type = vt->field_type(i);
 680     int field_offset = offset + vt->field_offset(i);
 681     // Each value type field has its own memory slice
 682     adr_type = adr_type->with_field_offset(field_offset);
 683     Node* value = NULL;
 684     if (vt->field_is_flattened(i)) {
 685       value = value_type_from_mem(mem, ctl, field_type->as_value_klass(), adr_type, field_offset, alloc);
 686     } else {
 687       const Type* ft = Type::get_const_type(field_type);
 688       BasicType bt = field_type->basic_type();
 689       if (UseCompressedOops && !is_java_primitive(bt)) {
 690         ft = ft->make_narrowoop();
 691         bt = T_NARROWOOP;
 692       }
 693       value = value_from_mem(mem, ctl, bt, ft, adr_type, alloc);
 694       if (value != NULL && ft->isa_narrowoop()) {

 695         assert(UseCompressedOops, "unexpected narrow oop");
 696         value = transform_later(new DecodeNNode(value, value->get_ptr_type()));
 697       }
 698     }
 699     if (value != NULL) {
 700       vt->set_field_value(i, value);
 701     } else {
 702       // We might have reached the TrackedInitializationLimit
 703       return NULL;
 704     }
 705   }
 706   return vt;
 707 }
 708 
 709 // Check the possibility of scalar replacement.
 710 bool PhaseMacroExpand::can_eliminate_allocation(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints) {
 711   //  Scan the uses of the allocation to check for anything that would
 712   //  prevent us from eliminating it.
 713   NOT_PRODUCT( const char* fail_eliminate = NULL; )
 714   DEBUG_ONLY( Node* disq_node = NULL; )
 715   bool  can_eliminate = true;
 716 
 717   Node* res = alloc->result_cast();
 718   const TypeOopPtr* res_type = NULL;
 719   if (res == NULL) {
 720     // All users were eliminated.
 721   } else if (!res->is_CheckCastPP()) {
 722     NOT_PRODUCT(fail_eliminate = "Allocation does not have unique CheckCastPP";)
 723     can_eliminate = false;
 724   } else {


< prev index next >