@@ -47,19 +47,21 @@ class FieldInfo {
47
47
// as an array of 6 shorts.
48
48
49
49
#define FIELDINFO_TAG_SIZE 2
50
- #define FIELDINFO_TAG_BLANK 0
51
- #define FIELDINFO_TAG_OFFSET 1
52
- #define FIELDINFO_TAG_TYPE_PLAIN 2
53
- #define FIELDINFO_TAG_TYPE_CONTENDED 3
54
- #define FIELDINFO_TAG_MASK 3
50
+ #define FIELDINFO_TAG_OFFSET 1 << 0
51
+ #define FIELDINFO_TAG_CONTENDED 1 << 1
55
52
56
53
// Packed field has the tag, and can be either of:
57
54
// hi bits <--------------------------- lo bits
58
55
// |---------high---------|---------low---------|
59
- // ..........................................00 - blank
56
+ // ..........................................CO
57
+ // ..........................................00 - non-contended field
58
+ // [--contention_group--]....................10 - contended field with contention group
60
59
// [------------------offset----------------]01 - real field offset
61
- // ......................[-------type-------]10 - plain field with type
62
- // [--contention_group--][-------type-------]11 - contended field with type and contention group
60
+
61
+ // Bit O indicates if the packed field contains an offset (O=1) or not (O=0)
62
+ // Bit C indicates if the field is contended (C=1) or not (C=0)
63
+ // (if it is contended, the high packed field contains the contention group)
64
+
63
65
enum FieldOffset {
64
66
access_flags_offset = 0 ,
65
67
name_index_offset = 1 ,
@@ -103,78 +105,22 @@ class FieldInfo {
103
105
104
106
u2 access_flags () const { return _shorts[access_flags_offset]; }
105
107
u4 offset () const {
106
- u2 lo = _shorts[low_packed_offset];
107
- switch (lo & FIELDINFO_TAG_MASK) {
108
- case FIELDINFO_TAG_OFFSET:
109
- return build_int_from_shorts (_shorts[low_packed_offset], _shorts[high_packed_offset]) >> FIELDINFO_TAG_SIZE;
110
- #ifndef PRODUCT
111
- case FIELDINFO_TAG_TYPE_PLAIN:
112
- fatal (" Asking offset for the plain type field" );
113
- case FIELDINFO_TAG_TYPE_CONTENDED:
114
- fatal (" Asking offset for the contended type field" );
115
- case FIELDINFO_TAG_BLANK:
116
- fatal (" Asking offset for the blank field" );
117
- #endif
118
- }
119
- ShouldNotReachHere ();
120
- return 0 ;
108
+ assert ((_shorts[low_packed_offset] & FIELDINFO_TAG_OFFSET) != 0 , " Offset must have been set" );
109
+ return build_int_from_shorts (_shorts[low_packed_offset], _shorts[high_packed_offset]) >> FIELDINFO_TAG_SIZE;
121
110
}
122
111
123
112
bool is_contended () const {
124
- u2 lo = _shorts[low_packed_offset];
125
- switch (lo & FIELDINFO_TAG_MASK) {
126
- case FIELDINFO_TAG_TYPE_PLAIN:
127
- return false ;
128
- case FIELDINFO_TAG_TYPE_CONTENDED:
129
- return true ;
130
- #ifndef PRODUCT
131
- case FIELDINFO_TAG_OFFSET:
132
- fatal (" Asking contended flag for the field with offset" );
133
- case FIELDINFO_TAG_BLANK:
134
- fatal (" Asking contended flag for the blank field" );
135
- #endif
136
- }
137
- ShouldNotReachHere ();
138
- return false ;
113
+ return (_shorts[low_packed_offset] & FIELDINFO_TAG_CONTENDED) != 0 ;
139
114
}
140
115
141
116
u2 contended_group () const {
142
- u2 lo = _shorts[low_packed_offset];
143
- switch (lo & FIELDINFO_TAG_MASK) {
144
- case FIELDINFO_TAG_TYPE_PLAIN:
145
- return 0 ;
146
- case FIELDINFO_TAG_TYPE_CONTENDED:
147
- return _shorts[high_packed_offset];
148
- #ifndef PRODUCT
149
- case FIELDINFO_TAG_OFFSET:
150
- fatal (" Asking the contended group for the field with offset" );
151
- case FIELDINFO_TAG_BLANK:
152
- fatal (" Asking the contended group for the blank field" );
153
- #endif
154
- }
155
- ShouldNotReachHere ();
156
- return 0 ;
117
+ assert ((_shorts[low_packed_offset] & FIELDINFO_TAG_OFFSET) == 0 , " Offset must not have been set" );
118
+ assert ((_shorts[low_packed_offset] & FIELDINFO_TAG_CONTENDED) != 0 , " Field must be contended" );
119
+ return _shorts[high_packed_offset];
157
120
}
158
121
159
- u2 allocation_type () const {
160
- u2 lo = _shorts[low_packed_offset];
161
- switch (lo & FIELDINFO_TAG_MASK) {
162
- case FIELDINFO_TAG_TYPE_PLAIN:
163
- case FIELDINFO_TAG_TYPE_CONTENDED:
164
- return (lo >> FIELDINFO_TAG_SIZE);
165
- #ifndef PRODUCT
166
- case FIELDINFO_TAG_OFFSET:
167
- fatal (" Asking the field type for field with offset" );
168
- case FIELDINFO_TAG_BLANK:
169
- fatal (" Asking the field type for the blank field" );
170
- #endif
171
- }
172
- ShouldNotReachHere ();
173
- return 0 ;
174
- }
175
-
176
122
bool is_offset_set () const {
177
- return (_shorts[low_packed_offset] & FIELDINFO_TAG_MASK) == FIELDINFO_TAG_OFFSET ;
123
+ return (_shorts[low_packed_offset] & FIELDINFO_TAG_OFFSET)!= 0 ;
178
124
}
179
125
180
126
Symbol* name (ConstantPool* cp) const {
@@ -200,41 +146,11 @@ class FieldInfo {
200
146
_shorts[high_packed_offset] = extract_high_short_from_int (val);
201
147
}
202
148
203
- void set_allocation_type (int type) {
204
- u2 lo = _shorts[low_packed_offset];
205
- switch (lo & FIELDINFO_TAG_MASK) {
206
- case FIELDINFO_TAG_BLANK:
207
- _shorts[low_packed_offset] = ((type << FIELDINFO_TAG_SIZE)) & 0xFFFF ;
208
- _shorts[low_packed_offset] &= ~FIELDINFO_TAG_MASK;
209
- _shorts[low_packed_offset] |= FIELDINFO_TAG_TYPE_PLAIN;
210
- return ;
211
- #ifndef PRODUCT
212
- case FIELDINFO_TAG_TYPE_PLAIN:
213
- case FIELDINFO_TAG_TYPE_CONTENDED:
214
- case FIELDINFO_TAG_OFFSET:
215
- fatal (" Setting the field type with overwriting" );
216
- #endif
217
- }
218
- ShouldNotReachHere ();
219
- }
220
-
221
149
void set_contended_group (u2 val) {
222
- u2 lo = _shorts[low_packed_offset];
223
- switch (lo & FIELDINFO_TAG_MASK) {
224
- case FIELDINFO_TAG_TYPE_PLAIN:
225
- _shorts[low_packed_offset] |= FIELDINFO_TAG_TYPE_CONTENDED;
226
- _shorts[high_packed_offset] = val;
227
- return ;
228
- #ifndef PRODUCT
229
- case FIELDINFO_TAG_TYPE_CONTENDED:
230
- fatal (" Overwriting contended group" );
231
- case FIELDINFO_TAG_BLANK:
232
- fatal (" Setting contended group for the blank field" );
233
- case FIELDINFO_TAG_OFFSET:
234
- fatal (" Setting contended group for field with offset" );
235
- #endif
236
- }
237
- ShouldNotReachHere ();
150
+ assert ((_shorts[low_packed_offset] & FIELDINFO_TAG_OFFSET) == 0 , " Offset must not have been set" );
151
+ assert ((_shorts[low_packed_offset] & FIELDINFO_TAG_CONTENDED) == 0 , " Overwritting contended group" );
152
+ _shorts[low_packed_offset] |= FIELDINFO_TAG_CONTENDED;
153
+ _shorts[high_packed_offset] = val;
238
154
}
239
155
240
156
bool is_internal () const {
0 commit comments