annotate src/share/vm/classfile/loaderConstraints.hpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents d2a62e0f25eb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
2 * Copyright (c) 2003, 2012, 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: 1339
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1339
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: 1339
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_LOADERCONSTRAINTS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_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/dictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "classfile/placeholders.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "utilities/hashtable.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class LoaderConstraintEntry;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
33 class Symbol;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
34
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
35 class LoaderConstraintTable : public Hashtable<Klass*, mtClass> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 enum Constants {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 _loader_constraint_size = 107, // number of entries in constraint table
a61af66fc99e Initial load
duke
parents:
diff changeset
41 _nof_buckets = 1009 // number of buckets in hash table
a61af66fc99e Initial load
duke
parents:
diff changeset
42 };
a61af66fc99e Initial load
duke
parents:
diff changeset
43
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
44 LoaderConstraintEntry** find_loader_constraint(Symbol* name,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45 Handle loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 LoaderConstraintTable(int nof_buckets);
a61af66fc99e Initial load
duke
parents:
diff changeset
50
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
51 LoaderConstraintEntry* new_entry(unsigned int hash, Symbol* name,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
52 Klass* klass, int num_loaders,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53 int max_loaders);
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
54 void free_entry(LoaderConstraintEntry *entry);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 LoaderConstraintEntry* bucket(int i) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
57 return (LoaderConstraintEntry*)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 LoaderConstraintEntry** bucket_addr(int i) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
61 return (LoaderConstraintEntry**)Hashtable<Klass*, mtClass>::bucket_addr(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
64 // Enhanced Class Redefinition support
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
65 void classes_do(KlassClosure* f);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Check class loader constraints
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
68 bool add_entry(Symbol* name, Klass* klass1, Handle loader1,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
69 Klass* klass2, Handle loader2);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
70
665
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
71 // Note: The main entry point for this module is via SystemDictionary.
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
72 // SystemDictionary::check_signature_loaders(Symbol* signature,
665
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
73 // Handle loader1, Handle loader2,
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
74 // bool is_method, TRAPS)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
76 Klass* find_constrained_klass(Symbol* name, Handle loader);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Class loader constraints
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 void ensure_loader_constraint_capacity(LoaderConstraintEntry *p, int nfree);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 void extend_loader_constraint(LoaderConstraintEntry* p, Handle loader,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
82 Klass* klass);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
83 void merge_loader_constraints(LoaderConstraintEntry** pp1,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
84 LoaderConstraintEntry** pp2, Klass* klass);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 bool check_or_update(instanceKlassHandle k, Handle loader,
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
87 Symbol* name);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
90 void purge_loader_constraints();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
91
1258
38836cf1d8d2 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 665
diff changeset
92 void verify(Dictionary* dictionary, PlaceholderTable* placeholders);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
93 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
94 void print();
a61af66fc99e Initial load
duke
parents:
diff changeset
95 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
96 };
a61af66fc99e Initial load
duke
parents:
diff changeset
97
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
98 class LoaderConstraintEntry : public HashtableEntry<Klass*, mtClass> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
99 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 private:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
101 Symbol* _name; // class name
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102 int _num_loaders;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 int _max_loaders;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
104 // Loader constraints enforce correct linking behavior.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
105 // Thus, it really operates on ClassLoaderData which represents linking domain,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
106 // not class loaders.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
107 ClassLoaderData** _loaders; // initiating loaders
0
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
110
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
111 Klass* klass() { return literal(); }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
112 Klass** klass_addr() { return literal_addr(); }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
113 void set_klass(Klass* k) { set_literal(k); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 LoaderConstraintEntry* next() {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
116 return (LoaderConstraintEntry*)HashtableEntry<Klass*, mtClass>::next();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 LoaderConstraintEntry** next_addr() {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
120 return (LoaderConstraintEntry**)HashtableEntry<Klass*, mtClass>::next_addr();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 void set_next(LoaderConstraintEntry* next) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
123 HashtableEntry<Klass*, mtClass>::set_next(next);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
126 Symbol* name() { return _name; }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
127 void set_name(Symbol* name) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
128 _name = name;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
129 if (name != NULL) name->increment_refcount();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
130 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 int num_loaders() { return _num_loaders; }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 void set_num_loaders(int i) { _num_loaders = i; }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 int max_loaders() { return _max_loaders; }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void set_max_loaders(int i) { _max_loaders = i; }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
138 ClassLoaderData** loaders() { return _loaders; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
139 void set_loaders(ClassLoaderData** loaders) { _loaders = loaders; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
140
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
141 ClassLoaderData* loader_data(int i) { return _loaders[i]; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
142 void set_loader_data(int i, ClassLoaderData* p) { _loaders[i] = p; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
143 // convenience
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
144 void set_loader(int i, oop p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
145 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
146
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
147 #endif // SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP