< prev index next >

src/share/vm/classfile/classFileParser.cpp

Print this page




3944   // Temporary value types restrictions
3945   if (is_value_type() || is_value_capable_class()) {
3946     if (is_contended_class) {
3947       throwValueTypeLimitation(THREAD_AND_LOCATION, "Value Types do not support @Contended annotation yet");
3948       return;
3949     }
3950   }
3951 
3952   // Compute the non-contended fields count.
3953   // The packing code below relies on these counts to determine if some field
3954   // can be squeezed into the alignment gap. Contended fields are obviously
3955   // exempt from that.
3956   unsigned int nonstatic_double_count = fac->count[NONSTATIC_DOUBLE] - fac_contended.count[NONSTATIC_DOUBLE];
3957   unsigned int nonstatic_word_count   = fac->count[NONSTATIC_WORD]   - fac_contended.count[NONSTATIC_WORD];
3958   unsigned int nonstatic_short_count  = fac->count[NONSTATIC_SHORT]  - fac_contended.count[NONSTATIC_SHORT];
3959   unsigned int nonstatic_byte_count   = fac->count[NONSTATIC_BYTE]   - fac_contended.count[NONSTATIC_BYTE];
3960   unsigned int nonstatic_oop_count    = fac->count[NONSTATIC_OOP]    - fac_contended.count[NONSTATIC_OOP];
3961 
3962   int static_value_type_count = 0;
3963   int nonstatic_value_type_count = 0;

3964   int* nonstatic_value_type_indexes = NULL;
3965   Klass** nonstatic_value_type_klasses = NULL;
3966   unsigned int value_type_oop_map_count = 0;
3967 
3968   int max_nonstatic_value_type = fac->count[NONSTATIC_VALUETYPE] + 1;
3969 
3970   nonstatic_value_type_indexes = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, int,
3971                                                               max_nonstatic_value_type);
3972   for (int i = 0; i < max_nonstatic_value_type; i++) {
3973     nonstatic_value_type_indexes[i] = -1;
3974   }
3975   nonstatic_value_type_klasses = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, Klass*,
3976                                                               max_nonstatic_value_type);
3977 
3978   for (AllFieldStream fs(_fields, _cp); !fs.done(); fs.next()) {
3979     if (fs.allocation_type() == STATIC_VALUETYPE) {
3980       static_value_type_count++;
3981     } else if (fs.allocation_type() == NONSTATIC_VALUETYPE) {
3982       Symbol* signature = fs.signature();
3983       Klass* klass = SystemDictionary::resolve_or_fail(signature,
3984                                                        Handle(THREAD, _loader_data->class_loader()),
3985                                                        _protection_domain, true, CHECK);
3986       assert(klass != NULL, "Sanity check");
3987       assert(klass->access_flags().is_value_type(), "Value type expected");




3988       nonstatic_value_type_indexes[nonstatic_value_type_count] = fs.index();
3989       nonstatic_value_type_klasses[nonstatic_value_type_count] = klass;
3990       nonstatic_value_type_count++;
3991 
3992       ValueKlass* vklass = ValueKlass::cast(klass);
3993       if (vklass->contains_oops()) {
3994         value_type_oop_map_count += vklass->nonstatic_oop_map_count();
3995       }






3996     }
3997   }
3998 
3999   // Total non-static fields count, including every contended field
4000   unsigned int nonstatic_fields_count = fac->count[NONSTATIC_DOUBLE] + fac->count[NONSTATIC_WORD] +
4001                                         fac->count[NONSTATIC_SHORT] + fac->count[NONSTATIC_BYTE] +
4002                                         fac->count[NONSTATIC_OOP] + fac->count[NONSTATIC_VALUETYPE];
4003 
4004   const bool super_has_nonstatic_fields =
4005           (_super_klass != NULL && _super_klass->has_nonstatic_fields());
4006   const bool has_nonstatic_fields =
4007     super_has_nonstatic_fields || (nonstatic_fields_count != 0);
4008   const bool has_nonstatic_value_fields = nonstatic_value_type_count > 0;
4009 
4010   if (is_value_type() && (!has_nonstatic_fields)) {
4011     // There are a number of fixes required throughout the type system and JIT
4012     if (class_name() != vmSymbols::java_lang____Value()) {
4013       throwValueTypeLimitation(THREAD_AND_LOCATION, "Value Types do not support zero instance size yet");
4014     }
4015   }


