< prev index next >

src/hotspot/share/oops/klass.inline.hpp

Print this page

 42   // Making the klass's CLD handle oops (e.g. the java_mirror), safe to store in the object
 43   // graph and its roots (e.g. Handles).
 44   static_cast<void>(klass_holder());
 45 }
 46 
 47 inline bool Klass::is_non_strong_hidden() const {
 48   return is_hidden() && class_loader_data()->has_class_mirror_holder();
 49 }
 50 
 51 // Iff the class loader (or mirror for non-strong hidden classes) is alive the
 52 // Klass is considered alive. This is safe to call before the CLD is marked as
 53 // unloading, and hence during concurrent class unloading.
 54 // This returns false if the Klass is unloaded, or about to be unloaded because the holder of
 55 // the CLD is no longer strongly reachable.
 56 // The return value of this function may change from true to false after a safepoint. So the caller
 57 // of this function must ensure that a safepoint doesn't happen while interpreting the return value.
 58 inline bool Klass::is_loader_alive() const {
 59   return class_loader_data()->is_alive();
 60 }
 61 


















 62 inline bool Klass::is_loader_present_and_alive() const {
 63   ClassLoaderData* cld = class_loader_data();
 64   return (cld != nullptr) ? cld->is_alive() : false;
 65 }
 66 
 67 inline markWord Klass::prototype_header() const {
 68   assert(UseCompactObjectHeaders, "only use with compact object headers");
 69 #ifdef _LP64
 70   // You only need prototypes for allocating objects. If the class is not instantiable, it won't live in
 71   // class space and have no narrow Klass ID. But in that case we should not need the prototype.
 72   assert(_prototype_header.narrow_klass() > 0, "Klass " PTR_FORMAT ": invalid prototype (" PTR_FORMAT ")",
 73          p2i(this), _prototype_header.value());
 74 #endif
 75   return _prototype_header;
 76 }
 77 
 78 // This is only used when dumping the archive. In other cases,
 79 // the _prototype_header is already initialized to the right thing.
 80 inline void Klass::set_prototype_header(markWord header) {
 81   assert(UseCompactObjectHeaders, "only with compact headers");
 82   _prototype_header = header;
 83 }
 84 

 85 // Loading the java_mirror does not keep its holder alive. See Klass::keep_alive().
 86 inline oop Klass::java_mirror() const {
 87   return _java_mirror.resolve();
 88 }
 89 
 90 inline oop Klass::java_mirror_no_keepalive() const {
 91   return _java_mirror.peek();
 92 }
 93 
 94 inline klassVtable Klass::vtable() const {
 95   return klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size());
 96 }
 97 
 98 inline oop Klass::class_loader() const {
 99   return class_loader_data()->class_loader();
100 }
101 
102 inline vtableEntry* Klass::start_of_vtable() const {
103   return (vtableEntry*) ((address)this + in_bytes(vtable_start_offset()));
104 }

 42   // Making the klass's CLD handle oops (e.g. the java_mirror), safe to store in the object
 43   // graph and its roots (e.g. Handles).
 44   static_cast<void>(klass_holder());
 45 }
 46 
 47 inline bool Klass::is_non_strong_hidden() const {
 48   return is_hidden() && class_loader_data()->has_class_mirror_holder();
 49 }
 50 
 51 // Iff the class loader (or mirror for non-strong hidden classes) is alive the
 52 // Klass is considered alive. This is safe to call before the CLD is marked as
 53 // unloading, and hence during concurrent class unloading.
 54 // This returns false if the Klass is unloaded, or about to be unloaded because the holder of
 55 // the CLD is no longer strongly reachable.
 56 // The return value of this function may change from true to false after a safepoint. So the caller
 57 // of this function must ensure that a safepoint doesn't happen while interpreting the return value.
 58 inline bool Klass::is_loader_alive() const {
 59   return class_loader_data()->is_alive();
 60 }
 61 
 62 inline markWord Klass::make_prototype_header(const Klass* kls, markWord prototype) {
 63   if (UseCompactObjectHeaders) {
 64     // With compact object headers, the narrow Klass ID is part of the mark word.
 65     // We therefore seed the mark word with the narrow Klass ID.
 66     // Note that only those Klass that can be instantiated have a narrow Klass ID.
 67     // For those who don't, we leave the klass bits empty and assert if someone
 68     // tries to use those.
 69     const narrowKlass nk = CompressedKlassPointers::is_encodable(kls) ?
 70         CompressedKlassPointers::encode(const_cast<Klass*>(kls)) : 0;
 71     prototype = prototype.set_narrow_klass(nk);
 72   }
 73   return prototype;
 74 }
 75 
 76 inline void Klass::set_prototype_header(markWord header) {
 77   _prototype_header = header;
 78 }
 79 
 80 inline bool Klass::is_loader_present_and_alive() const {
 81   ClassLoaderData* cld = class_loader_data();
 82   return (cld != nullptr) ? cld->is_alive() : false;
 83 }
 84 
 85 inline markWord Klass::prototype_header() const {


 86   // You only need prototypes for allocating objects. If the class is not instantiable, it won't live in
 87   // class space and have no narrow Klass ID. But in that case we should not need the prototype.
 88   assert(!UseCompactObjectHeaders || _prototype_header.narrow_klass() > 0, "Klass " PTR_FORMAT ": invalid prototype (" PTR_FORMAT ")",
 89          p2i(this), _prototype_header.value());

 90   return _prototype_header;
 91 }
 92 
 93 // May no longer be required (was used to avoid a bootstrapping problem...
 94 inline markWord Klass::default_prototype_header(Klass* k) {
 95   return (k == nullptr) ? markWord::prototype() : k->prototype_header();


 96 }
 97 
 98 
 99 // Loading the java_mirror does not keep its holder alive. See Klass::keep_alive().
100 inline oop Klass::java_mirror() const {
101   return _java_mirror.resolve();
102 }
103 
104 inline oop Klass::java_mirror_no_keepalive() const {
105   return _java_mirror.peek();
106 }
107 
108 inline klassVtable Klass::vtable() const {
109   return klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size());
110 }
111 
112 inline oop Klass::class_loader() const {
113   return class_loader_data()->class_loader();
114 }
115 
116 inline vtableEntry* Klass::start_of_vtable() const {
117   return (vtableEntry*) ((address)this + in_bytes(vtable_start_offset()));
118 }
< prev index next >