< prev index next >

src/hotspot/share/oops/klass.hpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_OOPS_KLASS_HPP
  26 #define SHARE_OOPS_KLASS_HPP
  27 
  28 #include "classfile/classLoaderData.hpp"
  29 #include "memory/iterator.hpp"
  30 #include "memory/memRegion.hpp"

  31 #include "oops/markOop.hpp"
  32 #include "oops/metadata.hpp"
  33 #include "oops/oop.hpp"
  34 #include "oops/oopHandle.hpp"
  35 #include "utilities/accessFlags.hpp"
  36 #include "utilities/macros.hpp"
  37 #if INCLUDE_JFR
  38 #include "jfr/support/jfrTraceIdExtension.hpp"
  39 #endif
  40 
  41 // Klass IDs for all subclasses of Klass
  42 enum KlassID {
  43   InstanceKlassID,
  44   InstanceRefKlassID,
  45   InstanceMirrorKlassID,
  46   InstanceClassLoaderKlassID,
  47   TypeArrayKlassID,
  48   ValueArrayKlassID,
  49   ObjArrayKlassID
  50 };


 466 
 467   // array copying
 468   virtual void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
 469 
 470   // tells if the class should be initialized
 471   virtual bool should_be_initialized() const    { return false; }
 472   // initializes the klass
 473   virtual void initialize(TRAPS);
 474   // lookup operation for MethodLookupCache
 475   friend class MethodLookupCache;
 476   virtual Klass* find_field(Symbol* name, Symbol* signature, fieldDescriptor* fd) const;
 477   virtual Method* uncached_lookup_method(const Symbol* name, const Symbol* signature,
 478                                          OverpassLookupMode overpass_mode,
 479                                          PrivateLookupMode = find_private) const;
 480  public:
 481   Method* lookup_method(const Symbol* name, const Symbol* signature) const {
 482     return uncached_lookup_method(name, signature, find_overpass);
 483   }
 484 
 485   // array class with specific rank
 486   Klass* array_klass(int rank, TRAPS)         {  return array_klass_impl(false, rank, THREAD); }





 487 
 488   // array class with this klass as element type
 489   Klass* array_klass(TRAPS)                   {  return array_klass_impl(false, THREAD); }


 490 
 491   // These will return NULL instead of allocating on the heap:
 492   // NB: these can block for a mutex, like other functions with TRAPS arg.
 493   Klass* array_klass_or_null(int rank);
 494   Klass* array_klass_or_null();
 495 
 496   virtual oop protection_domain() const = 0;
 497 
 498   oop class_loader() const;
 499 
 500   // This loads the klass's holder as a phantom. This is useful when a weak Klass
 501   // pointer has been "peeked" and then must be kept alive before it may
 502   // be used safely.  All uses of klass_holder need to apply the appropriate barriers,
 503   // except during GC.
 504   oop klass_holder() const { return class_loader_data()->holder_phantom(); }
 505 
 506  protected:
 507   virtual Klass* array_klass_impl(bool or_null, int rank, TRAPS);
 508   virtual Klass* array_klass_impl(bool or_null, TRAPS);
 509 
 510   // Error handling when length > max_length or length < 0
 511   static void check_array_allocation_length(int length, int max_length, TRAPS);
 512 
 513   void set_vtable_length(int len) { _vtable_len= len; }
 514 
 515   vtableEntry* start_of_vtable() const;
 516  public:
 517   Method* method_at_vtable(int index);
 518 
 519   static ByteSize vtable_start_offset();
 520   static ByteSize vtable_length_offset() {
 521     return byte_offset_of(Klass, _vtable_len);
 522   }
 523 
 524   // CDS support - remove and restore oops from metadata. Oops are not shared.
 525   virtual void remove_unshareable_info();
 526   virtual void remove_java_mirror();
 527   virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
 528 




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_OOPS_KLASS_HPP
  26 #define SHARE_OOPS_KLASS_HPP
  27 
  28 #include "classfile/classLoaderData.hpp"
  29 #include "memory/iterator.hpp"
  30 #include "memory/memRegion.hpp"
  31 #include "oops/arrayStorageProperties.hpp"
  32 #include "oops/markOop.hpp"
  33 #include "oops/metadata.hpp"
  34 #include "oops/oop.hpp"
  35 #include "oops/oopHandle.hpp"
  36 #include "utilities/accessFlags.hpp"
  37 #include "utilities/macros.hpp"
  38 #if INCLUDE_JFR
  39 #include "jfr/support/jfrTraceIdExtension.hpp"
  40 #endif
  41 
  42 // Klass IDs for all subclasses of Klass
  43 enum KlassID {
  44   InstanceKlassID,
  45   InstanceRefKlassID,
  46   InstanceMirrorKlassID,
  47   InstanceClassLoaderKlassID,
  48   TypeArrayKlassID,
  49   ValueArrayKlassID,
  50   ObjArrayKlassID
  51 };


 467 
 468   // array copying
 469   virtual void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
 470 
 471   // tells if the class should be initialized
 472   virtual bool should_be_initialized() const    { return false; }
 473   // initializes the klass
 474   virtual void initialize(TRAPS);
 475   // lookup operation for MethodLookupCache
 476   friend class MethodLookupCache;
 477   virtual Klass* find_field(Symbol* name, Symbol* signature, fieldDescriptor* fd) const;
 478   virtual Method* uncached_lookup_method(const Symbol* name, const Symbol* signature,
 479                                          OverpassLookupMode overpass_mode,
 480                                          PrivateLookupMode = find_private) const;
 481  public:
 482   Method* lookup_method(const Symbol* name, const Symbol* signature) const {
 483     return uncached_lookup_method(name, signature, find_overpass);
 484   }
 485 
 486   // array class with specific rank
 487   Klass* array_klass(int rank, TRAPS) {
 488     return array_klass_impl(ArrayStorageProperties::empty, false, rank, THREAD);
 489   }
 490   Klass* array_klass(ArrayStorageProperties storage_props, int rank, TRAPS) {
 491     return array_klass_impl(storage_props, false, rank, THREAD);
 492   }
 493 
 494   // array class with this klass as element type
 495   Klass* array_klass(TRAPS) {
 496     return array_klass_impl(ArrayStorageProperties::empty, false, THREAD);
 497   }
 498 
 499   // These will return NULL instead of allocating on the heap:
 500   // NB: these can block for a mutex, like other functions with TRAPS arg.
 501   Klass* array_klass_or_null(ArrayStorageProperties storage_props, int rank);
 502   Klass* array_klass_or_null(ArrayStorageProperties storage_props);
 503 
 504   virtual oop protection_domain() const = 0;
 505 
 506   oop class_loader() const;
 507 
 508   // This loads the klass's holder as a phantom. This is useful when a weak Klass
 509   // pointer has been "peeked" and then must be kept alive before it may
 510   // be used safely.  All uses of klass_holder need to apply the appropriate barriers,
 511   // except during GC.
 512   oop klass_holder() const { return class_loader_data()->holder_phantom(); }
 513 
 514  protected:
 515   virtual Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, int rank, TRAPS);
 516   virtual Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, TRAPS);
 517 
 518   // Error handling when length > max_length or length < 0
 519   static void check_array_allocation_length(int length, int max_length, TRAPS);
 520 
 521   void set_vtable_length(int len) { _vtable_len= len; }
 522 
 523   vtableEntry* start_of_vtable() const;
 524  public:
 525   Method* method_at_vtable(int index);
 526 
 527   static ByteSize vtable_start_offset();
 528   static ByteSize vtable_length_offset() {
 529     return byte_offset_of(Klass, _vtable_len);
 530   }
 531 
 532   // CDS support - remove and restore oops from metadata. Oops are not shared.
 533   virtual void remove_unshareable_info();
 534   virtual void remove_java_mirror();
 535   virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
 536 


< prev index next >