4058        _class_name == vmSymbols::java_lang_Boolean() ||
4059        _class_name == vmSymbols::java_lang_Character() ||
4060        _class_name == vmSymbols::java_lang_Float() ||
4061        _class_name == vmSymbols::java_lang_Double() ||
4062        _class_name == vmSymbols::java_lang_Byte() ||
4063        _class_name == vmSymbols::java_lang_Short() ||
4064        _class_name == vmSymbols::java_lang_Integer() ||
4065        _class_name == vmSymbols::java_lang_Long())) {
4066     allocation_style = 0;     // Allocate oops first
4067     compact_fields   = false; // Don't compact fields
4068   }
4069 
4070   int next_nonstatic_oop_offset = 0;
4071   int next_nonstatic_double_offset = 0;
4072 
4073   // Rearrange fields for a given allocation style
4074   if( allocation_style == 0 ) {
4075     // Fields order: oops, longs/doubles, ints, shorts/chars, bytes, padded fields
4076     next_nonstatic_oop_offset    = next_nonstatic_field_offset;
4077     next_nonstatic_double_offset = next_nonstatic_oop_offset +
4078                                     (nonstatic_oop_count * heapOopSize);
4079   } else if( allocation_style == 1 ) {
4080     // Fields order: longs/doubles, ints, shorts/chars, bytes, oops, padded fields
4081     next_nonstatic_double_offset = next_nonstatic_field_offset;
4082   } else if( allocation_style == 2 ) {
4083     // Fields allocation: oops fields in super and sub classes are together.
4084     if( nonstatic_field_size > 0 && super_oop_map_count > 0 ) {
4085       if (next_nonstatic_field_offset == nonstatic_oop_maps->last_oop_map()->end_offset()) {
4086         allocation_style = 0;   // allocate oops first
4087         next_nonstatic_oop_offset    = next_nonstatic_field_offset;
4088         next_nonstatic_double_offset = next_nonstatic_oop_offset +
4089                                        (nonstatic_oop_count * heapOopSize);
4090       }
4091     }
4092     if( allocation_style == 2 ) {
4093       allocation_style = 1;     // allocate oops last
4094       next_nonstatic_double_offset = next_nonstatic_field_offset;
4095     }
4096   } else {
4097     ShouldNotReachHere();
4098   }
4099 
4100   int nonstatic_oop_space_count   = 0;
4101   int nonstatic_word_space_count  = 0;
4102   int nonstatic_short_space_count = 0;
4103   int nonstatic_byte_space_count  = 0;
4104   int nonstatic_oop_space_offset = 0;
4105   int nonstatic_word_space_offset = 0;
4106   int nonstatic_short_space_offset = 0;
4107   int nonstatic_byte_space_offset = 0;
4108 
4109   // Try to squeeze some of the fields into the gaps due to


4142         nonstatic_oop_count      -= 1;
4143         nonstatic_oop_space_count = 1; // Only one will fit
4144         length -= heapOopSize;
4145         offset += heapOopSize;
4146       }
4147     }
4148   }
4149 
4150   int next_nonstatic_word_offset = next_nonstatic_double_offset +
4151                                      (nonstatic_double_count * BytesPerLong);
4152   int next_nonstatic_short_offset = next_nonstatic_word_offset +
4153                                       (nonstatic_word_count * BytesPerInt);
4154   int next_nonstatic_byte_offset = next_nonstatic_short_offset +
4155                                      (nonstatic_short_count * BytesPerShort);
4156   int next_nonstatic_padded_offset = next_nonstatic_byte_offset +
4157                                        nonstatic_byte_count;
4158 
4159   // let oops jump before padding with this allocation style
4160   if( allocation_style == 1 ) {
4161     next_nonstatic_oop_offset = next_nonstatic_padded_offset;
4162     if( nonstatic_oop_count > 0 ) {
4163       next_nonstatic_oop_offset = align_up(next_nonstatic_oop_offset, heapOopSize);
4164     }
4165     next_nonstatic_padded_offset = next_nonstatic_oop_offset + (nonstatic_oop_count * heapOopSize);

4166   }
4167 
4168   // Aligning embedded value types
4169   // bug below, the current algorithm to layout embedded value types always put them at the
4170   // end of the layout, which doesn't match the different allocation policies the VM is
4171   // supposed to provide => FixMe
4172   // Note also that the current alignment policy is to make each value type starting on a
4173   // 64 bits boundary. This could be optimized later. For instance, it could be nice to
4174   // align value types according to their most constrained internal type.
4175   next_nonstatic_valuetype_offset = align_up(next_nonstatic_padded_offset, BytesPerLong);
4176   int next_value_type_index = 0;
4177 
4178   // Iterate over fields again and compute correct offsets.
4179   // The field allocation type was temporarily stored in the offset slot.
4180   // oop fields are located before non-oop fields (static and non-static).
4181   for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
4182 
4183     // skip already laid out fields
4184     if (fs.is_offset_set()) continue;
4185 


