author | coleenp |
Fri, 28 Jul 2017 10:48:35 -0400 | |
changeset 46729 | c62d2e8b2728 |
parent 46382 | 5520c435279b |
child 46742 | 24ec8a039c90 |
permissions | -rw-r--r-- |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
1 |
/* |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
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 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
25 |
#ifndef SHARE_VM_CLASSFILE_PROTECTIONDOMAINCACHE_HPP |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
26 |
#define SHARE_VM_CLASSFILE_PROTECTIONDOMAINCACHE_HPP |
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" |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
29 |
#include "memory/iterator.hpp" |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
30 |
#include "utilities/hashtable.hpp" |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
31 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
32 |
// 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
|
33 |
// 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
|
34 |
// 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
|
35 |
// are used. |
46729 | 36 |
// This table is walked during GC, rather than the class loader data graph dictionaries. |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
37 |
class ProtectionDomainCacheEntry : public HashtableEntry<oop, mtClass> { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
38 |
friend class VMStructs; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
39 |
public: |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
40 |
oop protection_domain() { return literal(); } |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
41 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
42 |
ProtectionDomainCacheEntry* next() { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
43 |
return (ProtectionDomainCacheEntry*)HashtableEntry<oop, mtClass>::next(); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
44 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
45 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
46 |
ProtectionDomainCacheEntry** next_addr() { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
47 |
return (ProtectionDomainCacheEntry**)HashtableEntry<oop, mtClass>::next_addr(); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
48 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
49 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
50 |
void oops_do(OopClosure* f) { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
51 |
f->do_oop(literal_addr()); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
52 |
} |
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 |
void print() PRODUCT_RETURN; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
55 |
void verify(); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
56 |
}; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
57 |
|
46729 | 58 |
// The ProtectionDomainCacheTable contains all protection domain oops. The |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
59 |
// dictionary entries reference its entries instead of having references to oops |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
60 |
// directly. |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
61 |
// 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
|
62 |
// 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
|
63 |
// 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
|
64 |
// we only need to iterate over this set. |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
65 |
// The amount of different protection domains used is typically magnitudes smaller |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
66 |
// than the number of system dictionary entries (loaded classes). |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
67 |
class ProtectionDomainCacheTable : public Hashtable<oop, mtClass> { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
68 |
friend class VMStructs; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
69 |
private: |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
70 |
ProtectionDomainCacheEntry* bucket(int i) { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
71 |
return (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::bucket(i); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
72 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
73 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
74 |
// 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
|
75 |
ProtectionDomainCacheEntry** bucket_addr(int i) { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
76 |
return (ProtectionDomainCacheEntry**) Hashtable<oop, mtClass>::bucket_addr(i); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
77 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
78 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
79 |
ProtectionDomainCacheEntry* new_entry(unsigned int hash, Handle protection_domain) { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
80 |
ProtectionDomainCacheEntry* entry = (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::new_entry(hash, protection_domain()); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
81 |
return entry; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
82 |
} |
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 |
static unsigned int compute_hash(Handle protection_domain); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
85 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
86 |
int index_for(Handle protection_domain); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
87 |
ProtectionDomainCacheEntry* add_entry(int index, unsigned int hash, Handle protection_domain); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
88 |
ProtectionDomainCacheEntry* find_entry(int index, Handle protection_domain); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
89 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
90 |
public: |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
91 |
ProtectionDomainCacheTable(int table_size); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
92 |
ProtectionDomainCacheEntry* get(Handle protection_domain); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
93 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
94 |
void unlink(BoolObjectClosure* cl); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
95 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
96 |
// GC support |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
97 |
void oops_do(OopClosure* f); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
98 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
99 |
void print() PRODUCT_RETURN; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
100 |
void verify(); |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
101 |
}; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
102 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
103 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
104 |
class ProtectionDomainEntry :public CHeapObj<mtClass> { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
105 |
friend class VMStructs; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
106 |
public: |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
107 |
ProtectionDomainEntry* _next; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
108 |
ProtectionDomainCacheEntry* _pd_cache; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
109 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
110 |
ProtectionDomainEntry(ProtectionDomainCacheEntry* pd_cache, ProtectionDomainEntry* next) { |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
111 |
_pd_cache = pd_cache; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
112 |
_next = next; |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
113 |
} |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
114 |
|
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
115 |
ProtectionDomainEntry* next() { return _next; } |
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
diff
changeset
|
116 |
oop protection_domain() { return _pd_cache->protection_domain(); } |
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 |
#endif // SHARE_VM_CLASSFILE_PROTECTIONDOMAINCACHE_HPP |