Mercurial > hg > truffle
comparison src/share/vm/oops/instanceKlass.hpp @ 8124:5fc51c1ecdeb
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 05 Mar 2013 23:44:54 +0100 |
parents | 3ac7d10a6572 927a311d00f9 |
children | b8f261ba79c6 |
comparison
equal
deleted
inserted
replaced
7943:a413bcd552a4 | 8124:5fc51c1ecdeb |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
34 #include "runtime/atomic.hpp" | 34 #include "runtime/atomic.hpp" |
35 #include "runtime/handles.hpp" | 35 #include "runtime/handles.hpp" |
36 #include "runtime/os.hpp" | 36 #include "runtime/os.hpp" |
37 #include "utilities/accessFlags.hpp" | 37 #include "utilities/accessFlags.hpp" |
38 #include "utilities/bitMap.inline.hpp" | 38 #include "utilities/bitMap.inline.hpp" |
39 #include "utilities/macros.hpp" | |
39 | 40 |
40 // An InstanceKlass is the VM level representation of a Java class. | 41 // An InstanceKlass is the VM level representation of a Java class. |
41 // It contains all information needed for at class at execution runtime. | 42 // It contains all information needed for at class at execution runtime. |
42 | 43 |
43 // InstanceKlass layout: | 44 // InstanceKlass layout: |
152 int static_field_size, | 153 int static_field_size, |
153 int nonstatic_oop_map_size, | 154 int nonstatic_oop_map_size, |
154 ReferenceType rt, | 155 ReferenceType rt, |
155 AccessFlags access_flags, | 156 AccessFlags access_flags, |
156 Symbol* name, | 157 Symbol* name, |
157 Klass* super_klass, | 158 Klass* super_klass, |
158 KlassHandle host_klass, | 159 bool is_anonymous, |
159 TRAPS); | 160 TRAPS); |
160 | 161 |
161 InstanceKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } | 162 InstanceKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } |
162 | 163 |
163 // See "The Java Virtual Machine Specification" section 2.16.2-5 for a detailed description | 164 // See "The Java Virtual Machine Specification" section 2.16.2-5 for a detailed description |
254 // InstanceKlass. See PreviousVersionWalker below. | 255 // InstanceKlass. See PreviousVersionWalker below. |
255 GrowableArray<PreviousVersionNode *>* _previous_versions; | 256 GrowableArray<PreviousVersionNode *>* _previous_versions; |
256 // JVMTI fields can be moved to their own structure - see 6315920 | 257 // JVMTI fields can be moved to their own structure - see 6315920 |
257 unsigned char * _cached_class_file_bytes; // JVMTI: cached class file, before retransformable agent modified it in CFLH | 258 unsigned char * _cached_class_file_bytes; // JVMTI: cached class file, before retransformable agent modified it in CFLH |
258 jint _cached_class_file_len; // JVMTI: length of above | 259 jint _cached_class_file_len; // JVMTI: length of above |
260 | |
261 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change | |
262 | |
263 // Class states are defined as ClassState (see above). | |
264 // Place the _init_state here to utilize the unused 2-byte after | |
265 // _idnum_allocated_count. | |
266 u1 _init_state; // state of class | |
267 u1 _reference_type; // reference type | |
268 | |
269 | |
259 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration | 270 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration |
260 | 271 |
261 // Method array. | 272 // Method array. |
262 Array<Method*>* _methods; | 273 Array<Method*>* _methods; |
263 // Interface (Klass*s) this class declares locally to implement. | 274 // Interface (Klass*s) this class declares locally to implement. |
279 // [generic signature index] | 290 // [generic signature index] |
280 // [generic signature index] | 291 // [generic signature index] |
281 // ... | 292 // ... |
282 Array<u2>* _fields; | 293 Array<u2>* _fields; |
283 | 294 |
284 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change | |
285 | |
286 // Class states are defined as ClassState (see above). | |
287 // Place the _init_state here to utilize the unused 2-byte after | |
288 // _idnum_allocated_count. | |
289 u1 _init_state; // state of class | |
290 | |
291 u1 _reference_type; // reference type | |
292 | |
293 // embedded Java vtable follows here | 295 // embedded Java vtable follows here |
294 // embedded Java itables follows here | 296 // embedded Java itables follows here |
295 // embedded static fields follows here | 297 // embedded static fields follows here |
296 // embedded nonstatic oop-map blocks follows here | 298 // embedded nonstatic oop-map blocks follows here |
297 // embedded implementor of this interface follows here | 299 // embedded implementor of this interface follows here |
675 int cached_itable_index(size_t idnum); | 677 int cached_itable_index(size_t idnum); |
676 | 678 |
677 // annotations support | 679 // annotations support |
678 Annotations* annotations() const { return _annotations; } | 680 Annotations* annotations() const { return _annotations; } |
679 void set_annotations(Annotations* anno) { _annotations = anno; } | 681 void set_annotations(Annotations* anno) { _annotations = anno; } |
682 | |
680 AnnotationArray* class_annotations() const { | 683 AnnotationArray* class_annotations() const { |
681 if (annotations() == NULL) return NULL; | 684 return (_annotations != NULL) ? _annotations->class_annotations() : NULL; |
682 return annotations()->class_annotations(); | |
683 } | 685 } |
684 Array<AnnotationArray*>* fields_annotations() const { | 686 Array<AnnotationArray*>* fields_annotations() const { |
685 if (annotations() == NULL) return NULL; | 687 return (_annotations != NULL) ? _annotations->fields_annotations() : NULL; |
686 return annotations()->fields_annotations(); | 688 } |
687 } | 689 AnnotationArray* class_type_annotations() const { |
688 Annotations* type_annotations() const { | 690 return (_annotations != NULL) ? _annotations->class_type_annotations() : NULL; |
689 if (annotations() == NULL) return NULL; | 691 } |
690 return annotations()->type_annotations(); | 692 Array<AnnotationArray*>* fields_type_annotations() const { |
691 } | 693 return (_annotations != NULL) ? _annotations->fields_type_annotations() : NULL; |
692 | 694 } |
693 // allocation | 695 // allocation |
694 instanceOop allocate_instance(TRAPS); | 696 instanceOop allocate_instance(TRAPS); |
695 | 697 |
696 // additional member function to return a handle | 698 // additional member function to return a handle |
697 instanceHandle allocate_instance_handle(TRAPS) { return instanceHandle(THREAD, allocate_instance(THREAD)); } | 699 instanceHandle allocate_instance_handle(TRAPS) { return instanceHandle(THREAD, allocate_instance(THREAD)); } |
806 return (super() == NULL) ? NULL : cast(super()); | 808 return (super() == NULL) ? NULL : cast(super()); |
807 } | 809 } |
808 | 810 |
809 // Sizing (in words) | 811 // Sizing (in words) |
810 static int header_size() { return align_object_offset(sizeof(InstanceKlass)/HeapWordSize); } | 812 static int header_size() { return align_object_offset(sizeof(InstanceKlass)/HeapWordSize); } |
813 | |
811 static int size(int vtable_length, int itable_length, | 814 static int size(int vtable_length, int itable_length, |
812 int nonstatic_oop_map_size, | 815 int nonstatic_oop_map_size, |
813 bool is_interface, bool is_anonymous) { | 816 bool is_interface, bool is_anonymous) { |
814 return align_object_size(header_size() + | 817 return align_object_size(header_size() + |
815 align_object_offset(vtable_length) + | 818 align_object_offset(vtable_length) + |
824 itable_length(), | 827 itable_length(), |
825 nonstatic_oop_map_size(), | 828 nonstatic_oop_map_size(), |
826 is_interface(), | 829 is_interface(), |
827 is_anonymous()); | 830 is_anonymous()); |
828 } | 831 } |
832 #if INCLUDE_SERVICES | |
833 virtual void collect_statistics(KlassSizeStats *sz) const; | |
834 #endif | |
829 | 835 |
830 static int vtable_start_offset() { return header_size(); } | 836 static int vtable_start_offset() { return header_size(); } |
831 static int vtable_length_offset() { return offset_of(InstanceKlass, _vtable_len) / HeapWordSize; } | 837 static int vtable_length_offset() { return offset_of(InstanceKlass, _vtable_len) / HeapWordSize; } |
832 | 838 |
833 intptr_t* start_of_vtable() const { return ((intptr_t*)this) + vtable_start_offset(); } | 839 intptr_t* start_of_vtable() const { return ((intptr_t*)this) + vtable_start_offset(); } |
840 | 846 |
841 OopMapBlock* start_of_nonstatic_oop_maps() const { | 847 OopMapBlock* start_of_nonstatic_oop_maps() const { |
842 return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length())); | 848 return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length())); |
843 } | 849 } |
844 | 850 |
851 Klass** end_of_nonstatic_oop_maps() const { | |
852 return (Klass**)(start_of_nonstatic_oop_maps() + | |
853 nonstatic_oop_map_count()); | |
854 } | |
855 | |
845 Klass** adr_implementor() const { | 856 Klass** adr_implementor() const { |
846 if (is_interface()) { | 857 if (is_interface()) { |
847 return (Klass**)(start_of_nonstatic_oop_maps() + | 858 return (Klass**)end_of_nonstatic_oop_maps(); |
848 nonstatic_oop_map_count()); | |
849 } else { | 859 } else { |
850 return NULL; | 860 return NULL; |
851 } | 861 } |
852 }; | 862 }; |
853 | 863 |
855 if (is_anonymous()) { | 865 if (is_anonymous()) { |
856 Klass** adr_impl = adr_implementor(); | 866 Klass** adr_impl = adr_implementor(); |
857 if (adr_impl != NULL) { | 867 if (adr_impl != NULL) { |
858 return adr_impl + 1; | 868 return adr_impl + 1; |
859 } else { | 869 } else { |
860 return (Klass**)(start_of_nonstatic_oop_maps() + | 870 return end_of_nonstatic_oop_maps(); |
861 nonstatic_oop_map_count()); | |
862 } | 871 } |
863 } else { | 872 } else { |
864 return NULL; | 873 return NULL; |
865 } | 874 } |
866 } | 875 } |
930 MemRegion mr); | 939 MemRegion mr); |
931 | 940 |
932 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceKlass_OOP_OOP_ITERATE_DECL) | 941 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceKlass_OOP_OOP_ITERATE_DECL) |
933 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_DECL) | 942 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_DECL) |
934 | 943 |
935 #ifndef SERIALGC | 944 #if INCLUDE_ALL_GCS |
936 #define InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \ | 945 #define InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \ |
937 int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk); | 946 int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk); |
938 | 947 |
939 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DECL) | 948 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DECL) |
940 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DECL) | 949 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DECL) |
941 #endif // !SERIALGC | 950 #endif // INCLUDE_ALL_GCS |
942 | 951 |
943 u2 idnum_allocated_count() const { return _idnum_allocated_count; } | 952 u2 idnum_allocated_count() const { return _idnum_allocated_count; } |
944 private: | 953 private: |
945 // initialization state | 954 // initialization state |
946 #ifdef ASSERT | 955 #ifdef ASSERT |