4197         real_offset = next_static_oop_offset;
4198         next_static_oop_offset += heapOopSize;
4199         break;
4200       case STATIC_BYTE:
4201         real_offset = next_static_byte_offset;
4202         next_static_byte_offset += 1;
4203         break;
4204       case STATIC_SHORT:
4205         real_offset = next_static_short_offset;
4206         next_static_short_offset += BytesPerShort;
4207         break;
4208       case STATIC_WORD:
4209         real_offset = next_static_word_offset;
4210         next_static_word_offset += BytesPerInt;
4211         break;
4212       case STATIC_DOUBLE:
4213         real_offset = next_static_double_offset;
4214         next_static_double_offset += BytesPerLong;
4215         break;
4216       case NONSTATIC_VALUETYPE:
4217       {
4218         Klass* klass = nonstatic_value_type_klasses[next_value_type_index];
4219         assert(klass != NULL, "Klass should have been loaded and resolved earlier");
4220         assert(klass->access_flags().is_value_type(),"Must be a value type");
4221         ValueKlass* vklass = ValueKlass::cast(klass);
4222         real_offset = next_nonstatic_valuetype_offset;
4223         next_nonstatic_valuetype_offset += (vklass->size_helper()) * wordSize - vklass->first_field_offset();
4224         // aligning next value type on a 64 bits boundary
4225         next_nonstatic_valuetype_offset = align_up(next_nonstatic_valuetype_offset, BytesPerLong);
4226         next_value_type_index += 1;
4227 
4228         if (vklass->contains_oops()) { // add flatten oop maps
4229           int diff = real_offset - vklass->first_field_offset();
4230           const OopMapBlock* map = vklass->start_of_nonstatic_oop_maps();
4231           const OopMapBlock* const last_map = map + vklass->nonstatic_oop_map_count();
4232           while (map < last_map) {
4233             nonstatic_oop_maps->add(map->offset() + diff, map->count());
4234             map++;
4235           }
4236         }
4237       }
4238       break;



4239       case NONSTATIC_OOP:
4240         if( nonstatic_oop_space_count > 0 ) {
4241           real_offset = nonstatic_oop_space_offset;
4242           nonstatic_oop_space_offset += heapOopSize;
4243           nonstatic_oop_space_count  -= 1;
4244         } else {
4245           real_offset = next_nonstatic_oop_offset;
4246           next_nonstatic_oop_offset += heapOopSize;
4247         }
4248         nonstatic_oop_maps->add(real_offset, 1);
4249         break;
4250       case NONSTATIC_BYTE:
4251         if( nonstatic_byte_space_count > 0 ) {
4252           real_offset = nonstatic_byte_space_offset;
4253           nonstatic_byte_space_offset += 1;
4254           nonstatic_byte_space_count  -= 1;
4255         } else {
4256           real_offset = next_nonstatic_byte_offset;
4257           next_nonstatic_byte_offset += 1;
4258         }


