Mercurial > hg > truffle
comparison src/share/vm/oops/instanceMirrorKlass.hpp @ 2376:c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
Reviewed-by: kvn, coleenp, twisti, stefank
author | never |
---|---|
date | Fri, 18 Mar 2011 16:00:34 -0700 |
parents | |
children | 63997f575155 |
comparison
equal
deleted
inserted
replaced
2375:d673ef06fe96 | 2376:c7f3d0b4570f |
---|---|
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 */ | |
24 | |
25 #ifndef SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP | |
26 #define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP | |
27 | |
28 #include "oops/instanceKlass.hpp" | |
29 | |
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. | |
36 | |
37 | |
38 class instanceMirrorKlass: public instanceKlass { | |
39 private: | |
40 static int _offset_of_static_fields; | |
41 | |
42 public: | |
43 // Type testing | |
44 bool oop_is_instanceMirror() const { return true; } | |
45 | |
46 // Casting from klassOop | |
47 static instanceMirrorKlass* cast(klassOop k) { | |
48 assert(k->klass_part()->oop_is_instanceMirror(), "cast to instanceMirrorKlass"); | |
49 return (instanceMirrorKlass*) k->klass_part(); | |
50 } | |
51 | |
52 // Returns the size of the instance including the extra static fields. | |
53 virtual int oop_size(oop obj) const; | |
54 | |
55 // Static field offset is an offset into the Heap, should be converted by | |
56 // based on UseCompressedOop for traversal | |
57 static HeapWord* start_of_static_fields(oop obj) { | |
58 return (HeapWord*)((intptr_t)obj + offset_of_static_fields()); | |
59 } | |
60 | |
61 static void init_offset_of_static_fields() { | |
62 // Cache the offset of the static fields in the Class instance | |
63 assert(_offset_of_static_fields == 0, "once"); | |
64 _offset_of_static_fields = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize; | |
65 } | |
66 | |
67 static int offset_of_static_fields() { | |
68 return _offset_of_static_fields; | |
69 } | |
70 | |
71 int compute_static_oop_field_count(oop obj); | |
72 | |
73 // Given a Klass return the size of the instance | |
74 int instance_size(KlassHandle k); | |
75 | |
76 // allocation | |
77 DEFINE_ALLOCATE_PERMANENT(instanceMirrorKlass); | |
78 instanceOop allocate_instance(KlassHandle k, TRAPS); | |
79 | |
80 // Garbage collection | |
81 int oop_adjust_pointers(oop obj); | |
82 void oop_follow_contents(oop obj); | |
83 | |
84 // Parallel Scavenge and Parallel Old | |
85 PARALLEL_GC_DECLS | |
86 | |
87 int oop_oop_iterate(oop obj, OopClosure* blk) { | |
88 return oop_oop_iterate_v(obj, blk); | |
89 } | |
90 int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { | |
91 return oop_oop_iterate_v_m(obj, blk, mr); | |
92 } | |
93 | |
94 #define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \ | |
95 int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk); \ | |
96 int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr); | |
97 | |
98 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL) | |
99 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL) | |
100 | |
101 #ifndef SERIALGC | |
102 #define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \ | |
103 int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk); | |
104 | |
105 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL) | |
106 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL) | |
107 #endif // !SERIALGC | |
108 }; | |
109 | |
110 #endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP |