< prev index next >

src/hotspot/share/oops/cpCache.hpp

Print this page
rev 52749 : Bootstrap method consolidation
* clean up and simplify JDK support code for BSM invocation
* simplify JVM bootstrap handshake: use BootstrapCallInfo only
* remove unused JVM paths and data fields
* move bootstrap argument processing from MethodHandleNatives to ConstantPool
* remove ConstantGroup; merge argument access into BootstrapCallInfo
* adjust BSM argument access: remove copyArguments, add argumentRef API
* add metadata-free BSM modes, including symbolic arguments from CP


 163   void set_flags(intx flags)                     { _flags = flags; }
 164   void set_field_flags(TosState field_type, int option_bits, int field_index) {
 165     assert((field_index & field_index_mask) == field_index, "field_index in range");
 166     set_flags(make_flags(field_type, option_bits | (1 << is_field_entry_shift), field_index));
 167   }
 168   void set_method_flags(TosState return_type, int option_bits, int method_params) {
 169     assert((method_params & parameter_size_mask) == method_params, "method_params in range");
 170     set_flags(make_flags(return_type, option_bits, method_params));
 171   }
 172 
 173  public:
 174   // specific bit definitions for the flags field:
 175   // (Note: the interpreter must use these definitions to access the CP cache.)
 176   enum {
 177     // high order bits are the TosState corresponding to field type or method return type
 178     tos_state_bits             = 4,
 179     tos_state_mask             = right_n_bits(tos_state_bits),
 180     tos_state_shift            = BitsPerInt - tos_state_bits,  // see verify_tos_state_shift below
 181     // misc. option bits; can be any bit position in [16..27]
 182     is_field_entry_shift       = 26,  // (F) is it a field or a method?
 183     has_method_type_shift      = 25,  // (M) does the call site have a MethodType?
 184     has_appendix_shift         = 24,  // (A) does the call site have an appendix argument?
 185     is_forced_virtual_shift    = 23,  // (I) is the interface reference forced to virtual mode?
 186     is_final_shift             = 22,  // (f) is the field or method final?
 187     is_volatile_shift          = 21,  // (v) is the field volatile?
 188     is_vfinal_shift            = 20,  // (vf) did the call resolve to a final method?
 189     indy_resolution_failed_shift= 19, // (indy_rf) did call site specifier resolution fail ?
 190     // low order bits give field index (for FieldInfo) or method parameter size:
 191     field_index_bits           = 16,
 192     field_index_mask           = right_n_bits(field_index_bits),
 193     parameter_size_bits        = 8,  // subset of field_index_mask, range is 0..255
 194     parameter_size_mask        = right_n_bits(parameter_size_bits),
 195     option_bits_mask           = ~(((~0u) << tos_state_shift) | (field_index_mask | parameter_size_mask))
 196   };
 197 
 198   // specific bit definitions for the indices field:
 199   enum {
 200     cp_index_bits              = 2*BitsPerByte,
 201     cp_index_mask              = right_n_bits(cp_index_bits),
 202     bytecode_1_shift           = cp_index_bits,
 203     bytecode_1_mask            = right_n_bits(BitsPerByte), // == (u1)0xFF


 274   // null appendix, the argument is not passed at all.
 275   //
 276   // The appendix is *not* represented in the signature of the symbolic
 277   // reference for the call site, but (if present) it *is* represented in
 278   // the Method* bound to the site.  This means that static and dynamic
 279   // resolution logic needs to make slightly different assessments about the
 280   // number and types of arguments.
 281   void set_method_handle_common(
 282     const constantPoolHandle& cpool,                    // holding constant pool (required for locking)
 283     Bytecodes::Code invoke_code,                 // _invokehandle or _invokedynamic
 284     const CallInfo &call_info                    // Call link information
 285   );
 286 
 287   // Return TRUE if resolution failed and this thread got to record the failure
 288   // status.  Return FALSE if another thread succeeded or failed in resolving
 289   // the method and recorded the success or failure before this thread had a
 290   // chance to record its failure.
 291   bool save_and_throw_indy_exc(const constantPoolHandle& cpool, int cpool_index,
 292                                int index, constantTag tag, TRAPS);
 293 
 294   // invokedynamic and invokehandle call sites have two entries in the
 295   // resolved references array:
 296   //   appendix   (at index+0)
 297   //   MethodType (at index+1)
 298   enum {
 299     _indy_resolved_references_appendix_offset    = 0,
 300     _indy_resolved_references_method_type_offset = 1,
 301     _indy_resolved_references_entries
 302   };
 303 
 304   Method*      method_if_resolved(const constantPoolHandle& cpool);
 305   oop        appendix_if_resolved(const constantPoolHandle& cpool);
 306   oop     method_type_if_resolved(const constantPoolHandle& cpool);
 307 
 308   void set_parameter_size(int value);
 309 
 310   // Which bytecode number (1 or 2) in the index field is valid for this bytecode?
 311   // Returns -1 if neither is valid.
 312   static int bytecode_number(Bytecodes::Code code) {
 313     switch (code) {
 314       case Bytecodes::_getstatic       :    // fall through
 315       case Bytecodes::_getfield        :    // fall through
 316       case Bytecodes::_invokespecial   :    // fall through
 317       case Bytecodes::_invokestatic    :    // fall through
 318       case Bytecodes::_invokehandle    :    // fall through
 319       case Bytecodes::_invokedynamic   :    // fall through
 320       case Bytecodes::_invokeinterface : return 1;
 321       case Bytecodes::_putstatic       :    // fall through
 322       case Bytecodes::_putfield        :    // fall through
 323       case Bytecodes::_invokevirtual   : return 2;
 324       default                          : break;
 325     }
 326     return -1;


 339   Method*   f1_as_method() const;
 340   Klass*    f1_as_klass() const;
 341   // Use the accessor f1() to acquire _f1's value. This is needed for
 342   // example in BytecodeInterpreter::run(), where is_f1_null() is
 343   // called to check if an invokedynamic call is resolved. This load
 344   // of _f1 must be ordered with the loads performed by
 345   // cache->main_entry_index().
 346   bool      is_f1_null() const;  // classifies a CPC entry as unbound
 347   int       f2_as_index() const                  { assert(!is_vfinal(), ""); return (int) _f2; }
 348   Method*   f2_as_vfinal_method() const          { assert(is_vfinal(), ""); return (Method*)_f2; }
 349   Method*   f2_as_interface_method() const;
 350   intx flags_ord() const;
 351   int  field_index() const                       { assert(is_field_entry(),  ""); return (_flags & field_index_mask); }
 352   int  parameter_size() const                    { assert(is_method_entry(), ""); return (_flags & parameter_size_mask); }
 353   bool is_volatile() const                       { return (_flags & (1 << is_volatile_shift))       != 0; }
 354   bool is_final() const                          { return (_flags & (1 << is_final_shift))          != 0; }
 355   bool is_forced_virtual() const                 { return (_flags & (1 << is_forced_virtual_shift)) != 0; }
 356   bool is_vfinal() const                         { return (_flags & (1 << is_vfinal_shift))         != 0; }
 357   bool indy_resolution_failed() const;
 358   bool has_appendix() const;
 359   bool has_method_type() const;
 360   bool is_method_entry() const                   { return (_flags & (1 << is_field_entry_shift))    == 0; }
 361   bool is_field_entry() const                    { return (_flags & (1 << is_field_entry_shift))    != 0; }
 362   bool is_long() const                           { return flag_state() == ltos; }
 363   bool is_double() const                         { return flag_state() == dtos; }
 364   TosState flag_state() const                    { assert((uint)number_of_states <= (uint)tos_state_mask+1, "");
 365                                                    return (TosState)((_flags >> tos_state_shift) & tos_state_mask); }
 366   void set_indy_resolution_failed();
 367 
 368   // Code generation support
 369   static WordSize size()                         {
 370     return in_WordSize(align_up((int)sizeof(ConstantPoolCacheEntry), wordSize) / wordSize);
 371   }
 372   static ByteSize size_in_bytes()                { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); }
 373   static ByteSize indices_offset()               { return byte_offset_of(ConstantPoolCacheEntry, _indices); }
 374   static ByteSize f1_offset()                    { return byte_offset_of(ConstantPoolCacheEntry, _f1); }
 375   static ByteSize f2_offset()                    { return byte_offset_of(ConstantPoolCacheEntry, _f2); }
 376   static ByteSize flags_offset()                 { return byte_offset_of(ConstantPoolCacheEntry, _flags); }
 377 
 378 #if INCLUDE_JVMTI
 379   // RedefineClasses() API support:


 426   // time when caching java heap object is supported.
 427   CDS_JAVA_HEAP_ONLY(narrowOop _archived_references;)
 428 
 429   // Sizing
 430   debug_only(friend class ClassVerifier;)
 431 
 432   // Constructor
 433   ConstantPoolCache(int length,
 434                     const intStack& inverse_index_map,
 435                     const intStack& invokedynamic_inverse_index_map,
 436                     const intStack& invokedynamic_references_map);
 437 
 438   // Initialization
 439   void initialize(const intArray& inverse_index_map,
 440                   const intArray& invokedynamic_inverse_index_map,
 441                   const intArray& invokedynamic_references_map);
 442  public:
 443   static ConstantPoolCache* allocate(ClassLoaderData* loader_data,
 444                                      const intStack& cp_cache_map,
 445                                      const intStack& invokedynamic_cp_cache_map,
 446                                      const intStack& invokedynamic_references_map, TRAPS);
 447   bool is_constantPoolCache() const { return true; }
 448 
 449   int length() const                      { return _length; }
 450   void metaspace_pointers_do(MetaspaceClosure* it);
 451   MetaspaceObj::Type type() const         { return ConstantPoolCacheType; }
 452 
 453   oop  archived_references() NOT_CDS_JAVA_HEAP_RETURN_(NULL);
 454   void set_archived_references(oop o) NOT_CDS_JAVA_HEAP_RETURN;
 455 
 456   inline oop resolved_references();
 457   void set_resolved_references(OopHandle s) { _resolved_references = s; }
 458   Array<u2>* reference_map() const        { return _reference_map; }
 459   void set_reference_map(Array<u2>* o)    { _reference_map = o; }
 460 
 461   // Assembly code support
 462   static int resolved_references_offset_in_bytes() { return offset_of(ConstantPoolCache, _resolved_references); }
 463 
 464   // CDS support
 465   void remove_unshareable_info();
 466   void verify_just_initialized();




 163   void set_flags(intx flags)                     { _flags = flags; }
 164   void set_field_flags(TosState field_type, int option_bits, int field_index) {
 165     assert((field_index & field_index_mask) == field_index, "field_index in range");
 166     set_flags(make_flags(field_type, option_bits | (1 << is_field_entry_shift), field_index));
 167   }
 168   void set_method_flags(TosState return_type, int option_bits, int method_params) {
 169     assert((method_params & parameter_size_mask) == method_params, "method_params in range");
 170     set_flags(make_flags(return_type, option_bits, method_params));
 171   }
 172 
 173  public:
 174   // specific bit definitions for the flags field:
 175   // (Note: the interpreter must use these definitions to access the CP cache.)
 176   enum {
 177     // high order bits are the TosState corresponding to field type or method return type
 178     tos_state_bits             = 4,
 179     tos_state_mask             = right_n_bits(tos_state_bits),
 180     tos_state_shift            = BitsPerInt - tos_state_bits,  // see verify_tos_state_shift below
 181     // misc. option bits; can be any bit position in [16..27]
 182     is_field_entry_shift       = 26,  // (F) is it a field or a method?
 183     has_local_signature_shift  = 25,  // (M) does the call site have a per-site signature (sig-poly methods)?
 184     has_appendix_shift         = 24,  // (A) does the call site have an appendix argument?
 185     is_forced_virtual_shift    = 23,  // (I) is the interface reference forced to virtual mode?
 186     is_final_shift             = 22,  // (f) is the field or method final?
 187     is_volatile_shift          = 21,  // (v) is the field volatile?
 188     is_vfinal_shift            = 20,  // (vf) did the call resolve to a final method?
 189     indy_resolution_failed_shift= 19, // (indy_rf) did call site specifier resolution fail ?
 190     // low order bits give field index (for FieldInfo) or method parameter size:
 191     field_index_bits           = 16,
 192     field_index_mask           = right_n_bits(field_index_bits),
 193     parameter_size_bits        = 8,  // subset of field_index_mask, range is 0..255
 194     parameter_size_mask        = right_n_bits(parameter_size_bits),
 195     option_bits_mask           = ~(((~0u) << tos_state_shift) | (field_index_mask | parameter_size_mask))
 196   };
 197 
 198   // specific bit definitions for the indices field:
 199   enum {
 200     cp_index_bits              = 2*BitsPerByte,
 201     cp_index_mask              = right_n_bits(cp_index_bits),
 202     bytecode_1_shift           = cp_index_bits,
 203     bytecode_1_mask            = right_n_bits(BitsPerByte), // == (u1)0xFF


 274   // null appendix, the argument is not passed at all.
 275   //
 276   // The appendix is *not* represented in the signature of the symbolic
 277   // reference for the call site, but (if present) it *is* represented in
 278   // the Method* bound to the site.  This means that static and dynamic
 279   // resolution logic needs to make slightly different assessments about the
 280   // number and types of arguments.
 281   void set_method_handle_common(
 282     const constantPoolHandle& cpool,                    // holding constant pool (required for locking)
 283     Bytecodes::Code invoke_code,                 // _invokehandle or _invokedynamic
 284     const CallInfo &call_info                    // Call link information
 285   );
 286 
 287   // Return TRUE if resolution failed and this thread got to record the failure
 288   // status.  Return FALSE if another thread succeeded or failed in resolving
 289   // the method and recorded the success or failure before this thread had a
 290   // chance to record its failure.
 291   bool save_and_throw_indy_exc(const constantPoolHandle& cpool, int cpool_index,
 292                                int index, constantTag tag, TRAPS);
 293 
 294   // invokedynamic and invokehandle call sites have an "appendix" item in the
 295   // resolved references array:








 296   Method*      method_if_resolved(const constantPoolHandle& cpool);
 297   oop        appendix_if_resolved(const constantPoolHandle& cpool);

 298 
 299   void set_parameter_size(int value);
 300 
 301   // Which bytecode number (1 or 2) in the index field is valid for this bytecode?
 302   // Returns -1 if neither is valid.
 303   static int bytecode_number(Bytecodes::Code code) {
 304     switch (code) {
 305       case Bytecodes::_getstatic       :    // fall through
 306       case Bytecodes::_getfield        :    // fall through
 307       case Bytecodes::_invokespecial   :    // fall through
 308       case Bytecodes::_invokestatic    :    // fall through
 309       case Bytecodes::_invokehandle    :    // fall through
 310       case Bytecodes::_invokedynamic   :    // fall through
 311       case Bytecodes::_invokeinterface : return 1;
 312       case Bytecodes::_putstatic       :    // fall through
 313       case Bytecodes::_putfield        :    // fall through
 314       case Bytecodes::_invokevirtual   : return 2;
 315       default                          : break;
 316     }
 317     return -1;


 330   Method*   f1_as_method() const;
 331   Klass*    f1_as_klass() const;
 332   // Use the accessor f1() to acquire _f1's value. This is needed for
 333   // example in BytecodeInterpreter::run(), where is_f1_null() is
 334   // called to check if an invokedynamic call is resolved. This load
 335   // of _f1 must be ordered with the loads performed by
 336   // cache->main_entry_index().
 337   bool      is_f1_null() const;  // classifies a CPC entry as unbound
 338   int       f2_as_index() const                  { assert(!is_vfinal(), ""); return (int) _f2; }
 339   Method*   f2_as_vfinal_method() const          { assert(is_vfinal(), ""); return (Method*)_f2; }
 340   Method*   f2_as_interface_method() const;
 341   intx flags_ord() const;
 342   int  field_index() const                       { assert(is_field_entry(),  ""); return (_flags & field_index_mask); }
 343   int  parameter_size() const                    { assert(is_method_entry(), ""); return (_flags & parameter_size_mask); }
 344   bool is_volatile() const                       { return (_flags & (1 << is_volatile_shift))       != 0; }
 345   bool is_final() const                          { return (_flags & (1 << is_final_shift))          != 0; }
 346   bool is_forced_virtual() const                 { return (_flags & (1 << is_forced_virtual_shift)) != 0; }
 347   bool is_vfinal() const                         { return (_flags & (1 << is_vfinal_shift))         != 0; }
 348   bool indy_resolution_failed() const;
 349   bool has_appendix() const;
 350   bool has_local_signature() const;
 351   bool is_method_entry() const                   { return (_flags & (1 << is_field_entry_shift))    == 0; }
 352   bool is_field_entry() const                    { return (_flags & (1 << is_field_entry_shift))    != 0; }
 353   bool is_long() const                           { return flag_state() == ltos; }
 354   bool is_double() const                         { return flag_state() == dtos; }
 355   TosState flag_state() const                    { assert((uint)number_of_states <= (uint)tos_state_mask+1, "");
 356                                                    return (TosState)((_flags >> tos_state_shift) & tos_state_mask); }
 357   void set_indy_resolution_failed();
 358 
 359   // Code generation support
 360   static WordSize size()                         {
 361     return in_WordSize(align_up((int)sizeof(ConstantPoolCacheEntry), wordSize) / wordSize);
 362   }
 363   static ByteSize size_in_bytes()                { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); }
 364   static ByteSize indices_offset()               { return byte_offset_of(ConstantPoolCacheEntry, _indices); }
 365   static ByteSize f1_offset()                    { return byte_offset_of(ConstantPoolCacheEntry, _f1); }
 366   static ByteSize f2_offset()                    { return byte_offset_of(ConstantPoolCacheEntry, _f2); }
 367   static ByteSize flags_offset()                 { return byte_offset_of(ConstantPoolCacheEntry, _flags); }
 368 
 369 #if INCLUDE_JVMTI
 370   // RedefineClasses() API support:


 417   // time when caching java heap object is supported.
 418   CDS_JAVA_HEAP_ONLY(narrowOop _archived_references;)
 419 
 420   // Sizing
 421   debug_only(friend class ClassVerifier;)
 422 
 423   // Constructor
 424   ConstantPoolCache(int length,
 425                     const intStack& inverse_index_map,
 426                     const intStack& invokedynamic_inverse_index_map,
 427                     const intStack& invokedynamic_references_map);
 428 
 429   // Initialization
 430   void initialize(const intArray& inverse_index_map,
 431                   const intArray& invokedynamic_inverse_index_map,
 432                   const intArray& invokedynamic_references_map);
 433  public:
 434   static ConstantPoolCache* allocate(ClassLoaderData* loader_data,
 435                                      const intStack& cp_cache_map,
 436                                      const intStack& invokedynamic_cp_cache_map,
 437                                      const intStack& appendix_references_map, TRAPS);
 438   bool is_constantPoolCache() const { return true; }
 439 
 440   int length() const                      { return _length; }
 441   void metaspace_pointers_do(MetaspaceClosure* it);
 442   MetaspaceObj::Type type() const         { return ConstantPoolCacheType; }
 443 
 444   oop  archived_references() NOT_CDS_JAVA_HEAP_RETURN_(NULL);
 445   void set_archived_references(oop o) NOT_CDS_JAVA_HEAP_RETURN;
 446 
 447   inline oop resolved_references();
 448   void set_resolved_references(OopHandle s) { _resolved_references = s; }
 449   Array<u2>* reference_map() const        { return _reference_map; }
 450   void set_reference_map(Array<u2>* o)    { _reference_map = o; }
 451 
 452   // Assembly code support
 453   static int resolved_references_offset_in_bytes() { return offset_of(ConstantPoolCache, _resolved_references); }
 454 
 455   // CDS support
 456   void remove_unshareable_info();
 457   void verify_just_initialized();


< prev index next >