3712 int next_static_double_offset = next_static_oop_offset + |
3712 int next_static_double_offset = next_static_oop_offset + |
3713 ((fac->count[STATIC_OOP]) * heapOopSize); |
3713 ((fac->count[STATIC_OOP]) * heapOopSize); |
3714 if ( fac->count[STATIC_DOUBLE] && |
3714 if ( fac->count[STATIC_DOUBLE] && |
3715 (Universe::field_type_should_be_aligned(T_DOUBLE) || |
3715 (Universe::field_type_should_be_aligned(T_DOUBLE) || |
3716 Universe::field_type_should_be_aligned(T_LONG)) ) { |
3716 Universe::field_type_should_be_aligned(T_LONG)) ) { |
3717 next_static_double_offset = align_size_up(next_static_double_offset, BytesPerLong); |
3717 next_static_double_offset = align_up(next_static_double_offset, BytesPerLong); |
3718 } |
3718 } |
3719 |
3719 |
3720 int next_static_word_offset = next_static_double_offset + |
3720 int next_static_word_offset = next_static_double_offset + |
3721 ((fac->count[STATIC_DOUBLE]) * BytesPerLong); |
3721 ((fac->count[STATIC_DOUBLE]) * BytesPerLong); |
3722 int next_static_short_offset = next_static_word_offset + |
3722 int next_static_short_offset = next_static_word_offset + |
3854 |
3854 |
3855 // Try to squeeze some of the fields into the gaps due to |
3855 // Try to squeeze some of the fields into the gaps due to |
3856 // long/double alignment. |
3856 // long/double alignment. |
3857 if (nonstatic_double_count > 0) { |
3857 if (nonstatic_double_count > 0) { |
3858 int offset = next_nonstatic_double_offset; |
3858 int offset = next_nonstatic_double_offset; |
3859 next_nonstatic_double_offset = align_size_up(offset, BytesPerLong); |
3859 next_nonstatic_double_offset = align_up(offset, BytesPerLong); |
3860 if (compact_fields && offset != next_nonstatic_double_offset) { |
3860 if (compact_fields && offset != next_nonstatic_double_offset) { |
3861 // Allocate available fields into the gap before double field. |
3861 // Allocate available fields into the gap before double field. |
3862 int length = next_nonstatic_double_offset - offset; |
3862 int length = next_nonstatic_double_offset - offset; |
3863 assert(length == BytesPerInt, ""); |
3863 assert(length == BytesPerInt, ""); |
3864 nonstatic_word_space_offset = offset; |
3864 nonstatic_word_space_offset = offset; |
3904 |
3904 |
3905 // let oops jump before padding with this allocation style |
3905 // let oops jump before padding with this allocation style |
3906 if( allocation_style == 1 ) { |
3906 if( allocation_style == 1 ) { |
3907 next_nonstatic_oop_offset = next_nonstatic_padded_offset; |
3907 next_nonstatic_oop_offset = next_nonstatic_padded_offset; |
3908 if( nonstatic_oop_count > 0 ) { |
3908 if( nonstatic_oop_count > 0 ) { |
3909 next_nonstatic_oop_offset = align_size_up(next_nonstatic_oop_offset, heapOopSize); |
3909 next_nonstatic_oop_offset = align_up(next_nonstatic_oop_offset, heapOopSize); |
3910 } |
3910 } |
3911 next_nonstatic_padded_offset = next_nonstatic_oop_offset + (nonstatic_oop_count * heapOopSize); |
3911 next_nonstatic_padded_offset = next_nonstatic_oop_offset + (nonstatic_oop_count * heapOopSize); |
3912 } |
3912 } |
3913 |
3913 |
3914 // Iterate over fields again and compute correct offsets. |
3914 // Iterate over fields again and compute correct offsets. |
4059 int real_offset = 0; |
4059 int real_offset = 0; |
4060 FieldAllocationType atype = (FieldAllocationType) fs.allocation_type(); |
4060 FieldAllocationType atype = (FieldAllocationType) fs.allocation_type(); |
4061 |
4061 |
4062 switch (atype) { |
4062 switch (atype) { |
4063 case NONSTATIC_BYTE: |
4063 case NONSTATIC_BYTE: |
4064 next_nonstatic_padded_offset = align_size_up(next_nonstatic_padded_offset, 1); |
4064 next_nonstatic_padded_offset = align_up(next_nonstatic_padded_offset, 1); |
4065 real_offset = next_nonstatic_padded_offset; |
4065 real_offset = next_nonstatic_padded_offset; |
4066 next_nonstatic_padded_offset += 1; |
4066 next_nonstatic_padded_offset += 1; |
4067 break; |
4067 break; |
4068 |
4068 |
4069 case NONSTATIC_SHORT: |
4069 case NONSTATIC_SHORT: |
4070 next_nonstatic_padded_offset = align_size_up(next_nonstatic_padded_offset, BytesPerShort); |
4070 next_nonstatic_padded_offset = align_up(next_nonstatic_padded_offset, BytesPerShort); |
4071 real_offset = next_nonstatic_padded_offset; |
4071 real_offset = next_nonstatic_padded_offset; |
4072 next_nonstatic_padded_offset += BytesPerShort; |
4072 next_nonstatic_padded_offset += BytesPerShort; |
4073 break; |
4073 break; |
4074 |
4074 |
4075 case NONSTATIC_WORD: |
4075 case NONSTATIC_WORD: |
4076 next_nonstatic_padded_offset = align_size_up(next_nonstatic_padded_offset, BytesPerInt); |
4076 next_nonstatic_padded_offset = align_up(next_nonstatic_padded_offset, BytesPerInt); |
4077 real_offset = next_nonstatic_padded_offset; |
4077 real_offset = next_nonstatic_padded_offset; |
4078 next_nonstatic_padded_offset += BytesPerInt; |
4078 next_nonstatic_padded_offset += BytesPerInt; |
4079 break; |
4079 break; |
4080 |
4080 |
4081 case NONSTATIC_DOUBLE: |
4081 case NONSTATIC_DOUBLE: |
4082 next_nonstatic_padded_offset = align_size_up(next_nonstatic_padded_offset, BytesPerLong); |
4082 next_nonstatic_padded_offset = align_up(next_nonstatic_padded_offset, BytesPerLong); |
4083 real_offset = next_nonstatic_padded_offset; |
4083 real_offset = next_nonstatic_padded_offset; |
4084 next_nonstatic_padded_offset += BytesPerLong; |
4084 next_nonstatic_padded_offset += BytesPerLong; |
4085 break; |
4085 break; |
4086 |
4086 |
4087 case NONSTATIC_OOP: |
4087 case NONSTATIC_OOP: |
4088 next_nonstatic_padded_offset = align_size_up(next_nonstatic_padded_offset, heapOopSize); |
4088 next_nonstatic_padded_offset = align_up(next_nonstatic_padded_offset, heapOopSize); |
4089 real_offset = next_nonstatic_padded_offset; |
4089 real_offset = next_nonstatic_padded_offset; |
4090 next_nonstatic_padded_offset += heapOopSize; |
4090 next_nonstatic_padded_offset += heapOopSize; |
4091 |
4091 |
4092 // Record this oop in the oop maps |
4092 // Record this oop in the oop maps |
4093 if( nonstatic_oop_map_count > 0 && |
4093 if( nonstatic_oop_map_count > 0 && |
4145 next_nonstatic_padded_offset += ContendedPaddingWidth; |
4145 next_nonstatic_padded_offset += ContendedPaddingWidth; |
4146 } |
4146 } |
4147 |
4147 |
4148 int notaligned_nonstatic_fields_end = next_nonstatic_padded_offset; |
4148 int notaligned_nonstatic_fields_end = next_nonstatic_padded_offset; |
4149 |
4149 |
4150 int nonstatic_fields_end = align_size_up(notaligned_nonstatic_fields_end, heapOopSize); |
4150 int nonstatic_fields_end = align_up(notaligned_nonstatic_fields_end, heapOopSize); |
4151 int instance_end = align_size_up(notaligned_nonstatic_fields_end, wordSize); |
4151 int instance_end = align_up(notaligned_nonstatic_fields_end, wordSize); |
4152 int static_fields_end = align_size_up(next_static_byte_offset, wordSize); |
4152 int static_fields_end = align_up(next_static_byte_offset, wordSize); |
4153 |
4153 |
4154 int static_field_size = (static_fields_end - |
4154 int static_field_size = (static_fields_end - |
4155 InstanceMirrorKlass::offset_of_static_fields()) / wordSize; |
4155 InstanceMirrorKlass::offset_of_static_fields()) / wordSize; |
4156 nonstatic_field_size = nonstatic_field_size + |
4156 nonstatic_field_size = nonstatic_field_size + |
4157 (nonstatic_fields_end - nonstatic_fields_start) / heapOopSize; |
4157 (nonstatic_fields_end - nonstatic_fields_start) / heapOopSize; |
4158 |
4158 |
4159 int instance_size = align_object_size(instance_end / wordSize); |
4159 int instance_size = align_object_size(instance_end / wordSize); |
4160 |
4160 |
4161 assert(instance_size == align_object_size(align_size_up( |
4161 assert(instance_size == align_object_size(align_up( |
4162 (instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize), |
4162 (instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize), |
4163 wordSize) / wordSize), "consistent layout helper value"); |
4163 wordSize) / wordSize), "consistent layout helper value"); |
4164 |
4164 |
4165 // Invariant: nonstatic_field end/start should only change if there are |
4165 // Invariant: nonstatic_field end/start should only change if there are |
4166 // nonstatic fields in the class, or if the class is contended. We compare |
4166 // nonstatic fields in the class, or if the class is contended. We compare |