4387       // this is expected to alleviate memory contention effects for
4388       // subclass fields and/or adjacent object.
4389       // If this was the default group, the padding is already in place.
4390       if (current_group != 0) {
4391         next_nonstatic_padded_offset += ContendedPaddingWidth;
4392       }
4393     }
4394 
4395     // handle static fields
4396   }
4397 
4398   // Entire class is contended, pad in the back.
4399   // This helps to alleviate memory contention effects for subclass fields
4400   // and/or adjacent object.
4401   if (is_contended_class) {
4402     assert(!is_value_type() && !is_value_capable_class(), "@Contended not supported for value types yet");
4403     next_nonstatic_padded_offset += ContendedPaddingWidth;
4404   }
4405 
4406   int notaligned_nonstatic_fields_end;
4407   if (nonstatic_value_type_count != 0) {
4408     notaligned_nonstatic_fields_end = next_nonstatic_valuetype_offset;
4409   } else {
4410     notaligned_nonstatic_fields_end = next_nonstatic_padded_offset;
4411   }
4412 
4413   int nonstatic_field_sz_align = heapOopSize;
4414   if (is_value_type() || is_value_capable_class()) {
4415     if ((notaligned_nonstatic_fields_end - nonstatic_fields_start) > heapOopSize) {
4416       nonstatic_field_sz_align = BytesPerLong; // value copy of fields only uses jlong copy
4417     }
4418   }
4419   int nonstatic_fields_end      = align_up(notaligned_nonstatic_fields_end, nonstatic_field_sz_align);
4420   int instance_end              = align_up(notaligned_nonstatic_fields_end, wordSize);
4421   int static_fields_end         = align_up(next_static_byte_offset, wordSize);
4422 
4423   int static_field_size         = (static_fields_end -
4424                                    InstanceMirrorKlass::offset_of_static_fields()) / wordSize;
4425   nonstatic_field_size          = nonstatic_field_size +
4426                                   (nonstatic_fields_end - nonstatic_fields_start) / heapOopSize;
4427 




3944   // Temporary value types restrictions
3945   if (is_value_type() || is_value_capable_class()) {
3946     if (is_contended_class) {
3947       throwValueTypeLimitation(THREAD_AND_LOCATION, "Value Types do not support @Contended annotation yet");
3948       return;
3949     }
3950   }
3951 
3952   // Compute the non-contended fields count.
3953   // The packing code below relies on these counts to determine if some field
3954   // can be squeezed into the alignment gap. Contended fields are obviously
3955   // exempt from that.
3956   unsigned int nonstatic_double_count = fac->count[NONSTATIC_DOUBLE] - fac_contended.count[NONSTATIC_DOUBLE];
3957   unsigned int nonstatic_word_count   = fac->count[NONSTATIC_WORD]   - fac_contended.count[NONSTATIC_WORD];
3958   unsigned int nonstatic_short_count  = fac->count[NONSTATIC_SHORT]  - fac_contended.count[NONSTATIC_SHORT];
3959   unsigned int nonstatic_byte_count   = fac->count[NONSTATIC_BYTE]   - fac_contended.count[NONSTATIC_BYTE];
3960   unsigned int nonstatic_oop_count    = fac->count[NONSTATIC_OOP]    - fac_contended.count[NONSTATIC_OOP];
3961 
3962   int static_value_type_count = 0;
3963   int nonstatic_value_type_count = 0;
3964   int nonstatic_nonflattened_value_types_count = 0;
3965   int* nonstatic_value_type_indexes = NULL;
3966   Klass** nonstatic_value_type_klasses = NULL;
3967   unsigned int value_type_oop_map_count = 0;
3968 
3969   int max_nonstatic_value_type = fac->count[NONSTATIC_VALUETYPE] + 1;
3970 
3971   nonstatic_value_type_indexes = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, int,
3972                                                               max_nonstatic_value_type);
3973   for (int i = 0; i < max_nonstatic_value_type; i++) {
3974     nonstatic_value_type_indexes[i] = -1;
3975   }
3976   nonstatic_value_type_klasses = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, Klass*,
3977                                                               max_nonstatic_value_type);
3978 
3979   for (AllFieldStream fs(_fields, _cp); !fs.done(); fs.next()) {
3980     if (fs.allocation_type() == STATIC_VALUETYPE) {
3981       static_value_type_count++;
3982     } else if (fs.allocation_type() == NONSTATIC_VALUETYPE) {
3983       Symbol* signature = fs.signature();
3984       Klass* klass = SystemDictionary::resolve_or_fail(signature,
3985                                                        Handle(THREAD, _loader_data->class_loader()),
3986                                                        _protection_domain, true, CHECK);
3987       assert(klass != NULL, "Sanity check");
3988       assert(klass->access_flags().is_value_type(), "Value type expected");
3989       ValueKlass* vk = ValueKlass::cast(klass);
3990       // Conditions to apply flattening or not should be defined
3991       //in a single place
3992       if (vk->size_helper() <= ValueArrayElemMaxFlatSize) {
3993         nonstatic_value_type_indexes[nonstatic_value_type_count] = fs.index();
3994         nonstatic_value_type_klasses[nonstatic_value_type_count] = klass;
3995         nonstatic_value_type_count++;
3996 
3997         ValueKlass* vklass = ValueKlass::cast(klass);
3998         if (vklass->contains_oops()) {
3999           value_type_oop_map_count += vklass->nonstatic_oop_map_count();
4000         }
4001         fs.set_flattening(true);
4002       } else {
4003         nonstatic_nonflattened_value_types_count++;
4004         value_type_oop_map_count++;
4005         fs.set_flattening(false);
4006       }
4007     }
4008   }
4009 
4010   // Total non-static fields count, including every contended field
4011   unsigned int nonstatic_fields_count = fac->count[NONSTATIC_DOUBLE] + fac->count[NONSTATIC_WORD] +
4012                                         fac->count[NONSTATIC_SHORT] + fac->count[NONSTATIC_BYTE] +
4013                                         fac->count[NONSTATIC_OOP] + fac->count[NONSTATIC_VALUETYPE];
4014 
4015   const bool super_has_nonstatic_fields =
4016           (_super_klass != NULL && _super_klass->has_nonstatic_fields());
4017   const bool has_nonstatic_fields =
4018     super_has_nonstatic_fields || (nonstatic_fields_count != 0);
4019   const bool has_nonstatic_value_fields = nonstatic_value_type_count > 0;
4020 
4021   if (is_value_type() && (!has_nonstatic_fields)) {
4022     // There are a number of fixes required throughout the type system and JIT
4023     if (class_name() != vmSymbols::java_lang____Value()) {
4024       throwValueTypeLimitation(THREAD_AND_LOCATION, "Value Types do not support zero instance size yet");
4025     }
4026   }


