Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/classFileParser.cpp @ 8716:96480359523a
8008965: @Contended fails with classes having static fields
Summary: Disable @Contended support for static fields
Reviewed-by: coleenp, kvn
Contributed-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
author | coleenp |
---|---|
date | Mon, 11 Mar 2013 14:00:09 -0400 |
parents | 927a311d00f9 |
children | c8b31b461e1a |
comparison
equal
deleted
inserted
replaced
8714:35ef86296a5d | 8716:96480359523a |
---|---|
3490 int next_static_oop_offset; | 3490 int next_static_oop_offset; |
3491 int next_static_double_offset; | 3491 int next_static_double_offset; |
3492 int next_static_word_offset; | 3492 int next_static_word_offset; |
3493 int next_static_short_offset; | 3493 int next_static_short_offset; |
3494 int next_static_byte_offset; | 3494 int next_static_byte_offset; |
3495 int next_static_padded_offset; | |
3496 int next_nonstatic_oop_offset; | 3495 int next_nonstatic_oop_offset; |
3497 int next_nonstatic_double_offset; | 3496 int next_nonstatic_double_offset; |
3498 int next_nonstatic_word_offset; | 3497 int next_nonstatic_word_offset; |
3499 int next_nonstatic_short_offset; | 3498 int next_nonstatic_short_offset; |
3500 int next_nonstatic_byte_offset; | 3499 int next_nonstatic_byte_offset; |
3503 int first_nonstatic_field_offset; | 3502 int first_nonstatic_field_offset; |
3504 int next_nonstatic_field_offset; | 3503 int next_nonstatic_field_offset; |
3505 int next_nonstatic_padded_offset; | 3504 int next_nonstatic_padded_offset; |
3506 | 3505 |
3507 // Count the contended fields by type. | 3506 // Count the contended fields by type. |
3508 int static_contended_count = 0; | |
3509 int nonstatic_contended_count = 0; | 3507 int nonstatic_contended_count = 0; |
3510 FieldAllocationCount fac_contended; | 3508 FieldAllocationCount fac_contended; |
3511 for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) { | 3509 for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) { |
3512 FieldAllocationType atype = (FieldAllocationType) fs.allocation_type(); | 3510 FieldAllocationType atype = (FieldAllocationType) fs.allocation_type(); |
3513 if (fs.is_contended()) { | 3511 if (fs.is_contended()) { |
3514 fac_contended.count[atype]++; | 3512 fac_contended.count[atype]++; |
3515 if (fs.access_flags().is_static()) { | 3513 if (!fs.access_flags().is_static()) { |
3516 static_contended_count++; | |
3517 } else { | |
3518 nonstatic_contended_count++; | 3514 nonstatic_contended_count++; |
3519 } | 3515 } |
3520 } | 3516 } |
3521 } | 3517 } |
3522 int contended_count = static_contended_count + nonstatic_contended_count; | 3518 int contended_count = nonstatic_contended_count; |
3523 | 3519 |
3524 | 3520 |
3525 // Calculate the starting byte offsets | 3521 // Calculate the starting byte offsets |
3526 next_static_oop_offset = InstanceMirrorKlass::offset_of_static_fields(); | 3522 next_static_oop_offset = InstanceMirrorKlass::offset_of_static_fields(); |
3527 | 3523 |
3528 // class is contended, pad before all the fields | |
3529 if (parsed_annotations.is_contended()) { | |
3530 next_static_oop_offset += pad_size; | |
3531 } | |
3532 | |
3533 next_static_double_offset = next_static_oop_offset + | 3524 next_static_double_offset = next_static_oop_offset + |
3534 ((fac.count[STATIC_OOP] - fac_contended.count[STATIC_OOP]) * heapOopSize); | 3525 ((fac.count[STATIC_OOP]) * heapOopSize); |
3535 if ( fac.count[STATIC_DOUBLE] && | 3526 if ( fac.count[STATIC_DOUBLE] && |
3536 (Universe::field_type_should_be_aligned(T_DOUBLE) || | 3527 (Universe::field_type_should_be_aligned(T_DOUBLE) || |
3537 Universe::field_type_should_be_aligned(T_LONG)) ) { | 3528 Universe::field_type_should_be_aligned(T_LONG)) ) { |
3538 next_static_double_offset = align_size_up(next_static_double_offset, BytesPerLong); | 3529 next_static_double_offset = align_size_up(next_static_double_offset, BytesPerLong); |
3539 } | 3530 } |
3540 | 3531 |
3541 next_static_word_offset = next_static_double_offset + | 3532 next_static_word_offset = next_static_double_offset + |
3542 ((fac.count[STATIC_DOUBLE] - fac_contended.count[STATIC_DOUBLE]) * BytesPerLong); | 3533 ((fac.count[STATIC_DOUBLE]) * BytesPerLong); |
3543 next_static_short_offset = next_static_word_offset + | 3534 next_static_short_offset = next_static_word_offset + |
3544 ((fac.count[STATIC_WORD] - fac_contended.count[STATIC_WORD]) * BytesPerInt); | 3535 ((fac.count[STATIC_WORD]) * BytesPerInt); |
3545 next_static_byte_offset = next_static_short_offset + | 3536 next_static_byte_offset = next_static_short_offset + |
3546 ((fac.count[STATIC_SHORT] - fac_contended.count[STATIC_SHORT]) * BytesPerShort); | 3537 ((fac.count[STATIC_SHORT]) * BytesPerShort); |
3547 next_static_padded_offset = next_static_byte_offset + | |
3548 ((fac.count[STATIC_BYTE] - fac_contended.count[STATIC_BYTE]) * 1); | |
3549 | 3538 |
3550 first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() + | 3539 first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() + |
3551 nonstatic_field_size * heapOopSize; | 3540 nonstatic_field_size * heapOopSize; |
3552 | 3541 |
3553 // class is contended, pad before all the fields | 3542 // class is contended, pad before all the fields |
3736 for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) { | 3725 for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) { |
3737 | 3726 |
3738 // skip already laid out fields | 3727 // skip already laid out fields |
3739 if (fs.is_offset_set()) continue; | 3728 if (fs.is_offset_set()) continue; |
3740 | 3729 |
3741 // contended fields are handled below | 3730 // contended instance fields are handled below |
3742 if (fs.is_contended()) continue; | 3731 if (fs.is_contended() && !fs.access_flags().is_static()) continue; |
3743 | 3732 |
3744 int real_offset; | 3733 int real_offset; |
3745 FieldAllocationType atype = (FieldAllocationType) fs.allocation_type(); | 3734 FieldAllocationType atype = (FieldAllocationType) fs.allocation_type(); |
3746 | 3735 |
3747 // pack the rest of the fields | 3736 // pack the rest of the fields |
3941 } | 3930 } |
3942 } | 3931 } |
3943 | 3932 |
3944 // handle static fields | 3933 // handle static fields |
3945 | 3934 |
3946 // if there is at least one contended field, we need to have pre-padding for them | |
3947 if (static_contended_count > 0) { | |
3948 next_static_padded_offset += pad_size; | |
3949 } | |
3950 | |
3951 current_group = -1; | |
3952 while ((current_group = (int)bm.get_next_one_offset(current_group + 1)) != (int)bm.size()) { | |
3953 | |
3954 for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) { | |
3955 | |
3956 // skip already laid out fields | |
3957 if (fs.is_offset_set()) continue; | |
3958 | |
3959 // skip non-contended fields and fields from different group | |
3960 if (!fs.is_contended() || (fs.contended_group() != current_group)) continue; | |
3961 | |
3962 // non-statics already handled above | |
3963 if (!fs.access_flags().is_static()) continue; | |
3964 | |
3965 int real_offset; | |
3966 FieldAllocationType atype = (FieldAllocationType) fs.allocation_type(); | |
3967 | |
3968 switch (atype) { | |
3969 | |
3970 case STATIC_BYTE: | |
3971 next_static_padded_offset = align_size_up(next_static_padded_offset, 1); | |
3972 real_offset = next_static_padded_offset; | |
3973 next_static_padded_offset += 1; | |
3974 break; | |
3975 | |
3976 case STATIC_SHORT: | |
3977 next_static_padded_offset = align_size_up(next_static_padded_offset, BytesPerShort); | |
3978 real_offset = next_static_padded_offset; | |
3979 next_static_padded_offset += BytesPerShort; | |
3980 break; | |
3981 | |
3982 case STATIC_WORD: | |
3983 next_static_padded_offset = align_size_up(next_static_padded_offset, BytesPerInt); | |
3984 real_offset = next_static_padded_offset; | |
3985 next_static_padded_offset += BytesPerInt; | |
3986 break; | |
3987 | |
3988 case STATIC_DOUBLE: | |
3989 next_static_padded_offset = align_size_up(next_static_padded_offset, BytesPerLong); | |
3990 real_offset = next_static_padded_offset; | |
3991 next_static_padded_offset += BytesPerLong; | |
3992 break; | |
3993 | |
3994 case STATIC_OOP: | |
3995 next_static_padded_offset = align_size_up(next_static_padded_offset, heapOopSize); | |
3996 real_offset = next_static_padded_offset; | |
3997 next_static_padded_offset += heapOopSize; | |
3998 break; | |
3999 | |
4000 default: | |
4001 ShouldNotReachHere(); | |
4002 } | |
4003 | |
4004 if (fs.contended_group() == 0) { | |
4005 // Contended group defines the equivalence class over the fields: | |
4006 // the fields within the same contended group are not inter-padded. | |
4007 // The only exception is default group, which does not incur the | |
4008 // equivalence, and so requires intra-padding. | |
4009 next_static_padded_offset += pad_size; | |
4010 } | |
4011 | |
4012 fs.set_offset(real_offset); | |
4013 } // for | |
4014 | |
4015 // Start laying out the next group. | |
4016 // Note that this will effectively pad the last group in the back; | |
4017 // this is expected to alleviate memory contention effects for | |
4018 // subclass fields and/or adjacent object. | |
4019 // If this was the default group, the padding is already in place. | |
4020 if (current_group != 0) { | |
4021 next_static_padded_offset += pad_size; | |
4022 } | |
4023 | |
4024 } | |
4025 | |
4026 } // handle contended | 3935 } // handle contended |
4027 | 3936 |
4028 // Size of instances | 3937 // Size of instances |
4029 int instance_size; | 3938 int instance_size; |
4030 | 3939 |
4033 // Entire class is contended, pad in the back. | 3942 // Entire class is contended, pad in the back. |
4034 // This helps to alleviate memory contention effects for subclass fields | 3943 // This helps to alleviate memory contention effects for subclass fields |
4035 // and/or adjacent object. | 3944 // and/or adjacent object. |
4036 if (parsed_annotations.is_contended()) { | 3945 if (parsed_annotations.is_contended()) { |
4037 notaligned_offset += pad_size; | 3946 notaligned_offset += pad_size; |
4038 next_static_padded_offset += pad_size; | 3947 } |
4039 } | 3948 |
4040 | 3949 int next_static_type_offset = align_size_up(next_static_byte_offset, wordSize); |
4041 int next_static_type_offset = align_size_up(next_static_padded_offset, wordSize); | |
4042 int static_field_size = (next_static_type_offset - | 3950 int static_field_size = (next_static_type_offset - |
4043 InstanceMirrorKlass::offset_of_static_fields()) / wordSize; | 3951 InstanceMirrorKlass::offset_of_static_fields()) / wordSize; |
4044 | 3952 |
4045 next_nonstatic_type_offset = align_size_up(notaligned_offset, heapOopSize ); | 3953 next_nonstatic_type_offset = align_size_up(notaligned_offset, heapOopSize ); |
4046 nonstatic_field_size = nonstatic_field_size + ((next_nonstatic_type_offset | 3954 nonstatic_field_size = nonstatic_field_size + ((next_nonstatic_type_offset |