< prev index next >

src/hotspot/share/opto/macro.cpp

Print this page




 656     } else if (mem->is_ArrayCopy()) {
 657       Node* ctl = mem->in(0);
 658       Node* m = mem->in(TypeFunc::Memory);
 659       if (sfpt_ctl->is_Proj() && sfpt_ctl->as_Proj()->is_uncommon_trap_proj(Deoptimization::Reason_none)) {
 660         // pin the loads in the uncommon trap path
 661         ctl = sfpt_ctl;
 662         m = sfpt_mem;
 663       }
 664       return make_arraycopy_load(mem->as_ArrayCopy(), offset, ctl, m, ft, ftype, alloc);
 665     }
 666   }
 667   // Something went wrong.
 668   return NULL;
 669 }
 670 
 671 // Search the last value stored into the value type's fields.
 672 Node* PhaseMacroExpand::value_type_from_mem(Node* mem, Node* ctl, ciValueKlass* vk, const TypeAryPtr* adr_type, int offset, AllocateNode* alloc) {
 673   // Subtract the offset of the first field to account for the missing oop header
 674   offset -= vk->first_field_offset();
 675   // Create a new ValueTypeNode and retrieve the field values from memory
 676   ValueTypeNode* vt = ValueTypeNode::make(_igvn, vk)->as_ValueType();
 677   for (int i = 0; i < vk->nof_declared_nonstatic_fields(); ++i) {
 678     ciType* field_type = vt->field_type(i);
 679     int field_offset = offset + vt->field_offset(i);
 680     // Each value type field has its own memory slice
 681     adr_type = adr_type->with_field_offset(field_offset);
 682     Node* value = NULL;
 683     if (field_type->is_valuetype() && vt->field_is_flattened(i)) {
 684       value = value_type_from_mem(mem, ctl, field_type->as_value_klass(), adr_type, field_offset, alloc);
 685     } else {
 686       const Type* ft = Type::get_const_type(field_type);
 687       BasicType bt = field_type->basic_type();
 688       if (UseCompressedOops && !is_java_primitive(bt)) {
 689         ft = ft->make_narrowoop();
 690         bt = T_NARROWOOP;
 691       }
 692       value = value_from_mem(mem, ctl, bt, ft, adr_type, alloc);
 693       if (ft->isa_narrowoop()) {
 694         assert(UseCompressedOops, "unexpected narrow oop");
 695         value = transform_later(new DecodeNNode(value, value->get_ptr_type()));
 696       }
 697     }
 698     vt->set_field_value(i, value);
 699   }
 700   return vt;
 701 }
 702 
 703 // Check the possibility of scalar replacement.




 656     } else if (mem->is_ArrayCopy()) {
 657       Node* ctl = mem->in(0);
 658       Node* m = mem->in(TypeFunc::Memory);
 659       if (sfpt_ctl->is_Proj() && sfpt_ctl->as_Proj()->is_uncommon_trap_proj(Deoptimization::Reason_none)) {
 660         // pin the loads in the uncommon trap path
 661         ctl = sfpt_ctl;
 662         m = sfpt_mem;
 663       }
 664       return make_arraycopy_load(mem->as_ArrayCopy(), offset, ctl, m, ft, ftype, alloc);
 665     }
 666   }
 667   // Something went wrong.
 668   return NULL;
 669 }
 670 
 671 // Search the last value stored into the value type's fields.
 672 Node* PhaseMacroExpand::value_type_from_mem(Node* mem, Node* ctl, ciValueKlass* vk, const TypeAryPtr* adr_type, int offset, AllocateNode* alloc) {
 673   // Subtract the offset of the first field to account for the missing oop header
 674   offset -= vk->first_field_offset();
 675   // Create a new ValueTypeNode and retrieve the field values from memory
 676   ValueTypeNode* vt = ValueTypeNode::make_uninitialized(_igvn, vk)->as_ValueType();
 677   for (int i = 0; i < vk->nof_declared_nonstatic_fields(); ++i) {
 678     ciType* field_type = vt->field_type(i);
 679     int field_offset = offset + vt->field_offset(i);
 680     // Each value type field has its own memory slice
 681     adr_type = adr_type->with_field_offset(field_offset);
 682     Node* value = NULL;
 683     if (vt->field_is_flattened(i)) {
 684       value = value_type_from_mem(mem, ctl, field_type->as_value_klass(), adr_type, field_offset, alloc);
 685     } else {
 686       const Type* ft = Type::get_const_type(field_type);
 687       BasicType bt = field_type->basic_type();
 688       if (UseCompressedOops && !is_java_primitive(bt)) {
 689         ft = ft->make_narrowoop();
 690         bt = T_NARROWOOP;
 691       }
 692       value = value_from_mem(mem, ctl, bt, ft, adr_type, alloc);
 693       if (ft->isa_narrowoop()) {
 694         assert(UseCompressedOops, "unexpected narrow oop");
 695         value = transform_later(new DecodeNNode(value, value->get_ptr_type()));
 696       }
 697     }
 698     vt->set_field_value(i, value);
 699   }
 700   return vt;
 701 }
 702 
 703 // Check the possibility of scalar replacement.


< prev index next >