87 // _indices = invoke code for f1 (b1 section), invoke code for f2 (b2 section), |
87 // _indices = invoke code for f1 (b1 section), invoke code for f2 (b2 section), |
88 // original constant pool index |
88 // original constant pool index |
89 // _f1 = method for all but virtual calls, unused by virtual calls |
89 // _f1 = method for all but virtual calls, unused by virtual calls |
90 // (note: for interface calls, which are essentially virtual, |
90 // (note: for interface calls, which are essentially virtual, |
91 // contains klassOop for the corresponding interface. |
91 // contains klassOop for the corresponding interface. |
|
92 // for invokedynamic, f1 contains the CallSite object for the invocation |
92 // _f2 = method/vtable index for virtual calls only, unused by all other |
93 // _f2 = method/vtable index for virtual calls only, unused by all other |
93 // calls. The vf flag indicates this is a method pointer not an |
94 // calls. The vf flag indicates this is a method pointer not an |
94 // index. |
95 // index. |
95 // _flags = field type info (f section), |
96 // _flags = field type info (f section), |
96 // virtual final entry (vf), |
97 // virtual final entry (vf), |
106 // The fields are volatile so that they are stored in the order written in the |
107 // The fields are volatile so that they are stored in the order written in the |
107 // source code. The _indices field with the bytecode must be written last. |
108 // source code. The _indices field with the bytecode must be written last. |
108 |
109 |
109 class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC { |
110 class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC { |
110 friend class VMStructs; |
111 friend class VMStructs; |
|
112 friend class constantPoolCacheKlass; |
|
113 |
111 private: |
114 private: |
112 volatile intx _indices; // constant pool index & rewrite bytecodes |
115 volatile intx _indices; // constant pool index & rewrite bytecodes |
113 volatile oop _f1; // entry specific oop field |
116 volatile oop _f1; // entry specific oop field |
114 volatile intx _f2; // entry specific int/oop field |
117 volatile intx _f2; // entry specific int/oop field |
115 volatile intx _flags; // flags |
118 volatile intx _flags; // flags |
171 ); |
174 ); |
172 |
175 |
173 void set_interface_call( |
176 void set_interface_call( |
174 methodHandle method, // Resolved method |
177 methodHandle method, // Resolved method |
175 int index // Method index into interface |
178 int index // Method index into interface |
|
179 ); |
|
180 |
|
181 void set_dynamic_call( |
|
182 Handle call_site, // Resolved java.dyn.CallSite (f1) |
|
183 int extra_data // (f2) |
176 ); |
184 ); |
177 |
185 |
178 void set_parameter_size(int value) { |
186 void set_parameter_size(int value) { |
179 assert(parameter_size() == 0 || parameter_size() == value, |
187 assert(parameter_size() == 0 || parameter_size() == value, |
180 "size must not change"); |
188 "size must not change"); |
214 } |
222 } |
215 return false; // default: not resolved |
223 return false; // default: not resolved |
216 } |
224 } |
217 |
225 |
218 // Accessors |
226 // Accessors |
219 int constant_pool_index() const { return _indices & 0xFFFF; } |
227 bool is_secondary_entry() const { return (_indices & 0xFFFF) == 0; } |
|
228 int constant_pool_index() const { assert((_indices & 0xFFFF) != 0, "must be main entry"); |
|
229 return (_indices & 0xFFFF); } |
|
230 int main_entry_index() const { assert((_indices & 0xFFFF) == 0, "must be secondary entry"); |
|
231 return ((uintx)_indices >> 16); } |
220 Bytecodes::Code bytecode_1() const { return Bytecodes::cast((_indices >> 16) & 0xFF); } |
232 Bytecodes::Code bytecode_1() const { return Bytecodes::cast((_indices >> 16) & 0xFF); } |
221 Bytecodes::Code bytecode_2() const { return Bytecodes::cast((_indices >> 24) & 0xFF); } |
233 Bytecodes::Code bytecode_2() const { return Bytecodes::cast((_indices >> 24) & 0xFF); } |
222 volatile oop f1() const { return _f1; } |
234 volatile oop f1() const { return _f1; } |
223 intx f2() const { return _f2; } |
235 intx f2() const { return _f2; } |
224 int field_index() const; |
236 int field_index() const; |
312 |
324 |
313 public: |
325 public: |
314 // Initialization |
326 // Initialization |
315 void initialize(intArray& inverse_index_map); |
327 void initialize(intArray& inverse_index_map); |
316 |
328 |
|
329 // Secondary indexes. |
|
330 // They must look completely different from normal indexes. |
|
331 // The main reason is that byte swapping is sometimes done on normal indexes. |
|
332 // Also, it is helpful for debugging to tell the two apart. |
|
333 static bool is_secondary_index(int i) { return (i < 0); } |
|
334 static int decode_secondary_index(int i) { assert(is_secondary_index(i), ""); return ~i; } |
|
335 static int encode_secondary_index(int i) { assert(!is_secondary_index(i), ""); return ~i; } |
|
336 |
317 // Accessors |
337 // Accessors |
318 void set_constant_pool(constantPoolOop pool) { oop_store_without_check((oop*)&_constant_pool, (oop)pool); } |
338 void set_constant_pool(constantPoolOop pool) { oop_store_without_check((oop*)&_constant_pool, (oop)pool); } |
319 constantPoolOop constant_pool() const { return _constant_pool; } |
339 constantPoolOop constant_pool() const { return _constant_pool; } |
320 ConstantPoolCacheEntry* entry_at(int i) const { assert(0 <= i && i < length(), "index out of bounds"); return base() + i; } |
340 ConstantPoolCacheEntry* entry_at(int i) const { assert(0 <= i && i < length(), "index out of bounds"); return base() + i; } |
|
341 ConstantPoolCacheEntry* main_entry_at(int i) const { |
|
342 ConstantPoolCacheEntry* e; |
|
343 if (is_secondary_index(i)) { |
|
344 // run through an extra level of indirection: |
|
345 i = decode_secondary_index(i); |
|
346 e = entry_at(i); |
|
347 i = e->main_entry_index(); |
|
348 } |
|
349 e = entry_at(i); |
|
350 assert(!e->is_secondary_entry(), "only one level of indirection"); |
|
351 return e; |
|
352 } |
321 |
353 |
322 // GC support |
354 // GC support |
323 // If the _length field has not been set, the size of the |
355 // If the _length field has not been set, the size of the |
324 // constantPoolCache cannot be correctly calculated. |
356 // constantPoolCache cannot be correctly calculated. |
325 bool is_conc_safe() { return _is_conc_safe; } |
357 bool is_conc_safe() { return _is_conc_safe; } |