208 // Can this klass be a primary super? False for interfaces and arrays of
209 // interfaces. False also for arrays or classes with long super chains.
210 bool can_be_primary_super() const {
211 const juint secondary_offset = in_bytes(secondary_super_cache_offset());
212 return super_check_offset() != secondary_offset;
213 }
214 virtual bool can_be_primary_super_slow() const;
215
216 // Returns number of primary supers; may be a number in the inclusive range [0, primary_super_limit].
217 juint super_depth() const {
218 if (!can_be_primary_super()) {
219 return primary_super_limit();
220 } else {
221 juint d = (super_check_offset() - in_bytes(primary_supers_offset())) / sizeof(Klass*);
222 assert(d < primary_super_limit(), "oob");
223 assert(_primary_supers[d] == this, "proper init");
224 return d;
225 }
226 }
227
228 // store an oop into a field of a Klass
229 void klass_oop_store(oop* p, oop v);
230 void klass_oop_store(volatile oop* p, oop v);
231
232 // java mirror
233 oop java_mirror() const { return _java_mirror; }
234 void set_java_mirror(oop m) { klass_oop_store(&_java_mirror, m); }
235
236 // modifier flags
237 jint modifier_flags() const { return _modifier_flags; }
238 void set_modifier_flags(jint flags) { _modifier_flags = flags; }
239
240 // size helper
241 int layout_helper() const { return _layout_helper; }
242 void set_layout_helper(int lh) { _layout_helper = lh; }
243
244 // Note: for instances layout_helper() may include padding.
245 // Use InstanceKlass::contains_field_offset to classify field offsets.
246
247 // sub/superklass links
248 Klass* subklass() const { return _subklass; }
249 Klass* next_sibling() const { return _next_sibling; }
250 InstanceKlass* superklass() const;
251 void append_to_sibling_list(); // add newly created receiver to superklass' subklass list
252
253 void set_next_link(Klass* k) { _next_link = k; }
254 Klass* next_link() const { return _next_link; } // The next klass defined by the class loader.
420 bool search_secondary_supers(Klass* k) const;
421
422 // Find LCA in class hierarchy
423 Klass *LCA( Klass *k );
424
425 // Check whether reflection/jni/jvm code is allowed to instantiate this class;
426 // if not, throw either an Error or an Exception.
427 virtual void check_valid_for_instantiation(bool throwError, TRAPS);
428
429 // array copying
430 virtual void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
431
432 // tells if the class should be initialized
433 virtual bool should_be_initialized() const { return false; }
434 // initializes the klass
435 virtual void initialize(TRAPS);
436 // lookup operation for MethodLookupCache
437 friend class MethodLookupCache;
438 virtual Klass* find_field(Symbol* name, Symbol* signature, fieldDescriptor* fd) const;
439 virtual Method* uncached_lookup_method(const Symbol* name, const Symbol* signature, OverpassLookupMode overpass_mode) const;
440 public:
441 Method* lookup_method(const Symbol* name, const Symbol* signature) const {
442 return uncached_lookup_method(name, signature, find_overpass);
443 }
444
445 // array class with specific rank
446 Klass* array_klass(int rank, TRAPS) { return array_klass_impl(false, rank, THREAD); }
447
448 // array class with this klass as element type
449 Klass* array_klass(TRAPS) { return array_klass_impl(false, THREAD); }
450
451 // These will return NULL instead of allocating on the heap:
452 // NB: these can block for a mutex, like other functions with TRAPS arg.
453 Klass* array_klass_or_null(int rank);
454 Klass* array_klass_or_null();
455
456 virtual oop protection_domain() const = 0;
457
458 oop class_loader() const;
459
460 virtual oop klass_holder() const { return class_loader(); }
461
462 protected:
463 virtual Klass* array_klass_impl(bool or_null, int rank, TRAPS);
464 virtual Klass* array_klass_impl(bool or_null, TRAPS);
465
466 void set_vtable_length(int len) { _vtable_len= len; }
467
468 vtableEntry* start_of_vtable() const;
469 public:
470 Method* method_at_vtable(int index);
471
472 static ByteSize vtable_start_offset();
473 static ByteSize vtable_length_offset() {
474 return byte_offset_of(Klass, _vtable_len);
475 }
476
477 // CDS support - remove and restore oops from metadata. Oops are not shared.
478 virtual void remove_unshareable_info();
479 virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
480
663 // Verification
664 virtual void verify_on(outputStream* st);
665 void verify() { verify_on(tty); }
666
667 #ifndef PRODUCT
668 bool verify_vtable_index(int index);
669 bool verify_itable_index(int index);
670 #endif
671
672 virtual void oop_verify_on(oop obj, outputStream* st);
673
674 static bool is_null(narrowKlass obj);
675 static bool is_null(Klass* obj);
676
677 // klass encoding for klass pointer in objects.
678 static narrowKlass encode_klass_not_null(Klass* v);
679 static narrowKlass encode_klass(Klass* v);
680
681 static Klass* decode_klass_not_null(narrowKlass v);
682 static Klass* decode_klass(narrowKlass v);
683
684 private:
685 // barriers used by klass_oop_store
686 void klass_update_barrier_set(oop v);
687 void klass_update_barrier_set_pre(oop* p, oop v);
688 };
689
690 // Helper to convert the oop iterate macro suffixes into bool values that can be used by template functions.
691 #define nvs_nv_to_bool true
692 #define nvs_v_to_bool false
693 #define nvs_to_bool(nv_suffix) nvs##nv_suffix##_to_bool
694
695 // Oop iteration macros for declarations.
696 // Used to generate declarations in the *Klass header files.
697
698 #define OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \
699 void oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure); \
700 void oop_oop_iterate_bounded##nv_suffix(oop obj, OopClosureType* closure, MemRegion mr);
701
702 #if INCLUDE_ALL_GCS
703 #define OOP_OOP_ITERATE_DECL_BACKWARDS(OopClosureType, nv_suffix) \
704 void oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure);
705 #endif // INCLUDE_ALL_GCS
706
707
|
208 // Can this klass be a primary super? False for interfaces and arrays of
209 // interfaces. False also for arrays or classes with long super chains.
210 bool can_be_primary_super() const {
211 const juint secondary_offset = in_bytes(secondary_super_cache_offset());
212 return super_check_offset() != secondary_offset;
213 }
214 virtual bool can_be_primary_super_slow() const;
215
216 // Returns number of primary supers; may be a number in the inclusive range [0, primary_super_limit].
217 juint super_depth() const {
218 if (!can_be_primary_super()) {
219 return primary_super_limit();
220 } else {
221 juint d = (super_check_offset() - in_bytes(primary_supers_offset())) / sizeof(Klass*);
222 assert(d < primary_super_limit(), "oob");
223 assert(_primary_supers[d] == this, "proper init");
224 return d;
225 }
226 }
227
228 // java mirror
229 oop java_mirror() const { return _java_mirror; }
230 void set_java_mirror(oop m);
231
232 // modifier flags
233 jint modifier_flags() const { return _modifier_flags; }
234 void set_modifier_flags(jint flags) { _modifier_flags = flags; }
235
236 // size helper
237 int layout_helper() const { return _layout_helper; }
238 void set_layout_helper(int lh) { _layout_helper = lh; }
239
240 // Note: for instances layout_helper() may include padding.
241 // Use InstanceKlass::contains_field_offset to classify field offsets.
242
243 // sub/superklass links
244 Klass* subklass() const { return _subklass; }
245 Klass* next_sibling() const { return _next_sibling; }
246 InstanceKlass* superklass() const;
247 void append_to_sibling_list(); // add newly created receiver to superklass' subklass list
248
249 void set_next_link(Klass* k) { _next_link = k; }
250 Klass* next_link() const { return _next_link; } // The next klass defined by the class loader.
416 bool search_secondary_supers(Klass* k) const;
417
418 // Find LCA in class hierarchy
419 Klass *LCA( Klass *k );
420
421 // Check whether reflection/jni/jvm code is allowed to instantiate this class;
422 // if not, throw either an Error or an Exception.
423 virtual void check_valid_for_instantiation(bool throwError, TRAPS);
424
425 // array copying
426 virtual void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
427
428 // tells if the class should be initialized
429 virtual bool should_be_initialized() const { return false; }
430 // initializes the klass
431 virtual void initialize(TRAPS);
432 // lookup operation for MethodLookupCache
433 friend class MethodLookupCache;
434 virtual Klass* find_field(Symbol* name, Symbol* signature, fieldDescriptor* fd) const;
435 virtual Method* uncached_lookup_method(const Symbol* name, const Symbol* signature, OverpassLookupMode overpass_mode) const;
436
437 virtual oop* klass_holder_addr() const;
438 public:
439 Method* lookup_method(const Symbol* name, const Symbol* signature) const {
440 return uncached_lookup_method(name, signature, find_overpass);
441 }
442
443 // array class with specific rank
444 Klass* array_klass(int rank, TRAPS) { return array_klass_impl(false, rank, THREAD); }
445
446 // array class with this klass as element type
447 Klass* array_klass(TRAPS) { return array_klass_impl(false, THREAD); }
448
449 // These will return NULL instead of allocating on the heap:
450 // NB: these can block for a mutex, like other functions with TRAPS arg.
451 Klass* array_klass_or_null(int rank);
452 Klass* array_klass_or_null();
453
454 virtual oop protection_domain() const = 0;
455
456 oop class_loader() const;
457
458 oop klass_holder() const;
459
460 protected:
461 virtual Klass* array_klass_impl(bool or_null, int rank, TRAPS);
462 virtual Klass* array_klass_impl(bool or_null, TRAPS);
463
464 void set_vtable_length(int len) { _vtable_len= len; }
465
466 vtableEntry* start_of_vtable() const;
467 public:
468 Method* method_at_vtable(int index);
469
470 static ByteSize vtable_start_offset();
471 static ByteSize vtable_length_offset() {
472 return byte_offset_of(Klass, _vtable_len);
473 }
474
475 // CDS support - remove and restore oops from metadata. Oops are not shared.
476 virtual void remove_unshareable_info();
477 virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
478
661 // Verification
662 virtual void verify_on(outputStream* st);
663 void verify() { verify_on(tty); }
664
665 #ifndef PRODUCT
666 bool verify_vtable_index(int index);
667 bool verify_itable_index(int index);
668 #endif
669
670 virtual void oop_verify_on(oop obj, outputStream* st);
671
672 static bool is_null(narrowKlass obj);
673 static bool is_null(Klass* obj);
674
675 // klass encoding for klass pointer in objects.
676 static narrowKlass encode_klass_not_null(Klass* v);
677 static narrowKlass encode_klass(Klass* v);
678
679 static Klass* decode_klass_not_null(narrowKlass v);
680 static Klass* decode_klass(narrowKlass v);
681 };
682
683 // Helper to convert the oop iterate macro suffixes into bool values that can be used by template functions.
684 #define nvs_nv_to_bool true
685 #define nvs_v_to_bool false
686 #define nvs_to_bool(nv_suffix) nvs##nv_suffix##_to_bool
687
688 // Oop iteration macros for declarations.
689 // Used to generate declarations in the *Klass header files.
690
691 #define OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \
692 void oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure); \
693 void oop_oop_iterate_bounded##nv_suffix(oop obj, OopClosureType* closure, MemRegion mr);
694
695 #if INCLUDE_ALL_GCS
696 #define OOP_OOP_ITERATE_DECL_BACKWARDS(OopClosureType, nv_suffix) \
697 void oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure);
698 #endif // INCLUDE_ALL_GCS
699
700
|