1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 *
47 virtual void do_oop(oop* o) = 0;
48 virtual void do_oop(narrowOop* o) = 0;
49 };
50
51 // ExtendedOopClosure adds extra code to be run during oop iterations.
52 // This is needed by the GC and is extracted to a separate type to not
53 // pollute the OopClosure interface.
54 class ExtendedOopClosure : public OopClosure {
55 private:
56 ReferenceProcessor* _ref_processor;
57
58 protected:
59 ExtendedOopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { }
60 ExtendedOopClosure() : _ref_processor(NULL) { }
61 ~ExtendedOopClosure() { }
62
63 void set_ref_processor_internal(ReferenceProcessor* rp) { _ref_processor = rp; }
64
65 public:
66 ReferenceProcessor* ref_processor() const { return _ref_processor; }
67
68 // If the do_metadata functions return "true",
69 // we invoke the following when running oop_iterate():
70 //
71 // 1) do_klass on the header klass pointer.
72 // 2) do_klass on the klass pointer in the mirrors.
73 // 3) do_cld on the class loader data in class loaders.
74 //
75 // The virtual (without suffix) and the non-virtual (with _nv suffix) need
76 // to be updated together, or else the devirtualization will break.
77 //
78 // Providing default implementations of the _nv functions unfortunately
79 // removes the compile-time safeness, but reduces the clutter for the
80 // ExtendedOopClosures that don't need to walk the metadata.
81 // Currently, only CMS and G1 need these.
82
83 bool do_metadata_nv() { return false; }
84 virtual bool do_metadata() { return do_metadata_nv(); }
85
86 void do_klass_nv(Klass* k) { ShouldNotReachHere(); }
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 *
47 virtual void do_oop(oop* o) = 0;
48 virtual void do_oop(narrowOop* o) = 0;
49 };
50
51 // ExtendedOopClosure adds extra code to be run during oop iterations.
52 // This is needed by the GC and is extracted to a separate type to not
53 // pollute the OopClosure interface.
54 class ExtendedOopClosure : public OopClosure {
55 private:
56 ReferenceProcessor* _ref_processor;
57
58 protected:
59 ExtendedOopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { }
60 ExtendedOopClosure() : _ref_processor(NULL) { }
61 ~ExtendedOopClosure() { }
62
63 void set_ref_processor_internal(ReferenceProcessor* rp) { _ref_processor = rp; }
64
65 public:
66 ReferenceProcessor* ref_processor() const { return _ref_processor; }
67
68 // Iteration of InstanceRefKlasses differ depending on the closure,
69 // the below enum describes the different alternatives.
70 enum ReferenceIterationMode {
71 DO_DISCOVERY, // Tries to discover references
72 DO_FIELDS // Apply closure to all fields
73 };
74
75 // The current default iteration mode is to do discovery.
76 virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERY; }
77
78 // If the do_metadata functions return "true",
79 // we invoke the following when running oop_iterate():
80 //
81 // 1) do_klass on the header klass pointer.
82 // 2) do_klass on the klass pointer in the mirrors.
83 // 3) do_cld on the class loader data in class loaders.
84 //
85 // The virtual (without suffix) and the non-virtual (with _nv suffix) need
86 // to be updated together, or else the devirtualization will break.
87 //
88 // Providing default implementations of the _nv functions unfortunately
89 // removes the compile-time safeness, but reduces the clutter for the
90 // ExtendedOopClosures that don't need to walk the metadata.
91 // Currently, only CMS and G1 need these.
92
93 bool do_metadata_nv() { return false; }
94 virtual bool do_metadata() { return do_metadata_nv(); }
95
96 void do_klass_nv(Klass* k) { ShouldNotReachHere(); }
|