4069        _class_name == vmSymbols::java_lang_Boolean() ||
4070        _class_name == vmSymbols::java_lang_Character() ||
4071        _class_name == vmSymbols::java_lang_Float() ||
4072        _class_name == vmSymbols::java_lang_Double() ||
4073        _class_name == vmSymbols::java_lang_Byte() ||
4074        _class_name == vmSymbols::java_lang_Short() ||
4075        _class_name == vmSymbols::java_lang_Integer() ||
4076        _class_name == vmSymbols::java_lang_Long())) {
4077     allocation_style = 0;     // Allocate oops first
4078     compact_fields   = false; // Don't compact fields
4079   }
4080 
4081   int next_nonstatic_oop_offset = 0;
4082   int next_nonstatic_double_offset = 0;
4083 
4084   // Rearrange fields for a given allocation style
4085   if( allocation_style == 0 ) {
4086     // Fields order: oops, longs/doubles, ints, shorts/chars, bytes, padded fields
4087     next_nonstatic_oop_offset    = next_nonstatic_field_offset;
4088     next_nonstatic_double_offset = next_nonstatic_oop_offset +
4089                                     ((nonstatic_oop_count + nonstatic_nonflattened_value_types_count) * heapOopSize);
4090   } else if( allocation_style == 1 ) {
4091     // Fields order: longs/doubles, ints, shorts/chars, bytes, oops, padded fields
4092     next_nonstatic_double_offset = next_nonstatic_field_offset;
4093   } else if( allocation_style == 2 ) {
4094     // Fields allocation: oops fields in super and sub classes are together.
4095     if( nonstatic_field_size > 0 && super_oop_map_count > 0 ) {
4096       if (next_nonstatic_field_offset == nonstatic_oop_maps->last_oop_map()->end_offset()) {
4097         allocation_style = 0;   // allocate oops first
4098         next_nonstatic_oop_offset    = next_nonstatic_field_offset;
4099         next_nonstatic_double_offset = next_nonstatic_oop_offset +
4100                                        ((nonstatic_oop_count + nonstatic_nonflattened_value_types_count)* heapOopSize);
4101       }
4102     }
4103     if( allocation_style == 2 ) {
4104       allocation_style = 1;     // allocate oops last
4105       next_nonstatic_double_offset = next_nonstatic_field_offset;
4106     }
4107   } else {
4108     ShouldNotReachHere();
4109   }
4110 
4111   int nonstatic_oop_space_count   = 0;
4112   int nonstatic_word_space_count  = 0;
4113   int nonstatic_short_space_count = 0;
4114   int nonstatic_byte_space_count  = 0;
4115   int nonstatic_oop_space_offset = 0;
4116   int nonstatic_word_space_offset = 0;
4117   int nonstatic_short_space_offset = 0;
4118   int nonstatic_byte_space_offset = 0;
4119 
4120   // Try to squeeze some of the fields into the gaps due to


