src/share/vm/memory/classify.hpp

Fri, 15 Apr 2011 09:36:28 -0400

author
coleenp
date
Fri, 15 Apr 2011 09:36:28 -0400
changeset 2777
8ce625481709
parent 2314
f95d63e2154a
permissions
-rw-r--r--

7032407: Crash in LinkResolver::runtime_resolve_virtual_method()
Summary: Make CDS reorder vtables so that dump time vtables match run time order, so when redefine classes reinitializes them, they aren't in the wrong order.
Reviewed-by: dcubed, acorn

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_MEMORY_CLASSIFY_HPP
stefank@2314 26 #define SHARE_VM_MEMORY_CLASSIFY_HPP
stefank@2314 27
stefank@2314 28 #include "oops/oop.inline.hpp"
stefank@2314 29
duke@435 30 typedef enum oop_type {
duke@435 31 unknown_type,
duke@435 32 instance_type,
duke@435 33 instanceRef_type,
duke@435 34 objArray_type,
duke@435 35 symbol_type,
duke@435 36 klass_type,
duke@435 37 instanceKlass_type,
duke@435 38 method_type,
duke@435 39 constMethod_type,
duke@435 40 methodData_type,
duke@435 41 constantPool_type,
duke@435 42 constantPoolCache_type,
duke@435 43 typeArray_type,
duke@435 44 compiledICHolder_type,
duke@435 45 number_object_types
duke@435 46 } object_type;
duke@435 47
duke@435 48
duke@435 49 // Classify objects by type and keep counts.
duke@435 50 // Print the count and space taken for each type.
duke@435 51
duke@435 52
duke@435 53 class ClassifyObjectClosure : public ObjectClosure {
duke@435 54 private:
duke@435 55
duke@435 56 static const char* object_type_name[number_object_types];
duke@435 57
duke@435 58 int total_object_count;
duke@435 59 size_t total_object_size;
duke@435 60 int object_count[number_object_types];
duke@435 61 size_t object_size[number_object_types];
duke@435 62
duke@435 63 public:
duke@435 64 ClassifyObjectClosure() { reset(); }
duke@435 65 void reset();
duke@435 66 void do_object(oop obj);
duke@435 67 static object_type classify_object(oop obj, bool count);
duke@435 68 size_t print();
duke@435 69 };
duke@435 70
duke@435 71
duke@435 72 // Count objects using the alloc_count field in the object's klass
duke@435 73 // object.
duke@435 74
duke@435 75 class ClassifyInstanceKlassClosure : public ClassifyObjectClosure {
duke@435 76 private:
duke@435 77 int total_instances;
duke@435 78 public:
duke@435 79 ClassifyInstanceKlassClosure() { reset(); }
duke@435 80 void reset();
duke@435 81 void print();
duke@435 82 void do_object(oop obj);
duke@435 83 };
duke@435 84
duke@435 85
duke@435 86 // Clear the alloc_count fields in all classes so that the count can be
duke@435 87 // restarted.
duke@435 88
duke@435 89 class ClearAllocCountClosure : public ObjectClosure {
duke@435 90 public:
duke@435 91 void do_object(oop obj) {
duke@435 92 if (obj->is_klass()) {
duke@435 93 Klass* k = Klass::cast((klassOop)obj);
duke@435 94 k->set_alloc_count(0);
duke@435 95 }
duke@435 96 }
duke@435 97 };
stefank@2314 98
stefank@2314 99 #endif // SHARE_VM_MEMORY_CLASSIFY_HPP

mercurial