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

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

 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 markWord Klass::prototype_header() const {


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

 85   return _prototype_header;
 86 }
 87 
 88 // May no longer be required (was used to avoid a bootstrapping problem...
 89 inline markWord Klass::default_prototype_header(Klass* k) {
 90   return (k == nullptr) ? markWord::prototype() : k->prototype_header();


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