16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_OOPS_KLASS_HPP
26 #define SHARE_VM_OOPS_KLASS_HPP
27
28 #include "memory/genOopClosures.hpp"
29 #include "memory/iterator.hpp"
30 #include "memory/memRegion.hpp"
31 #include "memory/specialized_oop_closures.hpp"
32 #include "oops/klassPS.hpp"
33 #include "oops/metadata.hpp"
34 #include "oops/oop.hpp"
35 #include "trace/traceMacros.hpp"
36 #include "utilities/accessFlags.hpp"
37 #include "utilities/macros.hpp"
38 #if INCLUDE_ALL_GCS
39 #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp"
40 #include "gc_implementation/g1/g1OopClosures.hpp"
41 #include "gc_implementation/parNew/parOopClosures.hpp"
42 #endif // INCLUDE_ALL_GCS
43
44 //
45 // A Klass provides:
46 // 1: language level class object (method dictionary etc.)
47 // 2: provide vm dispatch behavior for the object
48 // Both functions are combined into one C++ class.
49
50 // One reason for the oop/klass dichotomy in the implementation is
51 // that we don't want a C++ vtbl pointer in every object. Thus,
52 // normal oops don't have any virtual functions. Instead, they
53 // forward all "virtual" functions to their klass, which does have
54 // a vtbl and does the C++ dispatch depending on the object's
55 // actual type. (See oop.inline.hpp for some of the forwarding code.)
155 Klass* _next_sibling;
156
157 // All klasses loaded by a class loader are chained through these links
158 Klass* _next_link;
159
160 // The VM's representation of the ClassLoader used to load this class.
161 // Provide access the corresponding instance java.lang.ClassLoader.
162 ClassLoaderData* _class_loader_data;
163
164 jint _modifier_flags; // Processed access flags, for use by Class.getModifiers.
165 AccessFlags _access_flags; // Access flags. The class/interface distinction is stored here.
166
167 // Biased locking implementation and statistics
168 // (the 64-bit chunk goes first, to avoid some fragmentation)
169 jlong _last_biased_lock_bulk_revocation_time;
170 markOop _prototype_header; // Used when biased locking is both enabled and disabled for this type
171 jint _biased_lock_revocation_count;
172
173 TRACE_DEFINE_KLASS_TRACE_ID;
174
175 // Remembered sets support for the oops in the klasses.
176 jbyte _modified_oops; // Card Table Equivalent (YC/CMS support)
177 jbyte _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
178
179 private:
180 // This is an index into FileMapHeader::_classpath_entry_table[], to
181 // associate this class with the JAR file where it's loaded from during
182 // dump time. If a class is not loaded from the shared archive, this field is
183 // -1.
184 jshort _shared_class_path_index;
185
186 friend class SharedClassUtil;
187 protected:
188
189 // Constructor
190 Klass();
191
192 void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();
193
194 public:
593 markOop prototype_header() const { return _prototype_header; }
594 // NOTE: once instances of this klass are floating around in the
595 // system, this header must only be updated at a safepoint.
596 // NOTE 2: currently we only ever set the prototype header to the
597 // biasable prototype for instanceKlasses. There is no technical
598 // reason why it could not be done for arrayKlasses aside from
599 // wanting to reduce the initial scope of this optimization. There
600 // are potential problems in setting the bias pattern for
601 // JVM-internal oops.
602 inline void set_prototype_header(markOop header);
603 static ByteSize prototype_header_offset() { return in_ByteSize(offset_of(Klass, _prototype_header)); }
604
605 int biased_lock_revocation_count() const { return (int) _biased_lock_revocation_count; }
606 // Atomically increments biased_lock_revocation_count and returns updated value
607 int atomic_incr_biased_lock_revocation_count();
608 void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; }
609 jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }
610 void set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }
611
612 TRACE_DEFINE_KLASS_METHODS;
613
614 // garbage collection support
615 virtual void oops_do(OopClosure* cl);
616
617 // Iff the class loader (or mirror for anonymous classes) is alive the
618 // Klass is considered alive.
619 // The is_alive closure passed in depends on the Garbage Collector used.
620 bool is_loader_alive(BoolObjectClosure* is_alive);
621
622 static void clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses = true);
623 static void clean_subklass_tree(BoolObjectClosure* is_alive) {
624 clean_weak_klass_links(is_alive, false /* clean_alive_klasses */);
625 }
626
627 // iterators
628 virtual int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) = 0;
629 virtual int oop_oop_iterate_v(oop obj, ExtendedOopClosure* blk) {
630 return oop_oop_iterate(obj, blk);
631 }
632
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_OOPS_KLASS_HPP
26 #define SHARE_VM_OOPS_KLASS_HPP
27
28 #include "memory/genOopClosures.hpp"
29 #include "memory/iterator.hpp"
30 #include "memory/memRegion.hpp"
31 #include "memory/specialized_oop_closures.hpp"
32 #include "oops/klassPS.hpp"
33 #include "oops/metadata.hpp"
34 #include "oops/oop.hpp"
35 #include "trace/traceMacros.hpp"
36 #include "evtrace/traceMacros.hpp"
37 #include "utilities/accessFlags.hpp"
38 #include "utilities/macros.hpp"
39 #if INCLUDE_ALL_GCS
40 #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp"
41 #include "gc_implementation/g1/g1OopClosures.hpp"
42 #include "gc_implementation/parNew/parOopClosures.hpp"
43 #endif // INCLUDE_ALL_GCS
44
45 //
46 // A Klass provides:
47 // 1: language level class object (method dictionary etc.)
48 // 2: provide vm dispatch behavior for the object
49 // Both functions are combined into one C++ class.
50
51 // One reason for the oop/klass dichotomy in the implementation is
52 // that we don't want a C++ vtbl pointer in every object. Thus,
53 // normal oops don't have any virtual functions. Instead, they
54 // forward all "virtual" functions to their klass, which does have
55 // a vtbl and does the C++ dispatch depending on the object's
56 // actual type. (See oop.inline.hpp for some of the forwarding code.)
156 Klass* _next_sibling;
157
158 // All klasses loaded by a class loader are chained through these links
159 Klass* _next_link;
160
161 // The VM's representation of the ClassLoader used to load this class.
162 // Provide access the corresponding instance java.lang.ClassLoader.
163 ClassLoaderData* _class_loader_data;
164
165 jint _modifier_flags; // Processed access flags, for use by Class.getModifiers.
166 AccessFlags _access_flags; // Access flags. The class/interface distinction is stored here.
167
168 // Biased locking implementation and statistics
169 // (the 64-bit chunk goes first, to avoid some fragmentation)
170 jlong _last_biased_lock_bulk_revocation_time;
171 markOop _prototype_header; // Used when biased locking is both enabled and disabled for this type
172 jint _biased_lock_revocation_count;
173
174 TRACE_DEFINE_KLASS_TRACE_ID;
175
176 EVTRACE_DECLARE_TRACKED_CLASS_FIELDS;
177
178 // Remembered sets support for the oops in the klasses.
179 jbyte _modified_oops; // Card Table Equivalent (YC/CMS support)
180 jbyte _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
181
182 private:
183 // This is an index into FileMapHeader::_classpath_entry_table[], to
184 // associate this class with the JAR file where it's loaded from during
185 // dump time. If a class is not loaded from the shared archive, this field is
186 // -1.
187 jshort _shared_class_path_index;
188
189 friend class SharedClassUtil;
190 protected:
191
192 // Constructor
193 Klass();
194
195 void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();
196
197 public:
596 markOop prototype_header() const { return _prototype_header; }
597 // NOTE: once instances of this klass are floating around in the
598 // system, this header must only be updated at a safepoint.
599 // NOTE 2: currently we only ever set the prototype header to the
600 // biasable prototype for instanceKlasses. There is no technical
601 // reason why it could not be done for arrayKlasses aside from
602 // wanting to reduce the initial scope of this optimization. There
603 // are potential problems in setting the bias pattern for
604 // JVM-internal oops.
605 inline void set_prototype_header(markOop header);
606 static ByteSize prototype_header_offset() { return in_ByteSize(offset_of(Klass, _prototype_header)); }
607
608 int biased_lock_revocation_count() const { return (int) _biased_lock_revocation_count; }
609 // Atomically increments biased_lock_revocation_count and returns updated value
610 int atomic_incr_biased_lock_revocation_count();
611 void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; }
612 jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }
613 void set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }
614
615 TRACE_DEFINE_KLASS_METHODS;
616
617 EVTRACE_DEFINE_TRACKED_CLASS_METHODS;
618
619 // garbage collection support
620 virtual void oops_do(OopClosure* cl);
621
622 // Iff the class loader (or mirror for anonymous classes) is alive the
623 // Klass is considered alive.
624 // The is_alive closure passed in depends on the Garbage Collector used.
625 bool is_loader_alive(BoolObjectClosure* is_alive);
626
627 static void clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses = true);
628 static void clean_subklass_tree(BoolObjectClosure* is_alive) {
629 clean_weak_klass_links(is_alive, false /* clean_alive_klasses */);
630 }
631
632 // iterators
633 virtual int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) = 0;
634 virtual int oop_oop_iterate_v(oop obj, ExtendedOopClosure* blk) {
635 return oop_oop_iterate(obj, blk);
636 }
637
|