Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/fieldInfo.hpp @ 7587:4a916f2ce331
8003985: Support @Contended Annotation - JEP 142
Summary: HotSpot changes to support @Contended annotation.
Reviewed-by: coleenp, kvn, jrose
Contributed-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
author | jwilhelm |
---|---|
date | Mon, 14 Jan 2013 15:17:47 +0100 |
parents | da91efe96a93 |
children | be4d5c6c1f79 |
comparison
equal
deleted
inserted
replaced
7586:90a92d5bca17 | 7587:4a916f2ce331 |
---|---|
41 friend class ClassFileParser; | 41 friend class ClassFileParser; |
42 | 42 |
43 public: | 43 public: |
44 // fields | 44 // fields |
45 // Field info extracted from the class file and stored | 45 // Field info extracted from the class file and stored |
46 // as an array of 7 shorts | 46 // as an array of 6 shorts. |
47 | |
48 #define FIELDINFO_TAG_SIZE 2 | |
49 #define FIELDINFO_TAG_BLANK 0 | |
50 #define FIELDINFO_TAG_OFFSET 1 | |
51 #define FIELDINFO_TAG_TYPE_PLAIN 2 | |
52 #define FIELDINFO_TAG_TYPE_CONTENDED 3 | |
53 #define FIELDINFO_TAG_MASK 3 | |
54 | |
55 // Packed field has the tag, and can be either of: | |
56 // hi bits <--------------------------- lo bits | |
57 // |---------high---------|---------low---------| | |
58 // ..........................................00 - blank | |
59 // [------------------offset----------------]01 - real field offset | |
60 // ......................[-------type-------]10 - plain field with type | |
61 // [--contention_group--][-------type-------]11 - contended field with type and contention group | |
47 enum FieldOffset { | 62 enum FieldOffset { |
48 access_flags_offset = 0, | 63 access_flags_offset = 0, |
49 name_index_offset = 1, | 64 name_index_offset = 1, |
50 signature_index_offset = 2, | 65 signature_index_offset = 2, |
51 initval_index_offset = 3, | 66 initval_index_offset = 3, |
52 low_offset = 4, | 67 low_packed_offset = 4, |
53 high_offset = 5, | 68 high_packed_offset = 5, |
54 field_slots = 6 | 69 field_slots = 6 |
55 }; | 70 }; |
56 | 71 |
57 private: | 72 private: |
58 u2 _shorts[field_slots]; | 73 u2 _shorts[field_slots]; |
74 } | 89 } |
75 | 90 |
76 void initialize(u2 access_flags, | 91 void initialize(u2 access_flags, |
77 u2 name_index, | 92 u2 name_index, |
78 u2 signature_index, | 93 u2 signature_index, |
79 u2 initval_index, | 94 u2 initval_index) { |
80 u4 offset) { | |
81 _shorts[access_flags_offset] = access_flags; | 95 _shorts[access_flags_offset] = access_flags; |
82 _shorts[name_index_offset] = name_index; | 96 _shorts[name_index_offset] = name_index; |
83 _shorts[signature_index_offset] = signature_index; | 97 _shorts[signature_index_offset] = signature_index; |
84 _shorts[initval_index_offset] = initval_index; | 98 _shorts[initval_index_offset] = initval_index; |
85 set_offset(offset); | 99 _shorts[low_packed_offset] = 0; |
100 _shorts[high_packed_offset] = 0; | |
86 } | 101 } |
87 | 102 |
88 u2 access_flags() const { return _shorts[access_flags_offset]; } | 103 u2 access_flags() const { return _shorts[access_flags_offset]; } |
89 u4 offset() const { return build_int_from_shorts(_shorts[low_offset], _shorts[high_offset]); } | 104 u4 offset() const { |
105 u2 lo = _shorts[low_packed_offset]; | |
106 switch(lo & FIELDINFO_TAG_MASK) { | |
107 case FIELDINFO_TAG_OFFSET: | |
108 return build_int_from_shorts(_shorts[low_packed_offset], _shorts[high_packed_offset]) >> FIELDINFO_TAG_SIZE; | |
109 #ifndef PRODUCT | |
110 case FIELDINFO_TAG_TYPE_PLAIN: | |
111 ShouldNotReachHere2("Asking offset for the plain type field"); | |
112 case FIELDINFO_TAG_TYPE_CONTENDED: | |
113 ShouldNotReachHere2("Asking offset for the contended type field"); | |
114 case FIELDINFO_TAG_BLANK: | |
115 ShouldNotReachHere2("Asking offset for the blank field"); | |
116 #endif | |
117 } | |
118 ShouldNotReachHere(); | |
119 return 0; | |
120 } | |
121 | |
122 bool is_contended() const { | |
123 u2 lo = _shorts[low_packed_offset]; | |
124 switch(lo & FIELDINFO_TAG_MASK) { | |
125 case FIELDINFO_TAG_TYPE_PLAIN: | |
126 return false; | |
127 case FIELDINFO_TAG_TYPE_CONTENDED: | |
128 return true; | |
129 #ifndef PRODUCT | |
130 case FIELDINFO_TAG_OFFSET: | |
131 ShouldNotReachHere2("Asking contended flag for the field with offset"); | |
132 case FIELDINFO_TAG_BLANK: | |
133 ShouldNotReachHere2("Asking contended flag for the blank field"); | |
134 #endif | |
135 } | |
136 ShouldNotReachHere(); | |
137 return false; | |
138 } | |
139 | |
140 u2 contended_group() const { | |
141 u2 lo = _shorts[low_packed_offset]; | |
142 switch(lo & FIELDINFO_TAG_MASK) { | |
143 case FIELDINFO_TAG_TYPE_PLAIN: | |
144 return 0; | |
145 case FIELDINFO_TAG_TYPE_CONTENDED: | |
146 return _shorts[high_packed_offset]; | |
147 #ifndef PRODUCT | |
148 case FIELDINFO_TAG_OFFSET: | |
149 ShouldNotReachHere2("Asking the contended group for the field with offset"); | |
150 case FIELDINFO_TAG_BLANK: | |
151 ShouldNotReachHere2("Asking the contended group for the blank field"); | |
152 #endif | |
153 } | |
154 ShouldNotReachHere(); | |
155 return 0; | |
156 } | |
157 | |
158 u2 allocation_type() const { | |
159 u2 lo = _shorts[low_packed_offset]; | |
160 switch(lo & FIELDINFO_TAG_MASK) { | |
161 case FIELDINFO_TAG_TYPE_PLAIN: | |
162 case FIELDINFO_TAG_TYPE_CONTENDED: | |
163 return (lo >> FIELDINFO_TAG_SIZE); | |
164 #ifndef PRODUCT | |
165 case FIELDINFO_TAG_OFFSET: | |
166 ShouldNotReachHere2("Asking the field type for field with offset"); | |
167 case FIELDINFO_TAG_BLANK: | |
168 ShouldNotReachHere2("Asking the field type for the blank field"); | |
169 #endif | |
170 } | |
171 ShouldNotReachHere(); | |
172 return 0; | |
173 } | |
174 | |
175 bool is_offset_set() const { | |
176 return (_shorts[low_packed_offset] & FIELDINFO_TAG_MASK) == FIELDINFO_TAG_OFFSET; | |
177 } | |
90 | 178 |
91 Symbol* name(constantPoolHandle cp) const { | 179 Symbol* name(constantPoolHandle cp) const { |
92 int index = name_index(); | 180 int index = name_index(); |
93 if (is_internal()) { | 181 if (is_internal()) { |
94 return lookup_symbol(index); | 182 return lookup_symbol(index); |
104 return cp->symbol_at(index); | 192 return cp->symbol_at(index); |
105 } | 193 } |
106 | 194 |
107 void set_access_flags(u2 val) { _shorts[access_flags_offset] = val; } | 195 void set_access_flags(u2 val) { _shorts[access_flags_offset] = val; } |
108 void set_offset(u4 val) { | 196 void set_offset(u4 val) { |
109 _shorts[low_offset] = extract_low_short_from_int(val); | 197 val = val << FIELDINFO_TAG_SIZE; // make room for tag |
110 _shorts[high_offset] = extract_high_short_from_int(val); | 198 _shorts[low_packed_offset] = extract_low_short_from_int(val) | FIELDINFO_TAG_OFFSET; |
199 _shorts[high_packed_offset] = extract_high_short_from_int(val); | |
200 } | |
201 | |
202 void set_allocation_type(int type) { | |
203 u2 lo = _shorts[low_packed_offset]; | |
204 switch(lo & FIELDINFO_TAG_MASK) { | |
205 case FIELDINFO_TAG_BLANK: | |
206 _shorts[low_packed_offset] = ((type << FIELDINFO_TAG_SIZE)) & 0xFFFF; | |
207 _shorts[low_packed_offset] &= ~FIELDINFO_TAG_MASK; | |
208 _shorts[low_packed_offset] |= FIELDINFO_TAG_TYPE_PLAIN; | |
209 return; | |
210 #ifndef PRODUCT | |
211 case FIELDINFO_TAG_TYPE_PLAIN: | |
212 case FIELDINFO_TAG_TYPE_CONTENDED: | |
213 case FIELDINFO_TAG_OFFSET: | |
214 ShouldNotReachHere2("Setting the field type with overwriting"); | |
215 #endif | |
216 } | |
217 ShouldNotReachHere(); | |
218 } | |
219 | |
220 void set_contended_group(u2 val) { | |
221 u2 lo = _shorts[low_packed_offset]; | |
222 switch(lo & FIELDINFO_TAG_MASK) { | |
223 case FIELDINFO_TAG_TYPE_PLAIN: | |
224 _shorts[low_packed_offset] |= FIELDINFO_TAG_TYPE_CONTENDED; | |
225 _shorts[high_packed_offset] = val; | |
226 return; | |
227 #ifndef PRODUCT | |
228 case FIELDINFO_TAG_TYPE_CONTENDED: | |
229 ShouldNotReachHere2("Overwriting contended group"); | |
230 case FIELDINFO_TAG_BLANK: | |
231 ShouldNotReachHere2("Setting contended group for the blank field"); | |
232 case FIELDINFO_TAG_OFFSET: | |
233 ShouldNotReachHere2("Setting contended group for field with offset"); | |
234 #endif | |
235 } | |
236 ShouldNotReachHere(); | |
111 } | 237 } |
112 | 238 |
113 bool is_internal() const { | 239 bool is_internal() const { |
114 return (access_flags() & JVM_ACC_FIELD_INTERNAL) != 0; | 240 return (access_flags() & JVM_ACC_FIELD_INTERNAL) != 0; |
115 } | 241 } |