author | coleenp |
Wed, 24 Jan 2018 11:33:18 -0500 | |
changeset 48811 | 58787a1708d2 |
parent 48781 | 6ebef5cd0c8d |
child 49340 | 4e82736053ae |
permissions | -rw-r--r-- |
1 | 1 |
/* |
48781
6ebef5cd0c8d
8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents:
47774
diff
changeset
|
2 |
* Copyright (c) 2003, 2018, 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 |
||
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
46380
diff
changeset
|
28 |
#include "classfile/protectionDomainCache.hpp" |
7397 | 29 |
#include "classfile/systemDictionary.hpp" |
30 |
#include "oops/instanceKlass.hpp" |
|
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
26181
diff
changeset
|
31 |
#include "oops/oop.hpp" |
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
32 |
#include "runtime/orderAccess.hpp" |
7397 | 33 |
#include "utilities/hashtable.hpp" |
36381
b9ed6bef9364
8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents:
35498
diff
changeset
|
34 |
#include "utilities/ostream.hpp" |
7397 | 35 |
|
1 | 36 |
class DictionaryEntry; |
20405 | 37 |
class BoolObjectClosure; |
1 | 38 |
|
39 |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
46729 | 40 |
// The data structure for the class loader data dictionaries (and the shared system |
1 | 41 |
// dictionary). |
42 |
||
46729 | 43 |
class Dictionary : public Hashtable<InstanceKlass*, mtClass> { |
1 | 44 |
friend class VMStructs; |
45 |
||
47774 | 46 |
static bool _some_dictionary_needs_resizing; |
47 |
bool _resizable; |
|
48 |
bool _needs_resizing; |
|
49 |
void check_if_needs_resize(); |
|
50 |
||
46729 | 51 |
ClassLoaderData* _loader_data; // backpointer to owning loader |
52 |
ClassLoaderData* loader_data() const { return _loader_data; } |
|
20405 | 53 |
|
46729 | 54 |
DictionaryEntry* get_entry(int index, unsigned int hash, Symbol* name); |
1 | 55 |
|
48811
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
56 |
void clean_cached_protection_domains(BoolObjectClosure* is_alive, DictionaryEntry* probe); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
57 |
|
34257
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33602
diff
changeset
|
58 |
protected: |
46729 | 59 |
static size_t entry_size(); |
60 |
public: |
|
47774 | 61 |
Dictionary(ClassLoaderData* loader_data, int table_size, bool resizable = false); |
62 |
Dictionary(ClassLoaderData* loader_data, int table_size, HashtableBucket<mtClass>* t, int number_of_entries, bool resizable = false); |
|
46729 | 63 |
~Dictionary(); |
1 | 64 |
|
47774 | 65 |
static bool does_any_dictionary_needs_resizing(); |
66 |
bool resize_if_needed(); |
|
67 |
||
46729 | 68 |
DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass); |
69 |
||
47774 | 70 |
void add_klass(unsigned int hash, Symbol* class_name, InstanceKlass* obj); |
46729 | 71 |
|
72 |
InstanceKlass* find_class(int index, unsigned int hash, Symbol* name); |
|
1 | 73 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
74 |
InstanceKlass* find_shared_class(int index, unsigned int hash, Symbol* name); |
1 | 75 |
|
76 |
// GC support |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
77 |
void oops_do(OopClosure* f); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
78 |
void roots_oops_do(OopClosure* strong, OopClosure* weak); |
1 | 79 |
|
46729 | 80 |
void classes_do(void f(InstanceKlass*)); |
81 |
void classes_do(void f(InstanceKlass*, TRAPS), TRAPS); |
|
82 |
void all_entries_do(void f(InstanceKlass*, ClassLoaderData*)); |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
83 |
void classes_do(MetaspaceClosure* it); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
84 |
|
20405 | 85 |
void unlink(BoolObjectClosure* is_alive); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
86 |
void remove_classes_in_error_state(); |
1 | 87 |
|
46729 | 88 |
// Unload classes whose defining loaders are unloaded |
48811
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
89 |
void do_unloading(BoolObjectClosure* is_alive); |
1 | 90 |
|
91 |
// Protection domains |
|
47774 | 92 |
InstanceKlass* find(unsigned int hash, Symbol* name, Handle protection_domain); |
93 |
bool is_valid_protection_domain(unsigned int hash, |
|
46729 | 94 |
Symbol* name, |
1 | 95 |
Handle protection_domain); |
96 |
void add_protection_domain(int index, unsigned int hash, |
|
46729 | 97 |
InstanceKlass* klass, |
1 | 98 |
Handle protection_domain, TRAPS); |
99 |
||
100 |
// Sharing support |
|
47761
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47634
diff
changeset
|
101 |
void reorder_dictionary_for_sharing() NOT_CDS_RETURN; |
1 | 102 |
|
46742 | 103 |
void print_on(outputStream* st) const; |
1 | 104 |
void verify(); |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
105 |
DictionaryEntry* bucket(int i) const { |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
106 |
return (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::bucket(i); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
107 |
} |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
108 |
|
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
109 |
// The following method is not MT-safe and must be done under lock. |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
110 |
DictionaryEntry** bucket_addr(int i) { |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
111 |
return (DictionaryEntry**)Hashtable<InstanceKlass*, mtClass>::bucket_addr(i); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
112 |
} |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
113 |
|
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
114 |
void add_entry(int index, DictionaryEntry* new_entry) { |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
115 |
Hashtable<InstanceKlass*, mtClass>::add_entry(index, (HashtableEntry<InstanceKlass*, mtClass>*)new_entry); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
116 |
} |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
117 |
|
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
118 |
void unlink_entry(DictionaryEntry* entry) { |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
119 |
Hashtable<InstanceKlass*, mtClass>::unlink_entry((HashtableEntry<InstanceKlass*, mtClass>*)entry); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
120 |
} |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
121 |
|
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
122 |
void free_entry(DictionaryEntry* entry); |
1 | 123 |
}; |
124 |
||
46729 | 125 |
// An entry in the class loader data dictionaries, this describes a class as |
126 |
// { InstanceKlass*, protection_domain }. |
|
1 | 127 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
128 |
class DictionaryEntry : public HashtableEntry<InstanceKlass*, mtClass> { |
1 | 129 |
friend class VMStructs; |
130 |
private: |
|
131 |
// Contains the set of approved protection domains that can access |
|
46729 | 132 |
// this dictionary entry. |
20405 | 133 |
// |
134 |
// This protection domain set is a set of tuples: |
|
135 |
// |
|
136 |
// (InstanceKlass C, initiating class loader ICL, Protection Domain PD) |
|
137 |
// |
|
138 |
// [Note that C.protection_domain(), which is stored in the java.lang.Class |
|
139 |
// mirror of C, is NOT the same as PD] |
|
140 |
// |
|
141 |
// If such an entry (C, ICL, PD) exists in the table, it means that |
|
142 |
// it is okay for a class Foo to reference C, where |
|
143 |
// |
|
144 |
// Foo.protection_domain() == PD, and |
|
145 |
// Foo's defining class loader == ICL |
|
146 |
// |
|
147 |
// The usage of the PD set can be seen in SystemDictionary::validate_protection_domain() |
|
148 |
// It is essentially a cache to avoid repeated Java up-calls to |
|
149 |
// ClassLoader.checkPackageAccess(). |
|
150 |
// |
|
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
151 |
ProtectionDomainEntry* volatile _pd_set; |
1 | 152 |
|
153 |
public: |
|
154 |
// Tells whether a protection is in the approved set. |
|
155 |
bool contains_protection_domain(oop protection_domain) const; |
|
156 |
// Adds a protection domain to the approved set. |
|
46274
534d019edb92
8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents:
42073
diff
changeset
|
157 |
void add_protection_domain(Dictionary* dict, Handle protection_domain); |
1 | 158 |
|
46729 | 159 |
InstanceKlass* instance_klass() const { return literal(); } |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
160 |
InstanceKlass** klass_addr() { return (InstanceKlass**)literal_addr(); } |
1 | 161 |
|
162 |
DictionaryEntry* next() const { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
163 |
return (DictionaryEntry*)HashtableEntry<InstanceKlass*, mtClass>::next(); |
1 | 164 |
} |
165 |
||
166 |
DictionaryEntry** next_addr() { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
167 |
return (DictionaryEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr(); |
1 | 168 |
} |
169 |
||
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
170 |
ProtectionDomainEntry* pd_set() const { return _pd_set; } |
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
171 |
void set_pd_set(ProtectionDomainEntry* new_head) { _pd_set = new_head; } |
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
172 |
|
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
173 |
ProtectionDomainEntry* pd_set_acquire() const { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
174 |
return OrderAccess::load_acquire(&_pd_set); |
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
175 |
} |
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
176 |
void release_set_pd_set(ProtectionDomainEntry* new_head) { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
177 |
OrderAccess::release_store(&_pd_set, new_head); |
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
178 |
} |
1 | 179 |
|
46729 | 180 |
// Tells whether the initiating class' protection domain can access the klass in this entry |
1 | 181 |
bool is_valid_protection_domain(Handle protection_domain) { |
182 |
if (!ProtectionDomainVerification) return true; |
|
183 |
if (!SystemDictionary::has_checkPackageAccess()) return true; |
|
184 |
||
185 |
return protection_domain() == NULL |
|
186 |
? true |
|
187 |
: contains_protection_domain(protection_domain()); |
|
188 |
} |
|
189 |
||
190 |
void verify_protection_domain_set() { |
|
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
191 |
for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint |
1 | 192 |
current != NULL; |
193 |
current = current->_next) { |
|
48781
6ebef5cd0c8d
8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents:
47774
diff
changeset
|
194 |
current->_pd_cache->object_no_keepalive()->verify(); |
1 | 195 |
} |
196 |
} |
|
197 |
||
46729 | 198 |
bool equals(const Symbol* class_name) const { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
199 |
InstanceKlass* klass = (InstanceKlass*)literal(); |
46729 | 200 |
return (klass->name() == class_name); |
1 | 201 |
} |
202 |
||
36381
b9ed6bef9364
8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents:
35498
diff
changeset
|
203 |
void print_count(outputStream *st) { |
1 | 204 |
int count = 0; |
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
205 |
for (ProtectionDomainEntry* current = pd_set(); // accessed inside SD lock |
1 | 206 |
current != NULL; |
207 |
current = current->_next) { |
|
208 |
count++; |
|
209 |
} |
|
36381
b9ed6bef9364
8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents:
35498
diff
changeset
|
210 |
st->print_cr("pd set count = #%d", count); |
1 | 211 |
} |
46475
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
212 |
|
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
213 |
void verify(); |
1 | 214 |
}; |
2534 | 215 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
216 |
// Entry in a SymbolPropertyTable, mapping a single Symbol* |
2534 | 217 |
// to a managed and an unmanaged pointer. |
13195 | 218 |
class SymbolPropertyEntry : public HashtableEntry<Symbol*, mtSymbol> { |
2534 | 219 |
friend class VMStructs; |
220 |
private: |
|
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
221 |
intptr_t _symbol_mode; // secondary key |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
222 |
Method* _method; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
223 |
oop _method_type; |
2534 | 224 |
|
225 |
public: |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
226 |
Symbol* symbol() const { return literal(); } |
2534 | 227 |
|
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
228 |
intptr_t symbol_mode() const { return _symbol_mode; } |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
229 |
void set_symbol_mode(intptr_t m) { _symbol_mode = m; } |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
230 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
231 |
Method* method() const { return _method; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
232 |
void set_method(Method* p) { _method = p; } |
2534 | 233 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
234 |
oop method_type() const { return _method_type; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
235 |
oop* method_type_addr() { return &_method_type; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
236 |
void set_method_type(oop p) { _method_type = p; } |
2534 | 237 |
|
238 |
SymbolPropertyEntry* next() const { |
|
13195 | 239 |
return (SymbolPropertyEntry*)HashtableEntry<Symbol*, mtSymbol>::next(); |
2534 | 240 |
} |
241 |
||
242 |
SymbolPropertyEntry** next_addr() { |
|
13195 | 243 |
return (SymbolPropertyEntry**)HashtableEntry<Symbol*, mtSymbol>::next_addr(); |
2534 | 244 |
} |
245 |
||
46742 | 246 |
void print_entry(outputStream* st) const { |
2534 | 247 |
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
|
248 |
st->print("/mode=" INTX_FORMAT, symbol_mode()); |
2534 | 249 |
st->print(" -> "); |
250 |
bool printed = false; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
251 |
if (method() != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
252 |
method()->print_value_on(st); |
2534 | 253 |
printed = true; |
254 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
255 |
if (method_type() != NULL) { |
2534 | 256 |
if (printed) st->print(" and "); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
20408
diff
changeset
|
257 |
st->print(INTPTR_FORMAT, p2i((void *)method_type())); |
2534 | 258 |
printed = true; |
259 |
} |
|
260 |
st->print_cr(printed ? "" : "(empty)"); |
|
261 |
} |
|
262 |
}; |
|
263 |
||
264 |
// A system-internal mapping of symbols to pointers, both managed |
|
265 |
// and unmanaged. Used to record the auto-generation of each method |
|
266 |
// MethodHandle.invoke(S)T, for all signatures (S)T. |
|
13195 | 267 |
class SymbolPropertyTable : public Hashtable<Symbol*, mtSymbol> { |
2534 | 268 |
friend class VMStructs; |
269 |
private: |
|
270 |
// The following method is not MT-safe and must be done under lock. |
|
271 |
SymbolPropertyEntry** bucket_addr(int i) { |
|
13195 | 272 |
return (SymbolPropertyEntry**) Hashtable<Symbol*, mtSymbol>::bucket_addr(i); |
2534 | 273 |
} |
274 |
||
275 |
void add_entry(int index, SymbolPropertyEntry* new_entry) { |
|
276 |
ShouldNotReachHere(); |
|
277 |
} |
|
278 |
void set_entry(int index, SymbolPropertyEntry* new_entry) { |
|
279 |
ShouldNotReachHere(); |
|
280 |
} |
|
281 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
282 |
SymbolPropertyEntry* new_entry(unsigned int hash, Symbol* symbol, intptr_t symbol_mode) { |
13195 | 283 |
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
|
284 |
// 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
|
285 |
symbol->increment_refcount(); |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
286 |
entry->set_symbol_mode(symbol_mode); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
287 |
entry->set_method(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
288 |
entry->set_method_type(NULL); |
2534 | 289 |
return entry; |
290 |
} |
|
291 |
||
292 |
public: |
|
293 |
SymbolPropertyTable(int table_size); |
|
13195 | 294 |
SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t, int number_of_entries); |
2534 | 295 |
|
296 |
void free_entry(SymbolPropertyEntry* entry) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
297 |
// decrement Symbol refcount here because hashtable doesn't. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
298 |
entry->literal()->decrement_refcount(); |
13195 | 299 |
Hashtable<Symbol*, mtSymbol>::free_entry(entry); |
2534 | 300 |
} |
301 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
302 |
unsigned int compute_hash(Symbol* sym, intptr_t symbol_mode) { |
2534 | 303 |
// Use the regular identity_hash. |
13195 | 304 |
return Hashtable<Symbol*, mtSymbol>::compute_hash(sym) ^ symbol_mode; |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
305 |
} |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
306 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
307 |
int index_for(Symbol* name, intptr_t symbol_mode) { |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
308 |
return hash_to_index(compute_hash(name, symbol_mode)); |
2534 | 309 |
} |
310 |
||
311 |
// need not be locked; no state change |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
312 |
SymbolPropertyEntry* find_entry(int index, unsigned int hash, Symbol* name, intptr_t name_mode); |
2534 | 313 |
|
314 |
// must be done under SystemDictionary_lock |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
315 |
SymbolPropertyEntry* add_entry(int index, unsigned int hash, Symbol* name, intptr_t name_mode); |
2534 | 316 |
|
317 |
// GC support |
|
318 |
void oops_do(OopClosure* f); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
319 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
320 |
void methods_do(void f(Method*)); |
2534 | 321 |
|
322 |
void verify(); |
|
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
323 |
|
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
324 |
SymbolPropertyEntry* bucket(int i) { |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
325 |
return (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::bucket(i); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
326 |
} |
2534 | 327 |
}; |
7397 | 328 |
#endif // SHARE_VM_CLASSFILE_DICTIONARY_HPP |