src/share/vm/oops/instanceKlass.hpp

Print this page




 180   // if this class is unloaded.
 181   Symbol*         _array_name;
 182 
 183   // Number of heapOopSize words used by non-static fields in this klass
 184   // (including inherited fields but after header_size()).
 185   int             _nonstatic_field_size;
 186   int             _static_field_size;    // number words used by static fields (oop and non-oop) in this klass
 187   // Constant pool index to the utf8 entry of the Generic signature,
 188   // or 0 if none.
 189   u2              _generic_signature_index;
 190   // Constant pool index to the utf8 entry for the name of source file
 191   // containing this klass, 0 if not specified.
 192   u2              _source_file_name_index;
 193   u2              _static_oop_field_count;// number of static oop fields in this klass
 194   u2              _java_fields_count;    // The number of declared Java fields
 195   int             _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
 196 
 197   // _is_marked_dependent can be set concurrently, thus cannot be part of the
 198   // _misc_flags.
 199   bool            _is_marked_dependent;  // used for marking during flushing and deoptimization

 200 
 201   enum {
 202     _misc_rewritten            = 1 << 0, // methods rewritten.
 203     _misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops
 204     _misc_should_verify_class  = 1 << 2, // allow caching of preverification
 205     _misc_is_anonymous         = 1 << 3, // has embedded _host_klass field
 206     _misc_is_contended         = 1 << 4, // marked with contended annotation
 207     _misc_has_default_methods  = 1 << 5  // class/superclass/implemented interfaces has default methods
 208   };
 209   u2              _misc_flags;
 210   u2              _minor_version;        // minor version number of class file
 211   u2              _major_version;        // major version number of class file
 212   Thread*         _init_thread;          // Pointer to current thread doing initialization (to handle recusive initialization)
 213   int             _vtable_len;           // length of Java vtable (in words)
 214   int             _itable_len;           // length of Java itable (in words)
 215   OopMapCache*    volatile _oop_map_cache;   // OopMapCache for all methods in the klass (allocated lazily)
 216   MemberNameTable* _member_names;        // Member names
 217   JNIid*          _jni_ids;              // First JNI identifier for static fields in this class
 218   jmethodID*      _methods_jmethod_ids;  // jmethodIDs corresponding to method_idnum, or NULL if none
 219   nmethodBucket*  _dependencies;         // list of dependent nmethods


 427   bool is_reentrant_initialization(Thread *thread)  { return thread == _init_thread; }
 428   ClassState  init_state()                 { return (ClassState)_init_state; }
 429   bool is_rewritten() const                { return (_misc_flags & _misc_rewritten) != 0; }
 430 
 431   // defineClass specified verification
 432   bool should_verify_class() const         {
 433     return (_misc_flags & _misc_should_verify_class) != 0;
 434   }
 435   void set_should_verify_class(bool value) {
 436     if (value) {
 437       _misc_flags |= _misc_should_verify_class;
 438     } else {
 439       _misc_flags &= ~_misc_should_verify_class;
 440     }
 441   }
 442 
 443   // marking
 444   bool is_marked_dependent() const         { return _is_marked_dependent; }
 445   void set_is_marked_dependent(bool value) { _is_marked_dependent = value; }
 446 



 447   // initialization (virtuals from Klass)
 448   bool should_be_initialized() const;  // means that initialize should be called
 449   void initialize(TRAPS);
 450   void link_class(TRAPS);
 451   bool link_class_or_fail(TRAPS); // returns false on failure
 452   void unlink_class();
 453   void rewrite_class(TRAPS);
 454   void link_methods(TRAPS);
 455   Method* class_initializer();
 456 
 457   // set the class to initialized if no static initializer is present
 458   void eager_initialize(Thread *thread);
 459 
 460   // reference type
 461   ReferenceType reference_type() const     { return (ReferenceType)_reference_type; }
 462   void set_reference_type(ReferenceType t) {
 463     assert(t == (u1)t, "overflow");
 464     _reference_type = (u1)t;
 465   }
 466 


 905     return !layout_helper_needs_slow_path(layout_helper());
 906   }
 907 
 908   // Java vtable/itable
 909   klassVtable* vtable() const;        // return new klassVtable wrapper
 910   inline Method* method_at_vtable(int index);
 911   klassItable* itable() const;        // return new klassItable wrapper
 912   Method* method_at_itable(Klass* holder, int index, TRAPS);
 913 
 914 #if INCLUDE_JVMTI
 915   void adjust_default_methods(Method** old_methods, Method** new_methods,
 916                               int methods_length, bool* trace_name_printed);
 917 #endif // INCLUDE_JVMTI
 918 
 919   // Garbage collection
 920   void oop_follow_contents(oop obj);
 921   int  oop_adjust_pointers(oop obj);
 922 
 923   void clean_implementors_list(BoolObjectClosure* is_alive);
 924   void clean_method_data(BoolObjectClosure* is_alive);

 925 
 926   // Explicit metaspace deallocation of fields
 927   // For RedefineClasses and class file parsing errors, we need to deallocate
 928   // instanceKlasses and the metadata they point to.
 929   void deallocate_contents(ClassLoaderData* loader_data);
 930   static void deallocate_methods(ClassLoaderData* loader_data,
 931                                  Array<Method*>* methods);
 932   void static deallocate_interfaces(ClassLoaderData* loader_data,
 933                                     Klass* super_klass,
 934                                     Array<Klass*>* local_interfaces,
 935                                     Array<Klass*>* transitive_interfaces);
 936 
 937   // The constant pool is on stack if any of the methods are executing or
 938   // referenced by handles.
 939   bool on_stack() const { return _constants->on_stack(); }
 940 
 941   // callbacks for actions during class unloading
 942   static void notify_unload_class(InstanceKlass* ik);
 943   static void release_C_heap_structures(InstanceKlass* ik);
 944 


