0N/A/*
1879N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_MEMORY_CLASSIFY_HPP
1879N/A#define SHARE_VM_MEMORY_CLASSIFY_HPP
1879N/A
1879N/A#include "oops/oop.inline.hpp"
1879N/A
0N/Atypedef enum oop_type {
0N/A unknown_type,
0N/A instance_type,
0N/A instanceRef_type,
0N/A objArray_type,
0N/A symbol_type,
0N/A klass_type,
0N/A instanceKlass_type,
0N/A method_type,
0N/A constMethod_type,
0N/A methodData_type,
0N/A constantPool_type,
0N/A constantPoolCache_type,
0N/A typeArray_type,
0N/A compiledICHolder_type,
0N/A number_object_types
0N/A} object_type;
0N/A
0N/A
0N/A// Classify objects by type and keep counts.
0N/A// Print the count and space taken for each type.
0N/A
0N/A
0N/Aclass ClassifyObjectClosure : public ObjectClosure {
0N/Aprivate:
0N/A
0N/A static const char* object_type_name[number_object_types];
0N/A
0N/A int total_object_count;
0N/A size_t total_object_size;
0N/A int object_count[number_object_types];
0N/A size_t object_size[number_object_types];
0N/A
0N/Apublic:
0N/A ClassifyObjectClosure() { reset(); }
0N/A void reset();
0N/A void do_object(oop obj);
0N/A static object_type classify_object(oop obj, bool count);
0N/A size_t print();
0N/A};
0N/A
0N/A
0N/A// Count objects using the alloc_count field in the object's klass
0N/A// object.
0N/A
0N/Aclass ClassifyInstanceKlassClosure : public ClassifyObjectClosure {
0N/Aprivate:
0N/A int total_instances;
0N/Apublic:
0N/A ClassifyInstanceKlassClosure() { reset(); }
0N/A void reset();
0N/A void print();
0N/A void do_object(oop obj);
0N/A};
0N/A
0N/A
0N/A// Clear the alloc_count fields in all classes so that the count can be
0N/A// restarted.
0N/A
0N/Aclass ClearAllocCountClosure : public ObjectClosure {
0N/Apublic:
0N/A void do_object(oop obj) {
0N/A if (obj->is_klass()) {
0N/A Klass* k = Klass::cast((klassOop)obj);
0N/A k->set_alloc_count(0);
0N/A }
0N/A }
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_MEMORY_CLASSIFY_HPP