40 // bit length |-8--|-8--|---16----| |
40 // bit length |-8--|-8--|---16----| |
41 // -------------------------------- |
41 // -------------------------------- |
42 // _indices [ b2 | b1 | index ] index = constant_pool_index |
42 // _indices [ b2 | b1 | index ] index = constant_pool_index |
43 // _f1 [ entry specific ] metadata ptr (method or klass) |
43 // _f1 [ entry specific ] metadata ptr (method or klass) |
44 // _f2 [ entry specific ] vtable or res_ref index, or vfinal method ptr |
44 // _f2 [ entry specific ] vtable or res_ref index, or vfinal method ptr |
45 // _flags [tos|0|F=1|0|0|f|v|0 |00000|field_index] (for field entries) |
45 // _flags [tos|0|F=1|0|0|0|f|v|0 |0000|field_index] (for field entries) |
46 // bit length [ 4 |1| 1 |1|1|1|1|1 |--5--|----16-----] |
46 // bit length [ 4 |1| 1 |1|1|1|1|1|1 |-4--|----16-----] |
47 // _flags [tos|0|F=0|A|I|f|0|vf|00000|00000|psize] (for method entries) |
47 // _flags [tos|0|F=0|M|A|I|f|0|vf|0000|00000|psize] (for method entries) |
48 // bit length [ 4 |1| 1 |1|1|1|1|1 |--5--|--8--|--8--] |
48 // bit length [ 4 |1| 1 |1|1|1|1|1|1 |-4--|--8--|--8--] |
49 |
49 |
50 // -------------------------------- |
50 // -------------------------------- |
51 // |
51 // |
52 // with: |
52 // with: |
53 // index = original constant pool index |
53 // index = original constant pool index |
164 tos_state_bits = 4, |
164 tos_state_bits = 4, |
165 tos_state_mask = right_n_bits(tos_state_bits), |
165 tos_state_mask = right_n_bits(tos_state_bits), |
166 tos_state_shift = BitsPerInt - tos_state_bits, // see verify_tos_state_shift below |
166 tos_state_shift = BitsPerInt - tos_state_bits, // see verify_tos_state_shift below |
167 // misc. option bits; can be any bit position in [16..27] |
167 // misc. option bits; can be any bit position in [16..27] |
168 is_field_entry_shift = 26, // (F) is it a field or a method? |
168 is_field_entry_shift = 26, // (F) is it a field or a method? |
169 has_appendix_shift = 25, // (A) does the call site have an appendix argument? |
169 has_method_type_shift = 25, // (M) does the call site have a MethodType? |
170 is_forced_virtual_shift = 24, // (I) is the interface reference forced to virtual mode? |
170 has_appendix_shift = 24, // (A) does the call site have an appendix argument? |
171 is_final_shift = 23, // (f) is the field or method final? |
171 is_forced_virtual_shift = 23, // (I) is the interface reference forced to virtual mode? |
172 is_volatile_shift = 22, // (v) is the field volatile? |
172 is_final_shift = 22, // (f) is the field or method final? |
173 is_vfinal_shift = 21, // (vf) did the call resolve to a final method? |
173 is_volatile_shift = 21, // (v) is the field volatile? |
|
174 is_vfinal_shift = 20, // (vf) did the call resolve to a final method? |
174 // low order bits give field index (for FieldInfo) or method parameter size: |
175 // low order bits give field index (for FieldInfo) or method parameter size: |
175 field_index_bits = 16, |
176 field_index_bits = 16, |
176 field_index_mask = right_n_bits(field_index_bits), |
177 field_index_mask = right_n_bits(field_index_bits), |
177 parameter_size_bits = 8, // subset of field_index_mask, range is 0..255 |
178 parameter_size_bits = 8, // subset of field_index_mask, range is 0..255 |
178 parameter_size_mask = right_n_bits(parameter_size_bits), |
179 parameter_size_mask = right_n_bits(parameter_size_bits), |
221 ); |
222 ); |
222 |
223 |
223 void set_method_handle( |
224 void set_method_handle( |
224 constantPoolHandle cpool, // holding constant pool (required for locking) |
225 constantPoolHandle cpool, // holding constant pool (required for locking) |
225 methodHandle method, // adapter for invokeExact, etc. |
226 methodHandle method, // adapter for invokeExact, etc. |
226 Handle appendix, // stored in refs[f2]; could be a java.lang.invoke.MethodType |
227 Handle appendix, // stored in refs[f2+0]; could be a java.lang.invoke.MethodType |
|
228 Handle method_type, // stored in refs[f2+1]; is a java.lang.invoke.MethodType |
227 objArrayHandle resolved_references |
229 objArrayHandle resolved_references |
228 ); |
230 ); |
229 |
231 |
230 void set_dynamic_call( |
232 void set_dynamic_call( |
231 constantPoolHandle cpool, // holding constant pool (required for locking) |
233 constantPoolHandle cpool, // holding constant pool (required for locking) |
232 methodHandle method, // adapter for this call site |
234 methodHandle method, // adapter for this call site |
233 Handle appendix, // stored in refs[f2]; could be a java.lang.invoke.CallSite |
235 Handle appendix, // stored in refs[f2+0]; could be a java.lang.invoke.CallSite |
|
236 Handle method_type, // stored in refs[f2+1]; is a java.lang.invoke.MethodType |
234 objArrayHandle resolved_references |
237 objArrayHandle resolved_references |
235 ); |
238 ); |
236 |
239 |
237 // Common code for invokedynamic and MH invocations. |
240 // Common code for invokedynamic and MH invocations. |
238 |
241 |
251 // number and types of arguments. |
254 // number and types of arguments. |
252 void set_method_handle_common( |
255 void set_method_handle_common( |
253 constantPoolHandle cpool, // holding constant pool (required for locking) |
256 constantPoolHandle cpool, // holding constant pool (required for locking) |
254 Bytecodes::Code invoke_code, // _invokehandle or _invokedynamic |
257 Bytecodes::Code invoke_code, // _invokehandle or _invokedynamic |
255 methodHandle adapter, // invoker method (f1) |
258 methodHandle adapter, // invoker method (f1) |
256 Handle appendix, // appendix such as CallSite, MethodType, etc. (refs[f2]) |
259 Handle appendix, // appendix such as CallSite, MethodType, etc. (refs[f2+0]) |
|
260 Handle method_type, // MethodType (refs[f2+1]) |
257 objArrayHandle resolved_references |
261 objArrayHandle resolved_references |
258 ); |
262 ); |
259 |
263 |
260 Method* method_if_resolved(constantPoolHandle cpool); |
264 // invokedynamic and invokehandle call sites have two entries in the |
261 oop appendix_if_resolved(constantPoolHandle cpool); |
265 // resolved references array: |
|
266 // appendix (at index+0) |
|
267 // MethodType (at index+1) |
|
268 enum { |
|
269 _indy_resolved_references_appendix_offset = 0, |
|
270 _indy_resolved_references_method_type_offset = 1, |
|
271 _indy_resolved_references_entries |
|
272 }; |
|
273 |
|
274 Method* method_if_resolved(constantPoolHandle cpool); |
|
275 oop appendix_if_resolved(constantPoolHandle cpool); |
|
276 oop method_type_if_resolved(constantPoolHandle cpool); |
262 |
277 |
263 void set_parameter_size(int value); |
278 void set_parameter_size(int value); |
264 |
279 |
265 // Which bytecode number (1 or 2) in the index field is valid for this bytecode? |
280 // Which bytecode number (1 or 2) in the index field is valid for this bytecode? |
266 // Returns -1 if neither is valid. |
281 // Returns -1 if neither is valid. |
268 switch (code) { |
283 switch (code) { |
269 case Bytecodes::_getstatic : // fall through |
284 case Bytecodes::_getstatic : // fall through |
270 case Bytecodes::_getfield : // fall through |
285 case Bytecodes::_getfield : // fall through |
271 case Bytecodes::_invokespecial : // fall through |
286 case Bytecodes::_invokespecial : // fall through |
272 case Bytecodes::_invokestatic : // fall through |
287 case Bytecodes::_invokestatic : // fall through |
|
288 case Bytecodes::_invokehandle : // fall through |
|
289 case Bytecodes::_invokedynamic : // fall through |
273 case Bytecodes::_invokeinterface : return 1; |
290 case Bytecodes::_invokeinterface : return 1; |
274 case Bytecodes::_putstatic : // fall through |
291 case Bytecodes::_putstatic : // fall through |
275 case Bytecodes::_putfield : // fall through |
292 case Bytecodes::_putfield : // fall through |
276 case Bytecodes::_invokehandle : // fall through |
|
277 case Bytecodes::_invokedynamic : // fall through |
|
278 case Bytecodes::_invokevirtual : return 2; |
293 case Bytecodes::_invokevirtual : return 2; |
279 default : break; |
294 default : break; |
280 } |
295 } |
281 return -1; |
296 return -1; |
282 } |
297 } |
305 bool is_volatile() const { return (_flags & (1 << is_volatile_shift)) != 0; } |
320 bool is_volatile() const { return (_flags & (1 << is_volatile_shift)) != 0; } |
306 bool is_final() const { return (_flags & (1 << is_final_shift)) != 0; } |
321 bool is_final() const { return (_flags & (1 << is_final_shift)) != 0; } |
307 bool is_forced_virtual() const { return (_flags & (1 << is_forced_virtual_shift)) != 0; } |
322 bool is_forced_virtual() const { return (_flags & (1 << is_forced_virtual_shift)) != 0; } |
308 bool is_vfinal() const { return (_flags & (1 << is_vfinal_shift)) != 0; } |
323 bool is_vfinal() const { return (_flags & (1 << is_vfinal_shift)) != 0; } |
309 bool has_appendix() const { return (_flags & (1 << has_appendix_shift)) != 0; } |
324 bool has_appendix() const { return (_flags & (1 << has_appendix_shift)) != 0; } |
|
325 bool has_method_type() const { return (_flags & (1 << has_method_type_shift)) != 0; } |
310 bool is_method_entry() const { return (_flags & (1 << is_field_entry_shift)) == 0; } |
326 bool is_method_entry() const { return (_flags & (1 << is_field_entry_shift)) == 0; } |
311 bool is_field_entry() const { return (_flags & (1 << is_field_entry_shift)) != 0; } |
327 bool is_field_entry() const { return (_flags & (1 << is_field_entry_shift)) != 0; } |
312 bool is_byte() const { return flag_state() == btos; } |
328 bool is_byte() const { return flag_state() == btos; } |
313 bool is_char() const { return flag_state() == ctos; } |
329 bool is_char() const { return flag_state() == ctos; } |
314 bool is_short() const { return flag_state() == stos; } |
330 bool is_short() const { return flag_state() == stos; } |