1193 // recording the method, a count of how many times a particular nmethod
1194 // was recorded is kept.  This ensures that any recording errors are
1195 // noticed since an nmethod should be removed as many times are it's
1196 // added.
1197 //
1198 class nmethodBucket: public CHeapObj<mtClass> {
1199   friend class VMStructs;
1200  private:
1201   nmethod*       _nmethod;
1202   int            _count;
1203   nmethodBucket* _next;
1204 
1205  public:
1206   nmethodBucket(nmethod* nmethod, nmethodBucket* next) {
1207     _nmethod = nmethod;
1208     _next = next;
1209     _count = 1;
1210   }
1211   int count()                             { return _count; }
1212   int increment()                         { _count += 1; return _count; }
1213   int decrement()                         { _count -= 1; assert(_count >= 0, "don't underflow"); return _count; }
1214   nmethodBucket* next()                   { return _next; }
1215   void set_next(nmethodBucket* b)         { _next = b; }
1216   nmethod* get_nmethod()                  { return _nmethod; }
1217 };
1218 
1219 // An iterator that's used to access the inner classes indices in the
1220 // InstanceKlass::_inner_classes array.
1221 class InnerClassesIterator : public StackObj {
1222  private:
1223   Array<jushort>* _inner_classes;
1224   int _length;
1225   int _idx;
1226  public:
1227 
1228   InnerClassesIterator(instanceKlassHandle k) {
1229     _inner_classes = k->inner_classes();
1230     if (k->inner_classes() != NULL) {
1231       _length = _inner_classes->length();
1232       // The inner class array's length should be the multiple of
1233       // inner_class_next_offset if it only contains the InnerClasses




 180   // if this class is unloaded.
 181   Symbol*         _array_name;
 182 
 183   // Number of heapOopSize words used by non-static fields in this klass
 184   // (including inherited fields but after header_size()).
 185   int             _nonstatic_field_size;
 186   int             _static_field_size;    // number words used by static fields (oop and non-oop) in this klass
 187   // Constant pool index to the utf8 entry of the Generic signature,
 188   // or 0 if none.
 189   u2              _generic_signature_index;
 190   // Constant pool index to the utf8 entry for the name of source file
 191   // containing this klass, 0 if not specified.
 192   u2              _source_file_name_index;
 193   u2              _static_oop_field_count;// number of static oop fields in this klass
 194   u2              _java_fields_count;    // The number of declared Java fields
 195   int             _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
 196 
 197   // _is_marked_dependent can be set concurrently, thus cannot be part of the
 198   // _misc_flags.
 199   bool            _is_marked_dependent;  // used for marking during flushing and deoptimization
 200   bool            _has_unloaded_dependent;
 201 
 202   enum {
 203     _misc_rewritten            = 1 << 0, // methods rewritten.
 204     _misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops
 205     _misc_should_verify_class  = 1 << 2, // allow caching of preverification
 206     _misc_is_anonymous         = 1 << 3, // has embedded _host_klass field
 207     _misc_is_contended         = 1 << 4, // marked with contended annotation
 208     _misc_has_default_methods  = 1 << 5  // class/superclass/implemented interfaces has default methods
 209   };
 210   u2              _misc_flags;
 211   u2              _minor_version;        // minor version number of class file
 212   u2              _major_version;        // major version number of class file
 213   Thread*         _init_thread;          // Pointer to current thread doing initialization (to handle recusive initialization)
 214   int             _vtable_len;           // length of Java vtable (in words)
 215   int             _itable_len;           // length of Java itable (in words)
 216   OopMapCache*    volatile _oop_map_cache;   // OopMapCache for all methods in the klass (allocated lazily)
 217   MemberNameTable* _member_names;        // Member names
 218   JNIid*          _jni_ids;              // First JNI identifier for static fields in this class
 219   jmethodID*      _methods_jmethod_ids;  // jmethodIDs corresponding to method_idnum, or NULL if none
 220   nmethodBucket*  _dependencies;         // list of dependent nmethods


 428   bool is_reentrant_initialization(Thread *thread)  { return thread == _init_thread; }
 429   ClassState  init_state()                 { return (ClassState)_init_state; }
 430   bool is_rewritten() const                { return (_misc_flags & _misc_rewritten) != 0; }
 431 
 432   // defineClass specified verification
 433   bool should_verify_class() const         {
 434     return (_misc_flags & _misc_should_verify_class) != 0;
 435   }
 436   void set_should_verify_class(bool value) {
 437     if (value) {
 438       _misc_flags |= _misc_should_verify_class;
 439     } else {
 440       _misc_flags &= ~_misc_should_verify_class;
 441     }
 442   }
 443 
 444   // marking
 445   bool is_marked_dependent() const         { return _is_marked_dependent; }
 446   void set_is_marked_dependent(bool value) { _is_marked_dependent = value; }
 447 
 448   bool has_unloaded_dependent() const         { return _has_unloaded_dependent; }
 449   void set_has_unloaded_dependent(bool value) { _has_unloaded_dependent = value; }
 450 
 451   // initialization (virtuals from Klass)
 452   bool should_be_initialized() const;  // means that initialize should be called
 453   void initialize(TRAPS);
 454   void link_class(TRAPS);
 455   bool link_class_or_fail(TRAPS); // returns false on failure
 456   void unlink_class();
 457   void rewrite_class(TRAPS);
 458   void link_methods(TRAPS);
 459   Method* class_initializer();
 460 
 461   // set the class to initialized if no static initializer is present
 462   void eager_initialize(Thread *thread);
 463 
 464   // reference type
 465   ReferenceType reference_type() const     { return (ReferenceType)_reference_type; }
 466   void set_reference_type(ReferenceType t) {
 467     assert(t == (u1)t, "overflow");
 468     _reference_type = (u1)t;
 469   }
 470 


 909     return !layout_helper_needs_slow_path(layout_helper());
 910   }
 911 
 912   // Java vtable/itable
 913   klassVtable* vtable() const;        // return new klassVtable wrapper
 914   inline Method* method_at_vtable(int index);
 915   klassItable* itable() const;        // return new klassItable wrapper
 916   Method* method_at_itable(Klass* holder, int index, TRAPS);
 917 
 918 #if INCLUDE_JVMTI
 919   void adjust_default_methods(Method** old_methods, Method** new_methods,
 920                               int methods_length, bool* trace_name_printed);
 921 #endif // INCLUDE_JVMTI
 922 
 923   // Garbage collection
 924   void oop_follow_contents(oop obj);
 925   int  oop_adjust_pointers(oop obj);
 926 
 927   void clean_implementors_list(BoolObjectClosure* is_alive);
 928   void clean_method_data(BoolObjectClosure* is_alive);
 929   void clean_dependent_nmethods();
 930 
 931   // Explicit metaspace deallocation of fields
 932   // For RedefineClasses and class file parsing errors, we need to deallocate
 933   // instanceKlasses and the metadata they point to.
 934   void deallocate_contents(ClassLoaderData* loader_data);
 935   static void deallocate_methods(ClassLoaderData* loader_data,
 936                                  Array<Method*>* methods);
 937   void static deallocate_interfaces(ClassLoaderData* loader_data,
 938                                     Klass* super_klass,
 939                                     Array<Klass*>* local_interfaces,
 940                                     Array<Klass*>* transitive_interfaces);
 941 
 942   // The constant pool is on stack if any of the methods are executing or
 943   // referenced by handles.
 944   bool on_stack() const { return _constants->on_stack(); }
 945 
 946   // callbacks for actions during class unloading
 947   static void notify_unload_class(InstanceKlass* ik);
 948   static void release_C_heap_structures(InstanceKlass* ik);
 949 


1198 // recording the method, a count of how many times a particular nmethod
1199 // was recorded is kept.  This ensures that any recording errors are
1200 // noticed since an nmethod should be removed as many times are it's
1201 // added.
1202 //
1203 class nmethodBucket: public CHeapObj<mtClass> {
1204   friend class VMStructs;
1205  private:
1206   nmethod*       _nmethod;
1207   int            _count;
1208   nmethodBucket* _next;
1209 
1210  public:
1211   nmethodBucket(nmethod* nmethod, nmethodBucket* next) {
1212     _nmethod = nmethod;
1213     _next = next;
1214     _count = 1;
1215   }
1216   int count()                             { return _count; }
1217   int increment()                         { _count += 1; return _count; }
1218   int decrement();
1219   nmethodBucket* next()                   { return _next; }
1220   void set_next(nmethodBucket* b)         { _next = b; }
1221   nmethod* get_nmethod()                  { return _nmethod; }
1222 };
1223 
1224 // An iterator that's used to access the inner classes indices in the
1225 // InstanceKlass::_inner_classes array.
1226 class InnerClassesIterator : public StackObj {
1227  private:
1228   Array<jushort>* _inner_classes;
1229   int _length;
1230   int _idx;
1231  public:
1232 
1233   InnerClassesIterator(instanceKlassHandle k) {
1234     _inner_classes = k->inner_classes();
1235     if (k->inner_classes() != NULL) {
1236       _length = _inner_classes->length();
1237       // The inner class array's length should be the multiple of
1238       // inner_class_next_offset if it only contains the InnerClasses