3112 // TODO: Ask VM about specific CPU we are running on |
3112 // TODO: Ask VM about specific CPU we are running on |
3113 int pad_size = ContendedPaddingWidth; |
3113 int pad_size = ContendedPaddingWidth; |
3114 |
3114 |
3115 // Field size and offset computation |
3115 // Field size and offset computation |
3116 int nonstatic_field_size = _super_klass() == NULL ? 0 : _super_klass()->nonstatic_field_size(); |
3116 int nonstatic_field_size = _super_klass() == NULL ? 0 : _super_klass()->nonstatic_field_size(); |
3117 #ifndef PRODUCT |
|
3118 int orig_nonstatic_field_size = 0; |
|
3119 #endif |
|
3120 int next_static_oop_offset; |
3117 int next_static_oop_offset; |
3121 int next_static_double_offset; |
3118 int next_static_double_offset; |
3122 int next_static_word_offset; |
3119 int next_static_word_offset; |
3123 int next_static_short_offset; |
3120 int next_static_short_offset; |
3124 int next_static_byte_offset; |
3121 int next_static_byte_offset; |
3199 nonstatic_oop_counts = NEW_RESOURCE_ARRAY_IN_THREAD( |
3196 nonstatic_oop_counts = NEW_RESOURCE_ARRAY_IN_THREAD( |
3200 THREAD, unsigned int, nonstatic_oop_count + 1); |
3197 THREAD, unsigned int, nonstatic_oop_count + 1); |
3201 |
3198 |
3202 first_nonstatic_oop_offset = 0; // will be set for first oop field |
3199 first_nonstatic_oop_offset = 0; // will be set for first oop field |
3203 |
3200 |
3204 #ifndef PRODUCT |
|
3205 if( PrintCompactFieldsSavings ) { |
|
3206 next_nonstatic_double_offset = next_nonstatic_field_offset + |
|
3207 (nonstatic_oop_count * heapOopSize); |
|
3208 if ( nonstatic_double_count > 0 ) { |
|
3209 next_nonstatic_double_offset = align_size_up(next_nonstatic_double_offset, BytesPerLong); |
|
3210 } |
|
3211 next_nonstatic_word_offset = next_nonstatic_double_offset + |
|
3212 (nonstatic_double_count * BytesPerLong); |
|
3213 next_nonstatic_short_offset = next_nonstatic_word_offset + |
|
3214 (nonstatic_word_count * BytesPerInt); |
|
3215 next_nonstatic_byte_offset = next_nonstatic_short_offset + |
|
3216 (nonstatic_short_count * BytesPerShort); |
|
3217 next_nonstatic_type_offset = align_size_up((next_nonstatic_byte_offset + |
|
3218 nonstatic_byte_count ), heapOopSize ); |
|
3219 orig_nonstatic_field_size = nonstatic_field_size + |
|
3220 ((next_nonstatic_type_offset - first_nonstatic_field_offset)/heapOopSize); |
|
3221 } |
|
3222 #endif |
|
3223 bool compact_fields = CompactFields; |
3201 bool compact_fields = CompactFields; |
3224 int allocation_style = FieldsAllocationStyle; |
3202 int allocation_style = FieldsAllocationStyle; |
3225 if( allocation_style < 0 || allocation_style > 2 ) { // Out of range? |
3203 if( allocation_style < 0 || allocation_style > 2 ) { // Out of range? |
3226 assert(false, "0 <= FieldsAllocationStyle <= 2"); |
3204 assert(false, "0 <= FieldsAllocationStyle <= 2"); |
3227 allocation_style = 1; // Optimistic |
3205 allocation_style = 1; // Optimistic |
3591 const unsigned int total_oop_map_count = |
3569 const unsigned int total_oop_map_count = |
3592 compute_oop_map_count(_super_klass, nonstatic_oop_map_count, |
3570 compute_oop_map_count(_super_klass, nonstatic_oop_map_count, |
3593 first_nonstatic_oop_offset); |
3571 first_nonstatic_oop_offset); |
3594 |
3572 |
3595 #ifndef PRODUCT |
3573 #ifndef PRODUCT |
3596 if( PrintCompactFieldsSavings ) { |
|
3597 ResourceMark rm; |
|
3598 if( nonstatic_field_size < orig_nonstatic_field_size ) { |
|
3599 tty->print("[Saved %d of %d bytes in %s]\n", |
|
3600 (orig_nonstatic_field_size - nonstatic_field_size)*heapOopSize, |
|
3601 orig_nonstatic_field_size*heapOopSize, |
|
3602 _class_name); |
|
3603 } else if( nonstatic_field_size > orig_nonstatic_field_size ) { |
|
3604 tty->print("[Wasted %d over %d bytes in %s]\n", |
|
3605 (nonstatic_field_size - orig_nonstatic_field_size)*heapOopSize, |
|
3606 orig_nonstatic_field_size*heapOopSize, |
|
3607 _class_name); |
|
3608 } |
|
3609 } |
|
3610 |
|
3611 if (PrintFieldLayout) { |
3574 if (PrintFieldLayout) { |
3612 print_field_layout(_class_name, |
3575 print_field_layout(_class_name, |
3613 _fields, |
3576 _fields, |
3614 _cp, |
3577 _cp, |
3615 instance_size, |
3578 instance_size, |