4153         nonstatic_oop_count      -= 1;
4154         nonstatic_oop_space_count = 1; // Only one will fit
4155         length -= heapOopSize;
4156         offset += heapOopSize;
4157       }
4158     }
4159   }
4160 
4161   int next_nonstatic_word_offset = next_nonstatic_double_offset +
4162                                      (nonstatic_double_count * BytesPerLong);
4163   int next_nonstatic_short_offset = next_nonstatic_word_offset +
4164                                       (nonstatic_word_count * BytesPerInt);
4165   int next_nonstatic_byte_offset = next_nonstatic_short_offset +
4166                                      (nonstatic_short_count * BytesPerShort);
4167   int next_nonstatic_padded_offset = next_nonstatic_byte_offset +
4168                                        nonstatic_byte_count;
4169 
4170   // let oops jump before padding with this allocation style
4171   if( allocation_style == 1 ) {
4172     next_nonstatic_oop_offset = next_nonstatic_padded_offset;
4173     if( (nonstatic_oop_count + nonstatic_nonflattened_value_types_count) > 0 ) {
4174       next_nonstatic_oop_offset = align_up(next_nonstatic_oop_offset, heapOopSize);
4175     }
4176     next_nonstatic_padded_offset = next_nonstatic_oop_offset
4177         + ((nonstatic_oop_count + nonstatic_nonflattened_value_types_count) * heapOopSize);
4178   }
4179 
4180   // Aligning embedded value types
4181   // bug below, the current algorithm to layout embedded value types always put them at the
4182   // end of the layout, which doesn't match the different allocation policies the VM is
4183   // supposed to provide => FixMe
4184   // Note also that the current alignment policy is to make each value type starting on a
4185   // 64 bits boundary. This could be optimized later. For instance, it could be nice to
4186   // align value types according to their most constrained internal type.
4187   next_nonstatic_valuetype_offset = align_up(next_nonstatic_padded_offset, BytesPerLong);
4188   int next_value_type_index = 0;
4189 
4190   // Iterate over fields again and compute correct offsets.
4191   // The field allocation type was temporarily stored in the offset slot.
4192   // oop fields are located before non-oop fields (static and non-static).
4193   for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
4194 
4195     // skip already laid out fields
4196     if (fs.is_offset_set()) continue;
4197 


