comparison src/share/vm/oops/instanceKlass.hpp @ 6152:958bb4b7be49

Merge
author asaha
date Tue, 10 Apr 2012 10:42:34 -0700
parents f7c4174b33ba
children 49036505ab5f c7ed11779ce8
comparison
equal deleted inserted replaced
6151:e778c29768e6 6152:958bb4b7be49
186 // This is only non-null for an anonymous class (JSR 292 enabled). 186 // This is only non-null for an anonymous class (JSR 292 enabled).
187 // The host class is either named, or a previously loaded anonymous class. 187 // The host class is either named, or a previously loaded anonymous class.
188 klassOop _host_klass; 188 klassOop _host_klass;
189 // Class signers. 189 // Class signers.
190 objArrayOop _signers; 190 objArrayOop _signers;
191 // inner_classes attribute. 191 // The InnerClasses attribute and EnclosingMethod attribute. The
192 // _inner_classes is an array of shorts. If the class has InnerClasses
193 // attribute, then the _inner_classes array begins with 4-tuples of shorts
194 // [inner_class_info_index, outer_class_info_index,
195 // inner_name_index, inner_class_access_flags] for the InnerClasses
196 // attribute. If the EnclosingMethod attribute exists, it occupies the
197 // last two shorts [class_index, method_index] of the array. If only
198 // the InnerClasses attribute exists, the _inner_classes array length is
199 // number_of_inner_classes * 4. If the class has both InnerClasses
200 // and EnclosingMethod attributes the _inner_classes array length is
201 // number_of_inner_classes * 4 + enclosing_method_attribute_size.
192 typeArrayOop _inner_classes; 202 typeArrayOop _inner_classes;
193 // Implementors of this interface (not valid if it overflows) 203 // Implementors of this interface (not valid if it overflows)
194 klassOop _implementors[implementors_limit]; 204 klassOop _implementors[implementors_limit];
195 // Annotations for this class, or null if none. 205 // Annotations for this class, or null if none.
196 typeArrayOop _class_annotations; 206 typeArrayOop _class_annotations;
238 u2 _minor_version; // minor version number of class file 248 u2 _minor_version; // minor version number of class file
239 u2 _major_version; // major version number of class file 249 u2 _major_version; // major version number of class file
240 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization) 250 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization)
241 int _vtable_len; // length of Java vtable (in words) 251 int _vtable_len; // length of Java vtable (in words)
242 int _itable_len; // length of Java itable (in words) 252 int _itable_len; // length of Java itable (in words)
243 ReferenceType _reference_type; // reference type
244 OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily) 253 OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)
245 JNIid* _jni_ids; // First JNI identifier for static fields in this class 254 JNIid* _jni_ids; // First JNI identifier for static fields in this class
246 jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none 255 jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none
247 int* _methods_cached_itable_indices; // itable_index cache for JNI invoke corresponding to methods idnum, or NULL 256 int* _methods_cached_itable_indices; // itable_index cache for JNI invoke corresponding to methods idnum, or NULL
248 nmethodBucket* _dependencies; // list of dependent nmethods 257 nmethodBucket* _dependencies; // list of dependent nmethods
250 BreakpointInfo* _breakpoints; // bpt lists, managed by methodOop 259 BreakpointInfo* _breakpoints; // bpt lists, managed by methodOop
251 int _nof_implementors; // No of implementors of this interface (zero if not an interface) 260 int _nof_implementors; // No of implementors of this interface (zero if not an interface)
252 // Array of interesting part(s) of the previous version(s) of this 261 // Array of interesting part(s) of the previous version(s) of this
253 // instanceKlass. See PreviousVersionWalker below. 262 // instanceKlass. See PreviousVersionWalker below.
254 GrowableArray<PreviousVersionNode *>* _previous_versions; 263 GrowableArray<PreviousVersionNode *>* _previous_versions;
255 u2 _enclosing_method_class_index; // Constant pool index for class of enclosing method, or 0 if none
256 u2 _enclosing_method_method_index; // Constant pool index for name and type of enclosing method, or 0 if none
257 // JVMTI fields can be moved to their own structure - see 6315920 264 // JVMTI fields can be moved to their own structure - see 6315920
258 unsigned char * _cached_class_file_bytes; // JVMTI: cached class file, before retransformable agent modified it in CFLH 265 unsigned char * _cached_class_file_bytes; // JVMTI: cached class file, before retransformable agent modified it in CFLH
259 jint _cached_class_file_len; // JVMTI: length of above 266 jint _cached_class_file_len; // JVMTI: length of above
260 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration 267 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration
261 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change 268 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
262 269
263 // Class states are defined as ClassState (see above). 270 // Class states are defined as ClassState (see above).
264 // Place the _init_state here to utilize the unused 2-byte after 271 // Place the _init_state here to utilize the unused 2-byte after
265 // _idnum_allocated_count. 272 // _idnum_allocated_count.
266 u1 _init_state; // state of class 273 u1 _init_state; // state of class
274
275 u1 _reference_type; // reference type
267 276
268 // embedded Java vtable follows here 277 // embedded Java vtable follows here
269 // embedded Java itables follows here 278 // embedded Java itables follows here
270 // embedded static fields follows here 279 // embedded static fields follows here
271 // embedded nonstatic oop-map blocks follows here 280 // embedded nonstatic oop-map blocks follows here
346 inner_class_inner_class_info_offset = 0, 355 inner_class_inner_class_info_offset = 0,
347 inner_class_outer_class_info_offset = 1, 356 inner_class_outer_class_info_offset = 1,
348 inner_class_inner_name_offset = 2, 357 inner_class_inner_name_offset = 2,
349 inner_class_access_flags_offset = 3, 358 inner_class_access_flags_offset = 3,
350 inner_class_next_offset = 4 359 inner_class_next_offset = 4
360 };
361
362 enum EnclosingMethodAttributeOffset {
363 enclosing_method_class_index_offset = 0,
364 enclosing_method_method_index_offset = 1,
365 enclosing_method_attribute_size = 2
351 }; 366 };
352 367
353 // method override check 368 // method override check
354 bool is_override(methodHandle super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS); 369 bool is_override(methodHandle super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);
355 370
405 420
406 // set the class to initialized if no static initializer is present 421 // set the class to initialized if no static initializer is present
407 void eager_initialize(Thread *thread); 422 void eager_initialize(Thread *thread);
408 423
409 // reference type 424 // reference type
410 ReferenceType reference_type() const { return _reference_type; } 425 ReferenceType reference_type() const { return (ReferenceType)_reference_type; }
411 void set_reference_type(ReferenceType t) { _reference_type = t; } 426 void set_reference_type(ReferenceType t) {
427 assert(t == (u1)t, "overflow");
428 _reference_type = (u1)t;
429 }
412 430
413 static ByteSize reference_type_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(instanceKlass, _reference_type)); } 431 static ByteSize reference_type_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(instanceKlass, _reference_type)); }
414 432
415 // find local field, returns true if found 433 // find local field, returns true if found
416 bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const; 434 bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
527 545
528 // generics support 546 // generics support
529 Symbol* generic_signature() const { return _generic_signature; } 547 Symbol* generic_signature() const { return _generic_signature; }
530 void set_generic_signature(Symbol* sig) { _generic_signature = sig; } 548 void set_generic_signature(Symbol* sig) { _generic_signature = sig; }
531 549
532 u2 enclosing_method_class_index() const { return _enclosing_method_class_index; } 550 u2 enclosing_method_data(int offset);
533 u2 enclosing_method_method_index() const { return _enclosing_method_method_index; } 551 u2 enclosing_method_class_index() {
552 return enclosing_method_data(enclosing_method_class_index_offset);
553 }
554 u2 enclosing_method_method_index() {
555 return enclosing_method_data(enclosing_method_method_index_offset);
556 }
534 void set_enclosing_method_indices(u2 class_index, 557 void set_enclosing_method_indices(u2 class_index,
535 u2 method_index) { _enclosing_method_class_index = class_index; 558 u2 method_index);
536 _enclosing_method_method_index = method_index; }
537 559
538 // jmethodID support 560 // jmethodID support
539 static jmethodID get_jmethod_id(instanceKlassHandle ik_h, 561 static jmethodID get_jmethod_id(instanceKlassHandle ik_h,
540 methodHandle method_h); 562 methodHandle method_h);
541 static jmethodID get_jmethod_id_fetch_or_update(instanceKlassHandle ik_h, 563 static jmethodID get_jmethod_id_fetch_or_update(instanceKlassHandle ik_h,
568 typeArrayOop get_method_default_annotations_of(int idnum) 590 typeArrayOop get_method_default_annotations_of(int idnum)
569 { return get_method_annotations_from(idnum, _methods_default_annotations); } 591 { return get_method_annotations_from(idnum, _methods_default_annotations); }
570 void set_method_annotations_of(int idnum, typeArrayOop anno) 592 void set_method_annotations_of(int idnum, typeArrayOop anno)
571 { set_methods_annotations_of(idnum, anno, &_methods_annotations); } 593 { set_methods_annotations_of(idnum, anno, &_methods_annotations); }
572 void set_method_parameter_annotations_of(int idnum, typeArrayOop anno) 594 void set_method_parameter_annotations_of(int idnum, typeArrayOop anno)
573 { set_methods_annotations_of(idnum, anno, &_methods_annotations); } 595 { set_methods_annotations_of(idnum, anno, &_methods_parameter_annotations); }
574 void set_method_default_annotations_of(int idnum, typeArrayOop anno) 596 void set_method_default_annotations_of(int idnum, typeArrayOop anno)
575 { set_methods_annotations_of(idnum, anno, &_methods_annotations); } 597 { set_methods_annotations_of(idnum, anno, &_methods_default_annotations); }
576 598
577 // allocation 599 // allocation
578 DEFINE_ALLOCATE_PERMANENT(instanceKlass); 600 DEFINE_ALLOCATE_PERMANENT(instanceKlass);
579 instanceOop allocate_instance(TRAPS); 601 instanceOop allocate_instance(TRAPS);
580 instanceOop allocate_permanent_instance(TRAPS); 602 instanceOop allocate_permanent_instance(TRAPS);
1047 nmethodBucket* next() { return _next; } 1069 nmethodBucket* next() { return _next; }
1048 void set_next(nmethodBucket* b) { _next = b; } 1070 void set_next(nmethodBucket* b) { _next = b; }
1049 nmethod* get_nmethod() { return _nmethod; } 1071 nmethod* get_nmethod() { return _nmethod; }
1050 }; 1072 };
1051 1073
1074 // An iterator that's used to access the inner classes indices in the
1075 // instanceKlass::_inner_classes array.
1076 class InnerClassesIterator : public StackObj {
1077 private:
1078 typeArrayHandle _inner_classes;
1079 int _length;
1080 int _idx;
1081 public:
1082
1083 InnerClassesIterator(instanceKlassHandle k) {
1084 _inner_classes = k->inner_classes();
1085 if (k->inner_classes() != NULL) {
1086 _length = _inner_classes->length();
1087 // The inner class array's length should be the multiple of
1088 // inner_class_next_offset if it only contains the InnerClasses
1089 // attribute data, or it should be
1090 // n*inner_class_next_offset+enclosing_method_attribute_size
1091 // if it also contains the EnclosingMethod data.
1092 assert((_length % instanceKlass::inner_class_next_offset == 0 ||
1093 _length % instanceKlass::inner_class_next_offset == instanceKlass::enclosing_method_attribute_size),
1094 "just checking");
1095 // Remove the enclosing_method portion if exists.
1096 if (_length % instanceKlass::inner_class_next_offset == instanceKlass::enclosing_method_attribute_size) {
1097 _length -= instanceKlass::enclosing_method_attribute_size;
1098 }
1099 } else {
1100 _length = 0;
1101 }
1102 _idx = 0;
1103 }
1104
1105 int length() const {
1106 return _length;
1107 }
1108
1109 void next() {
1110 _idx += instanceKlass::inner_class_next_offset;
1111 }
1112
1113 bool done() const {
1114 return (_idx >= _length);
1115 }
1116
1117 u2 inner_class_info_index() const {
1118 return _inner_classes->ushort_at(
1119 _idx + instanceKlass::inner_class_inner_class_info_offset);
1120 }
1121
1122 void set_inner_class_info_index(u2 index) {
1123 _inner_classes->ushort_at_put(
1124 _idx + instanceKlass::inner_class_inner_class_info_offset, index);
1125 }
1126
1127 u2 outer_class_info_index() const {
1128 return _inner_classes->ushort_at(
1129 _idx + instanceKlass::inner_class_outer_class_info_offset);
1130 }
1131
1132 void set_outer_class_info_index(u2 index) {
1133 _inner_classes->ushort_at_put(
1134 _idx + instanceKlass::inner_class_outer_class_info_offset, index);
1135 }
1136
1137 u2 inner_name_index() const {
1138 return _inner_classes->ushort_at(
1139 _idx + instanceKlass::inner_class_inner_name_offset);
1140 }
1141
1142 void set_inner_name_index(u2 index) {
1143 _inner_classes->ushort_at_put(
1144 _idx + instanceKlass::inner_class_inner_name_offset, index);
1145 }
1146
1147 u2 inner_access_flags() const {
1148 return _inner_classes->ushort_at(
1149 _idx + instanceKlass::inner_class_access_flags_offset);
1150 }
1151 };
1152
1052 #endif // SHARE_VM_OOPS_INSTANCEKLASS_HPP 1153 #endif // SHARE_VM_OOPS_INSTANCEKLASS_HPP