author | kvn |
Fri, 24 Jun 2016 15:09:00 -0700 | |
changeset 39450 | 78e99b030d5f |
parent 36381 | b9ed6bef9364 |
child 42073 | 89e056fd82cc |
permissions | -rw-r--r-- |
1 | 1 |
/* |
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
34666
diff
changeset
|
2 |
* Copyright (c) 2003, 2016, 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:
5420
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5420
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:
5420
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_CLASSFILE_DICTIONARY_HPP |
26 |
#define SHARE_VM_CLASSFILE_DICTIONARY_HPP |
|
27 |
||
28 |
#include "classfile/systemDictionary.hpp" |
|
29 |
#include "oops/instanceKlass.hpp" |
|
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
26181
diff
changeset
|
30 |
#include "oops/oop.hpp" |
7397 | 31 |
#include "utilities/hashtable.hpp" |
36381
b9ed6bef9364
8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents:
35498
diff
changeset
|
32 |
#include "utilities/ostream.hpp" |
7397 | 33 |
|
1 | 34 |
class DictionaryEntry; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
35 |
class PSPromotionManager; |
20405 | 36 |
class ProtectionDomainCacheTable; |
37 |
class ProtectionDomainCacheEntry; |
|
38 |
class BoolObjectClosure; |
|
1 | 39 |
|
40 |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
41 |
// The data structure for the system dictionary (and the shared system |
|
42 |
// dictionary). |
|
43 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
44 |
class Dictionary : public TwoOopHashtable<Klass*, mtClass> { |
1 | 45 |
friend class VMStructs; |
46 |
private: |
|
47 |
// current iteration index. |
|
48 |
static int _current_class_index; |
|
49 |
// pointer to the current hash table entry. |
|
50 |
static DictionaryEntry* _current_class_entry; |
|
51 |
||
20405 | 52 |
ProtectionDomainCacheTable* _pd_cache_table; |
53 |
||
1 | 54 |
DictionaryEntry* get_entry(int index, unsigned int hash, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
55 |
Symbol* name, ClassLoaderData* loader_data); |
1 | 56 |
|
34257
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33602
diff
changeset
|
57 |
protected: |
34666 | 58 |
DictionaryEntry* bucket(int i) const { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
59 |
return (DictionaryEntry*)Hashtable<Klass*, mtClass>::bucket(i); |
1 | 60 |
} |
61 |
||
62 |
// The following method is not MT-safe and must be done under lock. |
|
63 |
DictionaryEntry** bucket_addr(int i) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
64 |
return (DictionaryEntry**)Hashtable<Klass*, mtClass>::bucket_addr(i); |
1 | 65 |
} |
66 |
||
67 |
void add_entry(int index, DictionaryEntry* new_entry) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
68 |
Hashtable<Klass*, mtClass>::add_entry(index, (HashtableEntry<Klass*, mtClass>*)new_entry); |
1 | 69 |
} |
70 |
||
34257
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33602
diff
changeset
|
71 |
static size_t entry_size(); |
1 | 72 |
public: |
73 |
Dictionary(int table_size); |
|
13195 | 74 |
Dictionary(int table_size, HashtableBucket<mtClass>* t, int number_of_entries); |
1 | 75 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
76 |
DictionaryEntry* new_entry(unsigned int hash, Klass* klass, ClassLoaderData* loader_data); |
1 | 77 |
|
78 |
DictionaryEntry* new_entry(); |
|
79 |
||
80 |
void free_entry(DictionaryEntry* entry); |
|
81 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
82 |
void add_klass(Symbol* class_name, ClassLoaderData* loader_data,KlassHandle obj); |
1 | 83 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
84 |
Klass* find_class(int index, unsigned int hash, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
85 |
Symbol* name, ClassLoaderData* loader_data); |
1 | 86 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
87 |
Klass* find_shared_class(int index, unsigned int hash, Symbol* name); |
1 | 88 |
|
89 |
// Compiler support |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
90 |
Klass* try_get_next_class(); |
1 | 91 |
|
92 |
// GC support |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
93 |
void oops_do(OopClosure* f); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
94 |
void always_strong_oops_do(OopClosure* blk); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
95 |
void roots_oops_do(OopClosure* strong, OopClosure* weak); |
1 | 96 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
97 |
void always_strong_classes_do(KlassClosure* closure); |
1 | 98 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
99 |
void classes_do(void f(Klass*)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
100 |
void classes_do(void f(Klass*, TRAPS), TRAPS); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
101 |
void classes_do(void f(Klass*, ClassLoaderData*)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
102 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
103 |
void methods_do(void f(Method*)); |
1 | 104 |
|
20405 | 105 |
void unlink(BoolObjectClosure* is_alive); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
106 |
void remove_classes_in_error_state(); |
1 | 107 |
|
108 |
// Classes loaded by the bootstrap loader are always strongly reachable. |
|
109 |
// If we're not doing class unloading, all classes are strongly reachable. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
110 |
static bool is_strongly_reachable(ClassLoaderData* loader_data, Klass* klass) { |
1 | 111 |
assert (klass != NULL, "should have non-null klass"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
112 |
return (loader_data->is_the_null_class_loader_data() || !ClassUnloading); |
1 | 113 |
} |
114 |
||
26174
ca46a107cb78
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
25492
diff
changeset
|
115 |
// Unload (that is, break root links to) all unmarked classes and loaders. |
ca46a107cb78
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
25492
diff
changeset
|
116 |
void do_unloading(); |
1 | 117 |
|
118 |
// Protection domains |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
119 |
Klass* find(int index, unsigned int hash, Symbol* name, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
120 |
ClassLoaderData* loader_data, Handle protection_domain, TRAPS); |
1 | 121 |
bool is_valid_protection_domain(int index, unsigned int hash, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
122 |
Symbol* name, ClassLoaderData* loader_data, |
1 | 123 |
Handle protection_domain); |
124 |
void add_protection_domain(int index, unsigned int hash, |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
125 |
instanceKlassHandle klass, ClassLoaderData* loader_data, |
1 | 126 |
Handle protection_domain, TRAPS); |
127 |
||
128 |
// Sharing support |
|
129 |
void reorder_dictionary(); |
|
130 |
||
20405 | 131 |
ProtectionDomainCacheEntry* cache_get(oop protection_domain); |
1 | 132 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
133 |
void print(bool details = true); |
1 | 134 |
void verify(); |
135 |
}; |
|
136 |
||
137 |
// The following classes can be in dictionary.cpp, but we need these |
|
20405 | 138 |
// to be in header file so that SA's vmStructs can access them. |
139 |
class ProtectionDomainCacheEntry : public HashtableEntry<oop, mtClass> { |
|
140 |
friend class VMStructs; |
|
141 |
private: |
|
142 |
// Flag indicating whether this protection domain entry is strongly reachable. |
|
143 |
// Used during iterating over the system dictionary to remember oops that need |
|
144 |
// to be updated. |
|
145 |
bool _strongly_reachable; |
|
146 |
public: |
|
147 |
oop protection_domain() { return literal(); } |
|
148 |
||
149 |
void init() { |
|
150 |
_strongly_reachable = false; |
|
151 |
} |
|
152 |
||
153 |
ProtectionDomainCacheEntry* next() { |
|
154 |
return (ProtectionDomainCacheEntry*)HashtableEntry<oop, mtClass>::next(); |
|
155 |
} |
|
156 |
||
157 |
ProtectionDomainCacheEntry** next_addr() { |
|
158 |
return (ProtectionDomainCacheEntry**)HashtableEntry<oop, mtClass>::next_addr(); |
|
159 |
} |
|
160 |
||
161 |
void oops_do(OopClosure* f) { |
|
162 |
f->do_oop(literal_addr()); |
|
163 |
} |
|
164 |
||
165 |
void set_strongly_reachable() { _strongly_reachable = true; } |
|
166 |
bool is_strongly_reachable() { return _strongly_reachable; } |
|
167 |
void reset_strongly_reachable() { _strongly_reachable = false; } |
|
168 |
||
169 |
void print() PRODUCT_RETURN; |
|
170 |
void verify(); |
|
171 |
}; |
|
172 |
||
173 |
// The ProtectionDomainCacheTable contains all protection domain oops. The system |
|
174 |
// dictionary entries reference its entries instead of having references to oops |
|
175 |
// directly. |
|
176 |
// This is used to speed up system dictionary iteration: the oops in the |
|
177 |
// protection domain are the only ones referring the Java heap. So when there is |
|
178 |
// need to update these, instead of going over every entry of the system dictionary, |
|
179 |
// we only need to iterate over this set. |
|
180 |
// The amount of different protection domains used is typically magnitudes smaller |
|
181 |
// than the number of system dictionary entries (loaded classes). |
|
182 |
class ProtectionDomainCacheTable : public Hashtable<oop, mtClass> { |
|
183 |
friend class VMStructs; |
|
184 |
private: |
|
185 |
ProtectionDomainCacheEntry* bucket(int i) { |
|
186 |
return (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::bucket(i); |
|
187 |
} |
|
188 |
||
189 |
// The following method is not MT-safe and must be done under lock. |
|
190 |
ProtectionDomainCacheEntry** bucket_addr(int i) { |
|
191 |
return (ProtectionDomainCacheEntry**) Hashtable<oop, mtClass>::bucket_addr(i); |
|
192 |
} |
|
193 |
||
194 |
ProtectionDomainCacheEntry* new_entry(unsigned int hash, oop protection_domain) { |
|
195 |
ProtectionDomainCacheEntry* entry = (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::new_entry(hash, protection_domain); |
|
196 |
entry->init(); |
|
197 |
return entry; |
|
198 |
} |
|
199 |
||
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
34666
diff
changeset
|
200 |
static unsigned int compute_hash(oop protection_domain); |
20405 | 201 |
|
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
34666
diff
changeset
|
202 |
int index_for(oop protection_domain); |
20405 | 203 |
ProtectionDomainCacheEntry* add_entry(int index, unsigned int hash, oop protection_domain); |
204 |
ProtectionDomainCacheEntry* find_entry(int index, oop protection_domain); |
|
205 |
||
206 |
public: |
|
207 |
||
208 |
ProtectionDomainCacheTable(int table_size); |
|
209 |
||
210 |
ProtectionDomainCacheEntry* get(oop protection_domain); |
|
211 |
void free(ProtectionDomainCacheEntry* entry); |
|
212 |
||
213 |
void unlink(BoolObjectClosure* cl); |
|
214 |
||
215 |
// GC support |
|
216 |
void oops_do(OopClosure* f); |
|
217 |
void always_strong_oops_do(OopClosure* f); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
218 |
void roots_oops_do(OopClosure* strong, OopClosure* weak); |
20405 | 219 |
|
220 |
static uint bucket_size(); |
|
221 |
||
222 |
void print() PRODUCT_RETURN; |
|
223 |
void verify(); |
|
224 |
}; |
|
225 |
||
1 | 226 |
|
13195 | 227 |
class ProtectionDomainEntry :public CHeapObj<mtClass> { |
1 | 228 |
friend class VMStructs; |
229 |
public: |
|
230 |
ProtectionDomainEntry* _next; |
|
20405 | 231 |
ProtectionDomainCacheEntry* _pd_cache; |
1 | 232 |
|
20405 | 233 |
ProtectionDomainEntry(ProtectionDomainCacheEntry* pd_cache, ProtectionDomainEntry* next) { |
234 |
_pd_cache = pd_cache; |
|
235 |
_next = next; |
|
1 | 236 |
} |
237 |
||
238 |
ProtectionDomainEntry* next() { return _next; } |
|
20405 | 239 |
oop protection_domain() { return _pd_cache->protection_domain(); } |
1 | 240 |
}; |
241 |
||
242 |
// An entry in the system dictionary, this describes a class as |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
243 |
// { Klass*, loader, protection_domain }. |
1 | 244 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
245 |
class DictionaryEntry : public HashtableEntry<Klass*, mtClass> { |
1 | 246 |
friend class VMStructs; |
247 |
private: |
|
248 |
// Contains the set of approved protection domains that can access |
|
249 |
// this system dictionary entry. |
|
20405 | 250 |
// |
251 |
// This protection domain set is a set of tuples: |
|
252 |
// |
|
253 |
// (InstanceKlass C, initiating class loader ICL, Protection Domain PD) |
|
254 |
// |
|
255 |
// [Note that C.protection_domain(), which is stored in the java.lang.Class |
|
256 |
// mirror of C, is NOT the same as PD] |
|
257 |
// |
|
258 |
// If such an entry (C, ICL, PD) exists in the table, it means that |
|
259 |
// it is okay for a class Foo to reference C, where |
|
260 |
// |
|
261 |
// Foo.protection_domain() == PD, and |
|
262 |
// Foo's defining class loader == ICL |
|
263 |
// |
|
264 |
// The usage of the PD set can be seen in SystemDictionary::validate_protection_domain() |
|
265 |
// It is essentially a cache to avoid repeated Java up-calls to |
|
266 |
// ClassLoader.checkPackageAccess(). |
|
267 |
// |
|
1 | 268 |
ProtectionDomainEntry* _pd_set; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
269 |
ClassLoaderData* _loader_data; |
1 | 270 |
|
271 |
public: |
|
272 |
// Tells whether a protection is in the approved set. |
|
273 |
bool contains_protection_domain(oop protection_domain) const; |
|
274 |
// Adds a protection domain to the approved set. |
|
20405 | 275 |
void add_protection_domain(Dictionary* dict, oop protection_domain); |
1 | 276 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
277 |
Klass* klass() const { return (Klass*)literal(); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
278 |
Klass** klass_addr() { return (Klass**)literal_addr(); } |
1 | 279 |
|
280 |
DictionaryEntry* next() const { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
281 |
return (DictionaryEntry*)HashtableEntry<Klass*, mtClass>::next(); |
1 | 282 |
} |
283 |
||
284 |
DictionaryEntry** next_addr() { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
285 |
return (DictionaryEntry**)HashtableEntry<Klass*, mtClass>::next_addr(); |
1 | 286 |
} |
287 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
288 |
ClassLoaderData* loader_data() const { return _loader_data; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
289 |
void set_loader_data(ClassLoaderData* loader_data) { _loader_data = loader_data; } |
1 | 290 |
|
291 |
ProtectionDomainEntry* pd_set() const { return _pd_set; } |
|
292 |
void set_pd_set(ProtectionDomainEntry* pd_set) { _pd_set = pd_set; } |
|
293 |
||
294 |
bool has_protection_domain() { return _pd_set != NULL; } |
|
295 |
||
296 |
// Tells whether the initiating class' protection can access the this _klass |
|
297 |
bool is_valid_protection_domain(Handle protection_domain) { |
|
298 |
if (!ProtectionDomainVerification) return true; |
|
299 |
if (!SystemDictionary::has_checkPackageAccess()) return true; |
|
300 |
||
301 |
return protection_domain() == NULL |
|
302 |
? true |
|
303 |
: contains_protection_domain(protection_domain()); |
|
304 |
} |
|
305 |
||
20405 | 306 |
void set_strongly_reachable() { |
1 | 307 |
for (ProtectionDomainEntry* current = _pd_set; |
308 |
current != NULL; |
|
309 |
current = current->_next) { |
|
20405 | 310 |
current->_pd_cache->set_strongly_reachable(); |
1 | 311 |
} |
312 |
} |
|
313 |
||
314 |
void verify_protection_domain_set() { |
|
315 |
for (ProtectionDomainEntry* current = _pd_set; |
|
316 |
current != NULL; |
|
317 |
current = current->_next) { |
|
20405 | 318 |
current->_pd_cache->protection_domain()->verify(); |
1 | 319 |
} |
320 |
} |
|
321 |
||
34666 | 322 |
bool equals(const Symbol* class_name, ClassLoaderData* loader_data) const { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
323 |
Klass* klass = (Klass*)literal(); |
33602 | 324 |
return (klass->name() == class_name && _loader_data == loader_data); |
1 | 325 |
} |
326 |
||
36381
b9ed6bef9364
8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents:
35498
diff
changeset
|
327 |
void print_count(outputStream *st) { |
1 | 328 |
int count = 0; |
329 |
for (ProtectionDomainEntry* current = _pd_set; |
|
330 |
current != NULL; |
|
331 |
current = current->_next) { |
|
332 |
count++; |
|
333 |
} |
|
36381
b9ed6bef9364
8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents:
35498
diff
changeset
|
334 |
st->print_cr("pd set count = #%d", count); |
1 | 335 |
} |
336 |
}; |
|
2534 | 337 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
338 |
// Entry in a SymbolPropertyTable, mapping a single Symbol* |
2534 | 339 |
// to a managed and an unmanaged pointer. |
13195 | 340 |
class SymbolPropertyEntry : public HashtableEntry<Symbol*, mtSymbol> { |
2534 | 341 |
friend class VMStructs; |
342 |
private: |
|
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
343 |
intptr_t _symbol_mode; // secondary key |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
344 |
Method* _method; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
345 |
oop _method_type; |
2534 | 346 |
|
347 |
public: |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
348 |
Symbol* symbol() const { return literal(); } |
2534 | 349 |
|
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
350 |
intptr_t symbol_mode() const { return _symbol_mode; } |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
351 |
void set_symbol_mode(intptr_t m) { _symbol_mode = m; } |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
352 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
353 |
Method* method() const { return _method; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
354 |
void set_method(Method* p) { _method = p; } |
2534 | 355 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
356 |
oop method_type() const { return _method_type; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
357 |
oop* method_type_addr() { return &_method_type; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
358 |
void set_method_type(oop p) { _method_type = p; } |
2534 | 359 |
|
360 |
SymbolPropertyEntry* next() const { |
|
13195 | 361 |
return (SymbolPropertyEntry*)HashtableEntry<Symbol*, mtSymbol>::next(); |
2534 | 362 |
} |
363 |
||
364 |
SymbolPropertyEntry** next_addr() { |
|
13195 | 365 |
return (SymbolPropertyEntry**)HashtableEntry<Symbol*, mtSymbol>::next_addr(); |
2534 | 366 |
} |
367 |
||
368 |
void print_on(outputStream* st) const { |
|
369 |
symbol()->print_value_on(st); |
|
31592
43f48e165466
8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents:
29081
diff
changeset
|
370 |
st->print("/mode=" INTX_FORMAT, symbol_mode()); |
2534 | 371 |
st->print(" -> "); |
372 |
bool printed = false; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
373 |
if (method() != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
374 |
method()->print_value_on(st); |
2534 | 375 |
printed = true; |
376 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
377 |
if (method_type() != NULL) { |
2534 | 378 |
if (printed) st->print(" and "); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
20408
diff
changeset
|
379 |
st->print(INTPTR_FORMAT, p2i((void *)method_type())); |
2534 | 380 |
printed = true; |
381 |
} |
|
382 |
st->print_cr(printed ? "" : "(empty)"); |
|
383 |
} |
|
384 |
}; |
|
385 |
||
386 |
// A system-internal mapping of symbols to pointers, both managed |
|
387 |
// and unmanaged. Used to record the auto-generation of each method |
|
388 |
// MethodHandle.invoke(S)T, for all signatures (S)T. |
|
13195 | 389 |
class SymbolPropertyTable : public Hashtable<Symbol*, mtSymbol> { |
2534 | 390 |
friend class VMStructs; |
391 |
private: |
|
392 |
SymbolPropertyEntry* bucket(int i) { |
|
13195 | 393 |
return (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::bucket(i); |
2534 | 394 |
} |
395 |
||
396 |
// The following method is not MT-safe and must be done under lock. |
|
397 |
SymbolPropertyEntry** bucket_addr(int i) { |
|
13195 | 398 |
return (SymbolPropertyEntry**) Hashtable<Symbol*, mtSymbol>::bucket_addr(i); |
2534 | 399 |
} |
400 |
||
401 |
void add_entry(int index, SymbolPropertyEntry* new_entry) { |
|
402 |
ShouldNotReachHere(); |
|
403 |
} |
|
404 |
void set_entry(int index, SymbolPropertyEntry* new_entry) { |
|
405 |
ShouldNotReachHere(); |
|
406 |
} |
|
407 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
408 |
SymbolPropertyEntry* new_entry(unsigned int hash, Symbol* symbol, intptr_t symbol_mode) { |
13195 | 409 |
SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::new_entry(hash, symbol); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
410 |
// Hashtable with Symbol* literal must increment and decrement refcount. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
411 |
symbol->increment_refcount(); |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
412 |
entry->set_symbol_mode(symbol_mode); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
413 |
entry->set_method(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
414 |
entry->set_method_type(NULL); |
2534 | 415 |
return entry; |
416 |
} |
|
417 |
||
418 |
public: |
|
419 |
SymbolPropertyTable(int table_size); |
|
13195 | 420 |
SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t, int number_of_entries); |
2534 | 421 |
|
422 |
void free_entry(SymbolPropertyEntry* entry) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
423 |
// decrement Symbol refcount here because hashtable doesn't. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
424 |
entry->literal()->decrement_refcount(); |
13195 | 425 |
Hashtable<Symbol*, mtSymbol>::free_entry(entry); |
2534 | 426 |
} |
427 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
428 |
unsigned int compute_hash(Symbol* sym, intptr_t symbol_mode) { |
2534 | 429 |
// Use the regular identity_hash. |
13195 | 430 |
return Hashtable<Symbol*, mtSymbol>::compute_hash(sym) ^ symbol_mode; |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
431 |
} |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
432 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
433 |
int index_for(Symbol* name, intptr_t symbol_mode) { |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
434 |
return hash_to_index(compute_hash(name, symbol_mode)); |
2534 | 435 |
} |
436 |
||
437 |
// need not be locked; no state change |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
438 |
SymbolPropertyEntry* find_entry(int index, unsigned int hash, Symbol* name, intptr_t name_mode); |
2534 | 439 |
|
440 |
// must be done under SystemDictionary_lock |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
441 |
SymbolPropertyEntry* add_entry(int index, unsigned int hash, Symbol* name, intptr_t name_mode); |
2534 | 442 |
|
443 |
// GC support |
|
444 |
void oops_do(OopClosure* f); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
445 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
446 |
void methods_do(void f(Method*)); |
2534 | 447 |
|
448 |
// Sharing support |
|
449 |
void reorder_dictionary(); |
|
450 |
||
451 |
#ifndef PRODUCT |
|
452 |
void print(); |
|
453 |
#endif |
|
454 |
void verify(); |
|
455 |
}; |
|
7397 | 456 |
#endif // SHARE_VM_CLASSFILE_DICTIONARY_HPP |