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