11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
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,
559 // Atomically increments biased_lock_revocation_count and returns updated value
560 int atomic_incr_biased_lock_revocation_count();
561 void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; }
562 jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }
563 void set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }
564
565 TRACE_DEFINE_KLASS_METHODS;
566
567 // garbage collection support
568 void oops_do(OopClosure* cl);
569
570 // Iff the class loader (or mirror for anonymous classes) is alive the
571 // Klass is considered alive.
572 // The is_alive closure passed in depends on the Garbage Collector used.
573 bool is_loader_alive(BoolObjectClosure* is_alive);
574
575 static void clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses = true);
576 static void clean_subklass_tree(BoolObjectClosure* is_alive) {
577 clean_weak_klass_links(is_alive, false /* clean_alive_klasses */);
578 }
579
580 // iterators
581 virtual int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) = 0;
582 virtual int oop_oop_iterate_v(oop obj, ExtendedOopClosure* blk) {
583 return oop_oop_iterate(obj, blk);
584 }
585
586 #if INCLUDE_ALL_GCS
587 // In case we don't have a specialized backward scanner use forward
588 // iteration.
589 virtual int oop_oop_iterate_backwards_v(oop obj, ExtendedOopClosure* blk) {
590 return oop_oop_iterate_v(obj, blk);
591 }
592 #endif // INCLUDE_ALL_GCS
593
594 // Iterates "blk" over all the oops in "obj" (of type "this") within "mr".
595 // (I don't see why the _m should be required, but without it the Solaris
596 // C++ gives warning messages about overridings of the "oop_oop_iterate"
597 // defined above "hiding" this virtual function. (DLD, 6/20/00)) */
598 virtual int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) = 0;
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
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.inline.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,
559 // Atomically increments biased_lock_revocation_count and returns updated value
560 int atomic_incr_biased_lock_revocation_count();
561 void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; }
562 jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }
563 void set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }
564
565 TRACE_DEFINE_KLASS_METHODS;
566
567 // garbage collection support
568 void oops_do(OopClosure* cl);
569
570 // Iff the class loader (or mirror for anonymous classes) is alive the
571 // Klass is considered alive.
572 // The is_alive closure passed in depends on the Garbage Collector used.
573 bool is_loader_alive(BoolObjectClosure* is_alive);
574
575 static void clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses = true);
576 static void clean_subklass_tree(BoolObjectClosure* is_alive) {
577 clean_weak_klass_links(is_alive, false /* clean_alive_klasses */);
578 }
579
580 struct OopInterval {
581 int _offset;
582 uint _size;
583 };
584
585 // Returns positive value if oop maps could be returned and the klass doesn't need to know closure type.
586 // Otherwise returns a negative value corresponding to which klass implementation is being used (DispatchTag).
587 virtual int get_linear_oop_intervals(oop obj, OopInterval* &start, int &size) { return _unknown_klass; }
588
589 // iterators
590 virtual int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) = 0;
591 virtual int oop_oop_iterate_v(oop obj, ExtendedOopClosure* blk) {
592 return oop_oop_iterate(obj, blk);
593 }
594
595 #if INCLUDE_ALL_GCS
596 // In case we don't have a specialized backward scanner use forward
597 // iteration.
598 virtual int oop_oop_iterate_backwards_v(oop obj, ExtendedOopClosure* blk) {
599 return oop_oop_iterate_v(obj, blk);
600 }
601 #endif // INCLUDE_ALL_GCS
602
603 // Iterates "blk" over all the oops in "obj" (of type "this") within "mr".
604 // (I don't see why the _m should be required, but without it the Solaris
605 // C++ gives warning messages about overridings of the "oop_oop_iterate"
606 // defined above "hiding" this virtual function. (DLD, 6/20/00)) */
607 virtual int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) = 0;
|