author | lfoltan |
Mon, 21 Oct 2019 13:13:16 -0400 | |
changeset 58722 | cba8afa5cfed |
parent 54419 | 5c7418757bad |
permissions | -rw-r--r-- |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51610
diff
changeset
|
2 |
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
4 |
* |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
8 |
* |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
14 |
* |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
18 |
* |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
21 |
* questions. |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
22 |
* |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
23 |
*/ |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
24 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51610
diff
changeset
|
25 |
#ifndef SHARE_CLASSFILE_PROTECTIONDOMAINCACHE_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51610
diff
changeset
|
26 |
#define SHARE_CLASSFILE_PROTECTIONDOMAINCACHE_HPP |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
27 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
28 |
#include "oops/oop.hpp" |
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48811
diff
changeset
|
29 |
#include "oops/weakHandle.hpp" |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
30 |
#include "memory/iterator.hpp" |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
31 |
#include "utilities/hashtable.hpp" |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
32 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
33 |
// This class caches the approved protection domains that can access loaded classes. |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
34 |
// Dictionary entry pd_set point to entries in this hashtable. Please refer |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
35 |
// to dictionary.hpp pd_set for more information about how protection domain entries |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
36 |
// are used. |
46729 | 37 |
// This table is walked during GC, rather than the class loader data graph dictionaries. |
54419
5c7418757bad
8221872: Remove uses of ClassLoaderWeakHandle typedef in protection domain table
coleenp
parents:
53244
diff
changeset
|
38 |
class ProtectionDomainCacheEntry : public HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass> { |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
39 |
friend class VMStructs; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
40 |
public: |
48781
6ebef5cd0c8d
8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents:
47216
diff
changeset
|
41 |
oop object(); |
6ebef5cd0c8d
8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents:
47216
diff
changeset
|
42 |
oop object_no_keepalive(); |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
43 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
44 |
ProtectionDomainCacheEntry* next() { |
54419
5c7418757bad
8221872: Remove uses of ClassLoaderWeakHandle typedef in protection domain table
coleenp
parents:
53244
diff
changeset
|
45 |
return (ProtectionDomainCacheEntry*)HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass>::next(); |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
46 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
47 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
48 |
ProtectionDomainCacheEntry** next_addr() { |
54419
5c7418757bad
8221872: Remove uses of ClassLoaderWeakHandle typedef in protection domain table
coleenp
parents:
53244
diff
changeset
|
49 |
return (ProtectionDomainCacheEntry**)HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass>::next_addr(); |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
50 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
51 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
52 |
void verify(); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
53 |
}; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
54 |
|
46729 | 55 |
// The ProtectionDomainCacheTable contains all protection domain oops. The |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
56 |
// dictionary entries reference its entries instead of having references to oops |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
57 |
// directly. |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
58 |
// This is used to speed up system dictionary iteration: the oops in the |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
59 |
// protection domain are the only ones referring the Java heap. So when there is |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
60 |
// need to update these, instead of going over every entry of the system dictionary, |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
61 |
// we only need to iterate over this set. |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
62 |
// The amount of different protection domains used is typically magnitudes smaller |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
63 |
// than the number of system dictionary entries (loaded classes). |
54419
5c7418757bad
8221872: Remove uses of ClassLoaderWeakHandle typedef in protection domain table
coleenp
parents:
53244
diff
changeset
|
64 |
class ProtectionDomainCacheTable : public Hashtable<WeakHandle<vm_class_loader_data>, mtClass> { |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
65 |
friend class VMStructs; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
66 |
private: |
46742 | 67 |
ProtectionDomainCacheEntry* bucket(int i) const { |
54419
5c7418757bad
8221872: Remove uses of ClassLoaderWeakHandle typedef in protection domain table
coleenp
parents:
53244
diff
changeset
|
68 |
return (ProtectionDomainCacheEntry*) Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::bucket(i); |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
69 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
70 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
71 |
// The following method is not MT-safe and must be done under lock. |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
72 |
ProtectionDomainCacheEntry** bucket_addr(int i) { |
54419
5c7418757bad
8221872: Remove uses of ClassLoaderWeakHandle typedef in protection domain table
coleenp
parents:
53244
diff
changeset
|
73 |
return (ProtectionDomainCacheEntry**) Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::bucket_addr(i); |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
74 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
75 |
|
54419
5c7418757bad
8221872: Remove uses of ClassLoaderWeakHandle typedef in protection domain table
coleenp
parents:
53244
diff
changeset
|
76 |
ProtectionDomainCacheEntry* new_entry(unsigned int hash, WeakHandle<vm_class_loader_data> protection_domain) { |
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48811
diff
changeset
|
77 |
ProtectionDomainCacheEntry* entry = (ProtectionDomainCacheEntry*) |
54419
5c7418757bad
8221872: Remove uses of ClassLoaderWeakHandle typedef in protection domain table
coleenp
parents:
53244
diff
changeset
|
78 |
Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::new_entry(hash, protection_domain); |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
79 |
return entry; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
80 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
81 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
82 |
static unsigned int compute_hash(Handle protection_domain); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
83 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
84 |
int index_for(Handle protection_domain); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
85 |
ProtectionDomainCacheEntry* add_entry(int index, unsigned int hash, Handle protection_domain); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
86 |
ProtectionDomainCacheEntry* find_entry(int index, Handle protection_domain); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
87 |
|
51610
cdef4df6b0e7
8206424: Use locking for cleaning ProtectionDomainTable
pchilanomate
parents:
49818
diff
changeset
|
88 |
bool _dead_entries; |
cdef4df6b0e7
8206424: Use locking for cleaning ProtectionDomainTable
pchilanomate
parents:
49818
diff
changeset
|
89 |
int _total_oops_removed; |
cdef4df6b0e7
8206424: Use locking for cleaning ProtectionDomainTable
pchilanomate
parents:
49818
diff
changeset
|
90 |
|
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
91 |
public: |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
92 |
ProtectionDomainCacheTable(int table_size); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
93 |
ProtectionDomainCacheEntry* get(Handle protection_domain); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
94 |
|
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48811
diff
changeset
|
95 |
void unlink(); |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
96 |
|
46742 | 97 |
void print_on(outputStream* st) const; |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
98 |
void verify(); |
51610
cdef4df6b0e7
8206424: Use locking for cleaning ProtectionDomainTable
pchilanomate
parents:
49818
diff
changeset
|
99 |
|
cdef4df6b0e7
8206424: Use locking for cleaning ProtectionDomainTable
pchilanomate
parents:
49818
diff
changeset
|
100 |
bool has_work() { return _dead_entries; } |
cdef4df6b0e7
8206424: Use locking for cleaning ProtectionDomainTable
pchilanomate
parents:
49818
diff
changeset
|
101 |
void trigger_cleanup(); |
cdef4df6b0e7
8206424: Use locking for cleaning ProtectionDomainTable
pchilanomate
parents:
49818
diff
changeset
|
102 |
|
cdef4df6b0e7
8206424: Use locking for cleaning ProtectionDomainTable
pchilanomate
parents:
49818
diff
changeset
|
103 |
int removed_entries_count() { return _total_oops_removed; }; |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
104 |
}; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
105 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
106 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
107 |
class ProtectionDomainEntry :public CHeapObj<mtClass> { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
108 |
friend class VMStructs; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
109 |
public: |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
110 |
ProtectionDomainEntry* _next; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
111 |
ProtectionDomainCacheEntry* _pd_cache; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
112 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
113 |
ProtectionDomainEntry(ProtectionDomainCacheEntry* pd_cache, ProtectionDomainEntry* next) { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
114 |
_pd_cache = pd_cache; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
115 |
_next = next; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
116 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
117 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
118 |
ProtectionDomainEntry* next() { return _next; } |
48811
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
119 |
void set_next(ProtectionDomainEntry* entry) { _next = entry; } |
48781
6ebef5cd0c8d
8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents:
47216
diff
changeset
|
120 |
oop object(); |
6ebef5cd0c8d
8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents:
47216
diff
changeset
|
121 |
oop object_no_keepalive(); |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
122 |
}; |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51610
diff
changeset
|
123 |
#endif // SHARE_CLASSFILE_PROTECTIONDOMAINCACHE_HPP |