author | ihse |
Mon, 26 Nov 2018 14:18:22 +0100 | |
branch | ihse-manpages-branch |
changeset 57043 | 23d7457ca4c6 |
parent 51567 | 0c4f2b26849e |
child 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
46505 | 1 |
/* |
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
2 |
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
46505 | 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_PRIMS_RESOLVEDMETHOD_HPP |
|
26 |
#define SHARE_VM_PRIMS_RESOLVEDMETHOD_HPP |
|
27 |
||
28 |
#include "oops/symbol.hpp" |
|
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
29 |
#include "oops/weakHandle.hpp" |
46505 | 30 |
#include "utilities/hashtable.hpp" |
31 |
||
32 |
// Hashtable to record Method* used in ResolvedMethods, via. ResolvedMethod oops. |
|
33 |
// This is needed for redefinition to replace Method* with redefined versions. |
|
34 |
||
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
35 |
// Entry in a ResolvedMethodTable, mapping a ClassLoaderWeakHandle for a single oop of |
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
36 |
// java_lang_invoke_ResolvedMethodName which holds JVM Method* in vmtarget. |
46505 | 37 |
|
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
38 |
class ResolvedMethodEntry : public HashtableEntry<ClassLoaderWeakHandle, mtClass> { |
46505 | 39 |
public: |
40 |
ResolvedMethodEntry* next() const { |
|
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
41 |
return (ResolvedMethodEntry*)HashtableEntry<ClassLoaderWeakHandle, mtClass>::next(); |
46505 | 42 |
} |
43 |
||
44 |
ResolvedMethodEntry** next_addr() { |
|
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
45 |
return (ResolvedMethodEntry**)HashtableEntry<ClassLoaderWeakHandle, mtClass>::next_addr(); |
46505 | 46 |
} |
47 |
||
48615
31cd0c16f4d2
8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents:
47216
diff
changeset
|
48 |
oop object(); |
31cd0c16f4d2
8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents:
47216
diff
changeset
|
49 |
oop object_no_keepalive(); |
31cd0c16f4d2
8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents:
47216
diff
changeset
|
50 |
|
46505 | 51 |
void print_on(outputStream* st) const; |
52 |
}; |
|
53 |
||
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
54 |
class ResolvedMethodTable : public Hashtable<ClassLoaderWeakHandle, mtClass> { |
46505 | 55 |
enum Constants { |
56 |
_table_size = 1007 |
|
57 |
}; |
|
58 |
||
51567
0c4f2b26849e
8209844: MemberNameLeak.java fails when ResolvedMethod entry is not removed
pchilanomate
parents:
51472
diff
changeset
|
59 |
static int _total_oops_removed; |
46505 | 60 |
|
51472
eb97d1a319f9
8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents:
49818
diff
changeset
|
61 |
static bool _dead_entries; |
eb97d1a319f9
8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents:
49818
diff
changeset
|
62 |
|
46505 | 63 |
static ResolvedMethodTable* _the_table; |
64 |
private: |
|
65 |
ResolvedMethodEntry* bucket(int i) { |
|
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
66 |
return (ResolvedMethodEntry*) Hashtable<ClassLoaderWeakHandle, mtClass>::bucket(i); |
46505 | 67 |
} |
68 |
||
69 |
ResolvedMethodEntry** bucket_addr(int i) { |
|
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
70 |
return (ResolvedMethodEntry**) Hashtable<ClassLoaderWeakHandle, mtClass>::bucket_addr(i); |
46505 | 71 |
} |
72 |
||
73 |
unsigned int compute_hash(Method* method); |
|
74 |
||
75 |
// need not be locked; no state change |
|
76 |
oop lookup(int index, unsigned int hash, Method* method); |
|
77 |
oop lookup(Method* method); |
|
78 |
||
79 |
// must be done under ResolvedMethodTable_lock |
|
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
80 |
oop basic_add(Method* method, Handle rmethod_name); |
46505 | 81 |
|
82 |
public: |
|
83 |
ResolvedMethodTable(); |
|
84 |
||
85 |
static void create_table() { |
|
86 |
assert(_the_table == NULL, "One symbol table allowed."); |
|
87 |
_the_table = new ResolvedMethodTable(); |
|
88 |
} |
|
89 |
||
90 |
// Called from java_lang_invoke_ResolvedMethodName |
|
91 |
static oop find_method(Method* method); |
|
92 |
static oop add_method(Handle rmethod_name); |
|
93 |
||
51472
eb97d1a319f9
8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents:
49818
diff
changeset
|
94 |
static bool has_work() { return _dead_entries; } |
eb97d1a319f9
8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents:
49818
diff
changeset
|
95 |
static void trigger_cleanup(); |
eb97d1a319f9
8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents:
49818
diff
changeset
|
96 |
|
51567
0c4f2b26849e
8209844: MemberNameLeak.java fails when ResolvedMethod entry is not removed
pchilanomate
parents:
51472
diff
changeset
|
97 |
static int removed_entries_count() { return _total_oops_removed; }; |
0c4f2b26849e
8209844: MemberNameLeak.java fails when ResolvedMethod entry is not removed
pchilanomate
parents:
51472
diff
changeset
|
98 |
|
46505 | 99 |
#if INCLUDE_JVMTI |
100 |
// It is called at safepoint only for RedefineClasses |
|
101 |
static void adjust_method_entries(bool * trace_name_printed); |
|
102 |
#endif // INCLUDE_JVMTI |
|
103 |
||
104 |
// Cleanup cleared entries |
|
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
48615
diff
changeset
|
105 |
static void unlink(); |
46505 | 106 |
|
107 |
#ifndef PRODUCT |
|
108 |
void print(); |
|
109 |
#endif |
|
110 |
void verify(); |
|
111 |
}; |
|
112 |
||
113 |
#endif // SHARE_VM_PRIMS_RESOLVEDMETHOD_HPP |