author | simonis |
Tue, 19 Jun 2018 09:43:53 +0200 | |
changeset 50625 | d9753e3db0c6 |
parent 50113 | caf115bb98ad |
child 52587 | 6cd56deebb0d |
permissions | -rw-r--r-- |
36508 | 1 |
/* |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
36508 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#ifndef SHARE_VM_CLASSFILE_PACKAGEENTRY_HPP |
|
26 |
#define SHARE_VM_CLASSFILE_PACKAGEENTRY_HPP |
|
27 |
||
28 |
#include "classfile/moduleEntry.hpp" |
|
29 |
#include "oops/symbol.hpp" |
|
30 |
#include "utilities/growableArray.hpp" |
|
31 |
#include "utilities/hashtable.hpp" |
|
50113 | 32 |
#include "utilities/macros.hpp" |
37503
77531df4dad3
8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents:
36508
diff
changeset
|
33 |
#include "utilities/ostream.hpp" |
50113 | 34 |
#if INCLUDE_JFR |
35 |
#include "jfr/support/jfrTraceIdExtension.hpp" |
|
36 |
#endif |
|
37 |
||
36508 | 38 |
|
39 |
// A PackageEntry basically represents a Java package. It contains: |
|
40 |
// - Symbol* containing the package's name. |
|
41 |
// - ModuleEntry* for this package's containing module. |
|
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
42 |
// - a field indicating if the package is exported unqualifiedly or to all |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
43 |
// unnamed modules. |
36508 | 44 |
// - a growable array containing other module entries that this |
45 |
// package is exported to. |
|
46 |
// |
|
38940
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
47 |
// Packages can be exported in the following 3 ways: |
39290
0cc9f5028562
8156871: Possible concurrency issue with JVM_AddModuleExports
lfoltan
parents:
38940
diff
changeset
|
48 |
// - not exported: the package does not have qualified or unqualified exports. |
38940
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
49 |
// - qualified exports: the package has been explicitly qualified to at least |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
50 |
// one particular module or has been qualifiedly exported |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
51 |
// to all unnamed modules. |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
52 |
// Note: being exported to all unnamed is a form of a qualified |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
53 |
// export. It is equivalent to the package being explicitly |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
54 |
// exported to all current and future unnamed modules. |
38940
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
55 |
// - unqualified exports: the package is exported to all modules. |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
56 |
// |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
57 |
// A package can transition from: |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
58 |
// - being not exported, to being exported either in a qualified or unqualified manner |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
59 |
// - being qualifiedly exported, to unqualifiedly exported. Its exported scope is widened. |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
60 |
// |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
61 |
// A package cannot transition from: |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
62 |
// - being unqualifiedly exported, to exported qualifiedly to a specific module. |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
63 |
// This transition attempt is silently ignored in set_exported. |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
64 |
// - being qualifiedly exported to not exported. |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
65 |
// Because transitions are only allowed from less exposure to greater exposure, |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
66 |
// the transition from qualifiedly exported to not exported would be considered |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
67 |
// a backward direction. Therefore the implementation considers a package as |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
68 |
// qualifiedly exported even if its export-list exists but is empty. |
36508 | 69 |
// |
70 |
// The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either |
|
71 |
// data structure. |
|
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
72 |
|
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
73 |
// PKG_EXP_UNQUALIFIED and PKG_EXP_ALLUNNAMED indicate whether the package is |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
74 |
// exported unqualifiedly or exported to all unnamed modules. They are used to |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
75 |
// set the value of _export_flags. Field _export_flags and the _qualified_exports |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
76 |
// list are used to determine a package's export state. |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
77 |
// Valid states are: |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
78 |
// |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
79 |
// 1. Package is not exported |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
80 |
// _export_flags is zero and _qualified_exports is null |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
81 |
// 2. Package is unqualifiedly exported |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
82 |
// _export_flags is set to PKG_EXP_UNQUALIFIED |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
83 |
// _qualified_exports may or may not be null depending on whether the package |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
84 |
// transitioned from qualifiedly exported to unqualifiedly exported. |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
85 |
// 3. Package is qualifiedly exported |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
86 |
// _export_flags may be set to PKG_EXP_ALLUNNAMED if the package is also |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
87 |
// exported to all unnamed modules |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
88 |
// _qualified_exports will be non-null |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
89 |
// 4. Package is exported to all unnamed modules |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
90 |
// _export_flags is set to PKG_EXP_ALLUNNAMED |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
91 |
// _qualified_exports may or may not be null depending on whether the package |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
92 |
// is also qualifiedly exported to one or more named modules. |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
93 |
#define PKG_EXP_UNQUALIFIED 0x0001 |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
94 |
#define PKG_EXP_ALLUNNAMED 0x0002 |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
95 |
#define PKG_EXP_UNQUALIFIED_OR_ALL_UNAMED (PKG_EXP_UNQUALIFIED | PKG_EXP_ALLUNNAMED) |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
96 |
|
38733 | 97 |
class PackageEntry : public HashtableEntry<Symbol*, mtModule> { |
36508 | 98 |
private: |
99 |
ModuleEntry* _module; |
|
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
100 |
// Indicates if package is exported unqualifiedly or to all unnamed. Access to |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
101 |
// this field is protected by the Module_lock. |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
102 |
int _export_flags; |
36508 | 103 |
// Used to indicate for packages with classes loaded by the boot loader that |
104 |
// a class in that package has been loaded. And, for packages with classes |
|
105 |
// loaded by the boot loader from -Xbootclasspath/a in an unnamed module, it |
|
106 |
// indicates from which class path entry. |
|
107 |
s2 _classpath_index; |
|
39616
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
39290
diff
changeset
|
108 |
bool _must_walk_exports; |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
109 |
// Contains list of modules this package is qualifiedly exported to. Access |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
110 |
// to this list is protected by the Module_lock. |
36508 | 111 |
GrowableArray<ModuleEntry*>* _qualified_exports; |
50113 | 112 |
JFR_ONLY(DEFINE_TRACE_ID_FIELD;) |
36508 | 113 |
|
114 |
// Initial size of a package entry's list of qualified exports. |
|
115 |
enum {QUAL_EXP_SIZE = 43}; |
|
116 |
||
117 |
public: |
|
118 |
void init() { |
|
119 |
_module = NULL; |
|
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
120 |
_export_flags = 0; |
36508 | 121 |
_classpath_index = -1; |
39616
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
39290
diff
changeset
|
122 |
_must_walk_exports = false; |
36508 | 123 |
_qualified_exports = NULL; |
124 |
} |
|
125 |
||
126 |
// package name |
|
127 |
Symbol* name() const { return literal(); } |
|
128 |
||
129 |
// the module containing the package definition |
|
130 |
ModuleEntry* module() const { return _module; } |
|
131 |
void set_module(ModuleEntry* m) { _module = m; } |
|
132 |
||
133 |
// package's export state |
|
38940
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
134 |
bool is_exported() const { // qualifiedly or unqualifiedly exported |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
135 |
assert_locked_or_safepoint(Module_lock); |
46404
ae62ba99a1a7
8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents:
46387
diff
changeset
|
136 |
return module()->is_open() || |
ae62ba99a1a7
8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents:
46387
diff
changeset
|
137 |
((_export_flags & PKG_EXP_UNQUALIFIED_OR_ALL_UNAMED) != 0) || |
ae62ba99a1a7
8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents:
46387
diff
changeset
|
138 |
has_qual_exports_list(); |
38940
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
139 |
} |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
140 |
// Returns true if the package has any explicit qualified exports or is exported to all unnamed |
36508 | 141 |
bool is_qual_exported() const { |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
142 |
assert_locked_or_safepoint(Module_lock); |
38940
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
143 |
return (has_qual_exports_list() || is_exported_allUnnamed()); |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
144 |
} |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
145 |
// Returns true if there are any explicit qualified exports. Note that even |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
146 |
// if the _qualified_exports list is now empty (because the modules that were |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
147 |
// on the list got gc-ed and deleted from the list) this method may still |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
148 |
// return true. |
38940
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
149 |
bool has_qual_exports_list() const { |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
150 |
assert_locked_or_safepoint(Module_lock); |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
151 |
return (!is_unqual_exported() && _qualified_exports != NULL); |
38940
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
152 |
} |
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
153 |
bool is_exported_allUnnamed() const { |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
154 |
assert_locked_or_safepoint(Module_lock); |
46404
ae62ba99a1a7
8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents:
46387
diff
changeset
|
155 |
return (module()->is_open() || _export_flags == PKG_EXP_ALLUNNAMED); |
36508 | 156 |
} |
157 |
bool is_unqual_exported() const { |
|
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
158 |
assert_locked_or_safepoint(Module_lock); |
46404
ae62ba99a1a7
8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents:
46387
diff
changeset
|
159 |
return (module()->is_open() || _export_flags == PKG_EXP_UNQUALIFIED); |
36508 | 160 |
} |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
161 |
|
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
162 |
// Explicitly set _export_flags to PKG_EXP_UNQUALIFIED and clear |
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
163 |
// PKG_EXP_ALLUNNAMED, if it was set. |
36508 | 164 |
void set_unqual_exported() { |
46404
ae62ba99a1a7
8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents:
46387
diff
changeset
|
165 |
if (module()->is_open()) { |
ae62ba99a1a7
8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents:
46387
diff
changeset
|
166 |
// No-op for open modules since all packages are unqualifiedly exported |
ae62ba99a1a7
8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents:
46387
diff
changeset
|
167 |
return; |
ae62ba99a1a7
8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents:
46387
diff
changeset
|
168 |
} |
39290
0cc9f5028562
8156871: Possible concurrency issue with JVM_AddModuleExports
lfoltan
parents:
38940
diff
changeset
|
169 |
assert(Module_lock->owned_by_self(), "should have the Module_lock"); |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
170 |
_export_flags = PKG_EXP_UNQUALIFIED; |
36508 | 171 |
} |
43471
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
172 |
|
bfb383279a16
8171971: Fix timing bug in JVM management of package export lists
hseigel
parents:
39616
diff
changeset
|
173 |
bool exported_pending_delete() const; |
36508 | 174 |
|
175 |
void set_exported(ModuleEntry* m); |
|
176 |
||
38940
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
177 |
void set_is_exported_allUnnamed(); |
36508 | 178 |
|
179 |
void set_classpath_index(s2 classpath_index) { |
|
180 |
_classpath_index = classpath_index; |
|
181 |
} |
|
182 |
s2 classpath_index() const { return _classpath_index; } |
|
183 |
||
184 |
bool has_loaded_class() const { return _classpath_index != -1; } |
|
185 |
||
186 |
// returns true if the package is defined in the unnamed module |
|
187 |
bool in_unnamed_module() const { return !_module->is_named(); } |
|
188 |
||
38940
7de797f32b5f
8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents:
38733
diff
changeset
|
189 |
// returns true if the package specifies m as a qualified export, including through an unnamed export |
36508 | 190 |
bool is_qexported_to(ModuleEntry* m) const; |
191 |
||
192 |
// add the module to the package's qualified exports |
|
193 |
void add_qexport(ModuleEntry* m); |
|
39616
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
39290
diff
changeset
|
194 |
void set_export_walk_required(ClassLoaderData* m_loader_data); |
36508 | 195 |
|
196 |
PackageEntry* next() const { |
|
38733 | 197 |
return (PackageEntry*)HashtableEntry<Symbol*, mtModule>::next(); |
36508 | 198 |
} |
199 |
||
200 |
PackageEntry** next_addr() { |
|
38733 | 201 |
return (PackageEntry**)HashtableEntry<Symbol*, mtModule>::next_addr(); |
36508 | 202 |
} |
203 |
||
204 |
// iteration of qualified exports |
|
50113 | 205 |
void package_exports_do(ModuleClosure* f); |
36508 | 206 |
|
50113 | 207 |
JFR_ONLY(DEFINE_TRACE_ID_METHODS;) |
36508 | 208 |
|
209 |
// Purge dead weak references out of exported list when any given class loader is unloaded. |
|
210 |
void purge_qualified_exports(); |
|
211 |
void delete_qualified_exports(); |
|
212 |
||
37503
77531df4dad3
8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents:
36508
diff
changeset
|
213 |
void print(outputStream* st = tty); |
36508 | 214 |
void verify(); |
215 |
}; |
|
216 |
||
217 |
// The PackageEntryTable is a Hashtable containing a list of all packages defined |
|
218 |
// by a particular class loader. Each package is represented as a PackageEntry node. |
|
219 |
// The PackageEntryTable's lookup is lock free. |
|
220 |
// |
|
38733 | 221 |
class PackageEntryTable : public Hashtable<Symbol*, mtModule> { |
36508 | 222 |
friend class VMStructs; |
223 |
public: |
|
224 |
enum Constants { |
|
46387 | 225 |
_packagetable_entry_size = 109 // number of entries in package entry table |
36508 | 226 |
}; |
227 |
||
228 |
private: |
|
229 |
PackageEntry* new_entry(unsigned int hash, Symbol* name, ModuleEntry* module); |
|
230 |
void add_entry(int index, PackageEntry* new_entry); |
|
231 |
||
38733 | 232 |
int entry_size() const { return BasicHashtable<mtModule>::entry_size(); } |
36508 | 233 |
|
234 |
PackageEntry** bucket_addr(int i) { |
|
38733 | 235 |
return (PackageEntry**)Hashtable<Symbol*, mtModule>::bucket_addr(i); |
36508 | 236 |
} |
237 |
||
238 |
static unsigned int compute_hash(Symbol* name) { return (unsigned int)(name->identity_hash()); } |
|
239 |
int index_for(Symbol* name) const { return hash_to_index(compute_hash(name)); } |
|
240 |
||
241 |
public: |
|
242 |
PackageEntryTable(int table_size); |
|
243 |
~PackageEntryTable(); |
|
244 |
||
245 |
PackageEntry* bucket(int i) { |
|
38733 | 246 |
return (PackageEntry*)Hashtable<Symbol*, mtModule>::bucket(i); |
36508 | 247 |
} |
248 |
||
249 |
// Create package in loader's package entry table and return the entry. |
|
250 |
// If entry already exists, return null. Assume Module lock was taken by caller. |
|
251 |
PackageEntry* locked_create_entry_or_null(Symbol* name, ModuleEntry* module); |
|
252 |
||
253 |
// lookup Package with loader's package entry table, if not found add |
|
254 |
PackageEntry* lookup(Symbol* name, ModuleEntry* module); |
|
255 |
||
256 |
// Only lookup Package within loader's package entry table. The table read is lock-free. |
|
257 |
PackageEntry* lookup_only(Symbol* Package); |
|
258 |
||
259 |
void verify_javabase_packages(GrowableArray<Symbol*> *pkg_list); |
|
260 |
||
261 |
// purge dead weak references out of exported list |
|
262 |
void purge_all_package_exports(); |
|
263 |
||
37503
77531df4dad3
8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents:
36508
diff
changeset
|
264 |
void print(outputStream* st = tty); |
36508 | 265 |
void verify(); |
266 |
}; |
|
267 |
||
268 |
#endif // SHARE_VM_CLASSFILE_PACKAGEENTRY_HPP |