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_MEMORY_METASPACE_ITERATOR_HPP
26 #define SHARE_VM_MEMORY_METASPACE_ITERATOR_HPP
27
28 #include "logging/log.hpp"
29 #include "memory/allocation.hpp"
30 #include "oops/array.hpp"
31 #include "utilities/growableArray.hpp"
32 #include "utilities/hashtable.hpp"
33
34 // The metadata hierarchy is separate from the oop hierarchy
35 class MetaspaceObj; // no C++ vtable
36 //class Array; // no C++ vtable
37 class Annotations; // no C++ vtable
38 class ConstantPoolCache; // no C++ vtable
39 class ConstMethod; // no C++ vtable
40 class MethodCounters; // no C++ vtable
41 class Symbol; // no C++ vtable
42 class Metadata; // has C++ vtable (so do all subclasses)
43 class ConstantPool;
44 class MethodData;
45 class Method;
46 class Klass;
47 class InstanceKlass;
48 class InstanceMirrorKlass;
49 class InstanceClassLoaderKlass;
50 class InstanceRefKlass;
51 class ArrayKlass;
52 class ObjArrayKlass;
250
251 // If the above function doesn't match (mpp is not an Array<> type), then
252 // this will be matched by default.
253 template <class T> void push(T** mpp, Writability w = _default) {
254 ObjectRef<T> ref(mpp);
255 push_impl(&ref, w);
256 }
257 };
258
259 // This is a special MetaspaceClosure that visits each unique MetaspaceObj once.
260 class UniqueMetaspaceClosure : public MetaspaceClosure {
261 // Do not override. Returns true if we are discovering ref->obj() for the first time.
262 virtual bool do_ref(Ref* ref, bool read_only);
263
264 public:
265 // Gets called the first time we discover an object.
266 virtual void do_unique_ref(Ref* ref, bool read_only) = 0;
267 UniqueMetaspaceClosure() : _has_been_visited(15889) {}
268
269 private:
270 KVHashtable<address, bool> _has_been_visited;
271 };
272
273 #endif // SHARE_VM_MEMORY_METASPACE_ITERATOR_HPP
|
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_MEMORY_METASPACE_ITERATOR_HPP
26 #define SHARE_VM_MEMORY_METASPACE_ITERATOR_HPP
27
28 #include "logging/log.hpp"
29 #include "memory/allocation.hpp"
30 #include "oops/array.hpp"
31 #include "utilities/growableArray.hpp"
32 #include "utilities/hashtable.inline.hpp"
33
34 // The metadata hierarchy is separate from the oop hierarchy
35 class MetaspaceObj; // no C++ vtable
36 //class Array; // no C++ vtable
37 class Annotations; // no C++ vtable
38 class ConstantPoolCache; // no C++ vtable
39 class ConstMethod; // no C++ vtable
40 class MethodCounters; // no C++ vtable
41 class Symbol; // no C++ vtable
42 class Metadata; // has C++ vtable (so do all subclasses)
43 class ConstantPool;
44 class MethodData;
45 class Method;
46 class Klass;
47 class InstanceKlass;
48 class InstanceMirrorKlass;
49 class InstanceClassLoaderKlass;
50 class InstanceRefKlass;
51 class ArrayKlass;
52 class ObjArrayKlass;
250
251 // If the above function doesn't match (mpp is not an Array<> type), then
252 // this will be matched by default.
253 template <class T> void push(T** mpp, Writability w = _default) {
254 ObjectRef<T> ref(mpp);
255 push_impl(&ref, w);
256 }
257 };
258
259 // This is a special MetaspaceClosure that visits each unique MetaspaceObj once.
260 class UniqueMetaspaceClosure : public MetaspaceClosure {
261 // Do not override. Returns true if we are discovering ref->obj() for the first time.
262 virtual bool do_ref(Ref* ref, bool read_only);
263
264 public:
265 // Gets called the first time we discover an object.
266 virtual void do_unique_ref(Ref* ref, bool read_only) = 0;
267 UniqueMetaspaceClosure() : _has_been_visited(15889) {}
268
269 private:
270 KVHashtable<address, bool, mtInternal> _has_been_visited;
271 };
272
273 #endif // SHARE_VM_MEMORY_METASPACE_ITERATOR_HPP
|