annotate src/share/vm/classfile/dictionary.hpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children 3582bf76420e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_CLASSFILE_DICTIONARY_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CLASSFILE_DICTIONARY_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "oops/instanceKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "oops/oop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "utilities/hashtable.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class DictionaryEntry;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // The data structure for the system dictionary (and the shared system
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // dictionary).
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class Dictionary : public TwoOopHashtable {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // current iteration index.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 static int _current_class_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // pointer to the current hash table entry.
a61af66fc99e Initial load
duke
parents:
diff changeset
45 static DictionaryEntry* _current_class_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 DictionaryEntry* get_entry(int index, unsigned int hash,
a61af66fc99e Initial load
duke
parents:
diff changeset
48 symbolHandle name, Handle loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 DictionaryEntry* bucket(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 return (DictionaryEntry*)Hashtable::bucket(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // The following method is not MT-safe and must be done under lock.
a61af66fc99e Initial load
duke
parents:
diff changeset
55 DictionaryEntry** bucket_addr(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 return (DictionaryEntry**)Hashtable::bucket_addr(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 void add_entry(int index, DictionaryEntry* new_entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 Hashtable::add_entry(index, (HashtableEntry*)new_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
65 Dictionary(int table_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 Dictionary(int table_size, HashtableBucket* t, int number_of_entries);
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 DictionaryEntry* new_entry(unsigned int hash, klassOop klass, oop loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 DictionaryEntry* new_entry();
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void free_entry(DictionaryEntry* entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 void add_klass(symbolHandle class_name, Handle class_loader,KlassHandle obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 klassOop find_class(int index, unsigned int hash,
a61af66fc99e Initial load
duke
parents:
diff changeset
77 symbolHandle name, Handle loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 klassOop find_shared_class(int index, unsigned int hash, symbolHandle name);
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // Compiler support
a61af66fc99e Initial load
duke
parents:
diff changeset
82 klassOop try_get_next_class();
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // GC support
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 void oops_do(OopClosure* f);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 void always_strong_classes_do(OopClosure* blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 void classes_do(void f(klassOop));
a61af66fc99e Initial load
duke
parents:
diff changeset
89 void classes_do(void f(klassOop, TRAPS), TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 void classes_do(void f(klassOop, oop));
a61af66fc99e Initial load
duke
parents:
diff changeset
91 void classes_do(void f(klassOop, oop, TRAPS), TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 void methods_do(void f(methodOop));
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Classes loaded by the bootstrap loader are always strongly reachable.
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // If we're not doing class unloading, all classes are strongly reachable.
a61af66fc99e Initial load
duke
parents:
diff changeset
98 static bool is_strongly_reachable(oop class_loader, oop klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 assert (klass != NULL, "should have non-null klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
100 return (class_loader == NULL || !ClassUnloading);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Unload (that is, break root links to) all unmarked classes and
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // loaders. Returns "true" iff something was unloaded.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 bool do_unloading(BoolObjectClosure* is_alive);
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Protection domains
a61af66fc99e Initial load
duke
parents:
diff changeset
108 klassOop find(int index, unsigned int hash, symbolHandle name,
a61af66fc99e Initial load
duke
parents:
diff changeset
109 Handle loader, Handle protection_domain, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 bool is_valid_protection_domain(int index, unsigned int hash,
a61af66fc99e Initial load
duke
parents:
diff changeset
111 symbolHandle name, Handle class_loader,
a61af66fc99e Initial load
duke
parents:
diff changeset
112 Handle protection_domain);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 void add_protection_domain(int index, unsigned int hash,
a61af66fc99e Initial load
duke
parents:
diff changeset
114 instanceKlassHandle klass, Handle loader,
a61af66fc99e Initial load
duke
parents:
diff changeset
115 Handle protection_domain, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Sharing support
a61af66fc99e Initial load
duke
parents:
diff changeset
118 void dump(SerializeOopClosure* soc);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 void restore(SerializeOopClosure* soc);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void reorder_dictionary();
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
124 void print();
a61af66fc99e Initial load
duke
parents:
diff changeset
125 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
126 void verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
127 };
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // The following classes can be in dictionary.cpp, but we need these
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // to be in header file so that SA's vmStructs can access.
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 class ProtectionDomainEntry :public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
135 ProtectionDomainEntry* _next;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 oop _protection_domain;
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 ProtectionDomainEntry(oop protection_domain, ProtectionDomainEntry* next) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 _protection_domain = protection_domain;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 _next = next;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 ProtectionDomainEntry* next() { return _next; }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 oop protection_domain() { return _protection_domain; }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 };
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // An entry in the system dictionary, this describes a class as
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // { klassOop, loader, protection_domain }.
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 class DictionaryEntry : public HashtableEntry {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // Contains the set of approved protection domains that can access
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // this system dictionary entry.
a61af66fc99e Initial load
duke
parents:
diff changeset
155 ProtectionDomainEntry* _pd_set;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 oop _loader;
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Tells whether a protection is in the approved set.
a61af66fc99e Initial load
duke
parents:
diff changeset
161 bool contains_protection_domain(oop protection_domain) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // Adds a protection domain to the approved set.
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void add_protection_domain(oop protection_domain);
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 klassOop klass() const { return (klassOop)literal(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 klassOop* klass_addr() { return (klassOop*)literal_addr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 DictionaryEntry* next() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 return (DictionaryEntry*)HashtableEntry::next();
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 DictionaryEntry** next_addr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 return (DictionaryEntry**)HashtableEntry::next_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 oop loader() const { return _loader; }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 void set_loader(oop loader) { _loader = loader; }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 oop* loader_addr() { return &_loader; }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 ProtectionDomainEntry* pd_set() const { return _pd_set; }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 void set_pd_set(ProtectionDomainEntry* pd_set) { _pd_set = pd_set; }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 bool has_protection_domain() { return _pd_set != NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // Tells whether the initiating class' protection can access the this _klass
a61af66fc99e Initial load
duke
parents:
diff changeset
186 bool is_valid_protection_domain(Handle protection_domain) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 if (!ProtectionDomainVerification) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 if (!SystemDictionary::has_checkPackageAccess()) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 return protection_domain() == NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
191 ? true
a61af66fc99e Initial load
duke
parents:
diff changeset
192 : contains_protection_domain(protection_domain());
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 void protection_domain_set_oops_do(OopClosure* f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 for (ProtectionDomainEntry* current = _pd_set;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 current != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 current = current->_next) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 f->do_oop(&(current->_protection_domain));
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 void verify_protection_domain_set() {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 for (ProtectionDomainEntry* current = _pd_set;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 current != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 current = current->_next) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 current->_protection_domain->verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 bool equals(symbolOop class_name, oop class_loader) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 klassOop klass = (klassOop)literal();
a61af66fc99e Initial load
duke
parents:
diff changeset
214 return (instanceKlass::cast(klass)->name() == class_name &&
a61af66fc99e Initial load
duke
parents:
diff changeset
215 _loader == class_loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 int count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 for (ProtectionDomainEntry* current = _pd_set;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 current != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
222 current = current->_next) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 count++;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 tty->print_cr("pd set = #%d", count);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227 };
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
228
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
229 // Entry in a SymbolPropertyTable, mapping a single symbolOop
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
230 // to a managed and an unmanaged pointer.
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
231 class SymbolPropertyEntry : public HashtableEntry {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
232 friend class VMStructs;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
233 private:
1507
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
234 intptr_t _symbol_mode; // secondary key
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
235 oop _property_oop;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
236 address _property_data;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
237
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
238 public:
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
239 symbolOop symbol() const { return (symbolOop) literal(); }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
240
1507
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
241 intptr_t symbol_mode() const { return _symbol_mode; }
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
242 void set_symbol_mode(intptr_t m) { _symbol_mode = m; }
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
243
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
244 oop property_oop() const { return _property_oop; }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
245 void set_property_oop(oop p) { _property_oop = p; }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
246
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
247 address property_data() const { return _property_data; }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
248 void set_property_data(address p) { _property_data = p; }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
249
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
250 SymbolPropertyEntry* next() const {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
251 return (SymbolPropertyEntry*)HashtableEntry::next();
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
252 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
253
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
254 SymbolPropertyEntry** next_addr() {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
255 return (SymbolPropertyEntry**)HashtableEntry::next_addr();
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
256 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
257
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
258 oop* symbol_addr() { return literal_addr(); }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
259 oop* property_oop_addr() { return &_property_oop; }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
260
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
261 void print_on(outputStream* st) const {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
262 symbol()->print_value_on(st);
1507
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
263 st->print("/mode="INTX_FORMAT, symbol_mode());
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
264 st->print(" -> ");
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
265 bool printed = false;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
266 if (property_oop() != NULL) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
267 property_oop()->print_value_on(st);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
268 printed = true;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
269 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
270 if (property_data() != NULL) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
271 if (printed) st->print(" and ");
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
272 st->print(INTPTR_FORMAT, property_data());
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
273 printed = true;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
274 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
275 st->print_cr(printed ? "" : "(empty)");
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
276 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
277 };
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
278
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
279 // A system-internal mapping of symbols to pointers, both managed
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
280 // and unmanaged. Used to record the auto-generation of each method
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
281 // MethodHandle.invoke(S)T, for all signatures (S)T.
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
282 class SymbolPropertyTable : public Hashtable {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
283 friend class VMStructs;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
284 private:
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
285 SymbolPropertyEntry* bucket(int i) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
286 return (SymbolPropertyEntry*) Hashtable::bucket(i);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
287 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
288
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
289 // The following method is not MT-safe and must be done under lock.
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
290 SymbolPropertyEntry** bucket_addr(int i) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
291 return (SymbolPropertyEntry**) Hashtable::bucket_addr(i);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
292 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
293
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
294 void add_entry(int index, SymbolPropertyEntry* new_entry) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
295 ShouldNotReachHere();
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
296 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
297 void set_entry(int index, SymbolPropertyEntry* new_entry) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
298 ShouldNotReachHere();
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
299 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
300
1507
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
301 SymbolPropertyEntry* new_entry(unsigned int hash, symbolOop symbol, intptr_t symbol_mode) {
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
302 SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable::new_entry(hash, symbol);
1507
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
303 entry->set_symbol_mode(symbol_mode);
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
304 entry->set_property_oop(NULL);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
305 entry->set_property_data(NULL);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
306 return entry;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
307 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
308
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
309 public:
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
310 SymbolPropertyTable(int table_size);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
311 SymbolPropertyTable(int table_size, HashtableBucket* t, int number_of_entries);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
312
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
313 void free_entry(SymbolPropertyEntry* entry) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
314 Hashtable::free_entry(entry);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
315 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
316
1507
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
317 unsigned int compute_hash(symbolHandle sym, intptr_t symbol_mode) {
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
318 // Use the regular identity_hash.
1507
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
319 return Hashtable::compute_hash(sym) ^ symbol_mode;
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
320 }
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
321
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
322 int index_for(symbolHandle name, intptr_t symbol_mode) {
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
323 return hash_to_index(compute_hash(name, symbol_mode));
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
324 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
325
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
326 // need not be locked; no state change
1507
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
327 SymbolPropertyEntry* find_entry(int index, unsigned int hash, symbolHandle name, intptr_t name_mode);
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
328
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
329 // must be done under SystemDictionary_lock
1507
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 710
diff changeset
330 SymbolPropertyEntry* add_entry(int index, unsigned int hash, symbolHandle name, intptr_t name_mode);
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
331
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
332 // GC support
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
333 void oops_do(OopClosure* f);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
334 void methods_do(void f(methodOop));
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
335
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
336 // Sharing support
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
337 void dump(SerializeOopClosure* soc);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
338 void restore(SerializeOopClosure* soc);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
339 void reorder_dictionary();
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
340
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
341 #ifndef PRODUCT
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
342 void print();
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
343 #endif
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
344 void verify();
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
345 };
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
346
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
347
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
348 #endif // SHARE_VM_CLASSFILE_DICTIONARY_HPP