49 // This class represents the field information contained in the fields
50 // array of an InstanceKlass. Currently it's laid on top an array of
51 // Java shorts but in the future it could simply be used as a real
52 // array type. FieldInfo generally shouldn't be used directly.
53 // Fields should be queried either through InstanceKlass or through
54 // the various FieldStreams.
55 class FieldInfo {
56 friend class fieldDescriptor;
57 friend class JavaFieldStream;
58 friend class ClassFileParser;
59 friend class FieldInfoStream;
60 friend class FieldStreamBase;
61 friend class FieldInfoReader;
62 friend class VMStructs;
63
64 public:
65
66 class FieldFlags {
67 friend class VMStructs;
68 friend class JVMCIVMStructs;
69
70 // The ordering of this enum is totally internal. More frequent
71 // flags should come earlier than less frequent ones, because
72 // earlier ones compress better.
73 enum FieldFlagBitPosition {
74 _ff_initialized, // has ConstantValue initializer attribute
75 _ff_injected, // internal field injected by the JVM
76 _ff_generic, // has a generic signature
77 _ff_stable, // trust as stable b/c declared as @Stable
78 _ff_contended, // is contended, may have contention-group
79 };
80
81 // Some but not all of the flag bits signal the presence of an
82 // additional 32-bit item in the field record.
83 static const u4 _optional_item_bit_mask =
84 flag_mask((int)_ff_initialized) |
85 flag_mask((int)_ff_generic) |
86 flag_mask((int)_ff_contended);
87
88 // boilerplate:
89 u4 _flags;
90
91 bool test_flag(FieldFlagBitPosition pos) const {
92 return (_flags & flag_mask(pos)) != 0;
93 }
94 void update_flag(FieldFlagBitPosition pos, bool z) {
95 if (z) _flags |= flag_mask(pos);
96 else _flags &= ~flag_mask(pos);
97 }
98
99 public:
100 FieldFlags(u4 flags) {
101 _flags = flags;
102 }
103 u4 as_uint() const { return _flags; }
104 bool has_any_optionals() const {
105 return (_flags & _optional_item_bit_mask) != 0;
106 }
107
108 bool is_initialized() const { return test_flag(_ff_initialized); }
109 bool is_injected() const { return test_flag(_ff_injected); }
110 bool is_generic() const { return test_flag(_ff_generic); }
111 bool is_stable() const { return test_flag(_ff_stable); }
112 bool is_contended() const { return test_flag(_ff_contended); }
113
114 void update_initialized(bool z) { update_flag(_ff_initialized, z); }
115 void update_injected(bool z) { update_flag(_ff_injected, z); }
116 void update_generic(bool z) { update_flag(_ff_generic, z); }
117 void update_stable(bool z) { update_flag(_ff_stable, z); }
118 void update_contended(bool z) { update_flag(_ff_contended, z); }
119 };
120
121 private:
122 // The following items are the unpacked bitwise information content
123 // of a field record. Per-field metadata extracted from the class
124 // file are stored logically as a group of these items. The
125 // classfile parser produces these records in a temporary array, and
126 // then compresses them into a FieldInfoStream.
127 //
128 u4 _index; // which field it is
129 u2 _name_index; // index in CP of name
130 u2 _signature_index; // index in CP of descriptor
131 u4 _offset; // offset in object layout
132 AccessFlags _access_flags; // access flags (JVM spec)
133 FieldFlags _field_flags; // VM defined flags (not JVM spec)
134 u2 _initializer_index; // index from ConstantValue attr (or 0)
|
49 // This class represents the field information contained in the fields
50 // array of an InstanceKlass. Currently it's laid on top an array of
51 // Java shorts but in the future it could simply be used as a real
52 // array type. FieldInfo generally shouldn't be used directly.
53 // Fields should be queried either through InstanceKlass or through
54 // the various FieldStreams.
55 class FieldInfo {
56 friend class fieldDescriptor;
57 friend class JavaFieldStream;
58 friend class ClassFileParser;
59 friend class FieldInfoStream;
60 friend class FieldStreamBase;
61 friend class FieldInfoReader;
62 friend class VMStructs;
63
64 public:
65
66 class FieldFlags {
67 friend class VMStructs;
68 friend class JVMCIVMStructs;
69 friend class FieldDesc;
70
71 // The ordering of this enum is totally internal. More frequent
72 // flags should come earlier than less frequent ones, because
73 // earlier ones compress better.
74 enum FieldFlagBitPosition {
75 _ff_null_free_inline_type, // field's type is an inline type and the field is null free
76 _ff_flat, // field is a flat field
77 _ff_initialized, // has ConstantValue initializer attribute
78 _ff_injected, // internal field injected by the JVM
79 _ff_generic, // has a generic signature
80 _ff_stable, // trust as stable b/c declared as @Stable
81 _ff_contended, // is contended, may have contention-group
82 };
83
84 // Some but not all of the flag bits signal the presence of an
85 // additional 32-bit item in the field record.
86 static const u4 _optional_item_bit_mask =
87 flag_mask((int)_ff_initialized) |
88 flag_mask((int)_ff_generic) |
89 flag_mask((int)_ff_contended);
90
91 // boilerplate:
92 u4 _flags;
93
94 bool test_flag(FieldFlagBitPosition pos) const {
95 return (_flags & flag_mask(pos)) != 0;
96 }
97 void update_flag(FieldFlagBitPosition pos, bool z) {
98 if (z) _flags |= flag_mask(pos);
99 else _flags &= ~flag_mask(pos);
100 }
101
102 public:
103 FieldFlags(u4 flags) {
104 _flags = flags;
105 }
106 u4 as_uint() const { return _flags; }
107 bool has_any_optionals() const {
108 return (_flags & _optional_item_bit_mask) != 0;
109 }
110
111 bool is_initialized() const { return test_flag(_ff_initialized); }
112 bool is_null_free_inline_type() const { return test_flag(_ff_null_free_inline_type); }
113 bool is_flat() const { return test_flag(_ff_flat); }
114 bool is_injected() const { return test_flag(_ff_injected); }
115 bool is_generic() const { return test_flag(_ff_generic); }
116 bool is_stable() const { return test_flag(_ff_stable); }
117 bool is_contended() const { return test_flag(_ff_contended); }
118
119 void update_initialized(bool z) { update_flag(_ff_initialized, z); }
120 void update_null_free_inline_type(bool z) { update_flag(_ff_null_free_inline_type, z); }
121 void update_flat(bool z) { update_flag(_ff_flat, z); }
122 void update_injected(bool z) { update_flag(_ff_injected, z); }
123 void update_generic(bool z) { update_flag(_ff_generic, z); }
124 void update_stable(bool z) { update_flag(_ff_stable, z); }
125 void update_contended(bool z) { update_flag(_ff_contended, z); }
126 };
127
128 private:
129 // The following items are the unpacked bitwise information content
130 // of a field record. Per-field metadata extracted from the class
131 // file are stored logically as a group of these items. The
132 // classfile parser produces these records in a temporary array, and
133 // then compresses them into a FieldInfoStream.
134 //
135 u4 _index; // which field it is
136 u2 _name_index; // index in CP of name
137 u2 _signature_index; // index in CP of descriptor
138 u4 _offset; // offset in object layout
139 AccessFlags _access_flags; // access flags (JVM spec)
140 FieldFlags _field_flags; // VM defined flags (not JVM spec)
141 u2 _initializer_index; // index from ConstantValue attr (or 0)
|