author | chegar |
Thu, 17 Oct 2019 20:53:35 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58678 | 9cf78a70fa4f |
parent 54896 | ea619918de95 |
child 58679 | 9c3209ff7550 |
permissions | -rw-r--r-- |
46505 | 1 |
/* |
53904
9c3fe09f69bc
8078725: method adjustments can be done just once for all classes involved into redefinition
coleenp
parents:
51567
diff
changeset
|
2 |
* Copyright (c) 2017, 2019, 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 |
#include "precompiled.hpp" |
|
49593
4dd58ecc9912
8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents:
48615
diff
changeset
|
26 |
#include "classfile/javaClasses.hpp" |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
27 |
#include "gc/shared/oopStorage.inline.hpp" |
58678 | 28 |
#include "gc/shared/oopStorageSet.hpp" |
49982 | 29 |
#include "logging/log.hpp" |
46505 | 30 |
#include "memory/allocation.hpp" |
49593
4dd58ecc9912
8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents:
48615
diff
changeset
|
31 |
#include "memory/resourceArea.hpp" |
54786 | 32 |
#include "memory/universe.hpp" |
48615
31cd0c16f4d2
8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents:
47216
diff
changeset
|
33 |
#include "oops/access.inline.hpp" |
58678 | 34 |
#include "oops/method.hpp" |
46505 | 35 |
#include "oops/oop.inline.hpp" |
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
49594
diff
changeset
|
36 |
#include "oops/weakHandle.inline.hpp" |
46505 | 37 |
#include "prims/resolvedMethodTable.hpp" |
38 |
#include "runtime/handles.inline.hpp" |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
39 |
#include "runtime/interfaceSupport.inline.hpp" |
46505 | 40 |
#include "runtime/mutexLocker.hpp" |
49594
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49593
diff
changeset
|
41 |
#include "runtime/safepointVerifiers.hpp" |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
42 |
#include "runtime/timerTrace.hpp" |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
43 |
#include "utilities/concurrentHashTable.inline.hpp" |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
44 |
#include "utilities/concurrentHashTableTasks.inline.hpp" |
46505 | 45 |
#include "utilities/macros.hpp" |
48615
31cd0c16f4d2
8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents:
47216
diff
changeset
|
46 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
47 |
// 2^24 is max size |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
48 |
static const size_t END_SIZE = 24; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
49 |
// If a chain gets to 32 something might be wrong |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
50 |
static const size_t GROW_HINT = 32; |
46505 | 51 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
52 |
static const size_t ResolvedMethodTableSizeLog = 10; |
48615
31cd0c16f4d2
8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents:
47216
diff
changeset
|
53 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
54 |
unsigned int method_hash(const Method* method) { |
46505 | 55 |
unsigned int name_hash = method->name()->identity_hash(); |
56 |
unsigned int signature_hash = method->signature()->identity_hash(); |
|
57 |
return name_hash ^ signature_hash; |
|
58 |
} |
|
59 |
||
58678 | 60 |
typedef ConcurrentHashTable<ResolvedMethodTableConfig, |
54896
ea619918de95
8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents:
54786
diff
changeset
|
61 |
mtClass> ResolvedMethodTableHash; |
ea619918de95
8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents:
54786
diff
changeset
|
62 |
|
58678 | 63 |
class ResolvedMethodTableConfig : public AllStatic { |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
64 |
private: |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
65 |
public: |
58678 | 66 |
typedef WeakHandle<vm_resolved_method_table_data> Value; |
67 |
||
68 |
static uintx get_hash(Value const& value, bool* is_dead) { |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
69 |
oop val_oop = value.peek(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
70 |
if (val_oop == NULL) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
71 |
*is_dead = true; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
72 |
return 0; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
73 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
74 |
*is_dead = false; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
75 |
Method* method = java_lang_invoke_ResolvedMethodName::vmtarget(val_oop); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
76 |
return method_hash(method); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
77 |
} |
46505 | 78 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
79 |
// We use default allocation/deallocation but counted |
58678 | 80 |
static void* allocate_node(size_t size, Value const& value) { |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
81 |
ResolvedMethodTable::item_added(); |
58678 | 82 |
return AllocateHeap(size, mtClass); |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
83 |
} |
58678 | 84 |
static void free_node(void* memory, Value const& value) { |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
85 |
value.release(); |
58678 | 86 |
FreeHeap(memory); |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
87 |
ResolvedMethodTable::item_removed(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
88 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
89 |
}; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
90 |
|
54896
ea619918de95
8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents:
54786
diff
changeset
|
91 |
static ResolvedMethodTableHash* _local_table = NULL; |
ea619918de95
8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents:
54786
diff
changeset
|
92 |
static size_t _current_size = (size_t)1 << ResolvedMethodTableSizeLog; |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
93 |
|
54896
ea619918de95
8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents:
54786
diff
changeset
|
94 |
volatile bool ResolvedMethodTable::_has_work = false; |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
95 |
|
54896
ea619918de95
8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents:
54786
diff
changeset
|
96 |
volatile size_t _items_count = 0; |
ea619918de95
8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents:
54786
diff
changeset
|
97 |
volatile size_t _uncleaned_items_count = 0; |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
98 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
99 |
void ResolvedMethodTable::create_table() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
100 |
_local_table = new ResolvedMethodTableHash(ResolvedMethodTableSizeLog, END_SIZE, GROW_HINT); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
101 |
log_trace(membername, table)("Start size: " SIZE_FORMAT " (" SIZE_FORMAT ")", |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
102 |
_current_size, ResolvedMethodTableSizeLog); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
103 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
104 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
105 |
size_t ResolvedMethodTable::table_size() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
106 |
return (size_t)1 << _local_table->get_size_log2(Thread::current()); |
46505 | 107 |
} |
108 |
||
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
109 |
class ResolvedMethodTableLookup : StackObj { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
110 |
private: |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
111 |
Thread* _thread; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
112 |
uintx _hash; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
113 |
const Method* _method; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
114 |
Handle _found; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
115 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
116 |
public: |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
117 |
ResolvedMethodTableLookup(Thread* thread, uintx hash, const Method* key) |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
118 |
: _thread(thread), _hash(hash), _method(key) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
119 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
120 |
uintx get_hash() const { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
121 |
return _hash; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
122 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
123 |
bool equals(WeakHandle<vm_resolved_method_table_data>* value, bool* is_dead) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
124 |
oop val_oop = value->peek(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
125 |
if (val_oop == NULL) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
126 |
// dead oop, mark this hash dead for cleaning |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
127 |
*is_dead = true; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
128 |
return false; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
129 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
130 |
bool equals = _method == java_lang_invoke_ResolvedMethodName::vmtarget(val_oop); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
131 |
if (!equals) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
132 |
return false; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
133 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
134 |
// Need to resolve weak handle and Handleize through possible safepoint. |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
135 |
_found = Handle(_thread, value->resolve()); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
136 |
return true; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
137 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
138 |
}; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
139 |
|
46505 | 140 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
141 |
class ResolvedMethodGet : public StackObj { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
142 |
Thread* _thread; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
143 |
const Method* _method; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
144 |
Handle _return; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
145 |
public: |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
146 |
ResolvedMethodGet(Thread* thread, const Method* method) : _thread(thread), _method(method) {} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
147 |
void operator()(WeakHandle<vm_resolved_method_table_data>* val) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
148 |
oop result = val->resolve(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
149 |
assert(result != NULL, "Result should be reachable"); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
150 |
_return = Handle(_thread, result); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
151 |
log_get(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
152 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
153 |
oop get_res_oop() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
154 |
return _return(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
155 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
156 |
void log_get() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
157 |
LogTarget(Trace, membername, table) log; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
158 |
if (log.is_enabled()) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
159 |
ResourceMark rm; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
160 |
log.print("ResolvedMethod entry found for %s", |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
161 |
_method->name_and_sig_as_C_string()); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
162 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
163 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
164 |
}; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
165 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
166 |
oop ResolvedMethodTable::find_method(const Method* method) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
167 |
Thread* thread = Thread::current(); |
46505 | 168 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
169 |
ResolvedMethodTableLookup lookup(thread, method_hash(method), method); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
170 |
ResolvedMethodGet rmg(thread, method); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
171 |
_local_table->get(thread, lookup, rmg); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
172 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
173 |
return rmg.get_res_oop(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
174 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
175 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
176 |
static void log_insert(const Method* method) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
177 |
LogTarget(Debug, membername, table) log; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
178 |
if (log.is_enabled()) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
179 |
ResourceMark rm; |
54680 | 180 |
log.print("ResolvedMethod entry added for %s", |
181 |
method->name_and_sig_as_C_string()); |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
182 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
183 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
184 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
185 |
oop ResolvedMethodTable::add_method(const Method* method, Handle rmethod_name) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
186 |
Thread* thread = Thread::current(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
187 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
188 |
ResolvedMethodTableLookup lookup(thread, method_hash(method), method); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
189 |
ResolvedMethodGet rmg(thread, method); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
190 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
191 |
while (true) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
192 |
if (_local_table->get(thread, lookup, rmg)) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
193 |
return rmg.get_res_oop(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
194 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
195 |
WeakHandle<vm_resolved_method_table_data> wh = WeakHandle<vm_resolved_method_table_data>::create(rmethod_name); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
196 |
// The hash table takes ownership of the WeakHandle, even if it's not inserted. |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
197 |
if (_local_table->insert(thread, lookup, wh)) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
198 |
log_insert(method); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
199 |
return wh.resolve(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
200 |
} |
46505 | 201 |
} |
202 |
} |
|
203 |
||
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
204 |
void ResolvedMethodTable::item_added() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
205 |
Atomic::inc(&_items_count); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
206 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
207 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
208 |
void ResolvedMethodTable::item_removed() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
209 |
Atomic::dec(&_items_count); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
210 |
log_trace(membername, table) ("ResolvedMethod entry removed"); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
211 |
} |
46505 | 212 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
213 |
double ResolvedMethodTable::get_load_factor() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
214 |
return (double)_items_count/_current_size; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
215 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
216 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
217 |
double ResolvedMethodTable::get_dead_factor() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
218 |
return (double)_uncleaned_items_count/_current_size; |
46505 | 219 |
} |
220 |
||
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
221 |
static const double PREF_AVG_LIST_LEN = 2.0; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
222 |
// If we have as many dead items as 50% of the number of bucket |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
223 |
static const double CLEAN_DEAD_HIGH_WATER_MARK = 0.5; |
46505 | 224 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
225 |
void ResolvedMethodTable::check_concurrent_work() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
226 |
if (_has_work) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
227 |
return; |
46505 | 228 |
} |
54431
ad9fa99fa48e
8221992: Fix old method replacement in ResolvedMethodTable
coleenp
parents:
53924
diff
changeset
|
229 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
230 |
double load_factor = get_load_factor(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
231 |
double dead_factor = get_dead_factor(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
232 |
// We should clean/resize if we have more dead than alive, |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
233 |
// more items than preferred load factor or |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
234 |
// more dead items than water mark. |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
235 |
if ((dead_factor > load_factor) || |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
236 |
(load_factor > PREF_AVG_LIST_LEN) || |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
237 |
(dead_factor > CLEAN_DEAD_HIGH_WATER_MARK)) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
238 |
log_debug(membername, table)("Concurrent work triggered, live factor: %g dead factor: %g", |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
239 |
load_factor, dead_factor); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
240 |
trigger_concurrent_work(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
241 |
} |
46505 | 242 |
} |
243 |
||
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
244 |
void ResolvedMethodTable::trigger_concurrent_work() { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54574
diff
changeset
|
245 |
MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag); |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
246 |
_has_work = true; |
51472
eb97d1a319f9
8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents:
49982
diff
changeset
|
247 |
Service_lock->notify_all(); |
eb97d1a319f9
8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents:
49982
diff
changeset
|
248 |
} |
eb97d1a319f9
8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents:
49982
diff
changeset
|
249 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
250 |
void ResolvedMethodTable::do_concurrent_work(JavaThread* jt) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
251 |
_has_work = false; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
252 |
double load_factor = get_load_factor(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
253 |
log_debug(membername, table)("Concurrent work, live factor: %g", load_factor); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
254 |
// We prefer growing, since that also removes dead items |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
255 |
if (load_factor > PREF_AVG_LIST_LEN && !_local_table->is_max_size_reached()) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
256 |
grow(jt); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
257 |
} else { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
258 |
clean_dead_entries(jt); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
259 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
260 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
261 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
262 |
void ResolvedMethodTable::grow(JavaThread* jt) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
263 |
ResolvedMethodTableHash::GrowTask gt(_local_table); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
264 |
if (!gt.prepare(jt)) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
265 |
return; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
266 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
267 |
log_trace(membername, table)("Started to grow"); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
268 |
{ |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
269 |
TraceTime timer("Grow", TRACETIME_LOG(Debug, membername, table, perf)); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
270 |
while (gt.do_task(jt)) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
271 |
gt.pause(jt); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
272 |
{ |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
273 |
ThreadBlockInVM tbivm(jt); |
46505 | 274 |
} |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
275 |
gt.cont(jt); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
276 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
277 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
278 |
gt.done(jt); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
279 |
_current_size = table_size(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
280 |
log_info(membername, table)("Grown to size:" SIZE_FORMAT, _current_size); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
281 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
282 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
283 |
struct ResolvedMethodTableDoDelete : StackObj { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
284 |
void operator()(WeakHandle<vm_resolved_method_table_data>* val) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
285 |
/* do nothing */ |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
286 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
287 |
}; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
288 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
289 |
struct ResolvedMethodTableDeleteCheck : StackObj { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
290 |
long _count; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
291 |
long _item; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
292 |
ResolvedMethodTableDeleteCheck() : _count(0), _item(0) {} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
293 |
bool operator()(WeakHandle<vm_resolved_method_table_data>* val) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
294 |
++_item; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
295 |
oop tmp = val->peek(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
296 |
if (tmp == NULL) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
297 |
++_count; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
298 |
return true; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
299 |
} else { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
300 |
return false; |
46505 | 301 |
} |
302 |
} |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
303 |
}; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
304 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
305 |
void ResolvedMethodTable::clean_dead_entries(JavaThread* jt) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
306 |
ResolvedMethodTableHash::BulkDeleteTask bdt(_local_table); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
307 |
if (!bdt.prepare(jt)) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
308 |
return; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
309 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
310 |
ResolvedMethodTableDeleteCheck stdc; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
311 |
ResolvedMethodTableDoDelete stdd; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
312 |
{ |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
313 |
TraceTime timer("Clean", TRACETIME_LOG(Debug, membername, table, perf)); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
314 |
while(bdt.do_task(jt, stdc, stdd)) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
315 |
bdt.pause(jt); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
316 |
{ |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
317 |
ThreadBlockInVM tbivm(jt); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
318 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
319 |
bdt.cont(jt); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
320 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
321 |
bdt.done(jt); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
322 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
323 |
log_info(membername, table)("Cleaned %ld of %ld", stdc._count, stdc._item); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
324 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
325 |
void ResolvedMethodTable::reset_dead_counter() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
326 |
_uncleaned_items_count = 0; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
327 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
328 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
329 |
void ResolvedMethodTable::inc_dead_counter(size_t ndead) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
330 |
size_t total = Atomic::add(ndead, &_uncleaned_items_count); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
331 |
log_trace(membername, table)( |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
332 |
"Uncleaned items:" SIZE_FORMAT " added: " SIZE_FORMAT " total:" SIZE_FORMAT, |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
333 |
_uncleaned_items_count, ndead, total); |
46505 | 334 |
} |
335 |
||
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
336 |
// After the parallel walk this method must be called to trigger |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
337 |
// cleaning. Note it might trigger a resize instead. |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
338 |
void ResolvedMethodTable::finish_dead_counter() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
339 |
check_concurrent_work(); |
46505 | 340 |
} |
341 |
||
342 |
#if INCLUDE_JVMTI |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
343 |
class AdjustMethodEntries : public StackObj { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
344 |
bool* _trace_name_printed; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
345 |
public: |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
346 |
AdjustMethodEntries(bool* trace_name_printed) : _trace_name_printed(trace_name_printed) {}; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
347 |
bool operator()(WeakHandle<vm_resolved_method_table_data>* entry) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
348 |
oop mem_name = entry->peek(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
349 |
if (mem_name == NULL) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
350 |
// Removed |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
351 |
return true; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
352 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
353 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
354 |
Method* old_method = (Method*)java_lang_invoke_ResolvedMethodName::vmtarget(mem_name); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
355 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
356 |
if (old_method->is_old()) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
357 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
358 |
Method* new_method = (old_method->is_deleted()) ? |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
359 |
Universe::throw_no_such_method_error() : |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
360 |
old_method->get_new_method(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
361 |
java_lang_invoke_ResolvedMethodName::set_vmtarget(mem_name, new_method); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
362 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
363 |
ResourceMark rm; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
364 |
if (!(*_trace_name_printed)) { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
365 |
log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name()); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
366 |
*_trace_name_printed = true; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
367 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
368 |
log_debug(redefine, class, update, constantpool) |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
369 |
("ResolvedMethod method update: %s(%s)", |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
370 |
new_method->name()->as_C_string(), new_method->signature()->as_C_string()); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
371 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
372 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
373 |
return true; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
374 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
375 |
}; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
376 |
|
46505 | 377 |
// It is called at safepoint only for RedefineClasses |
378 |
void ResolvedMethodTable::adjust_method_entries(bool * trace_name_printed) { |
|
379 |
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); |
|
380 |
// For each entry in RMT, change to new method |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
381 |
AdjustMethodEntries adjust(trace_name_printed); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
382 |
_local_table->do_safepoint_scan(adjust); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
383 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
384 |
#endif // INCLUDE_JVMTI |
46505 | 385 |
|
54574 | 386 |
// Verification |
387 |
class VerifyResolvedMethod : StackObj { |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
388 |
public: |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
389 |
bool operator()(WeakHandle<vm_resolved_method_table_data>* val) { |
54574 | 390 |
oop obj = val->peek(); |
391 |
if (obj != NULL) { |
|
392 |
Method* method = (Method*)java_lang_invoke_ResolvedMethodName::vmtarget(obj); |
|
393 |
guarantee(method->is_method(), "Must be"); |
|
394 |
guarantee(!method->is_old(), "Must be"); |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
395 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
396 |
return true; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
397 |
}; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
398 |
}; |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
399 |
|
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
400 |
size_t ResolvedMethodTable::items_count() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
401 |
return _items_count; |
46505 | 402 |
} |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
403 |
|
54574 | 404 |
void ResolvedMethodTable::verify() { |
405 |
VerifyResolvedMethod vcs; |
|
406 |
if (!_local_table->try_scan(Thread::current(), vcs)) { |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
407 |
log_info(membername, table)("verify unavailable at this moment"); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
408 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
54431
diff
changeset
|
409 |
} |