annotate src/share/vm/classfile/loaderConstraints.cpp @ 1258:38836cf1d8d2

6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails Summary: the guarantee is too strict and the test will fail (incorrectly) if the class is not in the system dictionary but in the placeholders. Reviewed-by: acorn, phh
author tonyp
date Fri, 05 Feb 2010 11:05:50 -0500
parents a61af66fc99e
children 09ac706c2623
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 2003-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/_loaderConstraints.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 LoaderConstraintTable::LoaderConstraintTable(int nof_buckets)
a61af66fc99e Initial load
duke
parents:
diff changeset
29 : Hashtable(nof_buckets, sizeof(LoaderConstraintEntry)) {};
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 LoaderConstraintEntry* LoaderConstraintTable::new_entry(
a61af66fc99e Initial load
duke
parents:
diff changeset
33 unsigned int hash, symbolOop name,
a61af66fc99e Initial load
duke
parents:
diff changeset
34 klassOop klass, int num_loaders,
a61af66fc99e Initial load
duke
parents:
diff changeset
35 int max_loaders) {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 LoaderConstraintEntry* entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 entry = (LoaderConstraintEntry*)Hashtable::new_entry(hash, klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
38 entry->set_name(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
39 entry->set_num_loaders(num_loaders);
a61af66fc99e Initial load
duke
parents:
diff changeset
40 entry->set_max_loaders(max_loaders);
a61af66fc99e Initial load
duke
parents:
diff changeset
41 return entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 void LoaderConstraintTable::oops_do(OopClosure* f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 for (int index = 0; index < table_size(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 for (LoaderConstraintEntry* probe = bucket(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
48 probe != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 probe = probe->next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 f->do_oop((oop*)(probe->name_addr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
51 if (probe->klass() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 f->do_oop((oop*)probe->klass_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 for (int n = 0; n < probe->num_loaders(); n++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 if (probe->loader(n) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 f->do_oop(probe->loader_addr(n));
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // We must keep the symbolOop used in the name alive. We'll use the
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // loaders to decide if a particular entry can be purged.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 void LoaderConstraintTable::always_strong_classes_do(OopClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // We must keep the symbolOop used in the name alive.
a61af66fc99e Initial load
duke
parents:
diff changeset
67 for (int cindex = 0; cindex < table_size(); cindex++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 for (LoaderConstraintEntry* lc_probe = bucket(cindex);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 lc_probe != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 lc_probe = lc_probe->next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert (lc_probe->name() != NULL, "corrupted loader constraint table");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 blk->do_oop((oop*)lc_probe->name_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // The loaderConstraintTable must always be accessed with the
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // SystemDictionary lock held. This is true even for readers as
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // entries in the table could be being dynamically resized.
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint(
a61af66fc99e Initial load
duke
parents:
diff changeset
83 symbolHandle name, Handle loader) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 unsigned int hash = compute_hash(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 int index = hash_to_index(hash);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 LoaderConstraintEntry** pp = bucket_addr(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 while (*pp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 LoaderConstraintEntry* p = *pp;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (p->hash() == hash) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 if (p->name() == name()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 for (int i = p->num_loaders() - 1; i >= 0; i--) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (p->loader(i) == loader()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 return pp;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 pp = p->next_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 return pp;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void LoaderConstraintTable::purge_loader_constraints(BoolObjectClosure* is_alive) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint")
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Remove unloaded entries from constraint table
a61af66fc99e Initial load
duke
parents:
diff changeset
108 for (int index = 0; index < table_size(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 LoaderConstraintEntry** p = bucket_addr(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 while(*p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 LoaderConstraintEntry* probe = *p;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 klassOop klass = probe->klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // Remove klass that is no longer alive
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (klass != NULL && !is_alive->do_object_b(klass)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 probe->set_klass(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if (TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 tty->print_cr("[Purging class object from constraint for name %s,"
a61af66fc99e Initial load
duke
parents:
diff changeset
119 " loader list:",
a61af66fc99e Initial load
duke
parents:
diff changeset
120 probe->name()->as_C_string());
a61af66fc99e Initial load
duke
parents:
diff changeset
121 for (int i = 0; i < probe->num_loaders(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 tty->print_cr("[ [%d]: %s", i,
a61af66fc99e Initial load
duke
parents:
diff changeset
123 SystemDictionary::loader_name(probe->loader(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // Remove entries no longer alive from loader array
a61af66fc99e Initial load
duke
parents:
diff changeset
128 int n = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 while (n < probe->num_loaders()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 if (probe->loader(n) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (!is_alive->do_object_b(probe->loader(n))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 if (TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 tty->print_cr("[Purging loader %s from constraint for name %s",
a61af66fc99e Initial load
duke
parents:
diff changeset
135 SystemDictionary::loader_name(probe->loader(n)),
a61af66fc99e Initial load
duke
parents:
diff changeset
136 probe->name()->as_C_string()
a61af66fc99e Initial load
duke
parents:
diff changeset
137 );
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // Compact array
a61af66fc99e Initial load
duke
parents:
diff changeset
141 int num = probe->num_loaders() - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 probe->set_num_loaders(num);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 probe->set_loader(n, probe->loader(num));
a61af66fc99e Initial load
duke
parents:
diff changeset
144 probe->set_loader(num, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 if (TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 tty->print_cr("[New loader list:");
a61af66fc99e Initial load
duke
parents:
diff changeset
149 for (int i = 0; i < probe->num_loaders(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 tty->print_cr("[ [%d]: %s", i,
a61af66fc99e Initial load
duke
parents:
diff changeset
151 SystemDictionary::loader_name(probe->loader(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 continue; // current element replaced, so restart without
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // incrementing n
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159 n++;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // Check whether entry should be purged
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (probe->num_loaders() < 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 if (TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 tty->print("[Purging complete constraint for name %s\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
166 probe->name()->as_C_string());
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Purge entry
a61af66fc99e Initial load
duke
parents:
diff changeset
170 *p = probe->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
171 FREE_C_HEAP_ARRAY(oop, probe->loaders());
a61af66fc99e Initial load
duke
parents:
diff changeset
172 free_entry(probe);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
175 assert(is_alive->do_object_b(probe->name()), "name should be live");
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (probe->klass() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 assert(is_alive->do_object_b(probe->klass()), "klass should be live");
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 for (n = 0; n < probe->num_loaders(); n++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 if (probe->loader(n) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 assert(is_alive->do_object_b(probe->loader(n)), "loader should be live");
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // Go to next entry
a61af66fc99e Initial load
duke
parents:
diff changeset
186 p = probe->next_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 bool LoaderConstraintTable::add_entry(symbolHandle class_name,
a61af66fc99e Initial load
duke
parents:
diff changeset
193 klassOop klass1, Handle class_loader1,
a61af66fc99e Initial load
duke
parents:
diff changeset
194 klassOop klass2, Handle class_loader2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 int failure_code = 0; // encode different reasons for failing
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 if (klass1 != NULL && klass2 != NULL && klass1 != klass2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 failure_code = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 klassOop klass = klass1 != NULL ? klass1 : klass2;
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 LoaderConstraintEntry** pp1 = find_loader_constraint(class_name,
a61af66fc99e Initial load
duke
parents:
diff changeset
203 class_loader1);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if (*pp1 != NULL && (*pp1)->klass() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 if (klass != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 if (klass != (*pp1)->klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 failure_code = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 klass = (*pp1)->klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 LoaderConstraintEntry** pp2 = find_loader_constraint(class_name,
a61af66fc99e Initial load
duke
parents:
diff changeset
215 class_loader2);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if (*pp2 != NULL && (*pp2)->klass() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if (klass != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 if (klass != (*pp2)->klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 failure_code = 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 klass = (*pp2)->klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 if (failure_code == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if (*pp1 == NULL && *pp2 == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 unsigned int hash = compute_hash(class_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 int index = hash_to_index(hash);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 LoaderConstraintEntry* p;
a61af66fc99e Initial load
duke
parents:
diff changeset
231 p = new_entry(hash, class_name(), klass, 2, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 p->set_loaders(NEW_C_HEAP_ARRAY(oop, 2));
a61af66fc99e Initial load
duke
parents:
diff changeset
233 p->set_loader(0, class_loader1());
a61af66fc99e Initial load
duke
parents:
diff changeset
234 p->set_loader(1, class_loader2());
a61af66fc99e Initial load
duke
parents:
diff changeset
235 p->set_klass(klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 p->set_next(bucket(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
237 set_entry(index, p);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 if (TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 tty->print("[Adding new constraint for name: %s, loader[0]: %s,"
a61af66fc99e Initial load
duke
parents:
diff changeset
241 " loader[1]: %s ]\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
242 class_name()->as_C_string(),
a61af66fc99e Initial load
duke
parents:
diff changeset
243 SystemDictionary::loader_name(class_loader1()),
a61af66fc99e Initial load
duke
parents:
diff changeset
244 SystemDictionary::loader_name(class_loader2())
a61af66fc99e Initial load
duke
parents:
diff changeset
245 );
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247 } else if (*pp1 == *pp2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 /* constraint already imposed */
a61af66fc99e Initial load
duke
parents:
diff changeset
249 if ((*pp1)->klass() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 (*pp1)->set_klass(klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 if (TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
253 tty->print("[Setting class object in existing constraint for"
a61af66fc99e Initial load
duke
parents:
diff changeset
254 " name: %s and loader %s ]\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
255 class_name()->as_C_string(),
a61af66fc99e Initial load
duke
parents:
diff changeset
256 SystemDictionary::loader_name(class_loader1())
a61af66fc99e Initial load
duke
parents:
diff changeset
257 );
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 assert((*pp1)->klass() == klass, "loader constraints corrupted");
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262 } else if (*pp1 == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 extend_loader_constraint(*pp2, class_loader1, klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 } else if (*pp2 == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 extend_loader_constraint(*pp1, class_loader2, klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 merge_loader_constraints(pp1, pp2, klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 if (failure_code != 0 && TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
274 const char* reason = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
275 switch(failure_code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 case 1: reason = "the class objects presented by loader[0] and loader[1]"
a61af66fc99e Initial load
duke
parents:
diff changeset
277 " are different"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
278 case 2: reason = "the class object presented by loader[0] does not match"
a61af66fc99e Initial load
duke
parents:
diff changeset
279 " the stored class object in the constraint"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
280 case 3: reason = "the class object presented by loader[1] does not match"
a61af66fc99e Initial load
duke
parents:
diff changeset
281 " the stored class object in the constraint"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
282 default: reason = "unknown reason code";
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 tty->print("[Failed to add constraint for name: %s, loader[0]: %s,"
a61af66fc99e Initial load
duke
parents:
diff changeset
285 " loader[1]: %s, Reason: %s ]\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
286 class_name()->as_C_string(),
a61af66fc99e Initial load
duke
parents:
diff changeset
287 SystemDictionary::loader_name(class_loader1()),
a61af66fc99e Initial load
duke
parents:
diff changeset
288 SystemDictionary::loader_name(class_loader2()),
a61af66fc99e Initial load
duke
parents:
diff changeset
289 reason
a61af66fc99e Initial load
duke
parents:
diff changeset
290 );
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 return failure_code == 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // return true if the constraint was updated, false if the constraint is
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // violated
a61af66fc99e Initial load
duke
parents:
diff changeset
299 bool LoaderConstraintTable::check_or_update(instanceKlassHandle k,
a61af66fc99e Initial load
duke
parents:
diff changeset
300 Handle loader,
a61af66fc99e Initial load
duke
parents:
diff changeset
301 symbolHandle name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 LoaderConstraintEntry* p = *(find_loader_constraint(name, loader));
a61af66fc99e Initial load
duke
parents:
diff changeset
303 if (p && p->klass() != NULL && p->klass() != k()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 if (TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
306 tty->print("[Constraint check failed for name %s, loader %s: "
a61af66fc99e Initial load
duke
parents:
diff changeset
307 "the presented class object differs from that stored ]\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
308 name()->as_C_string(),
a61af66fc99e Initial load
duke
parents:
diff changeset
309 SystemDictionary::loader_name(loader()));
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
312 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 if (p && p->klass() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 p->set_klass(k());
a61af66fc99e Initial load
duke
parents:
diff changeset
315 if (TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
316 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
317 tty->print("[Updating constraint for name %s, loader %s, "
a61af66fc99e Initial load
duke
parents:
diff changeset
318 "by setting class object ]\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
319 name()->as_C_string(),
a61af66fc99e Initial load
duke
parents:
diff changeset
320 SystemDictionary::loader_name(loader()));
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
325 }
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 klassOop LoaderConstraintTable::find_constrained_klass(symbolHandle name,
a61af66fc99e Initial load
duke
parents:
diff changeset
328 Handle loader) {
a61af66fc99e Initial load
duke
parents:
diff changeset
329 LoaderConstraintEntry *p = *(find_loader_constraint(name, loader));
a61af66fc99e Initial load
duke
parents:
diff changeset
330 if (p != NULL && p->klass() != NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
331 return p->klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // No constraints, or else no klass loaded yet.
a61af66fc99e Initial load
duke
parents:
diff changeset
334 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337
a61af66fc99e Initial load
duke
parents:
diff changeset
338 klassOop LoaderConstraintTable::find_constrained_elem_klass(symbolHandle name,
a61af66fc99e Initial load
duke
parents:
diff changeset
339 symbolHandle elem_name,
a61af66fc99e Initial load
duke
parents:
diff changeset
340 Handle loader,
a61af66fc99e Initial load
duke
parents:
diff changeset
341 TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 LoaderConstraintEntry *p = *(find_loader_constraint(name, loader));
a61af66fc99e Initial load
duke
parents:
diff changeset
343 if (p != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 assert(p->klass() == NULL, "Expecting null array klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // The array name has a constraint, but it will not have a class. Check
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // each loader for an associated elem
a61af66fc99e Initial load
duke
parents:
diff changeset
348 for (int i = 0; i < p->num_loaders(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 Handle no_protection_domain;
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 klassOop k = SystemDictionary::find(elem_name, p->loader(i), no_protection_domain, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
352 if (k != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
353 // Return the first elem klass found.
a61af66fc99e Initial load
duke
parents:
diff changeset
354 return k;
a61af66fc99e Initial load
duke
parents:
diff changeset
355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // No constraints, or else no klass loaded yet.
a61af66fc99e Initial load
duke
parents:
diff changeset
360 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 void LoaderConstraintTable::ensure_loader_constraint_capacity(
a61af66fc99e Initial load
duke
parents:
diff changeset
365 LoaderConstraintEntry *p,
a61af66fc99e Initial load
duke
parents:
diff changeset
366 int nfree) {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 if (p->max_loaders() - p->num_loaders() < nfree) {
a61af66fc99e Initial load
duke
parents:
diff changeset
368 int n = nfree + p->num_loaders();
a61af66fc99e Initial load
duke
parents:
diff changeset
369 oop* new_loaders = NEW_C_HEAP_ARRAY(oop, n);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 memcpy(new_loaders, p->loaders(), sizeof(oop) * p->num_loaders());
a61af66fc99e Initial load
duke
parents:
diff changeset
371 p->set_max_loaders(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 FREE_C_HEAP_ARRAY(oop, p->loaders());
a61af66fc99e Initial load
duke
parents:
diff changeset
373 p->set_loaders(new_loaders);
a61af66fc99e Initial load
duke
parents:
diff changeset
374 }
a61af66fc99e Initial load
duke
parents:
diff changeset
375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 void LoaderConstraintTable::extend_loader_constraint(LoaderConstraintEntry* p,
a61af66fc99e Initial load
duke
parents:
diff changeset
379 Handle loader,
a61af66fc99e Initial load
duke
parents:
diff changeset
380 klassOop klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
381 ensure_loader_constraint_capacity(p, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
382 int num = p->num_loaders();
a61af66fc99e Initial load
duke
parents:
diff changeset
383 p->set_loader(num, loader());
a61af66fc99e Initial load
duke
parents:
diff changeset
384 p->set_num_loaders(num + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
385 if (TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
387 tty->print("[Extending constraint for name %s by adding loader[%d]: %s %s",
a61af66fc99e Initial load
duke
parents:
diff changeset
388 p->name()->as_C_string(),
a61af66fc99e Initial load
duke
parents:
diff changeset
389 num,
a61af66fc99e Initial load
duke
parents:
diff changeset
390 SystemDictionary::loader_name(loader()),
a61af66fc99e Initial load
duke
parents:
diff changeset
391 (p->klass() == NULL ? " and setting class object ]\n" : " ]\n")
a61af66fc99e Initial load
duke
parents:
diff changeset
392 );
a61af66fc99e Initial load
duke
parents:
diff changeset
393 }
a61af66fc99e Initial load
duke
parents:
diff changeset
394 if (p->klass() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
395 p->set_klass(klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
396 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
397 assert(klass == NULL || p->klass() == klass, "constraints corrupted");
a61af66fc99e Initial load
duke
parents:
diff changeset
398 }
a61af66fc99e Initial load
duke
parents:
diff changeset
399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
400
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 void LoaderConstraintTable::merge_loader_constraints(
a61af66fc99e Initial load
duke
parents:
diff changeset
403 LoaderConstraintEntry** pp1,
a61af66fc99e Initial load
duke
parents:
diff changeset
404 LoaderConstraintEntry** pp2,
a61af66fc99e Initial load
duke
parents:
diff changeset
405 klassOop klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
406 // make sure *pp1 has higher capacity
a61af66fc99e Initial load
duke
parents:
diff changeset
407 if ((*pp1)->max_loaders() < (*pp2)->max_loaders()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
408 LoaderConstraintEntry** tmp = pp2;
a61af66fc99e Initial load
duke
parents:
diff changeset
409 pp2 = pp1;
a61af66fc99e Initial load
duke
parents:
diff changeset
410 pp1 = tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 LoaderConstraintEntry* p1 = *pp1;
a61af66fc99e Initial load
duke
parents:
diff changeset
414 LoaderConstraintEntry* p2 = *pp2;
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416 ensure_loader_constraint_capacity(p1, p2->num_loaders());
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 for (int i = 0; i < p2->num_loaders(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 int num = p1->num_loaders();
a61af66fc99e Initial load
duke
parents:
diff changeset
420 p1->set_loader(num, p2->loader(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
421 p1->set_num_loaders(num + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424 if (TraceLoaderConstraints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
425 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
426 tty->print_cr("[Merged constraints for name %s, new loader list:",
a61af66fc99e Initial load
duke
parents:
diff changeset
427 p1->name()->as_C_string()
a61af66fc99e Initial load
duke
parents:
diff changeset
428 );
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430 for (int i = 0; i < p1->num_loaders(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 tty->print_cr("[ [%d]: %s", i,
a61af66fc99e Initial load
duke
parents:
diff changeset
432 SystemDictionary::loader_name(p1->loader(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
434 if (p1->klass() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
435 tty->print_cr("[... and setting class object]");
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // p1->klass() will hold NULL if klass, p2->klass(), and old
a61af66fc99e Initial load
duke
parents:
diff changeset
440 // p1->klass() are all NULL. In addition, all three must have
a61af66fc99e Initial load
duke
parents:
diff changeset
441 // matching non-NULL values, otherwise either the constraints would
a61af66fc99e Initial load
duke
parents:
diff changeset
442 // have been violated, or the constraints had been corrupted (and an
a61af66fc99e Initial load
duke
parents:
diff changeset
443 // assertion would fail).
a61af66fc99e Initial load
duke
parents:
diff changeset
444 if (p2->klass() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
445 assert(p2->klass() == klass, "constraints corrupted");
a61af66fc99e Initial load
duke
parents:
diff changeset
446 }
a61af66fc99e Initial load
duke
parents:
diff changeset
447 if (p1->klass() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
448 p1->set_klass(klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
449 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
450 assert(p1->klass() == klass, "constraints corrupted");
a61af66fc99e Initial load
duke
parents:
diff changeset
451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
452
a61af66fc99e Initial load
duke
parents:
diff changeset
453 *pp2 = p2->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
454 FREE_C_HEAP_ARRAY(oop, p2->loaders());
a61af66fc99e Initial load
duke
parents:
diff changeset
455 free_entry(p2);
a61af66fc99e Initial load
duke
parents:
diff changeset
456 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
458
a61af66fc99e Initial load
duke
parents:
diff changeset
459
1258
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
460 void LoaderConstraintTable::verify(Dictionary* dictionary,
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
461 PlaceholderTable* placeholders) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
462 Thread *thread = Thread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
463 for (int cindex = 0; cindex < _loader_constraint_size; cindex++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
464 for (LoaderConstraintEntry* probe = bucket(cindex);
a61af66fc99e Initial load
duke
parents:
diff changeset
465 probe != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
466 probe = probe->next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
467 guarantee(probe->name()->is_symbol(), "should be symbol");
a61af66fc99e Initial load
duke
parents:
diff changeset
468 if (probe->klass() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
469 instanceKlass* ik = instanceKlass::cast(probe->klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
470 guarantee(ik->name() == probe->name(), "name should match");
a61af66fc99e Initial load
duke
parents:
diff changeset
471 symbolHandle name (thread, ik->name());
a61af66fc99e Initial load
duke
parents:
diff changeset
472 Handle loader(thread, ik->class_loader());
a61af66fc99e Initial load
duke
parents:
diff changeset
473 unsigned int d_hash = dictionary->compute_hash(name, loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
474 int d_index = dictionary->hash_to_index(d_hash);
a61af66fc99e Initial load
duke
parents:
diff changeset
475 klassOop k = dictionary->find_class(d_index, d_hash, name, loader);
1258
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
476 if (k != NULL) {
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
477 // We found the class in the system dictionary, so we should
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
478 // make sure that the klassOop matches what we already have.
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
479 guarantee(k == probe->klass(), "klass should be in dictionary");
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
480 } else {
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
481 // If we don't find the class in the system dictionary, it
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
482 // has to be in the placeholders table.
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
483 unsigned int p_hash = placeholders->compute_hash(name, loader);
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
484 int p_index = placeholders->hash_to_index(p_hash);
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
485 PlaceholderEntry* entry = placeholders->get_entry(p_index, p_hash,
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
486 name, loader);
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
487
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
488 // The instanceKlass might not be on the entry, so the only
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
489 // thing we can check here is whether we were successful in
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
490 // finding the class in the placeholders table.
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
491 guarantee(entry != NULL, "klass should be in the placeholders");
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 0
diff changeset
492 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
493 }
a61af66fc99e Initial load
duke
parents:
diff changeset
494 for (int n = 0; n< probe->num_loaders(); n++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
495 guarantee(probe->loader(n)->is_oop_or_null(), "should be oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
496 }
a61af66fc99e Initial load
duke
parents:
diff changeset
497 }
a61af66fc99e Initial load
duke
parents:
diff changeset
498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
499 }
a61af66fc99e Initial load
duke
parents:
diff changeset
500
a61af66fc99e Initial load
duke
parents:
diff changeset
501 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
502
a61af66fc99e Initial load
duke
parents:
diff changeset
503 // Called with the system dictionary lock held
a61af66fc99e Initial load
duke
parents:
diff changeset
504 void LoaderConstraintTable::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
505 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 assert_locked_or_safepoint(SystemDictionary_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
508 tty->print_cr("Java loader constraints (entries=%d)", _loader_constraint_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
509 for (int cindex = 0; cindex < _loader_constraint_size; cindex++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
510 for (LoaderConstraintEntry* probe = bucket(cindex);
a61af66fc99e Initial load
duke
parents:
diff changeset
511 probe != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
512 probe = probe->next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 tty->print("%4d: ", cindex);
a61af66fc99e Initial load
duke
parents:
diff changeset
514 probe->name()->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
515 tty->print(" , loaders:");
a61af66fc99e Initial load
duke
parents:
diff changeset
516 for (int n = 0; n < probe->num_loaders(); n++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
517 probe->loader(n)->print_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
518 tty->print(", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
520 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
521 }
a61af66fc99e Initial load
duke
parents:
diff changeset
522 }
a61af66fc99e Initial load
duke
parents:
diff changeset
523 }
a61af66fc99e Initial load
duke
parents:
diff changeset
524 #endif