Wed, 30 Mar 2011 07:47:19 -0700
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
Reviewed-by: kvn, dcubed
1 /*
2 * Copyright (c) 2011, 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 *
23 */
25 #ifndef SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
26 #define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
28 #include "oops/instanceKlass.hpp"
30 // An instanceMirrorKlass is a specialized instanceKlass for
31 // java.lang.Class instances. These instances are special because
32 // they contain the static fields of the class in addition to the
33 // normal fields of Class. This means they are variable sized
34 // instances and need special logic for computing their size and for
35 // iteration of their oops.
38 class instanceMirrorKlass: public instanceKlass {
39 friend class VMStructs;
41 private:
42 static int _offset_of_static_fields;
44 public:
45 // Type testing
46 bool oop_is_instanceMirror() const { return true; }
48 // Casting from klassOop
49 static instanceMirrorKlass* cast(klassOop k) {
50 assert(k->klass_part()->oop_is_instanceMirror(), "cast to instanceMirrorKlass");
51 return (instanceMirrorKlass*) k->klass_part();
52 }
54 // Returns the size of the instance including the extra static fields.
55 virtual int oop_size(oop obj) const;
57 // Static field offset is an offset into the Heap, should be converted by
58 // based on UseCompressedOop for traversal
59 static HeapWord* start_of_static_fields(oop obj) {
60 return (HeapWord*)((intptr_t)obj + offset_of_static_fields());
61 }
63 static void init_offset_of_static_fields() {
64 // Cache the offset of the static fields in the Class instance
65 assert(_offset_of_static_fields == 0, "once");
66 _offset_of_static_fields = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
67 }
69 static int offset_of_static_fields() {
70 return _offset_of_static_fields;
71 }
73 int compute_static_oop_field_count(oop obj);
75 // Given a Klass return the size of the instance
76 int instance_size(KlassHandle k);
78 // allocation
79 DEFINE_ALLOCATE_PERMANENT(instanceMirrorKlass);
80 instanceOop allocate_instance(KlassHandle k, TRAPS);
82 // Garbage collection
83 int oop_adjust_pointers(oop obj);
84 void oop_follow_contents(oop obj);
86 // Parallel Scavenge and Parallel Old
87 PARALLEL_GC_DECLS
89 int oop_oop_iterate(oop obj, OopClosure* blk) {
90 return oop_oop_iterate_v(obj, blk);
91 }
92 int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
93 return oop_oop_iterate_v_m(obj, blk, mr);
94 }
96 #define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \
97 int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk); \
98 int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);
100 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
101 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
103 #ifndef SERIALGC
104 #define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \
105 int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);
107 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
108 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
109 #endif // !SERIALGC
110 };
112 #endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP