annotate src/share/vm/classfile/dictionary.hpp @ 12837:82af7d7a0128

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