Mercurial > hg > graal-jvmci-8
annotate src/share/vm/classfile/dictionary.hpp @ 23893:50e62b688ddc
8150752: Share Class Data
Reviewed-by: acorn, hseigel, mschoene
author | iklam |
---|---|
date | Thu, 24 Mar 2016 21:38:15 -0700 |
parents | 6e0cb14ce59b |
children |
rev | line source |
---|---|
0 | 1 /* |
23893 | 2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 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" | |
12837 | 30 #include "oops/oop.inline.hpp" |
1972 | 31 #include "utilities/hashtable.hpp" |
32 | |
0 | 33 class DictionaryEntry; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
34 class PSPromotionManager; |
12837 | 35 class ProtectionDomainCacheTable; |
36 class ProtectionDomainCacheEntry; | |
37 class BoolObjectClosure; | |
0 | 38 |
39 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
40 // The data structure for the system dictionary (and the shared system | |
41 // dictionary). | |
42 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
43 class Dictionary : public TwoOopHashtable<Klass*, mtClass> { |
0 | 44 friend class VMStructs; |
45 private: | |
46 // current iteration index. | |
47 static int _current_class_index; | |
48 // pointer to the current hash table entry. | |
49 static DictionaryEntry* _current_class_entry; | |
50 | |
12837 | 51 ProtectionDomainCacheTable* _pd_cache_table; |
52 | |
0 | 53 DictionaryEntry* get_entry(int index, unsigned int hash, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
54 Symbol* name, ClassLoaderData* loader_data); |
0 | 55 |
23893 | 56 protected: |
0 | 57 DictionaryEntry* bucket(int i) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
58 return (DictionaryEntry*)Hashtable<Klass*, mtClass>::bucket(i); |
0 | 59 } |
60 | |
61 // The following method is not MT-safe and must be done under lock. | |
62 DictionaryEntry** bucket_addr(int i) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
63 return (DictionaryEntry**)Hashtable<Klass*, mtClass>::bucket_addr(i); |
0 | 64 } |
65 | |
66 void add_entry(int index, DictionaryEntry* new_entry) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
67 Hashtable<Klass*, mtClass>::add_entry(index, (HashtableEntry<Klass*, mtClass>*)new_entry); |
0 | 68 } |
69 | |
23893 | 70 static size_t entry_size(); |
71 | |
0 | 72 public: |
73 Dictionary(int table_size); | |
6197 | 74 Dictionary(int table_size, HashtableBucket<mtClass>* t, int number_of_entries); |
0 | 75 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
76 DictionaryEntry* new_entry(unsigned int hash, Klass* klass, ClassLoaderData* loader_data); |
0 | 77 |
78 DictionaryEntry* new_entry(); | |
79 | |
80 void free_entry(DictionaryEntry* entry); | |
81 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
82 void add_klass(Symbol* class_name, ClassLoaderData* loader_data,KlassHandle obj); |
0 | 83 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
84 Klass* find_class(int index, unsigned int hash, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
85 Symbol* name, ClassLoaderData* loader_data); |
0 | 86 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
87 Klass* find_shared_class(int index, unsigned int hash, Symbol* name); |
0 | 88 |
89 // Compiler support | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
90 Klass* try_get_next_class(); |
0 | 91 |
92 // GC support | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
93 void oops_do(OopClosure* f); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
94 void always_strong_oops_do(OopClosure* blk); |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
17937
diff
changeset
|
95 void roots_oops_do(OopClosure* strong, OopClosure* weak); |
0 | 96 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
97 void always_strong_classes_do(KlassClosure* closure); |
0 | 98 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
99 void classes_do(void f(Klass*)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
100 void classes_do(void f(Klass*, TRAPS), TRAPS); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
101 void classes_do(void f(Klass*, ClassLoaderData*)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
102 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
103 void methods_do(void f(Method*)); |
0 | 104 |
12837 | 105 void unlink(BoolObjectClosure* is_alive); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
20350
diff
changeset
|
106 void remove_classes_in_error_state(); |
0 | 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. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
110 static bool is_strongly_reachable(ClassLoaderData* loader_data, Klass* klass) { |
0 | 111 assert (klass != NULL, "should have non-null klass"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
112 return (loader_data->is_the_null_class_loader_data() || !ClassUnloading); |
0 | 113 } |
114 | |
20350
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
20278
diff
changeset
|
115 // Unload (that is, break root links to) all unmarked classes and loaders. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
20278
diff
changeset
|
116 void do_unloading(); |
0 | 117 |
118 // Protection domains | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
119 Klass* find(int index, unsigned int hash, Symbol* name, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
120 ClassLoaderData* loader_data, Handle protection_domain, TRAPS); |
0 | 121 bool is_valid_protection_domain(int index, unsigned int hash, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
122 Symbol* name, ClassLoaderData* loader_data, |
0 | 123 Handle protection_domain); |
124 void add_protection_domain(int index, unsigned int hash, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
125 instanceKlassHandle klass, ClassLoaderData* loader_data, |
0 | 126 Handle protection_domain, TRAPS); |
127 | |
128 // Sharing support | |
129 void reorder_dictionary(); | |
130 | |
12837 | 131 ProtectionDomainCacheEntry* cache_get(oop protection_domain); |
0 | 132 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
20350
diff
changeset
|
133 void print(bool details = true); |
0 | 134 void verify(); |
135 }; | |
136 | |
137 // The following classes can be in dictionary.cpp, but we need these | |
12837 | 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 | |
200 static unsigned int compute_hash(oop protection_domain) { | |
201 return (unsigned int)(protection_domain->identity_hash()); | |
202 } | |
203 | |
204 int index_for(oop protection_domain) { | |
205 return hash_to_index(compute_hash(protection_domain)); | |
206 } | |
207 | |
208 ProtectionDomainCacheEntry* add_entry(int index, unsigned int hash, oop protection_domain); | |
209 ProtectionDomainCacheEntry* find_entry(int index, oop protection_domain); | |
210 | |
211 public: | |
212 | |
213 ProtectionDomainCacheTable(int table_size); | |
214 | |
215 ProtectionDomainCacheEntry* get(oop protection_domain); | |
216 void free(ProtectionDomainCacheEntry* entry); | |
217 | |
218 void unlink(BoolObjectClosure* cl); | |
219 | |
220 // GC support | |
221 void oops_do(OopClosure* f); | |
222 void always_strong_oops_do(OopClosure* f); | |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
17937
diff
changeset
|
223 void roots_oops_do(OopClosure* strong, OopClosure* weak); |
12837 | 224 |
225 static uint bucket_size(); | |
226 | |
227 void print() PRODUCT_RETURN; | |
228 void verify(); | |
229 }; | |
230 | |
0 | 231 |
6197 | 232 class ProtectionDomainEntry :public CHeapObj<mtClass> { |
0 | 233 friend class VMStructs; |
234 public: | |
235 ProtectionDomainEntry* _next; | |
12837 | 236 ProtectionDomainCacheEntry* _pd_cache; |
0 | 237 |
12837 | 238 ProtectionDomainEntry(ProtectionDomainCacheEntry* pd_cache, ProtectionDomainEntry* next) { |
239 _pd_cache = pd_cache; | |
240 _next = next; | |
0 | 241 } |
242 | |
243 ProtectionDomainEntry* next() { return _next; } | |
12837 | 244 oop protection_domain() { return _pd_cache->protection_domain(); } |
0 | 245 }; |
246 | |
247 // An entry in the system dictionary, this describes a class as | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
248 // { Klass*, loader, protection_domain }. |
0 | 249 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
250 class DictionaryEntry : public HashtableEntry<Klass*, mtClass> { |
0 | 251 friend class VMStructs; |
252 private: | |
253 // Contains the set of approved protection domains that can access | |
254 // this system dictionary entry. | |
12837 | 255 // |
256 // This protection domain set is a set of tuples: | |
257 // | |
258 // (InstanceKlass C, initiating class loader ICL, Protection Domain PD) | |
259 // | |
260 // [Note that C.protection_domain(), which is stored in the java.lang.Class | |
261 // mirror of C, is NOT the same as PD] | |
262 // | |
263 // If such an entry (C, ICL, PD) exists in the table, it means that | |
264 // it is okay for a class Foo to reference C, where | |
265 // | |
266 // Foo.protection_domain() == PD, and | |
267 // Foo's defining class loader == ICL | |
268 // | |
269 // The usage of the PD set can be seen in SystemDictionary::validate_protection_domain() | |
270 // It is essentially a cache to avoid repeated Java up-calls to | |
271 // ClassLoader.checkPackageAccess(). | |
272 // | |
0 | 273 ProtectionDomainEntry* _pd_set; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
274 ClassLoaderData* _loader_data; |
0 | 275 |
276 public: | |
277 // Tells whether a protection is in the approved set. | |
278 bool contains_protection_domain(oop protection_domain) const; | |
279 // Adds a protection domain to the approved set. | |
12837 | 280 void add_protection_domain(Dictionary* dict, oop protection_domain); |
0 | 281 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
282 Klass* klass() const { return (Klass*)literal(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
283 Klass** klass_addr() { return (Klass**)literal_addr(); } |
0 | 284 |
285 DictionaryEntry* next() const { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
286 return (DictionaryEntry*)HashtableEntry<Klass*, mtClass>::next(); |
0 | 287 } |
288 | |
289 DictionaryEntry** next_addr() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
290 return (DictionaryEntry**)HashtableEntry<Klass*, mtClass>::next_addr(); |
0 | 291 } |
292 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
293 ClassLoaderData* loader_data() const { return _loader_data; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
294 void set_loader_data(ClassLoaderData* loader_data) { _loader_data = loader_data; } |
0 | 295 |
296 ProtectionDomainEntry* pd_set() const { return _pd_set; } | |
297 void set_pd_set(ProtectionDomainEntry* pd_set) { _pd_set = pd_set; } | |
298 | |
299 bool has_protection_domain() { return _pd_set != NULL; } | |
300 | |
301 // Tells whether the initiating class' protection can access the this _klass | |
302 bool is_valid_protection_domain(Handle protection_domain) { | |
303 if (!ProtectionDomainVerification) return true; | |
304 if (!SystemDictionary::has_checkPackageAccess()) return true; | |
305 | |
306 return protection_domain() == NULL | |
307 ? true | |
308 : contains_protection_domain(protection_domain()); | |
309 } | |
310 | |
12837 | 311 void set_strongly_reachable() { |
0 | 312 for (ProtectionDomainEntry* current = _pd_set; |
313 current != NULL; | |
314 current = current->_next) { | |
12837 | 315 current->_pd_cache->set_strongly_reachable(); |
0 | 316 } |
317 } | |
318 | |
319 void verify_protection_domain_set() { | |
320 for (ProtectionDomainEntry* current = _pd_set; | |
321 current != NULL; | |
322 current = current->_next) { | |
12837 | 323 current->_pd_cache->protection_domain()->verify(); |
0 | 324 } |
325 } | |
326 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
327 bool equals(Symbol* class_name, ClassLoaderData* loader_data) const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
328 Klass* klass = (Klass*)literal(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
329 return (InstanceKlass::cast(klass)->name() == class_name && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
330 _loader_data == loader_data); |
0 | 331 } |
332 | |
333 void print() { | |
334 int count = 0; | |
335 for (ProtectionDomainEntry* current = _pd_set; | |
336 current != NULL; | |
337 current = current->_next) { | |
338 count++; | |
339 } | |
340 tty->print_cr("pd set = #%d", count); | |
341 } | |
342 }; | |
710 | 343 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
344 // Entry in a SymbolPropertyTable, mapping a single Symbol* |
710 | 345 // to a managed and an unmanaged pointer. |
6197 | 346 class SymbolPropertyEntry : public HashtableEntry<Symbol*, mtSymbol> { |
710 | 347 friend class VMStructs; |
348 private: | |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
710
diff
changeset
|
349 intptr_t _symbol_mode; // secondary key |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
350 Method* _method; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
351 oop _method_type; |
710 | 352 |
353 public: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
354 Symbol* symbol() const { return literal(); } |
710 | 355 |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
710
diff
changeset
|
356 intptr_t symbol_mode() const { return _symbol_mode; } |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
710
diff
changeset
|
357 void set_symbol_mode(intptr_t m) { _symbol_mode = m; } |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
710
diff
changeset
|
358 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
359 Method* method() const { return _method; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
360 void set_method(Method* p) { _method = p; } |
710 | 361 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
362 oop method_type() const { return _method_type; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
363 oop* method_type_addr() { return &_method_type; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
364 void set_method_type(oop p) { _method_type = p; } |
710 | 365 |
366 SymbolPropertyEntry* next() const { | |
6197 | 367 return (SymbolPropertyEntry*)HashtableEntry<Symbol*, mtSymbol>::next(); |
710 | 368 } |
369 | |
370 SymbolPropertyEntry** next_addr() { | |
6197 | 371 return (SymbolPropertyEntry**)HashtableEntry<Symbol*, mtSymbol>::next_addr(); |
710 | 372 } |
373 | |
374 void print_on(outputStream* st) const { | |
375 symbol()->print_value_on(st); | |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
710
diff
changeset
|
376 st->print("/mode="INTX_FORMAT, symbol_mode()); |
710 | 377 st->print(" -> "); |
378 bool printed = false; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
379 if (method() != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
380 method()->print_value_on(st); |
710 | 381 printed = true; |
382 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
383 if (method_type() != NULL) { |
710 | 384 if (printed) st->print(" and "); |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12840
diff
changeset
|
385 st->print(INTPTR_FORMAT, p2i((void *)method_type())); |
710 | 386 printed = true; |
387 } | |
388 st->print_cr(printed ? "" : "(empty)"); | |
389 } | |
390 }; | |
391 | |
392 // A system-internal mapping of symbols to pointers, both managed | |
393 // and unmanaged. Used to record the auto-generation of each method | |
394 // MethodHandle.invoke(S)T, for all signatures (S)T. | |
6197 | 395 class SymbolPropertyTable : public Hashtable<Symbol*, mtSymbol> { |
710 | 396 friend class VMStructs; |
397 private: | |
398 SymbolPropertyEntry* bucket(int i) { | |
6197 | 399 return (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::bucket(i); |
710 | 400 } |
401 | |
402 // The following method is not MT-safe and must be done under lock. | |
403 SymbolPropertyEntry** bucket_addr(int i) { | |
6197 | 404 return (SymbolPropertyEntry**) Hashtable<Symbol*, mtSymbol>::bucket_addr(i); |
710 | 405 } |
406 | |
407 void add_entry(int index, SymbolPropertyEntry* new_entry) { | |
408 ShouldNotReachHere(); | |
409 } | |
410 void set_entry(int index, SymbolPropertyEntry* new_entry) { | |
411 ShouldNotReachHere(); | |
412 } | |
413 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
414 SymbolPropertyEntry* new_entry(unsigned int hash, Symbol* symbol, intptr_t symbol_mode) { |
6197 | 415 SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::new_entry(hash, symbol); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
416 // Hashtable with Symbol* literal must increment and decrement refcount. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
417 symbol->increment_refcount(); |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
710
diff
changeset
|
418 entry->set_symbol_mode(symbol_mode); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
419 entry->set_method(NULL); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
420 entry->set_method_type(NULL); |
710 | 421 return entry; |
422 } | |
423 | |
424 public: | |
425 SymbolPropertyTable(int table_size); | |
6197 | 426 SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t, int number_of_entries); |
710 | 427 |
428 void free_entry(SymbolPropertyEntry* entry) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
429 // decrement Symbol refcount here because hashtable doesn't. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
430 entry->literal()->decrement_refcount(); |
6197 | 431 Hashtable<Symbol*, mtSymbol>::free_entry(entry); |
710 | 432 } |
433 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
434 unsigned int compute_hash(Symbol* sym, intptr_t symbol_mode) { |
710 | 435 // Use the regular identity_hash. |
6197 | 436 return Hashtable<Symbol*, mtSymbol>::compute_hash(sym) ^ symbol_mode; |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
710
diff
changeset
|
437 } |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
710
diff
changeset
|
438 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
439 int index_for(Symbol* name, intptr_t symbol_mode) { |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
710
diff
changeset
|
440 return hash_to_index(compute_hash(name, symbol_mode)); |
710 | 441 } |
442 | |
443 // need not be locked; no state change | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
444 SymbolPropertyEntry* find_entry(int index, unsigned int hash, Symbol* name, intptr_t name_mode); |
710 | 445 |
446 // must be done under SystemDictionary_lock | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
447 SymbolPropertyEntry* add_entry(int index, unsigned int hash, Symbol* name, intptr_t name_mode); |
710 | 448 |
449 // GC support | |
450 void oops_do(OopClosure* f); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
451 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
452 void methods_do(void f(Method*)); |
710 | 453 |
454 // Sharing support | |
455 void reorder_dictionary(); | |
456 | |
457 #ifndef PRODUCT | |
458 void print(); | |
459 #endif | |
460 void verify(); | |
461 }; | |
1972 | 462 #endif // SHARE_VM_CLASSFILE_DICTIONARY_HPP |