4209         real_offset = next_static_oop_offset;
4210         next_static_oop_offset += heapOopSize;
4211         break;
4212       case STATIC_BYTE:
4213         real_offset = next_static_byte_offset;
4214         next_static_byte_offset += 1;
4215         break;
4216       case STATIC_SHORT:
4217         real_offset = next_static_short_offset;
4218         next_static_short_offset += BytesPerShort;
4219         break;
4220       case STATIC_WORD:
4221         real_offset = next_static_word_offset;
4222         next_static_word_offset += BytesPerInt;
4223         break;
4224       case STATIC_DOUBLE:
4225         real_offset = next_static_double_offset;
4226         next_static_double_offset += BytesPerLong;
4227         break;
4228       case NONSTATIC_VALUETYPE:
4229         if (fs.is_flatten()) {
4230           Klass* klass = nonstatic_value_type_klasses[next_value_type_index];
4231           assert(klass != NULL, "Klass should have been loaded and resolved earlier");
4232           assert(klass->access_flags().is_value_type(),"Must be a value type");
4233           ValueKlass* vklass = ValueKlass::cast(klass);
4234           real_offset = next_nonstatic_valuetype_offset;
4235           next_nonstatic_valuetype_offset += (vklass->size_helper()) * wordSize - vklass->first_field_offset();
4236           // aligning next value type on a 64 bits boundary
4237           next_nonstatic_valuetype_offset = align_up(next_nonstatic_valuetype_offset, BytesPerLong);
4238           next_value_type_index += 1;
4239 
4240           if (vklass->contains_oops()) { // add flatten oop maps
4241             int diff = real_offset - vklass->first_field_offset();
4242             const OopMapBlock* map = vklass->start_of_nonstatic_oop_maps();
4243             const OopMapBlock* const last_map = map + vklass->nonstatic_oop_map_count();
4244             while (map < last_map) {
4245               nonstatic_oop_maps->add(map->offset() + diff, map->count());
4246               map++;
4247             }
4248           }

4249           break;
4250         } else {
4251           // Fall through
4252         }
4253       case NONSTATIC_OOP:
4254         if( nonstatic_oop_space_count > 0 ) {
4255           real_offset = nonstatic_oop_space_offset;
4256           nonstatic_oop_space_offset += heapOopSize;
4257           nonstatic_oop_space_count  -= 1;
4258         } else {
4259           real_offset = next_nonstatic_oop_offset;
4260           next_nonstatic_oop_offset += heapOopSize;
4261         }
4262         nonstatic_oop_maps->add(real_offset, 1);
4263         break;
4264       case NONSTATIC_BYTE:
4265         if( nonstatic_byte_space_count > 0 ) {
4266           real_offset = nonstatic_byte_space_offset;
4267           nonstatic_byte_space_offset += 1;
4268           nonstatic_byte_space_count  -= 1;
4269         } else {
4270           real_offset = next_nonstatic_byte_offset;
4271           next_nonstatic_byte_offset += 1;
4272         }


4401       // this is expected to alleviate memory contention effects for
4402       // subclass fields and/or adjacent object.
4403       // If this was the default group, the padding is already in place.
4404       if (current_group != 0) {
4405         next_nonstatic_padded_offset += ContendedPaddingWidth;
4406       }
4407     }
4408 
4409     // handle static fields
4410   }
4411 
4412   // Entire class is contended, pad in the back.
4413   // This helps to alleviate memory contention effects for subclass fields
4414   // and/or adjacent object.
4415   if (is_contended_class) {
4416     assert(!is_value_type() && !is_value_capable_class(), "@Contended not supported for value types yet");
4417     next_nonstatic_padded_offset += ContendedPaddingWidth;
4418   }
4419 
4420   int notaligned_nonstatic_fields_end;
4421   if ((nonstatic_value_type_count - nonstatic_nonflattened_value_types_count) != 0) {
4422     notaligned_nonstatic_fields_end = next_nonstatic_valuetype_offset;
4423   } else {
4424     notaligned_nonstatic_fields_end = next_nonstatic_padded_offset;
4425   }
4426 
4427   int nonstatic_field_sz_align = heapOopSize;
4428   if (is_value_type() || is_value_capable_class()) {
4429     if ((notaligned_nonstatic_fields_end - nonstatic_fields_start) > heapOopSize) {
4430       nonstatic_field_sz_align = BytesPerLong; // value copy of fields only uses jlong copy
4431     }
4432   }
4433   int nonstatic_fields_end      = align_up(notaligned_nonstatic_fields_end, nonstatic_field_sz_align);
4434   int instance_end              = align_up(notaligned_nonstatic_fields_end, wordSize);
4435   int static_fields_end         = align_up(next_static_byte_offset, wordSize);
4436 
4437   int static_field_size         = (static_fields_end -
4438                                    InstanceMirrorKlass::offset_of_static_fields()) / wordSize;
4439   nonstatic_field_size          = nonstatic_field_size +
4440                                   (nonstatic_fields_end - nonstatic_fields_start) / heapOopSize;
4441 


< prev index next >