comparison src/share/vm/oops/instanceKlass.hpp @ 6275:957c266d8bc5

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Tue, 21 Aug 2012 10:39:19 +0200
parents 33df1aeaebbf 04ade88d9712
children dddcdb7ae209
comparison
equal deleted inserted replaced
5891:fd8832ae511d 6275:957c266d8bc5
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, 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.
54 // [next sibling ] Klass 54 // [next sibling ] Klass
55 // [array klasses ] 55 // [array klasses ]
56 // [methods ] 56 // [methods ]
57 // [local interfaces ] 57 // [local interfaces ]
58 // [transitive interfaces ] 58 // [transitive interfaces ]
59 // [number of implementors ]
60 // [implementors ] klassOop[2]
61 // [fields ] 59 // [fields ]
62 // [constants ] 60 // [constants ]
63 // [class loader ] 61 // [class loader ]
64 // [protection domain ] 62 // [protection domain ]
65 // [signers ] 63 // [signers ]
75 // [initializing thread ] 73 // [initializing thread ]
76 // [Java vtable length ] 74 // [Java vtable length ]
77 // [oop map cache (stack maps) ] 75 // [oop map cache (stack maps) ]
78 // [EMBEDDED Java vtable ] size in words = vtable_len 76 // [EMBEDDED Java vtable ] size in words = vtable_len
79 // [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size 77 // [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
80 // 78 // The embedded nonstatic oop-map blocks are short pairs (offset, length)
81 // The embedded nonstatic oop-map blocks are short pairs (offset, length) indicating 79 // indicating where oops are located in instances of this klass.
82 // where oops are located in instances of this klass. 80 // [EMBEDDED implementor of the interface] only exist for interface
81 // [EMBEDDED host klass ] only exist for an anonymous class (JSR 292 enabled)
83 82
84 83
85 // forward declaration for class -- see below for definition 84 // forward declaration for class -- see below for definition
86 class SuperTypeClosure; 85 class SuperTypeClosure;
87 class JNIid; 86 class JNIid;
151 150
152 public: 151 public:
153 oop* oop_block_beg() const { return adr_array_klasses(); } 152 oop* oop_block_beg() const { return adr_array_klasses(); }
154 oop* oop_block_end() const { return adr_methods_default_annotations() + 1; } 153 oop* oop_block_end() const { return adr_methods_default_annotations() + 1; }
155 154
156 enum {
157 implementors_limit = 2 // how many implems can we track?
158 };
159
160 protected: 155 protected:
161 // 156 //
162 // The oop block. See comment in klass.hpp before making changes. 157 // The oop block. See comment in klass.hpp before making changes.
163 // 158 //
164 159
171 typeArrayOop _method_ordering; 166 typeArrayOop _method_ordering;
172 // Interface (klassOops) this class declares locally to implement. 167 // Interface (klassOops) this class declares locally to implement.
173 objArrayOop _local_interfaces; 168 objArrayOop _local_interfaces;
174 // Interface (klassOops) this class implements transitively. 169 // Interface (klassOops) this class implements transitively.
175 objArrayOop _transitive_interfaces; 170 objArrayOop _transitive_interfaces;
176 // Instance and static variable information, 5-tuples of shorts [access, name 171 // Instance and static variable information, starts with 6-tuples of shorts
177 // index, sig index, initval index, offset]. 172 // [access, name index, sig index, initval index, low_offset, high_offset]
173 // for all fields, followed by the generic signature data at the end of
174 // the array. Only fields with generic signature attributes have the generic
175 // signature data set in the array. The fields array looks like following:
176 //
177 // f1: [access, name index, sig index, initial value index, low_offset, high_offset]
178 // f2: [access, name index, sig index, initial value index, low_offset, high_offset]
179 // ...
180 // fn: [access, name index, sig index, initial value index, low_offset, high_offset]
181 // [generic signature index]
182 // [generic signature index]
183 // ...
178 typeArrayOop _fields; 184 typeArrayOop _fields;
179 // Constant pool for this class. 185 // Constant pool for this class.
180 constantPoolOop _constants; 186 constantPoolOop _constants;
181 // Class loader used to load this class, NULL if VM loader used. 187 // Class loader used to load this class, NULL if VM loader used.
182 oop _class_loader; 188 oop _class_loader;
183 // Protection domain. 189 // Protection domain.
184 oop _protection_domain; 190 oop _protection_domain;
185 // Host class, which grants its access privileges to this class also.
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.
188 klassOop _host_klass;
189 // Class signers. 191 // Class signers.
190 objArrayOop _signers; 192 objArrayOop _signers;
191 // inner_classes attribute. 193 // The InnerClasses attribute and EnclosingMethod attribute. The
194 // _inner_classes is an array of shorts. If the class has InnerClasses
195 // attribute, then the _inner_classes array begins with 4-tuples of shorts
196 // [inner_class_info_index, outer_class_info_index,
197 // inner_name_index, inner_class_access_flags] for the InnerClasses
198 // attribute. If the EnclosingMethod attribute exists, it occupies the
199 // last two shorts [class_index, method_index] of the array. If only
200 // the InnerClasses attribute exists, the _inner_classes array length is
201 // number_of_inner_classes * 4. If the class has both InnerClasses
202 // and EnclosingMethod attributes the _inner_classes array length is
203 // number_of_inner_classes * 4 + enclosing_method_attribute_size.
192 typeArrayOop _inner_classes; 204 typeArrayOop _inner_classes;
193 // Implementors of this interface (not valid if it overflows)
194 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;
197 // Annotation objects (byte arrays) for fields, or null if no annotations. 207 // Annotation objects (byte arrays) for fields, or null if no annotations.
198 // Indices correspond to entries (not indices) in fields array. 208 // Indices correspond to entries (not indices) in fields array.
199 objArrayOop _fields_annotations; 209 objArrayOop _fields_annotations;
214 // 224 //
215 225
216 // Name of source file containing this klass, NULL if not specified. 226 // Name of source file containing this klass, NULL if not specified.
217 Symbol* _source_file_name; 227 Symbol* _source_file_name;
218 // the source debug extension for this klass, NULL if not specified. 228 // the source debug extension for this klass, NULL if not specified.
219 Symbol* _source_debug_extension; 229 // Specified as UTF-8 string without terminating zero byte in the classfile,
230 // it is stored in the instanceklass as a NULL-terminated UTF-8 string
231 char* _source_debug_extension;
220 // Generic signature, or null if none. 232 // Generic signature, or null if none.
221 Symbol* _generic_signature; 233 Symbol* _generic_signature;
222 // Array name derived from this class which needs unreferencing 234 // Array name derived from this class which needs unreferencing
223 // if this class is unloaded. 235 // if this class is unloaded.
224 Symbol* _array_name; 236 Symbol* _array_name;
230 u2 _static_oop_field_count;// number of static oop fields in this klass 242 u2 _static_oop_field_count;// number of static oop fields in this klass
231 u2 _java_fields_count; // The number of declared Java fields 243 u2 _java_fields_count; // The number of declared Java fields
232 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks 244 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
233 245
234 bool _is_marked_dependent; // used for marking during flushing and deoptimization 246 bool _is_marked_dependent; // used for marking during flushing and deoptimization
235 bool _rewritten; // methods rewritten. 247 enum {
236 bool _has_nonstatic_fields; // for sizing with UseCompressedOops 248 _misc_rewritten = 1 << 0, // methods rewritten.
237 bool _should_verify_class; // allow caching of preverification 249 _misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops
250 _misc_should_verify_class = 1 << 2, // allow caching of preverification
251 _misc_is_anonymous = 1 << 3 // has embedded _inner_classes field
252 };
253 u2 _misc_flags;
238 u2 _minor_version; // minor version number of class file 254 u2 _minor_version; // minor version number of class file
239 u2 _major_version; // major version number of class file 255 u2 _major_version; // major version number of class file
240 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization) 256 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization)
241 int _vtable_len; // length of Java vtable (in words) 257 int _vtable_len; // length of Java vtable (in words)
242 int _itable_len; // length of Java itable (in words) 258 int _itable_len; // length of Java itable (in words)
245 jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none 261 jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none
246 int* _methods_cached_itable_indices; // itable_index cache for JNI invoke corresponding to methods idnum, or NULL 262 int* _methods_cached_itable_indices; // itable_index cache for JNI invoke corresponding to methods idnum, or NULL
247 nmethodBucket* _dependencies; // list of dependent nmethods 263 nmethodBucket* _dependencies; // list of dependent nmethods
248 nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class 264 nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class
249 BreakpointInfo* _breakpoints; // bpt lists, managed by methodOop 265 BreakpointInfo* _breakpoints; // bpt lists, managed by methodOop
250 int _nof_implementors; // No of implementors of this interface (zero if not an interface)
251 // Array of interesting part(s) of the previous version(s) of this 266 // Array of interesting part(s) of the previous version(s) of this
252 // instanceKlass. See PreviousVersionWalker below. 267 // instanceKlass. See PreviousVersionWalker below.
253 GrowableArray<PreviousVersionNode *>* _previous_versions; 268 GrowableArray<PreviousVersionNode *>* _previous_versions;
254 u2 _enclosing_method_class_index; // Constant pool index for class of enclosing method, or 0 if none
255 u2 _enclosing_method_method_index; // Constant pool index for name and type of enclosing method, or 0 if none
256 // JVMTI fields can be moved to their own structure - see 6315920 269 // 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 270 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 271 jint _cached_class_file_len; // JVMTI: length of above
259 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration 272 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration
260 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change 273 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
268 281
269 // embedded Java vtable follows here 282 // embedded Java vtable follows here
270 // embedded Java itables follows here 283 // embedded Java itables follows here
271 // embedded static fields follows here 284 // embedded static fields follows here
272 // embedded nonstatic oop-map blocks follows here 285 // embedded nonstatic oop-map blocks follows here
286 // embedded implementor of this interface follows here
287 // The embedded implementor only exists if the current klass is an
288 // iterface. The possible values of the implementor fall into following
289 // three cases:
290 // NULL: no implementor.
291 // A klassOop that's not itself: one implementor.
292 // Itsef: more than one implementors.
293 // embedded host klass follows here
294 // The embedded host klass only exists in an anonymous class for
295 // dynamic language support (JSR 292 enabled). The host class grants
296 // its access privileges to this class also. The host class is either
297 // named, or a previously loaded anonymous class. A non-anonymous class
298 // or an anonymous class loaded through normal classloading does not
299 // have this embedded field.
300 //
273 301
274 friend class instanceKlassKlass; 302 friend class instanceKlassKlass;
275 friend class SystemDictionary; 303 friend class SystemDictionary;
276 304
277 public: 305 public:
278 bool has_nonstatic_fields() const { return _has_nonstatic_fields; } 306 bool has_nonstatic_fields() const {
279 void set_has_nonstatic_fields(bool b) { _has_nonstatic_fields = b; } 307 return (_misc_flags & _misc_has_nonstatic_fields) != 0;
308 }
309 void set_has_nonstatic_fields(bool b) {
310 if (b) {
311 _misc_flags |= _misc_has_nonstatic_fields;
312 } else {
313 _misc_flags &= ~_misc_has_nonstatic_fields;
314 }
315 }
280 316
281 // field sizes 317 // field sizes
282 int nonstatic_field_size() const { return _nonstatic_field_size; } 318 int nonstatic_field_size() const { return _nonstatic_field_size; }
283 void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; } 319 void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; }
284 320
325 Symbol* field_name (int index) const { return field(index)->name(constants()); } 361 Symbol* field_name (int index) const { return field(index)->name(constants()); }
326 Symbol* field_signature (int index) const { return field(index)->signature(constants()); } 362 Symbol* field_signature (int index) const { return field(index)->signature(constants()); }
327 363
328 // Number of Java declared fields 364 // Number of Java declared fields
329 int java_fields_count() const { return (int)_java_fields_count; } 365 int java_fields_count() const { return (int)_java_fields_count; }
330
331 // Number of fields including any injected fields
332 int all_fields_count() const { return _fields->length() / sizeof(FieldInfo::field_slots); }
333 366
334 typeArrayOop fields() const { return _fields; } 367 typeArrayOop fields() const { return _fields; }
335 368
336 void set_fields(typeArrayOop f, u2 java_fields_count) { 369 void set_fields(typeArrayOop f, u2 java_fields_count) {
337 oop_store_without_check((oop*) &_fields, (oop) f); 370 oop_store_without_check((oop*) &_fields, (oop) f);
347 inner_class_inner_class_info_offset = 0, 380 inner_class_inner_class_info_offset = 0,
348 inner_class_outer_class_info_offset = 1, 381 inner_class_outer_class_info_offset = 1,
349 inner_class_inner_name_offset = 2, 382 inner_class_inner_name_offset = 2,
350 inner_class_access_flags_offset = 3, 383 inner_class_access_flags_offset = 3,
351 inner_class_next_offset = 4 384 inner_class_next_offset = 4
385 };
386
387 enum EnclosingMethodAttributeOffset {
388 enclosing_method_class_index_offset = 0,
389 enclosing_method_method_index_offset = 1,
390 enclosing_method_attribute_size = 2
352 }; 391 };
353 392
354 // method override check 393 // method override check
355 bool is_override(methodHandle super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS); 394 bool is_override(methodHandle super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);
356 395
382 bool is_not_initialized() const { return _init_state < being_initialized; } 421 bool is_not_initialized() const { return _init_state < being_initialized; }
383 bool is_being_initialized() const { return _init_state == being_initialized; } 422 bool is_being_initialized() const { return _init_state == being_initialized; }
384 bool is_in_error_state() const { return _init_state == initialization_error; } 423 bool is_in_error_state() const { return _init_state == initialization_error; }
385 bool is_reentrant_initialization(Thread *thread) { return thread == _init_thread; } 424 bool is_reentrant_initialization(Thread *thread) { return thread == _init_thread; }
386 ClassState init_state() { return (ClassState)_init_state; } 425 ClassState init_state() { return (ClassState)_init_state; }
387 bool is_rewritten() const { return _rewritten; } 426 bool is_rewritten() const { return (_misc_flags & _misc_rewritten) != 0; }
388 427
389 // defineClass specified verification 428 // defineClass specified verification
390 bool should_verify_class() const { return _should_verify_class; } 429 bool should_verify_class() const {
391 void set_should_verify_class(bool value) { _should_verify_class = value; } 430 return (_misc_flags & _misc_should_verify_class) != 0;
431 }
432 void set_should_verify_class(bool value) {
433 if (value) {
434 _misc_flags |= _misc_should_verify_class;
435 } else {
436 _misc_flags &= ~_misc_should_verify_class;
437 }
438 }
392 439
393 // marking 440 // marking
394 bool is_marked_dependent() const { return _is_marked_dependent; } 441 bool is_marked_dependent() const { return _is_marked_dependent; }
395 void set_is_marked_dependent(bool value) { _is_marked_dependent = value; } 442 void set_is_marked_dependent(bool value) { _is_marked_dependent = value; }
396 443
455 // protection domain 502 // protection domain
456 oop protection_domain() { return _protection_domain; } 503 oop protection_domain() { return _protection_domain; }
457 void set_protection_domain(oop pd) { oop_store((oop*) &_protection_domain, pd); } 504 void set_protection_domain(oop pd) { oop_store((oop*) &_protection_domain, pd); }
458 505
459 // host class 506 // host class
460 oop host_klass() const { return _host_klass; } 507 oop host_klass() const {
461 void set_host_klass(oop host) { oop_store((oop*) &_host_klass, host); } 508 oop* hk = adr_host_klass();
462 bool is_anonymous() const { return _host_klass != NULL; } 509 if (hk == NULL) {
510 return NULL;
511 } else {
512 return *hk;
513 }
514 }
515 void set_host_klass(oop host) {
516 assert(is_anonymous(), "not anonymous");
517 oop* addr = adr_host_klass();
518 assert(addr != NULL, "no reversed space");
519 oop_store(addr, host);
520 }
521 bool is_anonymous() const {
522 return (_misc_flags & _misc_is_anonymous) != 0;
523 }
524 void set_is_anonymous(bool value) {
525 if (value) {
526 _misc_flags |= _misc_is_anonymous;
527 } else {
528 _misc_flags &= ~_misc_is_anonymous;
529 }
530 }
463 531
464 // signers 532 // signers
465 objArrayOop signers() const { return _signers; } 533 objArrayOop signers() const { return _signers; }
466 void set_signers(objArrayOop s) { oop_store((oop*) &_signers, oop(s)); } 534 void set_signers(objArrayOop s) { oop_store((oop*) &_signers, oop(s)); }
467 535
474 void set_minor_version(u2 minor_version) { _minor_version = minor_version; } 542 void set_minor_version(u2 minor_version) { _minor_version = minor_version; }
475 u2 major_version() const { return _major_version; } 543 u2 major_version() const { return _major_version; }
476 void set_major_version(u2 major_version) { _major_version = major_version; } 544 void set_major_version(u2 major_version) { _major_version = major_version; }
477 545
478 // source debug extension 546 // source debug extension
479 Symbol* source_debug_extension() const { return _source_debug_extension; } 547 char* source_debug_extension() const { return _source_debug_extension; }
480 void set_source_debug_extension(Symbol* n); 548 void set_source_debug_extension(char* array, int length);
481 549
482 // symbol unloading support (refcount already added) 550 // symbol unloading support (refcount already added)
483 Symbol* array_name() { return _array_name; } 551 Symbol* array_name() { return _array_name; }
484 void set_array_name(Symbol* name) { assert(_array_name == NULL, "name already created"); _array_name = name; } 552 void set_array_name(Symbol* name) { assert(_array_name == NULL, "name already created"); _array_name = name; }
485 553
531 599
532 // generics support 600 // generics support
533 Symbol* generic_signature() const { return _generic_signature; } 601 Symbol* generic_signature() const { return _generic_signature; }
534 void set_generic_signature(Symbol* sig) { _generic_signature = sig; } 602 void set_generic_signature(Symbol* sig) { _generic_signature = sig; }
535 603
536 u2 enclosing_method_class_index() const { return _enclosing_method_class_index; } 604 u2 enclosing_method_data(int offset);
537 u2 enclosing_method_method_index() const { return _enclosing_method_method_index; } 605 u2 enclosing_method_class_index() {
606 return enclosing_method_data(enclosing_method_class_index_offset);
607 }
608 u2 enclosing_method_method_index() {
609 return enclosing_method_data(enclosing_method_method_index_offset);
610 }
538 void set_enclosing_method_indices(u2 class_index, 611 void set_enclosing_method_indices(u2 class_index,
539 u2 method_index) { _enclosing_method_class_index = class_index; 612 u2 method_index);
540 _enclosing_method_method_index = method_index; }
541 613
542 // jmethodID support 614 // jmethodID support
543 static jmethodID get_jmethod_id(instanceKlassHandle ik_h, 615 static jmethodID get_jmethod_id(instanceKlassHandle ik_h,
544 methodHandle method_h); 616 methodHandle method_h);
545 static jmethodID get_jmethod_id_fetch_or_update(instanceKlassHandle ik_h, 617 static jmethodID get_jmethod_id_fetch_or_update(instanceKlassHandle ik_h,
624 BreakpointInfo* breakpoints() const { return _breakpoints; }; 696 BreakpointInfo* breakpoints() const { return _breakpoints; };
625 void set_breakpoints(BreakpointInfo* bps) { _breakpoints = bps; }; 697 void set_breakpoints(BreakpointInfo* bps) { _breakpoints = bps; };
626 698
627 // support for stub routines 699 // support for stub routines
628 static ByteSize init_state_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(instanceKlass, _init_state)); } 700 static ByteSize init_state_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(instanceKlass, _init_state)); }
701 TRACE_DEFINE_OFFSET;
629 static ByteSize init_thread_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(instanceKlass, _init_thread)); } 702 static ByteSize init_thread_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(instanceKlass, _init_thread)); }
630 703
631 // subclass/subinterface checks 704 // subclass/subinterface checks
632 bool implements_interface(klassOop k) const; 705 bool implements_interface(klassOop k) const;
633 706
634 // Access to implementors of an interface. We only store the count 707 // Access to the implementor of an interface.
635 // of implementors, and in case, there are only a few 708 klassOop implementor() const
636 // implementors, we store them in a short list. 709 {
637 // This accessor returns NULL if we walk off the end of the list. 710 klassOop* k = (klassOop*)adr_implementor();
638 klassOop implementor(int i) const { 711 if (k == NULL) {
639 return (i < implementors_limit)? _implementors[i]: (klassOop) NULL; 712 return NULL;
640 } 713 } else {
641 int nof_implementors() const { return _nof_implementors; } 714 return *k;
715 }
716 }
717
718 void set_implementor(klassOop k) {
719 assert(is_interface(), "not interface");
720 oop* addr = adr_implementor();
721 oop_store_without_check(addr, k);
722 }
723
724 int nof_implementors() const {
725 klassOop k = implementor();
726 if (k == NULL) {
727 return 0;
728 } else if (k != this->as_klassOop()) {
729 return 1;
730 } else {
731 return 2;
732 }
733 }
734
642 void add_implementor(klassOop k); // k is a new class that implements this interface 735 void add_implementor(klassOop k); // k is a new class that implements this interface
643 void init_implementor(); // initialize 736 void init_implementor(); // initialize
644 737
645 // link this class into the implementors list of every interface it implements 738 // link this class into the implementors list of every interface it implements
646 void process_interfaces(Thread *thread); 739 void process_interfaces(Thread *thread);
647 740
648 // virtual operations from Klass 741 // virtual operations from Klass
649 bool is_leaf_class() const { return _subklass == NULL && _nof_implementors == 0; } 742 bool is_leaf_class() const { return _subklass == NULL; }
650 objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS); 743 objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS);
651 bool compute_is_subtype_of(klassOop k); 744 bool compute_is_subtype_of(klassOop k);
652 bool can_be_primary_super_slow() const; 745 bool can_be_primary_super_slow() const;
653 klassOop java_super() const { return super(); } 746 klassOop java_super() const { return super(); }
654 int oop_size(oop obj) const { return size_helper(); } 747 int oop_size(oop obj) const { return size_helper(); }
673 return (instanceKlass*) kp; 766 return (instanceKlass*) kp;
674 } 767 }
675 768
676 // Sizing (in words) 769 // Sizing (in words)
677 static int header_size() { return align_object_offset(oopDesc::header_size() + sizeof(instanceKlass)/HeapWordSize); } 770 static int header_size() { return align_object_offset(oopDesc::header_size() + sizeof(instanceKlass)/HeapWordSize); }
678 int object_size() const { return object_size(align_object_offset(vtable_length()) + align_object_offset(itable_length()) + nonstatic_oop_map_size()); } 771
772 int object_size() const
773 {
774 return object_size(align_object_offset(vtable_length()) +
775 align_object_offset(itable_length()) +
776 ((is_interface() || is_anonymous()) ?
777 align_object_offset(nonstatic_oop_map_size()) :
778 nonstatic_oop_map_size()) +
779 (is_interface() ? (int)sizeof(klassOop)/HeapWordSize : 0) +
780 (is_anonymous() ? (int)sizeof(klassOop)/HeapWordSize : 0));
781 }
679 static int vtable_start_offset() { return header_size(); } 782 static int vtable_start_offset() { return header_size(); }
680 static int vtable_length_offset() { return oopDesc::header_size() + offset_of(instanceKlass, _vtable_len) / HeapWordSize; } 783 static int vtable_length_offset() { return oopDesc::header_size() + offset_of(instanceKlass, _vtable_len) / HeapWordSize; }
681 static int object_size(int extra) { return align_object_size(header_size() + extra); } 784 static int object_size(int extra) { return align_object_size(header_size() + extra); }
682 785
683 intptr_t* start_of_vtable() const { return ((intptr_t*)as_klassOop()) + vtable_start_offset(); } 786 intptr_t* start_of_vtable() const { return ((intptr_t*)as_klassOop()) + vtable_start_offset(); }
688 791
689 address static_field_addr(int offset); 792 address static_field_addr(int offset);
690 793
691 OopMapBlock* start_of_nonstatic_oop_maps() const { 794 OopMapBlock* start_of_nonstatic_oop_maps() const {
692 return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length())); 795 return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length()));
796 }
797
798 oop* adr_implementor() const {
799 if (is_interface()) {
800 return (oop*)(start_of_nonstatic_oop_maps() +
801 nonstatic_oop_map_count());
802 } else {
803 return NULL;
804 }
805 };
806
807 oop* adr_host_klass() const {
808 if (is_anonymous()) {
809 oop* adr_impl = adr_implementor();
810 if (adr_impl != NULL) {
811 return adr_impl + 1;
812 } else {
813 return (oop*)(start_of_nonstatic_oop_maps() +
814 nonstatic_oop_map_count());
815 }
816 } else {
817 return NULL;
818 }
693 } 819 }
694 820
695 // Allocation profiling support 821 // Allocation profiling support
696 juint alloc_size() const { return _alloc_count * size_helper(); } 822 juint alloc_size() const { return _alloc_count * size_helper(); }
697 void set_alloc_size(juint n) {} 823 void set_alloc_size(juint n) {}
763 #ifdef ASSERT 889 #ifdef ASSERT
764 void set_init_state(ClassState state); 890 void set_init_state(ClassState state);
765 #else 891 #else
766 void set_init_state(ClassState state) { _init_state = (u1)state; } 892 void set_init_state(ClassState state) { _init_state = (u1)state; }
767 #endif 893 #endif
768 void set_rewritten() { _rewritten = true; } 894 void set_rewritten() { _misc_flags |= _misc_rewritten; }
769 void set_init_thread(Thread *thread) { _init_thread = thread; } 895 void set_init_thread(Thread *thread) { _init_thread = thread; }
770 896
771 u2 idnum_allocated_count() const { return _idnum_allocated_count; } 897 u2 idnum_allocated_count() const { return _idnum_allocated_count; }
772 // The RedefineClasses() API can cause new method idnums to be needed 898 // The RedefineClasses() API can cause new method idnums to be needed
773 // which will cause the caches to grow. Safety requires different 899 // which will cause the caches to grow. Safety requires different
796 oop* adr_transitive_interfaces() const { return (oop*)&this->_transitive_interfaces;} 922 oop* adr_transitive_interfaces() const { return (oop*)&this->_transitive_interfaces;}
797 oop* adr_fields() const { return (oop*)&this->_fields;} 923 oop* adr_fields() const { return (oop*)&this->_fields;}
798 oop* adr_constants() const { return (oop*)&this->_constants;} 924 oop* adr_constants() const { return (oop*)&this->_constants;}
799 oop* adr_class_loader() const { return (oop*)&this->_class_loader;} 925 oop* adr_class_loader() const { return (oop*)&this->_class_loader;}
800 oop* adr_protection_domain() const { return (oop*)&this->_protection_domain;} 926 oop* adr_protection_domain() const { return (oop*)&this->_protection_domain;}
801 oop* adr_host_klass() const { return (oop*)&this->_host_klass;}
802 oop* adr_signers() const { return (oop*)&this->_signers;} 927 oop* adr_signers() const { return (oop*)&this->_signers;}
803 oop* adr_inner_classes() const { return (oop*)&this->_inner_classes;} 928 oop* adr_inner_classes() const { return (oop*)&this->_inner_classes;}
804 oop* adr_implementors() const { return (oop*)&this->_implementors[0];}
805 oop* adr_methods_jmethod_ids() const { return (oop*)&this->_methods_jmethod_ids;} 929 oop* adr_methods_jmethod_ids() const { return (oop*)&this->_methods_jmethod_ids;}
806 oop* adr_methods_cached_itable_indices() const { return (oop*)&this->_methods_cached_itable_indices;} 930 oop* adr_methods_cached_itable_indices() const { return (oop*)&this->_methods_cached_itable_indices;}
807 oop* adr_class_annotations() const { return (oop*)&this->_class_annotations;} 931 oop* adr_class_annotations() const { return (oop*)&this->_class_annotations;}
808 oop* adr_fields_annotations() const { return (oop*)&this->_fields_annotations;} 932 oop* adr_fields_annotations() const { return (oop*)&this->_fields_annotations;}
809 oop* adr_methods_annotations() const { return (oop*)&this->_methods_annotations;} 933 oop* adr_methods_annotations() const { return (oop*)&this->_methods_annotations;}
883 } 1007 }
884 } 1008 }
885 1009
886 1010
887 /* JNIid class for jfieldIDs only */ 1011 /* JNIid class for jfieldIDs only */
888 class JNIid: public CHeapObj { 1012 class JNIid: public CHeapObj<mtClass> {
889 friend class VMStructs; 1013 friend class VMStructs;
890 private: 1014 private:
891 klassOop _holder; 1015 klassOop _holder;
892 JNIid* _next; 1016 JNIid* _next;
893 int _offset; 1017 int _offset;
934 // the information so that the information may be collected as needed 1058 // the information so that the information may be collected as needed
935 // by the system. If the information is shared, then a regular 1059 // by the system. If the information is shared, then a regular
936 // reference must be used because a weak reference would be seen as 1060 // reference must be used because a weak reference would be seen as
937 // collectible. A GrowableArray of PreviousVersionNodes is attached 1061 // collectible. A GrowableArray of PreviousVersionNodes is attached
938 // to the instanceKlass as needed. See PreviousVersionWalker below. 1062 // to the instanceKlass as needed. See PreviousVersionWalker below.
939 class PreviousVersionNode : public CHeapObj { 1063 class PreviousVersionNode : public CHeapObj<mtClass> {
940 private: 1064 private:
941 // A shared ConstantPool is never collected so we'll always have 1065 // A shared ConstantPool is never collected so we'll always have
942 // a reference to it so we can update items in the cache. We'll 1066 // a reference to it so we can update items in the cache. We'll
943 // have a weak reference to a non-shared ConstantPool until all 1067 // have a weak reference to a non-shared ConstantPool until all
944 // of the methods (EMCP or obsolete) have been collected; the 1068 // of the methods (EMCP or obsolete) have been collected; the
1029 // recording the method, a count of how many times a particular nmethod 1153 // recording the method, a count of how many times a particular nmethod
1030 // was recorded is kept. This ensures that any recording errors are 1154 // was recorded is kept. This ensures that any recording errors are
1031 // noticed since an nmethod should be removed as many times are it's 1155 // noticed since an nmethod should be removed as many times are it's
1032 // added. 1156 // added.
1033 // 1157 //
1034 class nmethodBucket: public CHeapObj { 1158 class nmethodBucket: public CHeapObj<mtClass> {
1035 friend class VMStructs; 1159 friend class VMStructs;
1036 private: 1160 private:
1037 nmethod* _nmethod; 1161 nmethod* _nmethod;
1038 int _count; 1162 int _count;
1039 nmethodBucket* _next; 1163 nmethodBucket* _next;
1050 nmethodBucket* next() { return _next; } 1174 nmethodBucket* next() { return _next; }
1051 void set_next(nmethodBucket* b) { _next = b; } 1175 void set_next(nmethodBucket* b) { _next = b; }
1052 nmethod* get_nmethod() { return _nmethod; } 1176 nmethod* get_nmethod() { return _nmethod; }
1053 }; 1177 };
1054 1178
1179 // An iterator that's used to access the inner classes indices in the
1180 // instanceKlass::_inner_classes array.
1181 class InnerClassesIterator : public StackObj {
1182 private:
1183 typeArrayHandle _inner_classes;
1184 int _length;
1185 int _idx;
1186 public:
1187
1188 InnerClassesIterator(instanceKlassHandle k) {
1189 _inner_classes = k->inner_classes();
1190 if (k->inner_classes() != NULL) {
1191 _length = _inner_classes->length();
1192 // The inner class array's length should be the multiple of
1193 // inner_class_next_offset if it only contains the InnerClasses
1194 // attribute data, or it should be
1195 // n*inner_class_next_offset+enclosing_method_attribute_size
1196 // if it also contains the EnclosingMethod data.
1197 assert((_length % instanceKlass::inner_class_next_offset == 0 ||
1198 _length % instanceKlass::inner_class_next_offset == instanceKlass::enclosing_method_attribute_size),
1199 "just checking");
1200 // Remove the enclosing_method portion if exists.
1201 if (_length % instanceKlass::inner_class_next_offset == instanceKlass::enclosing_method_attribute_size) {
1202 _length -= instanceKlass::enclosing_method_attribute_size;
1203 }
1204 } else {
1205 _length = 0;
1206 }
1207 _idx = 0;
1208 }
1209
1210 int length() const {
1211 return _length;
1212 }
1213
1214 void next() {
1215 _idx += instanceKlass::inner_class_next_offset;
1216 }
1217
1218 bool done() const {
1219 return (_idx >= _length);
1220 }
1221
1222 u2 inner_class_info_index() const {
1223 return _inner_classes->ushort_at(
1224 _idx + instanceKlass::inner_class_inner_class_info_offset);
1225 }
1226
1227 void set_inner_class_info_index(u2 index) {
1228 _inner_classes->ushort_at_put(
1229 _idx + instanceKlass::inner_class_inner_class_info_offset, index);
1230 }
1231
1232 u2 outer_class_info_index() const {
1233 return _inner_classes->ushort_at(
1234 _idx + instanceKlass::inner_class_outer_class_info_offset);
1235 }
1236
1237 void set_outer_class_info_index(u2 index) {
1238 _inner_classes->ushort_at_put(
1239 _idx + instanceKlass::inner_class_outer_class_info_offset, index);
1240 }
1241
1242 u2 inner_name_index() const {
1243 return _inner_classes->ushort_at(
1244 _idx + instanceKlass::inner_class_inner_name_offset);
1245 }
1246
1247 void set_inner_name_index(u2 index) {
1248 _inner_classes->ushort_at_put(
1249 _idx + instanceKlass::inner_class_inner_name_offset, index);
1250 }
1251
1252 u2 inner_access_flags() const {
1253 return _inner_classes->ushort_at(
1254 _idx + instanceKlass::inner_class_access_flags_offset);
1255 }
1256 };
1257
1055 #endif // SHARE_VM_OOPS_INSTANCEKLASS_HPP 1258 #endif // SHARE_VM_OOPS_INSTANCEKLASS_HPP