914 void do_nonstatic_fields(FieldClosure* cl); // including inherited fields 915 void do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle, TRAPS); 916 917 void methods_do(void f(Method* method)); 918 void array_klasses_do(void f(Klass* k)); 919 void array_klasses_do(void f(Klass* k, TRAPS), TRAPS); 920 bool super_types_do(SuperTypeClosure* blk); 921 922 // Casting from Klass* 923 static InstanceKlass* cast(Klass* k) { 924 assert(k != NULL, "k should not be null"); 925 assert(k->is_instance_klass(), "cast to InstanceKlass"); 926 return static_cast<InstanceKlass*>(k); 927 } 928 929 InstanceKlass* java_super() const { 930 return (super() == NULL) ? NULL : cast(super()); 931 } 932 933 // Sizing (in words) 934 static int header_size() { return align_object_offset(sizeof(InstanceKlass)/HeapWordSize); } 935 936 static int size(int vtable_length, int itable_length, 937 int nonstatic_oop_map_size, 938 bool is_interface, bool is_anonymous) { 939 return align_object_size(header_size() + 940 align_object_offset(vtable_length) + 941 align_object_offset(itable_length) + 942 ((is_interface || is_anonymous) ? 943 align_object_offset(nonstatic_oop_map_size) : 944 nonstatic_oop_map_size) + 945 (is_interface ? (int)sizeof(Klass*)/HeapWordSize : 0) + 946 (is_anonymous ? (int)sizeof(Klass*)/HeapWordSize : 0)); 947 } 948 int size() const { return size(vtable_length(), 949 itable_length(), 950 nonstatic_oop_map_size(), 951 is_interface(), 952 is_anonymous()); 953 } 954 #if INCLUDE_SERVICES 955 virtual void collect_statistics(KlassSizeStats *sz) const; 956 #endif 957 958 static int vtable_start_offset() { return header_size(); } 959 static int vtable_length_offset() { return offset_of(InstanceKlass, _vtable_len) / HeapWordSize; } 960 961 intptr_t* start_of_vtable() const { return ((intptr_t*)this) + vtable_start_offset(); } 962 intptr_t* start_of_itable() const { return start_of_vtable() + align_object_offset(vtable_length()); } 963 int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; } 964 965 intptr_t* end_of_itable() const { return start_of_itable() + itable_length(); } 966 967 address static_field_addr(int offset); 968 969 OopMapBlock* start_of_nonstatic_oop_maps() const { 970 return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length())); 971 } 972 973 Klass** end_of_nonstatic_oop_maps() const { 974 return (Klass**)(start_of_nonstatic_oop_maps() + 975 nonstatic_oop_map_count()); 976 } 977 978 Klass** adr_implementor() const { 979 if (is_interface()) { 980 return (Klass**)end_of_nonstatic_oop_maps(); 981 } else { 982 return NULL; 983 } 984 }; 985 986 Klass** adr_host_klass() const { 987 if (is_anonymous()) { 988 Klass** adr_impl = adr_implementor(); 989 if (adr_impl != NULL) { 990 return adr_impl + 1; | 914 void do_nonstatic_fields(FieldClosure* cl); // including inherited fields 915 void do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle, TRAPS); 916 917 void methods_do(void f(Method* method)); 918 void array_klasses_do(void f(Klass* k)); 919 void array_klasses_do(void f(Klass* k, TRAPS), TRAPS); 920 bool super_types_do(SuperTypeClosure* blk); 921 922 // Casting from Klass* 923 static InstanceKlass* cast(Klass* k) { 924 assert(k != NULL, "k should not be null"); 925 assert(k->is_instance_klass(), "cast to InstanceKlass"); 926 return static_cast<InstanceKlass*>(k); 927 } 928 929 InstanceKlass* java_super() const { 930 return (super() == NULL) ? NULL : cast(super()); 931 } 932 933 // Sizing (in words) 934 static int header_size() { return sizeof(InstanceKlass)/HeapWordSize; } 935 936 static int size(int vtable_length, int itable_length, 937 int nonstatic_oop_map_size, 938 bool is_interface, bool is_anonymous) { 939 return align_object_size(header_size() + 940 vtable_length + 941 itable_length + 942 nonstatic_oop_map_size + 943 (is_interface ? (int)sizeof(Klass*)/HeapWordSize : 0) + 944 (is_anonymous ? (int)sizeof(Klass*)/HeapWordSize : 0)); 945 } 946 int size() const { return size(vtable_length(), 947 itable_length(), 948 nonstatic_oop_map_size(), 949 is_interface(), 950 is_anonymous()); 951 } 952 #if INCLUDE_SERVICES 953 virtual void collect_statistics(KlassSizeStats *sz) const; 954 #endif 955 956 static int vtable_start_offset() { return header_size(); } 957 static int vtable_length_offset() { return offset_of(InstanceKlass, _vtable_len) / HeapWordSize; } 958 959 intptr_t* start_of_vtable() const { return ((intptr_t*)this) + vtable_start_offset(); } 960 intptr_t* start_of_itable() const { return start_of_vtable() + vtable_length(); } 961 int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; } 962 963 intptr_t* end_of_itable() const { return start_of_itable() + itable_length(); } 964 965 address static_field_addr(int offset); 966 967 OopMapBlock* start_of_nonstatic_oop_maps() const { 968 return (OopMapBlock*)(start_of_itable() + itable_length()); 969 } 970 971 Klass** end_of_nonstatic_oop_maps() const { 972 return (Klass**)(start_of_nonstatic_oop_maps() + 973 nonstatic_oop_map_count()); 974 } 975 976 Klass** adr_implementor() const { 977 if (is_interface()) { 978 return (Klass**)end_of_nonstatic_oop_maps(); 979 } else { 980 return NULL; 981 } 982 }; 983 984 Klass** adr_host_klass() const { 985 if (is_anonymous()) { 986 Klass** adr_impl = adr_implementor(); 987 if (adr_impl != NULL) { 988 return adr_impl + 1; |