< prev index next >

src/hotspot/share/oops/instanceKlass.hpp

Print this page




 222   static const unsigned _misc_kind_reference    = 1; // InstanceRefKlass
 223   static const unsigned _misc_kind_class_loader = 2; // InstanceClassLoaderKlass
 224   static const unsigned _misc_kind_mirror       = 3; // InstanceMirrorKlass
 225 
 226   // Start after _misc_kind field.
 227   enum {
 228     _misc_rewritten                           = 1 << 2,  // methods rewritten.
 229     _misc_has_nonstatic_fields                = 1 << 3,  // for sizing with UseCompressedOops
 230     _misc_should_verify_class                 = 1 << 4,  // allow caching of preverification
 231     _misc_is_unsafe_anonymous                 = 1 << 5,  // has embedded _unsafe_anonymous_host field
 232     _misc_is_contended                        = 1 << 6,  // marked with contended annotation
 233     _misc_has_nonstatic_concrete_methods      = 1 << 7,  // class/superclass/implemented interfaces has non-static, concrete methods
 234     _misc_declares_nonstatic_concrete_methods = 1 << 8,  // directly declares non-static, concrete methods
 235     _misc_has_been_redefined                  = 1 << 9,  // class has been redefined
 236     _misc_has_passed_fingerprint_check        = 1 << 10, // when this class was loaded, the fingerprint computed from its
 237                                                          // code source was found to be matching the value recorded by AOT.
 238     _misc_is_scratch_class                    = 1 << 11, // class is the redefined scratch class
 239     _misc_is_shared_boot_class                = 1 << 12, // defining class loader is boot class loader
 240     _misc_is_shared_platform_class            = 1 << 13, // defining class loader is platform class loader
 241     _misc_is_shared_app_class                 = 1 << 14, // defining class loader is app class loader
 242     _misc_has_resolved_methods                = 1 << 15  // resolved methods table entries added for this class

 243   };
 244   u2 loader_type_bits() {
 245     return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
 246   }
 247   u2              _misc_flags;
 248   u2              _minor_version;        // minor version number of class file
 249   u2              _major_version;        // major version number of class file
 250   Thread*         _init_thread;          // Pointer to current thread doing initialization (to handle recusive initialization)
 251   OopMapCache*    volatile _oop_map_cache;   // OopMapCache for all methods in the klass (allocated lazily)
 252   JNIid*          _jni_ids;              // First JNI identifier for static fields in this class
 253   jmethodID*      volatile _methods_jmethod_ids;  // jmethodIDs corresponding to method_idnum, or NULL if none
 254   nmethodBucket*  volatile _dep_context;          // packed DependencyContext structure
 255   uint64_t        volatile _dep_context_last_cleaned;
 256   nmethod*        _osr_nmethods_head;    // Head of list of on-stack replacement nmethods for this class
 257 #if INCLUDE_JVMTI
 258   BreakpointInfo* _breakpoints;          // bpt lists, managed by Method*
 259   // Linked instanceKlasses of previous versions
 260   InstanceKlass* _previous_versions;
 261   // JVMTI fields can be moved to their own structure - see 6315920
 262   // JVMTI: cached class file, before retransformable agent modified it in CFLH
 263   JvmtiCachedClassFileData* _cached_class_file;
 264 #endif
 265 
 266   volatile u2     _idnum_allocated_count;         // JNI/JVMTI: increments with the addition of methods, old ids don't change
 267 


 428   int java_fields_count() const           { return (int)_java_fields_count; }
 429 
 430   Array<u2>* fields() const            { return _fields; }
 431   void set_fields(Array<u2>* f, u2 java_fields_count) {
 432     guarantee(_fields == NULL || f == NULL, "Just checking");
 433     _fields = f;
 434     _java_fields_count = java_fields_count;
 435   }
 436 
 437   // inner classes
 438   Array<u2>* inner_classes() const       { return _inner_classes; }
 439   void set_inner_classes(Array<u2>* f)   { _inner_classes = f; }
 440 
 441   // nest members
 442   Array<u2>* nest_members() const     { return _nest_members; }
 443   void set_nest_members(Array<u2>* m) { _nest_members = m; }
 444 
 445   // nest-host index
 446   jushort nest_host_index() const { return _nest_host_index; }
 447   void set_nest_host_index(u2 i)  { _nest_host_index = i; }


 448 
 449 private:
 450   // Called to verify that k is a member of this nest - does not look at k's nest-host
 451   bool has_nest_member(InstanceKlass* k, TRAPS) const;
 452 public:
 453   // Returns nest-host class, resolving and validating it if needed
 454   // Returns NULL if an exception occurs during loading, or validation fails
 455   InstanceKlass* nest_host(Symbol* validationException, TRAPS);
 456   // Check if this klass is a nestmate of k - resolves this nest-host and k's
 457   bool has_nestmate_access_to(InstanceKlass* k, TRAPS);
 458 
 459   enum InnerClassAttributeOffset {
 460     // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814
 461     inner_class_inner_class_info_offset = 0,
 462     inner_class_outer_class_info_offset = 1,
 463     inner_class_inner_name_offset = 2,
 464     inner_class_access_flags_offset = 3,
 465     inner_class_next_offset = 4
 466   };
 467 


 647   }
 648   void set_unsafe_anonymous_host(const InstanceKlass* host) {
 649     assert(is_unsafe_anonymous(), "not unsafe anonymous");
 650     const InstanceKlass** addr = (const InstanceKlass **)adr_unsafe_anonymous_host();
 651     assert(addr != NULL, "no reversed space");
 652     if (addr != NULL) {
 653       *addr = host;
 654     }
 655   }
 656   bool is_unsafe_anonymous() const                {
 657     return (_misc_flags & _misc_is_unsafe_anonymous) != 0;
 658   }
 659   void set_is_unsafe_anonymous(bool value)        {
 660     if (value) {
 661       _misc_flags |= _misc_is_unsafe_anonymous;
 662     } else {
 663       _misc_flags &= ~_misc_is_unsafe_anonymous;
 664     }
 665   }
 666 











 667   bool is_contended() const                {
 668     return (_misc_flags & _misc_is_contended) != 0;
 669   }
 670   void set_is_contended(bool value)        {
 671     if (value) {
 672       _misc_flags |= _misc_is_contended;
 673     } else {
 674       _misc_flags &= ~_misc_is_contended;
 675     }
 676   }
 677 
 678   // source file name
 679   Symbol* source_file_name() const               {
 680     return (_source_file_name_index == 0) ?
 681       (Symbol*)NULL : _constants->symbol_at(_source_file_name_index);
 682   }
 683   u2 source_file_name_index() const              {
 684     return _source_file_name_index;
 685   }
 686   void set_source_file_name_index(u2 sourcefile_index) {


 738 
 739   bool has_been_redefined() const {
 740     return (_misc_flags & _misc_has_been_redefined) != 0;
 741   }
 742   void set_has_been_redefined() {
 743     _misc_flags |= _misc_has_been_redefined;
 744   }
 745 
 746   bool has_passed_fingerprint_check() const {
 747     return (_misc_flags & _misc_has_passed_fingerprint_check) != 0;
 748   }
 749   void set_has_passed_fingerprint_check(bool b) {
 750     if (b) {
 751       _misc_flags |= _misc_has_passed_fingerprint_check;
 752     } else {
 753       _misc_flags &= ~_misc_has_passed_fingerprint_check;
 754     }
 755   }
 756   bool supers_have_passed_fingerprint_checks();
 757 
 758   static bool should_store_fingerprint(bool is_unsafe_anonymous);
 759   bool should_store_fingerprint() const { return should_store_fingerprint(is_unsafe_anonymous()); }
 760   bool has_stored_fingerprint() const;
 761   uint64_t get_stored_fingerprint() const;
 762   void store_fingerprint(uint64_t fingerprint);
 763 
 764   bool is_scratch_class() const {
 765     return (_misc_flags & _misc_is_scratch_class) != 0;
 766   }
 767 
 768   void set_is_scratch_class() {
 769     _misc_flags |= _misc_is_scratch_class;
 770   }
 771 
 772   bool has_resolved_methods() const {
 773     return (_misc_flags & _misc_has_resolved_methods) != 0;
 774   }
 775 
 776   void set_has_resolved_methods() {
 777     _misc_flags |= _misc_has_resolved_methods;
 778   }
 779 private:


1012 
1013   static InstanceKlass* cast(Klass* k) {
1014     return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));
1015   }
1016 
1017   static const InstanceKlass* cast(const Klass* k) {
1018     assert(k != NULL, "k should not be null");
1019     assert(k->is_instance_klass(), "cast to InstanceKlass");
1020     return static_cast<const InstanceKlass*>(k);
1021   }
1022 
1023   virtual InstanceKlass* java_super() const {
1024     return (super() == NULL) ? NULL : cast(super());
1025   }
1026 
1027   // Sizing (in words)
1028   static int header_size()            { return sizeof(InstanceKlass)/wordSize; }
1029 
1030   static int size(int vtable_length, int itable_length,
1031                   int nonstatic_oop_map_size,
1032                   bool is_interface, bool is_unsafe_anonymous, bool has_stored_fingerprint) {
1033     return align_metadata_size(header_size() +
1034            vtable_length +
1035            itable_length +
1036            nonstatic_oop_map_size +
1037            (is_interface ? (int)sizeof(Klass*)/wordSize : 0) +
1038            (is_unsafe_anonymous ? (int)sizeof(Klass*)/wordSize : 0) +
1039            (has_stored_fingerprint ? (int)sizeof(uint64_t*)/wordSize : 0));
1040   }
1041   int size() const                    { return size(vtable_length(),
1042                                                itable_length(),
1043                                                nonstatic_oop_map_size(),
1044                                                is_interface(),
1045                                                is_unsafe_anonymous(),
1046                                                has_stored_fingerprint());
1047   }
1048 #if INCLUDE_SERVICES
1049   virtual void collect_statistics(KlassSizeStats *sz) const;
1050 #endif
1051 
1052   intptr_t* start_of_itable()   const { return (intptr_t*)start_of_vtable() + vtable_length(); }
1053   intptr_t* end_of_itable()     const { return start_of_itable() + itable_length(); }
1054 
1055   int  itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
1056 
1057   oop static_field_base_raw() { return java_mirror(); }
1058 
1059   OopMapBlock* start_of_nonstatic_oop_maps() const {
1060     return (OopMapBlock*)(start_of_itable() + itable_length());
1061   }
1062 
1063   Klass** end_of_nonstatic_oop_maps() const {
1064     return (Klass**)(start_of_nonstatic_oop_maps() +
1065                      nonstatic_oop_map_count());




 222   static const unsigned _misc_kind_reference    = 1; // InstanceRefKlass
 223   static const unsigned _misc_kind_class_loader = 2; // InstanceClassLoaderKlass
 224   static const unsigned _misc_kind_mirror       = 3; // InstanceMirrorKlass
 225 
 226   // Start after _misc_kind field.
 227   enum {
 228     _misc_rewritten                           = 1 << 2,  // methods rewritten.
 229     _misc_has_nonstatic_fields                = 1 << 3,  // for sizing with UseCompressedOops
 230     _misc_should_verify_class                 = 1 << 4,  // allow caching of preverification
 231     _misc_is_unsafe_anonymous                 = 1 << 5,  // has embedded _unsafe_anonymous_host field
 232     _misc_is_contended                        = 1 << 6,  // marked with contended annotation
 233     _misc_has_nonstatic_concrete_methods      = 1 << 7,  // class/superclass/implemented interfaces has non-static, concrete methods
 234     _misc_declares_nonstatic_concrete_methods = 1 << 8,  // directly declares non-static, concrete methods
 235     _misc_has_been_redefined                  = 1 << 9,  // class has been redefined
 236     _misc_has_passed_fingerprint_check        = 1 << 10, // when this class was loaded, the fingerprint computed from its
 237                                                          // code source was found to be matching the value recorded by AOT.
 238     _misc_is_scratch_class                    = 1 << 11, // class is the redefined scratch class
 239     _misc_is_shared_boot_class                = 1 << 12, // defining class loader is boot class loader
 240     _misc_is_shared_platform_class            = 1 << 13, // defining class loader is platform class loader
 241     _misc_is_shared_app_class                 = 1 << 14, // defining class loader is app class loader
 242     _misc_has_resolved_methods                = 1 << 15, // resolved methods table entries added for this class
 243     _misc_is_nonfindable                      = 1 << 16  // is a non findable class, not stored in the SystemDictionary.
 244   };
 245   u2 loader_type_bits() {
 246     return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
 247   }
 248   u4              _misc_flags;
 249   u2              _minor_version;        // minor version number of class file
 250   u2              _major_version;        // major version number of class file
 251   Thread*         _init_thread;          // Pointer to current thread doing initialization (to handle recusive initialization)
 252   OopMapCache*    volatile _oop_map_cache;   // OopMapCache for all methods in the klass (allocated lazily)
 253   JNIid*          _jni_ids;              // First JNI identifier for static fields in this class
 254   jmethodID*      volatile _methods_jmethod_ids;  // jmethodIDs corresponding to method_idnum, or NULL if none
 255   nmethodBucket*  volatile _dep_context;          // packed DependencyContext structure
 256   uint64_t        volatile _dep_context_last_cleaned;
 257   nmethod*        _osr_nmethods_head;    // Head of list of on-stack replacement nmethods for this class
 258 #if INCLUDE_JVMTI
 259   BreakpointInfo* _breakpoints;          // bpt lists, managed by Method*
 260   // Linked instanceKlasses of previous versions
 261   InstanceKlass* _previous_versions;
 262   // JVMTI fields can be moved to their own structure - see 6315920
 263   // JVMTI: cached class file, before retransformable agent modified it in CFLH
 264   JvmtiCachedClassFileData* _cached_class_file;
 265 #endif
 266 
 267   volatile u2     _idnum_allocated_count;         // JNI/JVMTI: increments with the addition of methods, old ids don't change
 268 


 429   int java_fields_count() const           { return (int)_java_fields_count; }
 430 
 431   Array<u2>* fields() const            { return _fields; }
 432   void set_fields(Array<u2>* f, u2 java_fields_count) {
 433     guarantee(_fields == NULL || f == NULL, "Just checking");
 434     _fields = f;
 435     _java_fields_count = java_fields_count;
 436   }
 437 
 438   // inner classes
 439   Array<u2>* inner_classes() const       { return _inner_classes; }
 440   void set_inner_classes(Array<u2>* f)   { _inner_classes = f; }
 441 
 442   // nest members
 443   Array<u2>* nest_members() const     { return _nest_members; }
 444   void set_nest_members(Array<u2>* m) { _nest_members = m; }
 445 
 446   // nest-host index
 447   jushort nest_host_index() const { return _nest_host_index; }
 448   void set_nest_host_index(u2 i)  { _nest_host_index = i; }
 449   // dynamic nest member support
 450   void set_nest_host(InstanceKlass* host, TRAPS);
 451 
 452 private:
 453   // Called to verify that k is a member of this nest - does not look at k's nest-host
 454   bool has_nest_member(InstanceKlass* k, TRAPS) const;
 455 public:
 456   // Returns nest-host class, resolving and validating it if needed
 457   // Returns NULL if an exception occurs during loading, or validation fails
 458   InstanceKlass* nest_host(Symbol* validationException, TRAPS);
 459   // Check if this klass is a nestmate of k - resolves this nest-host and k's
 460   bool has_nestmate_access_to(InstanceKlass* k, TRAPS);
 461 
 462   enum InnerClassAttributeOffset {
 463     // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814
 464     inner_class_inner_class_info_offset = 0,
 465     inner_class_outer_class_info_offset = 1,
 466     inner_class_inner_name_offset = 2,
 467     inner_class_access_flags_offset = 3,
 468     inner_class_next_offset = 4
 469   };
 470 


 650   }
 651   void set_unsafe_anonymous_host(const InstanceKlass* host) {
 652     assert(is_unsafe_anonymous(), "not unsafe anonymous");
 653     const InstanceKlass** addr = (const InstanceKlass **)adr_unsafe_anonymous_host();
 654     assert(addr != NULL, "no reversed space");
 655     if (addr != NULL) {
 656       *addr = host;
 657     }
 658   }
 659   bool is_unsafe_anonymous() const                {
 660     return (_misc_flags & _misc_is_unsafe_anonymous) != 0;
 661   }
 662   void set_is_unsafe_anonymous(bool value)        {
 663     if (value) {
 664       _misc_flags |= _misc_is_unsafe_anonymous;
 665     } else {
 666       _misc_flags &= ~_misc_is_unsafe_anonymous;
 667     }
 668   }
 669 
 670   bool is_nonfindable() const                {
 671     return (_misc_flags & _misc_is_nonfindable) != 0;
 672   }
 673   void set_is_nonfindable(bool value)        {
 674     if (value) {
 675       _misc_flags |= _misc_is_nonfindable;
 676     } else {
 677       _misc_flags &= ~_misc_is_nonfindable;
 678     }
 679   }
 680 
 681   bool is_contended() const                {
 682     return (_misc_flags & _misc_is_contended) != 0;
 683   }
 684   void set_is_contended(bool value)        {
 685     if (value) {
 686       _misc_flags |= _misc_is_contended;
 687     } else {
 688       _misc_flags &= ~_misc_is_contended;
 689     }
 690   }
 691 
 692   // source file name
 693   Symbol* source_file_name() const               {
 694     return (_source_file_name_index == 0) ?
 695       (Symbol*)NULL : _constants->symbol_at(_source_file_name_index);
 696   }
 697   u2 source_file_name_index() const              {
 698     return _source_file_name_index;
 699   }
 700   void set_source_file_name_index(u2 sourcefile_index) {


 752 
 753   bool has_been_redefined() const {
 754     return (_misc_flags & _misc_has_been_redefined) != 0;
 755   }
 756   void set_has_been_redefined() {
 757     _misc_flags |= _misc_has_been_redefined;
 758   }
 759 
 760   bool has_passed_fingerprint_check() const {
 761     return (_misc_flags & _misc_has_passed_fingerprint_check) != 0;
 762   }
 763   void set_has_passed_fingerprint_check(bool b) {
 764     if (b) {
 765       _misc_flags |= _misc_has_passed_fingerprint_check;
 766     } else {
 767       _misc_flags &= ~_misc_has_passed_fingerprint_check;
 768     }
 769   }
 770   bool supers_have_passed_fingerprint_checks();
 771 
 772   static bool should_store_fingerprint(bool is_nonfindable);
 773   bool should_store_fingerprint() const { return should_store_fingerprint(is_nonfindable() || is_unsafe_anonymous()); }
 774   bool has_stored_fingerprint() const;
 775   uint64_t get_stored_fingerprint() const;
 776   void store_fingerprint(uint64_t fingerprint);
 777 
 778   bool is_scratch_class() const {
 779     return (_misc_flags & _misc_is_scratch_class) != 0;
 780   }
 781 
 782   void set_is_scratch_class() {
 783     _misc_flags |= _misc_is_scratch_class;
 784   }
 785 
 786   bool has_resolved_methods() const {
 787     return (_misc_flags & _misc_has_resolved_methods) != 0;
 788   }
 789 
 790   void set_has_resolved_methods() {
 791     _misc_flags |= _misc_has_resolved_methods;
 792   }
 793 private:


1026 
1027   static InstanceKlass* cast(Klass* k) {
1028     return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));
1029   }
1030 
1031   static const InstanceKlass* cast(const Klass* k) {
1032     assert(k != NULL, "k should not be null");
1033     assert(k->is_instance_klass(), "cast to InstanceKlass");
1034     return static_cast<const InstanceKlass*>(k);
1035   }
1036 
1037   virtual InstanceKlass* java_super() const {
1038     return (super() == NULL) ? NULL : cast(super());
1039   }
1040 
1041   // Sizing (in words)
1042   static int header_size()            { return sizeof(InstanceKlass)/wordSize; }
1043 
1044   static int size(int vtable_length, int itable_length,
1045                   int nonstatic_oop_map_size,
1046                   bool is_interface, bool is_nonfindable, bool has_stored_fingerprint) {
1047     return align_metadata_size(header_size() +
1048            vtable_length +
1049            itable_length +
1050            nonstatic_oop_map_size +
1051            (is_interface ? (int)sizeof(Klass*)/wordSize : 0) +
1052            (is_nonfindable ? (int)sizeof(Klass*)/wordSize : 0) +
1053            (has_stored_fingerprint ? (int)sizeof(uint64_t*)/wordSize : 0));
1054   }
1055   int size() const                    { return size(vtable_length(),
1056                                                itable_length(),
1057                                                nonstatic_oop_map_size(),
1058                                                is_interface(),
1059                                                (is_nonfindable() || is_unsafe_anonymous()),
1060                                                has_stored_fingerprint());
1061   }
1062 #if INCLUDE_SERVICES
1063   virtual void collect_statistics(KlassSizeStats *sz) const;
1064 #endif
1065 
1066   intptr_t* start_of_itable()   const { return (intptr_t*)start_of_vtable() + vtable_length(); }
1067   intptr_t* end_of_itable()     const { return start_of_itable() + itable_length(); }
1068 
1069   int  itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
1070 
1071   oop static_field_base_raw() { return java_mirror(); }
1072 
1073   OopMapBlock* start_of_nonstatic_oop_maps() const {
1074     return (OopMapBlock*)(start_of_itable() + itable_length());
1075   }
1076 
1077   Klass** end_of_nonstatic_oop_maps() const {
1078     return (Klass**)(start_of_nonstatic_oop_maps() +
1079                      nonstatic_oop_map_count());


< prev index next >