author | lfoltan |
Mon, 21 Oct 2019 13:13:16 -0400 | |
changeset 58722 | cba8afa5cfed |
parent 53776 | 7c17199fa37d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53776
7c17199fa37d
8218851: JVM crash in custom classloader stress test, JDK 12 & 13
coleenp
parents:
51959
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
51375
diff
changeset
|
26 |
#include "classfile/classLoaderData.inline.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
51375
diff
changeset
|
27 |
#include "classfile/classLoaderDataGraph.hpp" |
46729 | 28 |
#include "classfile/dictionary.hpp" |
7397 | 29 |
#include "classfile/loaderConstraints.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
30 |
#include "logging/log.hpp" |
7397 | 31 |
#include "memory/resourceArea.hpp" |
32 |
#include "oops/oop.inline.hpp" |
|
33 |
#include "runtime/handles.inline.hpp" |
|
34 |
#include "runtime/safepoint.hpp" |
|
35 |
#include "utilities/hashtable.inline.hpp" |
|
1 | 36 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
37 |
void LoaderConstraintEntry::set_loader(int i, oop p) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
38 |
set_loader_data(i, ClassLoaderData::class_loader_data(p)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
39 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
40 |
|
46729 | 41 |
LoaderConstraintTable::LoaderConstraintTable(int table_size) |
42 |
: Hashtable<InstanceKlass*, mtClass>(table_size, sizeof(LoaderConstraintEntry)) {}; |
|
1 | 43 |
|
44 |
||
45 |
LoaderConstraintEntry* LoaderConstraintTable::new_entry( |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
46 |
unsigned int hash, Symbol* name, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
47 |
InstanceKlass* klass, int num_loaders, |
1 | 48 |
int max_loaders) { |
49 |
LoaderConstraintEntry* entry; |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
50 |
entry = (LoaderConstraintEntry*)Hashtable<InstanceKlass*, mtClass>::new_entry(hash, klass); |
1 | 51 |
entry->set_name(name); |
52 |
entry->set_num_loaders(num_loaders); |
|
53 |
entry->set_max_loaders(max_loaders); |
|
54 |
return entry; |
|
55 |
} |
|
56 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
57 |
void LoaderConstraintTable::free_entry(LoaderConstraintEntry *entry) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
58 |
// decrement name refcount before freeing |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
59 |
entry->name()->decrement_refcount(); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
60 |
Hashtable<InstanceKlass*, mtClass>::free_entry(entry); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
61 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
62 |
|
1 | 63 |
// The loaderConstraintTable must always be accessed with the |
64 |
// SystemDictionary lock held. This is true even for readers as |
|
65 |
// entries in the table could be being dynamically resized. |
|
66 |
||
67 |
LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint( |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
68 |
Symbol* name, Handle loader) { |
51375
b812a85b3aa4
8207778: Add locking to ModuleEntry and PackageEntry tables
hseigel
parents:
50634
diff
changeset
|
69 |
assert_lock_strong(SystemDictionary_lock); |
1 | 70 |
unsigned int hash = compute_hash(name); |
71 |
int index = hash_to_index(hash); |
|
72 |
LoaderConstraintEntry** pp = bucket_addr(index); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
73 |
ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(loader()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
74 |
|
1 | 75 |
while (*pp) { |
76 |
LoaderConstraintEntry* p = *pp; |
|
77 |
if (p->hash() == hash) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
78 |
if (p->name() == name) { |
1 | 79 |
for (int i = p->num_loaders() - 1; i >= 0; i--) { |
53776
7c17199fa37d
8218851: JVM crash in custom classloader stress test, JDK 12 & 13
coleenp
parents:
51959
diff
changeset
|
80 |
if (p->loader_data(i) == loader_data && |
7c17199fa37d
8218851: JVM crash in custom classloader stress test, JDK 12 & 13
coleenp
parents:
51959
diff
changeset
|
81 |
// skip unloaded klasses |
7c17199fa37d
8218851: JVM crash in custom classloader stress test, JDK 12 & 13
coleenp
parents:
51959
diff
changeset
|
82 |
(p->klass() == NULL || |
7c17199fa37d
8218851: JVM crash in custom classloader stress test, JDK 12 & 13
coleenp
parents:
51959
diff
changeset
|
83 |
p->klass()->is_loader_alive())) { |
1 | 84 |
return pp; |
85 |
} |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
pp = p->next_addr(); |
|
90 |
} |
|
91 |
return pp; |
|
92 |
} |
|
93 |
||
94 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
95 |
void LoaderConstraintTable::purge_loader_constraints() { |
51375
b812a85b3aa4
8207778: Add locking to ModuleEntry and PackageEntry tables
hseigel
parents:
50634
diff
changeset
|
96 |
assert_locked_or_safepoint(SystemDictionary_lock); |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
97 |
LogTarget(Info, class, loader, constraints) lt; |
1 | 98 |
// Remove unloaded entries from constraint table |
99 |
for (int index = 0; index < table_size(); index++) { |
|
100 |
LoaderConstraintEntry** p = bucket_addr(index); |
|
101 |
while(*p) { |
|
102 |
LoaderConstraintEntry* probe = *p; |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
103 |
InstanceKlass* klass = probe->klass(); |
1 | 104 |
// Remove klass that is no longer alive |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
105 |
if (klass != NULL && |
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
106 |
!klass->is_loader_alive()) { |
1 | 107 |
probe->set_klass(NULL); |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
108 |
if (lt.is_enabled()) { |
1 | 109 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
110 |
lt.print("purging class object from constraint for name %s," |
1 | 111 |
" loader list:", |
112 |
probe->name()->as_C_string()); |
|
113 |
for (int i = 0; i < probe->num_loaders(); i++) { |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
114 |
lt.print(" [%d]: %s", i, |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
115 |
probe->loader_data(i)->loader_name_and_id()); |
1 | 116 |
} |
117 |
} |
|
118 |
} |
|
119 |
// Remove entries no longer alive from loader array |
|
120 |
int n = 0; |
|
121 |
while (n < probe->num_loaders()) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
122 |
if (probe->loader_data(n)->is_unloading()) { |
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
123 |
if (lt.is_enabled()) { |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
124 |
ResourceMark rm; |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
125 |
lt.print("purging loader %s from constraint for name %s", |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
126 |
probe->loader_data(n)->loader_name_and_id(), |
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
127 |
probe->name()->as_C_string() |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
128 |
); |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
129 |
} |
1 | 130 |
|
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
131 |
// Compact array |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
132 |
int num = probe->num_loaders() - 1; |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
133 |
probe->set_num_loaders(num); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
134 |
probe->set_loader_data(n, probe->loader_data(num)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
135 |
probe->set_loader_data(num, NULL); |
1 | 136 |
|
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
137 |
if (lt.is_enabled()) { |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
138 |
ResourceMark rm; |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
139 |
lt.print("new loader list:"); |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
140 |
for (int i = 0; i < probe->num_loaders(); i++) { |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
141 |
lt.print(" [%d]: %s", i, |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
142 |
probe->loader_data(i)->loader_name_and_id()); |
1 | 143 |
} |
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
144 |
} |
1 | 145 |
|
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
146 |
continue; // current element replaced, so restart without |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
147 |
// incrementing n |
1 | 148 |
} |
149 |
n++; |
|
150 |
} |
|
151 |
// Check whether entry should be purged |
|
152 |
if (probe->num_loaders() < 2) { |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
153 |
if (lt.is_enabled()) { |
1 | 154 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
155 |
lt.print("purging complete constraint for name %s", |
1 | 156 |
probe->name()->as_C_string()); |
157 |
} |
|
158 |
||
159 |
// Purge entry |
|
160 |
*p = probe->next(); |
|
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
14588
diff
changeset
|
161 |
FREE_C_HEAP_ARRAY(oop, probe->loaders()); |
1 | 162 |
free_entry(probe); |
163 |
} else { |
|
164 |
#ifdef ASSERT |
|
165 |
if (probe->klass() != NULL) { |
|
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
47216
diff
changeset
|
166 |
assert(probe->klass()->is_loader_alive(), "klass should be live"); |
1 | 167 |
} |
168 |
#endif |
|
169 |
// Go to next entry |
|
170 |
p = probe->next_addr(); |
|
171 |
} |
|
172 |
} |
|
173 |
} |
|
174 |
} |
|
175 |
||
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
176 |
void log_ldr_constraint_msg(Symbol* class_name, const char* reason, |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
177 |
Handle class_loader1, Handle class_loader2) { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
178 |
LogTarget(Info, class, loader, constraints) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
179 |
if (lt.is_enabled()) { |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
180 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
181 |
lt.print("Failed to add constraint for name: %s, loader[0]: %s," |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
182 |
" loader[1]: %s, Reason: %s", |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
183 |
class_name->as_C_string(), |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
184 |
ClassLoaderData::class_loader_data(class_loader1())->loader_name_and_id(), |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
185 |
ClassLoaderData::class_loader_data(class_loader2())->loader_name_and_id(), |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
186 |
reason); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
187 |
} |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
188 |
} |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
189 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
190 |
bool LoaderConstraintTable::add_entry(Symbol* class_name, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
191 |
InstanceKlass* klass1, Handle class_loader1, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
192 |
InstanceKlass* klass2, Handle class_loader2) { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
193 |
LogTarget(Info, class, loader, constraints) lt; |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
194 |
if (klass1 != NULL && klass2 != NULL) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
195 |
if (klass1 == klass2) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
196 |
// Same type already loaded in both places. There is no need for any constraint. |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
197 |
return true; |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
198 |
} else { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
199 |
log_ldr_constraint_msg(class_name, |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
200 |
"The class objects presented by loader[0] and loader[1] " |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
201 |
"are different", |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
202 |
class_loader1, class_loader2); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
203 |
return false; |
1 | 204 |
} |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
205 |
} |
1 | 206 |
|
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
207 |
InstanceKlass* klass = klass1 != NULL ? klass1 : klass2; |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
208 |
LoaderConstraintEntry** pp1 = find_loader_constraint(class_name, class_loader1); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
209 |
if (*pp1 != NULL && (*pp1)->klass() != NULL) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
210 |
if (klass != NULL) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
211 |
if (klass != (*pp1)->klass()) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
212 |
log_ldr_constraint_msg(class_name, |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
213 |
"The class object presented by loader[0] does not match " |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
214 |
"the stored class object in the constraint", |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
215 |
class_loader1, class_loader2); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
216 |
return false; |
1 | 217 |
} |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
218 |
} else { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
219 |
klass = (*pp1)->klass(); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
220 |
} |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
221 |
} |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
222 |
|
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
223 |
LoaderConstraintEntry** pp2 = find_loader_constraint(class_name, class_loader2); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
224 |
if (*pp2 != NULL && (*pp2)->klass() != NULL) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
225 |
if (klass != NULL) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
226 |
if (klass != (*pp2)->klass()) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
227 |
log_ldr_constraint_msg(class_name, |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
228 |
"The class object presented by loader[1] does not match " |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
229 |
"the stored class object in the constraint", |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
230 |
class_loader1, class_loader2); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
231 |
return false; |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
232 |
} |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
233 |
} else { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
234 |
klass = (*pp2)->klass(); |
1 | 235 |
} |
236 |
} |
|
237 |
||
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
238 |
if (*pp1 == NULL && *pp2 == NULL) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
239 |
unsigned int hash = compute_hash(class_name); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
240 |
int index = hash_to_index(hash); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
241 |
LoaderConstraintEntry* p; |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
242 |
p = new_entry(hash, class_name, klass, 2, 2); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
243 |
p->set_loaders(NEW_C_HEAP_ARRAY(ClassLoaderData*, 2, mtClass)); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
244 |
p->set_loader(0, class_loader1()); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
245 |
p->set_loader(1, class_loader2()); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
246 |
p->set_klass(klass); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
247 |
p->set_next(bucket(index)); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
248 |
set_entry(index, p); |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
249 |
if (lt.is_enabled()) { |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
250 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
251 |
lt.print("adding new constraint for name: %s, loader[0]: %s," |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
252 |
" loader[1]: %s", |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
253 |
class_name->as_C_string(), |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
254 |
ClassLoaderData::class_loader_data(class_loader1())->loader_name_and_id(), |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
255 |
ClassLoaderData::class_loader_data(class_loader2())->loader_name_and_id() |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
256 |
); |
1 | 257 |
} |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
258 |
} else if (*pp1 == *pp2) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
259 |
/* constraint already imposed */ |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
260 |
if ((*pp1)->klass() == NULL) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
261 |
(*pp1)->set_klass(klass); |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
262 |
if (lt.is_enabled()) { |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
263 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
264 |
lt.print("setting class object in existing constraint for" |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
265 |
" name: %s and loader %s", |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
266 |
class_name->as_C_string(), |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
267 |
ClassLoaderData::class_loader_data(class_loader1())->loader_name_and_id() |
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
268 |
); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
269 |
} |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
270 |
} else { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
271 |
assert((*pp1)->klass() == klass, "loader constraints corrupted"); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
272 |
} |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
273 |
} else if (*pp1 == NULL) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
274 |
extend_loader_constraint(*pp2, class_loader1, klass); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
275 |
} else if (*pp2 == NULL) { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
276 |
extend_loader_constraint(*pp1, class_loader2, klass); |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
277 |
} else { |
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
278 |
merge_loader_constraints(pp1, pp2, klass); |
1 | 279 |
} |
280 |
||
46468
be80e262d2a2
8152295: Redundant CLCs for classes resolved in both loaders
hseigel
parents:
46380
diff
changeset
|
281 |
return true; |
1 | 282 |
} |
283 |
||
284 |
||
285 |
// return true if the constraint was updated, false if the constraint is |
|
286 |
// violated |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
287 |
bool LoaderConstraintTable::check_or_update(InstanceKlass* k, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
288 |
Handle loader, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
289 |
Symbol* name) { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
290 |
LogTarget(Info, class, loader, constraints) lt; |
1 | 291 |
LoaderConstraintEntry* p = *(find_loader_constraint(name, loader)); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
292 |
if (p && p->klass() != NULL && p->klass() != k) { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
293 |
if (lt.is_enabled()) { |
1 | 294 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
295 |
lt.print("constraint check failed for name %s, loader %s: " |
37202
4100f25e4b09
8149996: TraceLoaderConstraints has been converted to Unified Logging.
mockner
parents:
33611
diff
changeset
|
296 |
"the presented class object differs from that stored", |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
297 |
name->as_C_string(), |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
298 |
ClassLoaderData::class_loader_data(loader())->loader_name_and_id()); |
1 | 299 |
} |
300 |
return false; |
|
301 |
} else { |
|
302 |
if (p && p->klass() == NULL) { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
303 |
p->set_klass(k); |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
304 |
if (lt.is_enabled()) { |
1 | 305 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
306 |
lt.print("updating constraint for name %s, loader %s, " |
37202
4100f25e4b09
8149996: TraceLoaderConstraints has been converted to Unified Logging.
mockner
parents:
33611
diff
changeset
|
307 |
"by setting class object", |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
308 |
name->as_C_string(), |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
309 |
ClassLoaderData::class_loader_data(loader())->loader_name_and_id()); |
1 | 310 |
} |
311 |
} |
|
312 |
return true; |
|
313 |
} |
|
314 |
} |
|
315 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
316 |
InstanceKlass* LoaderConstraintTable::find_constrained_klass(Symbol* name, |
1 | 317 |
Handle loader) { |
318 |
LoaderConstraintEntry *p = *(find_loader_constraint(name, loader)); |
|
8314
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
319 |
if (p != NULL && p->klass() != NULL) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
320 |
assert(p->klass()->is_instance_klass(), "sanity"); |
46716
53915543333d
8178107: Compiler crashes with "assert(get_instanceKlass()->is_loaded()) failed: must be at least loaded"
hseigel
parents:
46701
diff
changeset
|
321 |
if (!p->klass()->is_loaded()) { |
8314
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
322 |
// Only return fully loaded classes. Classes found through the |
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
323 |
// constraints might still be in the process of loading. |
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
324 |
return NULL; |
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
325 |
} |
1 | 326 |
return p->klass(); |
8314
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
327 |
} |
1 | 328 |
|
329 |
// No constraints, or else no klass loaded yet. |
|
330 |
return NULL; |
|
331 |
} |
|
332 |
||
333 |
void LoaderConstraintTable::ensure_loader_constraint_capacity( |
|
334 |
LoaderConstraintEntry *p, |
|
335 |
int nfree) { |
|
336 |
if (p->max_loaders() - p->num_loaders() < nfree) { |
|
337 |
int n = nfree + p->num_loaders(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
338 |
ClassLoaderData** new_loaders = NEW_C_HEAP_ARRAY(ClassLoaderData*, n, mtClass); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
339 |
memcpy(new_loaders, p->loaders(), sizeof(ClassLoaderData*) * p->num_loaders()); |
1 | 340 |
p->set_max_loaders(n); |
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
14588
diff
changeset
|
341 |
FREE_C_HEAP_ARRAY(ClassLoaderData*, p->loaders()); |
1 | 342 |
p->set_loaders(new_loaders); |
343 |
} |
|
344 |
} |
|
345 |
||
346 |
||
347 |
void LoaderConstraintTable::extend_loader_constraint(LoaderConstraintEntry* p, |
|
348 |
Handle loader, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
349 |
InstanceKlass* klass) { |
1 | 350 |
ensure_loader_constraint_capacity(p, 1); |
351 |
int num = p->num_loaders(); |
|
352 |
p->set_loader(num, loader()); |
|
353 |
p->set_num_loaders(num + 1); |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
354 |
LogTarget(Info, class, loader, constraints) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
355 |
if (lt.is_enabled()) { |
1 | 356 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
357 |
lt.print("extending constraint for name %s by adding loader[%d]: %s %s", |
1 | 358 |
p->name()->as_C_string(), |
359 |
num, |
|
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
360 |
ClassLoaderData::class_loader_data(loader())->loader_name_and_id(), |
37202
4100f25e4b09
8149996: TraceLoaderConstraints has been converted to Unified Logging.
mockner
parents:
33611
diff
changeset
|
361 |
(p->klass() == NULL ? " and setting class object" : "") |
1 | 362 |
); |
363 |
} |
|
364 |
if (p->klass() == NULL) { |
|
365 |
p->set_klass(klass); |
|
366 |
} else { |
|
367 |
assert(klass == NULL || p->klass() == klass, "constraints corrupted"); |
|
368 |
} |
|
369 |
} |
|
370 |
||
371 |
||
372 |
void LoaderConstraintTable::merge_loader_constraints( |
|
373 |
LoaderConstraintEntry** pp1, |
|
374 |
LoaderConstraintEntry** pp2, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
375 |
InstanceKlass* klass) { |
1 | 376 |
// make sure *pp1 has higher capacity |
377 |
if ((*pp1)->max_loaders() < (*pp2)->max_loaders()) { |
|
378 |
LoaderConstraintEntry** tmp = pp2; |
|
379 |
pp2 = pp1; |
|
380 |
pp1 = tmp; |
|
381 |
} |
|
382 |
||
383 |
LoaderConstraintEntry* p1 = *pp1; |
|
384 |
LoaderConstraintEntry* p2 = *pp2; |
|
385 |
||
386 |
ensure_loader_constraint_capacity(p1, p2->num_loaders()); |
|
387 |
||
388 |
for (int i = 0; i < p2->num_loaders(); i++) { |
|
389 |
int num = p1->num_loaders(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
390 |
p1->set_loader_data(num, p2->loader_data(i)); |
1 | 391 |
p1->set_num_loaders(num + 1); |
392 |
} |
|
393 |
||
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
394 |
LogTarget(Info, class, loader, constraints) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
395 |
if (lt.is_enabled()) { |
1 | 396 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
397 |
lt.print("merged constraints for name %s, new loader list:", |
1 | 398 |
p1->name()->as_C_string() |
399 |
); |
|
400 |
||
401 |
for (int i = 0; i < p1->num_loaders(); i++) { |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
402 |
lt.print(" [%d]: %s", i, |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
49821
diff
changeset
|
403 |
p1->loader_data(i)->loader_name_and_id()); |
1 | 404 |
} |
405 |
if (p1->klass() == NULL) { |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46468
diff
changeset
|
406 |
lt.print("... and setting class object"); |
1 | 407 |
} |
408 |
} |
|
409 |
||
410 |
// p1->klass() will hold NULL if klass, p2->klass(), and old |
|
411 |
// p1->klass() are all NULL. In addition, all three must have |
|
412 |
// matching non-NULL values, otherwise either the constraints would |
|
413 |
// have been violated, or the constraints had been corrupted (and an |
|
414 |
// assertion would fail). |
|
415 |
if (p2->klass() != NULL) { |
|
416 |
assert(p2->klass() == klass, "constraints corrupted"); |
|
417 |
} |
|
418 |
if (p1->klass() == NULL) { |
|
419 |
p1->set_klass(klass); |
|
420 |
} else { |
|
421 |
assert(p1->klass() == klass, "constraints corrupted"); |
|
422 |
} |
|
423 |
||
424 |
*pp2 = p2->next(); |
|
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
14588
diff
changeset
|
425 |
FREE_C_HEAP_ARRAY(oop, p2->loaders()); |
1 | 426 |
free_entry(p2); |
427 |
return; |
|
428 |
} |
|
429 |
||
430 |
||
46729 | 431 |
void LoaderConstraintTable::verify(PlaceholderTable* placeholders) { |
1 | 432 |
Thread *thread = Thread::current(); |
46729 | 433 |
for (int cindex = 0; cindex < table_size(); cindex++) { |
1 | 434 |
for (LoaderConstraintEntry* probe = bucket(cindex); |
435 |
probe != NULL; |
|
436 |
probe = probe->next()) { |
|
437 |
if (probe->klass() != NULL) { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38151
diff
changeset
|
438 |
InstanceKlass* ik = probe->klass(); |
1 | 439 |
guarantee(ik->name() == probe->name(), "name should match"); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
440 |
Symbol* name = ik->name(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
441 |
ClassLoaderData* loader_data = ik->class_loader_data(); |
46729 | 442 |
Dictionary* dictionary = loader_data->dictionary(); |
443 |
unsigned int d_hash = dictionary->compute_hash(name); |
|
1 | 444 |
int d_index = dictionary->hash_to_index(d_hash); |
46729 | 445 |
InstanceKlass* k = dictionary->find_class(d_index, d_hash, name); |
4899
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
446 |
if (k != NULL) { |
46729 | 447 |
// We found the class in the dictionary, so we should |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
448 |
// make sure that the Klass* matches what we already have. |
4899
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
449 |
guarantee(k == probe->klass(), "klass should be in dictionary"); |
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
450 |
} else { |
46729 | 451 |
// If we don't find the class in the dictionary, it |
4899
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
452 |
// has to be in the placeholders table. |
46729 | 453 |
unsigned int p_hash = placeholders->compute_hash(name); |
4899
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
454 |
int p_index = placeholders->hash_to_index(p_hash); |
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
455 |
PlaceholderEntry* entry = placeholders->get_entry(p_index, p_hash, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
456 |
name, loader_data); |
4899
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
457 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
458 |
// The InstanceKlass might not be on the entry, so the only |
4899
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
459 |
// thing we can check here is whether we were successful in |
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
460 |
// finding the class in the placeholders table. |
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
461 |
guarantee(entry != NULL, "klass should be in the placeholders"); |
ab225bac579c
6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents:
1
diff
changeset
|
462 |
} |
1 | 463 |
} |
464 |
for (int n = 0; n< probe->num_loaders(); n++) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
465 |
assert(ClassLoaderDataGraph::contains_loader_data(probe->loader_data(n)), "The loader is missing"); |
1 | 466 |
} |
467 |
} |
|
468 |
} |
|
469 |
} |
|
470 |
||
471 |
// Called with the system dictionary lock held |
|
46742 | 472 |
void LoaderConstraintTable::print_on(outputStream* st) const { |
1 | 473 |
ResourceMark rm; |
474 |
assert_locked_or_safepoint(SystemDictionary_lock); |
|
46742 | 475 |
st->print_cr("Java loader constraints (table_size=%d, constraints=%d)", |
476 |
table_size(), number_of_entries()); |
|
46729 | 477 |
for (int cindex = 0; cindex < table_size(); cindex++) { |
1 | 478 |
for (LoaderConstraintEntry* probe = bucket(cindex); |
479 |
probe != NULL; |
|
480 |
probe = probe->next()) { |
|
46742 | 481 |
st->print("%4d: ", cindex); |
482 |
probe->name()->print_on(st); |
|
483 |
st->print(" , loaders:"); |
|
1 | 484 |
for (int n = 0; n < probe->num_loaders(); n++) { |
46742 | 485 |
probe->loader_data(n)->print_value_on(st); |
486 |
st->print(", "); |
|
1 | 487 |
} |
46742 | 488 |
st->cr(); |
1 | 489 |
} |
490 |
} |
|
491 |
} |