1.1 --- a/src/share/vm/classfile/classFileParser.cpp Fri May 17 09:10:04 2013 -0700 1.2 +++ b/src/share/vm/classfile/classFileParser.cpp Fri May 17 11:36:43 2013 -0700 1.3 @@ -1719,15 +1719,28 @@ 1.4 coll->set_annotation(id); 1.5 1.6 if (id == AnnotationCollector::_sun_misc_Contended) { 1.7 + // @Contended can optionally specify the contention group. 1.8 + // 1.9 + // Contended group defines the equivalence class over the fields: 1.10 + // the fields within the same contended group are not treated distinct. 1.11 + // The only exception is default group, which does not incur the 1.12 + // equivalence. Naturally, contention group for classes is meaningless. 1.13 + // 1.14 + // While the contention group is specified as String, annotation 1.15 + // values are already interned, and we might as well use the constant 1.16 + // pool index as the group tag. 1.17 + // 1.18 + u2 group_index = 0; // default contended group 1.19 if (count == 1 1.20 && s_size == (index - index0) // match size 1.21 && s_tag_val == *(abase + tag_off) 1.22 && member == vmSymbols::value_name()) { 1.23 - u2 group_index = Bytes::get_Java_u2(abase + s_con_off); 1.24 - coll->set_contended_group(group_index); 1.25 - } else { 1.26 - coll->set_contended_group(0); // default contended group 1.27 + group_index = Bytes::get_Java_u2(abase + s_con_off); 1.28 + if (_cp->symbol_at(group_index)->utf8_length() == 0) { 1.29 + group_index = 0; // default contended group 1.30 + } 1.31 } 1.32 + coll->set_contended_group(group_index); 1.33 } 1.34 } 1.35 } 1.36 @@ -3165,13 +3178,13 @@ 1.37 first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() + 1.38 nonstatic_field_size * heapOopSize; 1.39 1.40 + next_nonstatic_field_offset = first_nonstatic_field_offset; 1.41 + 1.42 // class is contended, pad before all the fields 1.43 if (parsed_annotations->is_contended()) { 1.44 - first_nonstatic_field_offset += pad_size; 1.45 + next_nonstatic_field_offset += pad_size; 1.46 } 1.47 1.48 - next_nonstatic_field_offset = first_nonstatic_field_offset; 1.49 - 1.50 unsigned int nonstatic_double_count = fac->count[NONSTATIC_DOUBLE] - fac_contended.count[NONSTATIC_DOUBLE]; 1.51 unsigned int nonstatic_word_count = fac->count[NONSTATIC_WORD] - fac_contended.count[NONSTATIC_WORD]; 1.52 unsigned int nonstatic_short_count = fac->count[NONSTATIC_SHORT] - fac_contended.count[NONSTATIC_SHORT]; 1.53 @@ -3562,7 +3575,7 @@ 1.54 int instance_size = align_object_size(next_nonstatic_type_offset / wordSize); 1.55 1.56 assert(instance_size == align_object_size(align_size_up( 1.57 - (instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize + ((parsed_annotations->is_contended()) ? pad_size : 0)), 1.58 + (instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize), 1.59 wordSize) / wordSize), "consistent layout helper value"); 1.60 1.61 // Number of non-static oop map blocks allocated at end of klass.