annotate src/share/vm/oops/cpCacheKlass.cpp @ 47:2c106685d6d0

6497639: 4/3 Profiling Swing application caused JVM crash Summary: Make RedefineClasses() interoperate better with class sharing. Reviewed-by: sspitsyn, jmasa
author dcubed
date Wed, 12 Mar 2008 18:06:50 -0700
parents a61af66fc99e
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_cpCacheKlass.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 int constantPoolCacheKlass::oop_size(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
30 assert(obj->is_constantPoolCache(), "must be constantPool");
a61af66fc99e Initial load
duke
parents:
diff changeset
31 return constantPoolCacheOop(obj)->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
32 }
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 constantPoolCacheOop constantPoolCacheKlass::allocate(int length, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // allocate memory
a61af66fc99e Initial load
duke
parents:
diff changeset
37 int size = constantPoolCacheOopDesc::object_size(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
38 KlassHandle klass (THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
39 constantPoolCacheOop cache = (constantPoolCacheOop)
a61af66fc99e Initial load
duke
parents:
diff changeset
40 CollectedHeap::permanent_array_allocate(klass, size, length, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
41 cache->set_constant_pool(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 return cache;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 klassOop constantPoolCacheKlass::create_klass(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 constantPoolCacheKlass o;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 KlassHandle klassklass(THREAD, Universe::arrayKlassKlassObj());
a61af66fc99e Initial load
duke
parents:
diff changeset
49 arrayKlassHandle k = base_create_array_klass(o.vtbl_value(), header_size(), klassklass, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 KlassHandle super (THREAD, k->super());
a61af66fc99e Initial load
duke
parents:
diff changeset
51 complete_create_array_klass(k, super, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 return k();
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 void constantPoolCacheKlass::oop_follow_contents(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
58 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // know that Universe::constantPoolCacheKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // gc of constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
62 MarkSweep::mark_and_push((oop*)cache->constant_pool_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // gc of constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
64 int i = cache->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 while (i-- > 0) cache->entry_at(i)->follow_contents();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
69 void constantPoolCacheKlass::oop_follow_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
70 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // know that Universe::constantPoolCacheKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // gc of constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
76 PSParallelCompact::mark_and_push(cm, (oop*)cache->constant_pool_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // gc of constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
78 int i = cache->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 while (i-- > 0) cache->entry_at(i)->follow_contents(cm);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int constantPoolCacheKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int size = cache->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // know that Universe::constantPoolCacheKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // iteration over constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
93 blk->do_oop((oop*)cache->constant_pool_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // iteration over constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
95 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate(blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 int constantPoolCacheKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 int size = cache->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // know that Universe::constantPoolCacheKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // iteration over constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
109 oop* addr = (oop*)cache->constant_pool_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (mr.contains(addr)) blk->do_oop(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // iteration over constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
112 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate_m(blk, mr);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 int constantPoolCacheKlass::oop_adjust_pointers(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
119 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
122 int size = cache->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // know that Universe::constantPoolCacheKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Iteration over constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
126 MarkSweep::adjust_pointer((oop*)cache->constant_pool_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // iteration over constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
128 for (int i = 0; i < cache->length(); i++)
a61af66fc99e Initial load
duke
parents:
diff changeset
129 cache->entry_at(i)->adjust_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
134 void constantPoolCacheKlass::oop_copy_contents(PSPromotionManager* pm,
a61af66fc99e Initial load
duke
parents:
diff changeset
135 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 assert(obj->is_constantPoolCache(), "should be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
a61af66fc99e Initial load
duke
parents:
diff changeset
140 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 assert(obj->is_constantPoolCache(), "should be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 int
a61af66fc99e Initial load
duke
parents:
diff changeset
145 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
147 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Iteration over constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
150 PSParallelCompact::adjust_pointer((oop*)cache->constant_pool_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // iteration over constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
153 for (int i = 0; i < cache->length(); ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 cache->entry_at(i)->update_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return cache->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 int
a61af66fc99e Initial load
duke
parents:
diff changeset
161 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
162 HeapWord* beg_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
163 HeapWord* end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
165 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // Iteration over constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
168 oop* p;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 p = (oop*)cache->constant_pool_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
170 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // Iteration over constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
173 for (int i = 0; i < cache->length(); ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 cache->entry_at(i)->update_pointers(beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 return cache->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
184 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // super print
a61af66fc99e Initial load
duke
parents:
diff changeset
186 arrayKlass::oop_print_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // print constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
188 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->print(st, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 void constantPoolCacheKlass::oop_verify_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 guarantee(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
195 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // super verify
a61af66fc99e Initial load
duke
parents:
diff changeset
197 arrayKlass::oop_verify_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // print constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
199 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->verify(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 const char* constantPoolCacheKlass::internal_name() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 return "{constant pool cache}";
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }