comparison src/share/vm/oops/cpCacheKlass.cpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children ba764ed4b6f2
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 1998-2006 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 #include "incls/_precompiled.incl"
26 #include "incls/_cpCacheKlass.cpp.incl"
27
28
29 int constantPoolCacheKlass::oop_size(oop obj) const {
30 assert(obj->is_constantPoolCache(), "must be constantPool");
31 return constantPoolCacheOop(obj)->object_size();
32 }
33
34
35 constantPoolCacheOop constantPoolCacheKlass::allocate(int length, TRAPS) {
36 // allocate memory
37 int size = constantPoolCacheOopDesc::object_size(length);
38 KlassHandle klass (THREAD, as_klassOop());
39 constantPoolCacheOop cache = (constantPoolCacheOop)
40 CollectedHeap::permanent_array_allocate(klass, size, length, CHECK_NULL);
41 cache->set_constant_pool(NULL);
42 return cache;
43 }
44
45
46 klassOop constantPoolCacheKlass::create_klass(TRAPS) {
47 constantPoolCacheKlass o;
48 KlassHandle klassklass(THREAD, Universe::arrayKlassKlassObj());
49 arrayKlassHandle k = base_create_array_klass(o.vtbl_value(), header_size(), klassklass, CHECK_NULL);
50 KlassHandle super (THREAD, k->super());
51 complete_create_array_klass(k, super, CHECK_NULL);
52 return k();
53 }
54
55
56 void constantPoolCacheKlass::oop_follow_contents(oop obj) {
57 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
58 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
59 // Performance tweak: We skip iterating over the klass pointer since we
60 // know that Universe::constantPoolCacheKlassObj never moves.
61 // gc of constant pool cache instance variables
62 MarkSweep::mark_and_push((oop*)cache->constant_pool_addr());
63 // gc of constant pool cache entries
64 int i = cache->length();
65 while (i-- > 0) cache->entry_at(i)->follow_contents();
66 }
67
68 #ifndef SERIALGC
69 void constantPoolCacheKlass::oop_follow_contents(ParCompactionManager* cm,
70 oop obj) {
71 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
72 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
73 // Performance tweak: We skip iterating over the klass pointer since we
74 // know that Universe::constantPoolCacheKlassObj never moves.
75 // gc of constant pool cache instance variables
76 PSParallelCompact::mark_and_push(cm, (oop*)cache->constant_pool_addr());
77 // gc of constant pool cache entries
78 int i = cache->length();
79 while (i-- > 0) cache->entry_at(i)->follow_contents(cm);
80 }
81 #endif // SERIALGC
82
83
84 int constantPoolCacheKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
85 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
86 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
87 // Get size before changing pointers.
88 // Don't call size() or oop_size() since that is a virtual call.
89 int size = cache->object_size();
90 // Performance tweak: We skip iterating over the klass pointer since we
91 // know that Universe::constantPoolCacheKlassObj never moves.
92 // iteration over constant pool cache instance variables
93 blk->do_oop((oop*)cache->constant_pool_addr());
94 // iteration over constant pool cache entries
95 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate(blk);
96 return size;
97 }
98
99
100 int constantPoolCacheKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
101 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
102 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
103 // Get size before changing pointers.
104 // Don't call size() or oop_size() since that is a virtual call.
105 int size = cache->object_size();
106 // Performance tweak: We skip iterating over the klass pointer since we
107 // know that Universe::constantPoolCacheKlassObj never moves.
108 // iteration over constant pool cache instance variables
109 oop* addr = (oop*)cache->constant_pool_addr();
110 if (mr.contains(addr)) blk->do_oop(addr);
111 // iteration over constant pool cache entries
112 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate_m(blk, mr);
113 return size;
114 }
115
116
117 int constantPoolCacheKlass::oop_adjust_pointers(oop obj) {
118 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
119 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
120 // Get size before changing pointers.
121 // Don't call size() or oop_size() since that is a virtual call.
122 int size = cache->object_size();
123 // Performance tweak: We skip iterating over the klass pointer since we
124 // know that Universe::constantPoolCacheKlassObj never moves.
125 // Iteration over constant pool cache instance variables
126 MarkSweep::adjust_pointer((oop*)cache->constant_pool_addr());
127 // iteration over constant pool cache entries
128 for (int i = 0; i < cache->length(); i++)
129 cache->entry_at(i)->adjust_pointers();
130 return size;
131 }
132
133 #ifndef SERIALGC
134 void constantPoolCacheKlass::oop_copy_contents(PSPromotionManager* pm,
135 oop obj) {
136 assert(obj->is_constantPoolCache(), "should be constant pool");
137 }
138
139 void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
140 oop obj) {
141 assert(obj->is_constantPoolCache(), "should be constant pool");
142 }
143
144 int
145 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
146 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
147 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
148
149 // Iteration over constant pool cache instance variables
150 PSParallelCompact::adjust_pointer((oop*)cache->constant_pool_addr());
151
152 // iteration over constant pool cache entries
153 for (int i = 0; i < cache->length(); ++i) {
154 cache->entry_at(i)->update_pointers();
155 }
156
157 return cache->object_size();
158 }
159
160 int
161 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
162 HeapWord* beg_addr,
163 HeapWord* end_addr) {
164 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
165 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
166
167 // Iteration over constant pool cache instance variables
168 oop* p;
169 p = (oop*)cache->constant_pool_addr();
170 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
171
172 // Iteration over constant pool cache entries
173 for (int i = 0; i < cache->length(); ++i) {
174 cache->entry_at(i)->update_pointers(beg_addr, end_addr);
175 }
176 return cache->object_size();
177 }
178 #endif // SERIALGC
179
180 #ifndef PRODUCT
181
182 void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) {
183 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
184 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
185 // super print
186 arrayKlass::oop_print_on(obj, st);
187 // print constant pool cache entries
188 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->print(st, i);
189 }
190
191 #endif
192
193 void constantPoolCacheKlass::oop_verify_on(oop obj, outputStream* st) {
194 guarantee(obj->is_constantPoolCache(), "obj must be constant pool cache");
195 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
196 // super verify
197 arrayKlass::oop_verify_on(obj, st);
198 // print constant pool cache entries
199 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->verify(st);
200 }
201
202
203 const char* constantPoolCacheKlass::internal_name() const {
204 return "{constant pool cache}";
205 }