Tue, 24 Jun 2008 16:00:14 -0700
6718676: putback for 6604014 is incomplete
Reviewed-by: kvn, jrose
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 */
25 #include "incls/_precompiled.incl"
26 #include "incls/_cpCacheKlass.cpp.incl"
29 int constantPoolCacheKlass::oop_size(oop obj) const {
30 assert(obj->is_constantPoolCache(), "must be constantPool");
31 return constantPoolCacheOop(obj)->object_size();
32 }
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_obj_allocate(klass, size, CHECK_NULL);
41 cache->set_length(length);
42 cache->set_constant_pool(NULL);
43 return cache;
44 }
46 klassOop constantPoolCacheKlass::create_klass(TRAPS) {
47 constantPoolCacheKlass o;
48 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
49 KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL);
50 // Make sure size calculation is right
51 assert(k()->size() == align_object_size(header_size()), "wrong size for object");
52 java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
53 return k();
54 }
57 void constantPoolCacheKlass::oop_follow_contents(oop obj) {
58 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
59 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
60 // Performance tweak: We skip iterating over the klass pointer since we
61 // know that Universe::constantPoolCacheKlassObj never moves.
62 // gc of constant pool cache instance variables
63 MarkSweep::mark_and_push((oop*)cache->constant_pool_addr());
64 // gc of constant pool cache entries
65 int i = cache->length();
66 while (i-- > 0) cache->entry_at(i)->follow_contents();
67 }
69 #ifndef SERIALGC
70 void constantPoolCacheKlass::oop_follow_contents(ParCompactionManager* cm,
71 oop obj) {
72 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
73 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
74 // Performance tweak: We skip iterating over the klass pointer since we
75 // know that Universe::constantPoolCacheKlassObj never moves.
76 // gc of constant pool cache instance variables
77 PSParallelCompact::mark_and_push(cm, (oop*)cache->constant_pool_addr());
78 // gc of constant pool cache entries
79 int i = cache->length();
80 while (i-- > 0) cache->entry_at(i)->follow_contents(cm);
81 }
82 #endif // SERIALGC
85 int constantPoolCacheKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
86 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
87 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
88 // Get size before changing pointers.
89 // Don't call size() or oop_size() since that is a virtual call.
90 int size = cache->object_size();
91 // Performance tweak: We skip iterating over the klass pointer since we
92 // know that Universe::constantPoolCacheKlassObj never moves.
93 // iteration over constant pool cache instance variables
94 blk->do_oop((oop*)cache->constant_pool_addr());
95 // iteration over constant pool cache entries
96 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate(blk);
97 return size;
98 }
101 int constantPoolCacheKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
102 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
103 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
104 // Get size before changing pointers.
105 // Don't call size() or oop_size() since that is a virtual call.
106 int size = cache->object_size();
107 // Performance tweak: We skip iterating over the klass pointer since we
108 // know that Universe::constantPoolCacheKlassObj never moves.
109 // iteration over constant pool cache instance variables
110 oop* addr = (oop*)cache->constant_pool_addr();
111 if (mr.contains(addr)) blk->do_oop(addr);
112 // iteration over constant pool cache entries
113 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate_m(blk, mr);
114 return size;
115 }
118 int constantPoolCacheKlass::oop_adjust_pointers(oop obj) {
119 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
120 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
121 // Get size before changing pointers.
122 // Don't call size() or oop_size() since that is a virtual call.
123 int size = cache->object_size();
124 // Performance tweak: We skip iterating over the klass pointer since we
125 // know that Universe::constantPoolCacheKlassObj never moves.
126 // Iteration over constant pool cache instance variables
127 MarkSweep::adjust_pointer((oop*)cache->constant_pool_addr());
128 // iteration over constant pool cache entries
129 for (int i = 0; i < cache->length(); i++)
130 cache->entry_at(i)->adjust_pointers();
131 return size;
132 }
134 #ifndef SERIALGC
135 void constantPoolCacheKlass::oop_copy_contents(PSPromotionManager* pm,
136 oop obj) {
137 assert(obj->is_constantPoolCache(), "should be constant pool");
138 }
140 void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
141 oop obj) {
142 assert(obj->is_constantPoolCache(), "should be constant pool");
143 }
145 int
146 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
147 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
148 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
150 // Iteration over constant pool cache instance variables
151 PSParallelCompact::adjust_pointer((oop*)cache->constant_pool_addr());
153 // iteration over constant pool cache entries
154 for (int i = 0; i < cache->length(); ++i) {
155 cache->entry_at(i)->update_pointers();
156 }
158 return cache->object_size();
159 }
161 int
162 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
163 HeapWord* beg_addr,
164 HeapWord* end_addr) {
165 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
166 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
168 // Iteration over constant pool cache instance variables
169 oop* p;
170 p = (oop*)cache->constant_pool_addr();
171 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
173 // Iteration over constant pool cache entries
174 for (int i = 0; i < cache->length(); ++i) {
175 cache->entry_at(i)->update_pointers(beg_addr, end_addr);
176 }
177 return cache->object_size();
178 }
179 #endif // SERIALGC
181 #ifndef PRODUCT
183 void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) {
184 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
185 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
186 // super print
187 Klass::oop_print_on(obj, st);
188 // print constant pool cache entries
189 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->print(st, i);
190 }
192 #endif
194 void constantPoolCacheKlass::oop_verify_on(oop obj, outputStream* st) {
195 guarantee(obj->is_constantPoolCache(), "obj must be constant pool cache");
196 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
197 // super verify
198 Klass::oop_verify_on(obj, st);
199 // print constant pool cache entries
200 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->verify(st);
201 }
204 const char* constantPoolCacheKlass::internal_name() const {
205 return "{constant pool cache}";
206 }