27 #include "classfile/classFileParser.hpp"
28 #include "classfile/classFileStream.hpp"
29 #include "classfile/classLoader.hpp"
30 #include "classfile/classLoaderData.inline.hpp"
31 #include "classfile/defaultMethods.hpp"
32 #include "classfile/dictionary.hpp"
33 #include "classfile/javaClasses.inline.hpp"
34 #include "classfile/moduleEntry.hpp"
35 #include "classfile/symbolTable.hpp"
36 #include "classfile/systemDictionary.hpp"
37 #include "classfile/verificationType.hpp"
38 #include "classfile/verifier.hpp"
39 #include "classfile/vmSymbols.hpp"
40 #include "gc/shared/gcLocker.hpp"
41 #include "logging/log.hpp"
42 #include "logging/logStream.hpp"
43 #include "memory/allocation.hpp"
44 #include "memory/metadataFactory.hpp"
45 #include "memory/oopFactory.hpp"
46 #include "memory/resourceArea.hpp"
47 #include "memory/universe.inline.hpp"
48 #include "oops/annotations.hpp"
49 #include "oops/constantPool.inline.hpp"
50 #include "oops/fieldStreams.hpp"
51 #include "oops/instanceKlass.hpp"
52 #include "oops/instanceMirrorKlass.hpp"
53 #include "oops/klass.inline.hpp"
54 #include "oops/klassVtable.hpp"
55 #include "oops/metadata.hpp"
56 #include "oops/method.hpp"
57 #include "oops/oop.inline.hpp"
58 #include "oops/symbol.hpp"
59 #include "prims/jvmtiExport.hpp"
60 #include "prims/jvmtiThreadState.hpp"
61 #include "runtime/javaCalls.hpp"
62 #include "runtime/perfData.hpp"
63 #include "runtime/reflection.hpp"
64 #include "runtime/signature.hpp"
65 #include "runtime/timer.hpp"
66 #include "services/classLoadingService.hpp"
67 #include "services/threadService.hpp"
3750 //
3751 // We ignore static fields, because @Contended is not supported for them.
3752 // The layout code below will also ignore the static fields.
3753 int nonstatic_contended_count = 0;
3754 FieldAllocationCount fac_contended;
3755 for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
3756 FieldAllocationType atype = (FieldAllocationType) fs.allocation_type();
3757 if (fs.is_contended()) {
3758 fac_contended.count[atype]++;
3759 if (!fs.access_flags().is_static()) {
3760 nonstatic_contended_count++;
3761 }
3762 }
3763 }
3764
3765
3766 // Calculate the starting byte offsets
3767 int next_static_oop_offset = InstanceMirrorKlass::offset_of_static_fields();
3768 int next_static_double_offset = next_static_oop_offset +
3769 ((fac->count[STATIC_OOP]) * heapOopSize);
3770 if ( fac->count[STATIC_DOUBLE] &&
3771 (Universe::field_type_should_be_aligned(T_DOUBLE) ||
3772 Universe::field_type_should_be_aligned(T_LONG)) ) {
3773 next_static_double_offset = align_up(next_static_double_offset, BytesPerLong);
3774 }
3775
3776 int next_static_word_offset = next_static_double_offset +
3777 ((fac->count[STATIC_DOUBLE]) * BytesPerLong);
3778 int next_static_short_offset = next_static_word_offset +
3779 ((fac->count[STATIC_WORD]) * BytesPerInt);
3780 int next_static_byte_offset = next_static_short_offset +
3781 ((fac->count[STATIC_SHORT]) * BytesPerShort);
3782
3783 int nonstatic_fields_start = instanceOopDesc::base_offset_in_bytes() +
3784 nonstatic_field_size * heapOopSize;
3785
3786 int next_nonstatic_field_offset = nonstatic_fields_start;
3787
3788 const bool is_contended_class = parsed_annotations->is_contended();
3789
3790 // Class is contended, pad before all the fields
3791 if (is_contended_class) {
3792 next_nonstatic_field_offset += ContendedPaddingWidth;
|
27 #include "classfile/classFileParser.hpp"
28 #include "classfile/classFileStream.hpp"
29 #include "classfile/classLoader.hpp"
30 #include "classfile/classLoaderData.inline.hpp"
31 #include "classfile/defaultMethods.hpp"
32 #include "classfile/dictionary.hpp"
33 #include "classfile/javaClasses.inline.hpp"
34 #include "classfile/moduleEntry.hpp"
35 #include "classfile/symbolTable.hpp"
36 #include "classfile/systemDictionary.hpp"
37 #include "classfile/verificationType.hpp"
38 #include "classfile/verifier.hpp"
39 #include "classfile/vmSymbols.hpp"
40 #include "gc/shared/gcLocker.hpp"
41 #include "logging/log.hpp"
42 #include "logging/logStream.hpp"
43 #include "memory/allocation.hpp"
44 #include "memory/metadataFactory.hpp"
45 #include "memory/oopFactory.hpp"
46 #include "memory/resourceArea.hpp"
47 #include "memory/universe.hpp"
48 #include "oops/annotations.hpp"
49 #include "oops/constantPool.inline.hpp"
50 #include "oops/fieldStreams.hpp"
51 #include "oops/instanceKlass.hpp"
52 #include "oops/instanceMirrorKlass.hpp"
53 #include "oops/klass.inline.hpp"
54 #include "oops/klassVtable.hpp"
55 #include "oops/metadata.hpp"
56 #include "oops/method.hpp"
57 #include "oops/oop.inline.hpp"
58 #include "oops/symbol.hpp"
59 #include "prims/jvmtiExport.hpp"
60 #include "prims/jvmtiThreadState.hpp"
61 #include "runtime/javaCalls.hpp"
62 #include "runtime/perfData.hpp"
63 #include "runtime/reflection.hpp"
64 #include "runtime/signature.hpp"
65 #include "runtime/timer.hpp"
66 #include "services/classLoadingService.hpp"
67 #include "services/threadService.hpp"
3750 //
3751 // We ignore static fields, because @Contended is not supported for them.
3752 // The layout code below will also ignore the static fields.
3753 int nonstatic_contended_count = 0;
3754 FieldAllocationCount fac_contended;
3755 for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
3756 FieldAllocationType atype = (FieldAllocationType) fs.allocation_type();
3757 if (fs.is_contended()) {
3758 fac_contended.count[atype]++;
3759 if (!fs.access_flags().is_static()) {
3760 nonstatic_contended_count++;
3761 }
3762 }
3763 }
3764
3765
3766 // Calculate the starting byte offsets
3767 int next_static_oop_offset = InstanceMirrorKlass::offset_of_static_fields();
3768 int next_static_double_offset = next_static_oop_offset +
3769 ((fac->count[STATIC_OOP]) * heapOopSize);
3770 if (fac->count[STATIC_DOUBLE]) {
3771 next_static_double_offset = align_up(next_static_double_offset, BytesPerLong);
3772 }
3773
3774 int next_static_word_offset = next_static_double_offset +
3775 ((fac->count[STATIC_DOUBLE]) * BytesPerLong);
3776 int next_static_short_offset = next_static_word_offset +
3777 ((fac->count[STATIC_WORD]) * BytesPerInt);
3778 int next_static_byte_offset = next_static_short_offset +
3779 ((fac->count[STATIC_SHORT]) * BytesPerShort);
3780
3781 int nonstatic_fields_start = instanceOopDesc::base_offset_in_bytes() +
3782 nonstatic_field_size * heapOopSize;
3783
3784 int next_nonstatic_field_offset = nonstatic_fields_start;
3785
3786 const bool is_contended_class = parsed_annotations->is_contended();
3787
3788 // Class is contended, pad before all the fields
3789 if (is_contended_class) {
3790 next_nonstatic_field_offset += ContendedPaddingWidth;
|