author | eosterlund |
Fri, 02 Nov 2018 08:33:59 +0100 | |
changeset 52385 | 5c679ec60888 |
parent 52384 | d6dc479bcdd3 |
child 52405 | c0c6cdea32f1 |
permissions | -rw-r--r-- |
38133 | 1 |
/* |
48955
e22914003cf0
8194691: Cleanup unnecessary casts in Atomic/OrderAccess uses
kbarrett
parents:
48557
diff
changeset
|
2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
38133 | 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" |
|
26 |
#include "code/compiledIC.hpp" |
|
46623
261b9d05b79d
8183299: Improve inlining of CompiledMethod methods into frame::sender
redestad
parents:
42650
diff
changeset
|
27 |
#include "code/compiledMethod.inline.hpp" |
38133 | 28 |
#include "code/scopeDesc.hpp" |
29 |
#include "code/codeCache.hpp" |
|
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
30 |
#include "gc/shared/barrierSet.hpp" |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
31 |
#include "gc/shared/gcBehaviours.hpp" |
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
48955
diff
changeset
|
32 |
#include "interpreter/bytecode.inline.hpp" |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
33 |
#include "logging/log.hpp" |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
34 |
#include "logging/logTag.hpp" |
38133 | 35 |
#include "memory/resourceArea.hpp" |
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
36 |
#include "oops/methodData.hpp" |
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
48955
diff
changeset
|
37 |
#include "oops/method.inline.hpp" |
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49449
diff
changeset
|
38 |
#include "prims/methodHandles.hpp" |
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49340
diff
changeset
|
39 |
#include "runtime/handles.inline.hpp" |
38133 | 40 |
#include "runtime/mutexLocker.hpp" |
41 |
||
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
42 |
CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
43 |
int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
44 |
bool caller_must_gc_arguments) |
42040
70ec5a09a0d5
8166377: is_compiled_by_jvmci hot in some profiles - improve nmethod compiler type detection
neliasso
parents:
39430
diff
changeset
|
45 |
: CodeBlob(name, type, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments), |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
46 |
_mark_for_deoptimization_status(not_marked), |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
47 |
_is_unloading_state(0), |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
48 |
_method(method) |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
49 |
{ |
38133 | 50 |
init_defaults(); |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
51 |
clear_unloading_state(); |
38133 | 52 |
} |
53 |
||
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
54 |
CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, int size, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
55 |
int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
56 |
OopMapSet* oop_maps, bool caller_must_gc_arguments) |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
57 |
: CodeBlob(name, type, CodeBlobLayout((address) this, size, header_size, cb), cb, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
58 |
frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments), |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
59 |
_mark_for_deoptimization_status(not_marked), |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
60 |
_is_unloading_state(0), |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
61 |
_method(method) |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
62 |
{ |
38133 | 63 |
init_defaults(); |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
64 |
clear_unloading_state(); |
38133 | 65 |
} |
66 |
||
67 |
void CompiledMethod::init_defaults() { |
|
68 |
_has_unsafe_access = 0; |
|
69 |
_has_method_handle_invokes = 0; |
|
70 |
_lazy_critical_native = 0; |
|
71 |
_has_wide_vectors = 0; |
|
72 |
} |
|
73 |
||
74 |
bool CompiledMethod::is_method_handle_return(address return_pc) { |
|
75 |
if (!has_method_handle_invokes()) return false; |
|
76 |
PcDesc* pd = pc_desc_at(return_pc); |
|
77 |
if (pd == NULL) |
|
78 |
return false; |
|
79 |
return pd->is_method_handle_invoke(); |
|
80 |
} |
|
81 |
||
82 |
// Returns a string version of the method state. |
|
83 |
const char* CompiledMethod::state() const { |
|
84 |
int state = get_state(); |
|
85 |
switch (state) { |
|
48007
ab3959df2115
8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents:
47687
diff
changeset
|
86 |
case not_installed: |
ab3959df2115
8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents:
47687
diff
changeset
|
87 |
return "not installed"; |
38133 | 88 |
case in_use: |
89 |
return "in use"; |
|
90 |
case not_used: |
|
91 |
return "not_used"; |
|
92 |
case not_entrant: |
|
93 |
return "not_entrant"; |
|
94 |
case zombie: |
|
95 |
return "zombie"; |
|
96 |
case unloaded: |
|
97 |
return "unloaded"; |
|
98 |
default: |
|
99 |
fatal("unexpected method state: %d", state); |
|
100 |
return NULL; |
|
101 |
} |
|
102 |
} |
|
103 |
||
104 |
//----------------------------------------------------------------------------- |
|
105 |
||
106 |
void CompiledMethod::add_exception_cache_entry(ExceptionCache* new_entry) { |
|
107 |
assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock"); |
|
108 |
assert(new_entry != NULL,"Must be non null"); |
|
109 |
assert(new_entry->next() == NULL, "Must be null"); |
|
110 |
||
111 |
ExceptionCache *ec = exception_cache(); |
|
112 |
if (ec != NULL) { |
|
113 |
new_entry->set_next(ec); |
|
114 |
} |
|
115 |
release_set_exception_cache(new_entry); |
|
116 |
} |
|
117 |
||
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
118 |
void CompiledMethod::clean_exception_cache() { |
38133 | 119 |
ExceptionCache* prev = NULL; |
120 |
ExceptionCache* curr = exception_cache(); |
|
121 |
||
122 |
while (curr != NULL) { |
|
123 |
ExceptionCache* next = curr->next(); |
|
124 |
||
125 |
Klass* ex_klass = curr->exception_type(); |
|
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
126 |
if (ex_klass != NULL && !ex_klass->is_loader_alive()) { |
38133 | 127 |
if (prev == NULL) { |
128 |
set_exception_cache(next); |
|
129 |
} else { |
|
130 |
prev->set_next(next); |
|
131 |
} |
|
132 |
delete curr; |
|
133 |
// prev stays the same. |
|
134 |
} else { |
|
135 |
prev = curr; |
|
136 |
} |
|
137 |
||
138 |
curr = next; |
|
139 |
} |
|
140 |
} |
|
141 |
||
142 |
// public method for accessing the exception cache |
|
143 |
// These are the public access methods. |
|
144 |
address CompiledMethod::handler_for_exception_and_pc(Handle exception, address pc) { |
|
145 |
// We never grab a lock to read the exception cache, so we may |
|
146 |
// have false negatives. This is okay, as it can only happen during |
|
147 |
// the first few exception lookups for a given nmethod. |
|
148 |
ExceptionCache* ec = exception_cache(); |
|
149 |
while (ec != NULL) { |
|
150 |
address ret_val; |
|
151 |
if ((ret_val = ec->match(exception,pc)) != NULL) { |
|
152 |
return ret_val; |
|
153 |
} |
|
154 |
ec = ec->next(); |
|
155 |
} |
|
156 |
return NULL; |
|
157 |
} |
|
158 |
||
159 |
void CompiledMethod::add_handler_for_exception_and_pc(Handle exception, address pc, address handler) { |
|
160 |
// There are potential race conditions during exception cache updates, so we |
|
161 |
// must own the ExceptionCache_lock before doing ANY modifications. Because |
|
162 |
// we don't lock during reads, it is possible to have several threads attempt |
|
163 |
// to update the cache with the same data. We need to check for already inserted |
|
164 |
// copies of the current data before adding it. |
|
165 |
||
166 |
MutexLocker ml(ExceptionCache_lock); |
|
167 |
ExceptionCache* target_entry = exception_cache_entry_for_exception(exception); |
|
168 |
||
169 |
if (target_entry == NULL || !target_entry->add_address_and_handler(pc,handler)) { |
|
170 |
target_entry = new ExceptionCache(exception,pc,handler); |
|
171 |
add_exception_cache_entry(target_entry); |
|
172 |
} |
|
173 |
} |
|
174 |
||
175 |
//-------------end of code for ExceptionCache-------------- |
|
176 |
||
177 |
// private method for handling exception cache |
|
178 |
// These methods are private, and used to manipulate the exception cache |
|
179 |
// directly. |
|
180 |
ExceptionCache* CompiledMethod::exception_cache_entry_for_exception(Handle exception) { |
|
181 |
ExceptionCache* ec = exception_cache(); |
|
182 |
while (ec != NULL) { |
|
183 |
if (ec->match_exception_with_space(exception)) { |
|
184 |
return ec; |
|
185 |
} |
|
186 |
ec = ec->next(); |
|
187 |
} |
|
188 |
return NULL; |
|
189 |
} |
|
190 |
||
191 |
bool CompiledMethod::is_at_poll_return(address pc) { |
|
192 |
RelocIterator iter(this, pc, pc+1); |
|
193 |
while (iter.next()) { |
|
194 |
if (iter.type() == relocInfo::poll_return_type) |
|
195 |
return true; |
|
196 |
} |
|
197 |
return false; |
|
198 |
} |
|
199 |
||
200 |
||
201 |
bool CompiledMethod::is_at_poll_or_poll_return(address pc) { |
|
202 |
RelocIterator iter(this, pc, pc+1); |
|
203 |
while (iter.next()) { |
|
204 |
relocInfo::relocType t = iter.type(); |
|
205 |
if (t == relocInfo::poll_return_type || t == relocInfo::poll_type) |
|
206 |
return true; |
|
207 |
} |
|
208 |
return false; |
|
209 |
} |
|
210 |
||
211 |
void CompiledMethod::verify_oop_relocations() { |
|
212 |
// Ensure sure that the code matches the current oop values |
|
213 |
RelocIterator iter(this, NULL, NULL); |
|
214 |
while (iter.next()) { |
|
215 |
if (iter.type() == relocInfo::oop_type) { |
|
216 |
oop_Relocation* reloc = iter.oop_reloc(); |
|
217 |
if (!reloc->oop_is_immediate()) { |
|
218 |
reloc->verify_oop_relocation(); |
|
219 |
} |
|
220 |
} |
|
221 |
} |
|
222 |
} |
|
223 |
||
224 |
||
225 |
ScopeDesc* CompiledMethod::scope_desc_at(address pc) { |
|
226 |
PcDesc* pd = pc_desc_at(pc); |
|
227 |
guarantee(pd != NULL, "scope must be present"); |
|
228 |
return new ScopeDesc(this, pd->scope_decode_offset(), |
|
229 |
pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(), |
|
230 |
pd->return_oop()); |
|
231 |
} |
|
232 |
||
46796 | 233 |
ScopeDesc* CompiledMethod::scope_desc_near(address pc) { |
234 |
PcDesc* pd = pc_desc_near(pc); |
|
235 |
guarantee(pd != NULL, "scope must be present"); |
|
236 |
return new ScopeDesc(this, pd->scope_decode_offset(), |
|
237 |
pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(), |
|
238 |
pd->return_oop()); |
|
239 |
} |
|
240 |
||
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
241 |
address CompiledMethod::oops_reloc_begin() const { |
38133 | 242 |
// If the method is not entrant or zombie then a JMP is plastered over the |
243 |
// first few bytes. If an oop in the old code was there, that oop |
|
244 |
// should not get GC'd. Skip the first few bytes of oops on |
|
245 |
// not-entrant methods. |
|
246 |
address low_boundary = verified_entry_point(); |
|
247 |
if (!is_in_use() && is_nmethod()) { |
|
248 |
low_boundary += NativeJump::instruction_size; |
|
249 |
// %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. |
|
250 |
// This means that the low_boundary is going to be a little too high. |
|
251 |
// This shouldn't matter, since oops of non-entrant methods are never used. |
|
252 |
// In fact, why are we bothering to look at oops in a non-entrant method?? |
|
253 |
} |
|
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
254 |
return low_boundary; |
38133 | 255 |
} |
256 |
||
257 |
int CompiledMethod::verify_icholder_relocations() { |
|
258 |
ResourceMark rm; |
|
259 |
int count = 0; |
|
260 |
||
261 |
RelocIterator iter(this); |
|
262 |
while(iter.next()) { |
|
263 |
if (iter.type() == relocInfo::virtual_call_type) { |
|
42650 | 264 |
if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc(), this)) { |
38133 | 265 |
CompiledIC *ic = CompiledIC_at(&iter); |
266 |
if (TraceCompiledIC) { |
|
267 |
tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder())); |
|
268 |
ic->print(); |
|
269 |
} |
|
270 |
assert(ic->cached_icholder() != NULL, "must be non-NULL"); |
|
271 |
count++; |
|
272 |
} |
|
273 |
} |
|
274 |
} |
|
275 |
||
276 |
return count; |
|
277 |
} |
|
278 |
||
279 |
// Method that knows how to preserve outgoing arguments at call. This method must be |
|
280 |
// called with a frame corresponding to a Java invoke |
|
281 |
void CompiledMethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { |
|
282 |
if (method() != NULL && !method()->is_native()) { |
|
283 |
address pc = fr.pc(); |
|
284 |
SimpleScopeDesc ssd(this, pc); |
|
285 |
Bytecode_invoke call(ssd.method(), ssd.bci()); |
|
286 |
bool has_receiver = call.has_receiver(); |
|
287 |
bool has_appendix = call.has_appendix(); |
|
288 |
Symbol* signature = call.signature(); |
|
289 |
||
290 |
// The method attached by JIT-compilers should be used, if present. |
|
291 |
// Bytecode can be inaccurate in such case. |
|
292 |
Method* callee = attached_method_before_pc(pc); |
|
293 |
if (callee != NULL) { |
|
294 |
has_receiver = !(callee->access_flags().is_static()); |
|
295 |
has_appendix = false; |
|
296 |
signature = callee->signature(); |
|
297 |
} |
|
298 |
||
299 |
fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f); |
|
300 |
} |
|
301 |
} |
|
302 |
||
303 |
Method* CompiledMethod::attached_method(address call_instr) { |
|
304 |
assert(code_contains(call_instr), "not part of the nmethod"); |
|
305 |
RelocIterator iter(this, call_instr, call_instr + 1); |
|
306 |
while (iter.next()) { |
|
307 |
if (iter.addr() == call_instr) { |
|
308 |
switch(iter.type()) { |
|
309 |
case relocInfo::static_call_type: return iter.static_call_reloc()->method_value(); |
|
310 |
case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value(); |
|
311 |
case relocInfo::virtual_call_type: return iter.virtual_call_reloc()->method_value(); |
|
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46623
diff
changeset
|
312 |
default: break; |
38133 | 313 |
} |
314 |
} |
|
315 |
} |
|
316 |
return NULL; // not found |
|
317 |
} |
|
318 |
||
319 |
Method* CompiledMethod::attached_method_before_pc(address pc) { |
|
320 |
if (NativeCall::is_call_before(pc)) { |
|
321 |
NativeCall* ncall = nativeCall_before(pc); |
|
322 |
return attached_method(ncall->instruction_address()); |
|
323 |
} |
|
324 |
return NULL; // not a call |
|
325 |
} |
|
326 |
||
327 |
void CompiledMethod::clear_inline_caches() { |
|
328 |
assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint"); |
|
329 |
if (is_zombie()) { |
|
330 |
return; |
|
331 |
} |
|
332 |
||
333 |
RelocIterator iter(this); |
|
334 |
while (iter.next()) { |
|
335 |
iter.reloc()->clear_inline_cache(); |
|
336 |
} |
|
337 |
} |
|
338 |
||
339 |
// Clear ICStubs of all compiled ICs |
|
340 |
void CompiledMethod::clear_ic_stubs() { |
|
52384
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51591
diff
changeset
|
341 |
assert(CompiledICLocker::is_safe(this), "mt unsafe call"); |
50995
3c59afe1afc9
8206394: missing ResourceMark in AOTCompiledMethod::metadata_do, AOTCompiledMethod::clear_inline_caches , CompiledMethod::clear_ic_stubs , CompiledMethod::cleanup_inline_caches_impl
mbaesken
parents:
50416
diff
changeset
|
342 |
ResourceMark rm; |
38133 | 343 |
RelocIterator iter(this); |
344 |
while(iter.next()) { |
|
345 |
if (iter.type() == relocInfo::virtual_call_type) { |
|
346 |
CompiledIC* ic = CompiledIC_at(&iter); |
|
347 |
ic->clear_ic_stub(); |
|
348 |
} |
|
349 |
} |
|
350 |
} |
|
351 |
||
352 |
#ifdef ASSERT |
|
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
353 |
// Check class_loader is alive for this bit of metadata. |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
354 |
static void check_class(Metadata* md) { |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
355 |
Klass* klass = NULL; |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
356 |
if (md->is_klass()) { |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
357 |
klass = ((Klass*)md); |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
358 |
} else if (md->is_method()) { |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
359 |
klass = ((Method*)md)->method_holder(); |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
360 |
} else if (md->is_methodData()) { |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
361 |
klass = ((MethodData*)md)->method()->method_holder(); |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
362 |
} else { |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
363 |
md->print(); |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
364 |
ShouldNotReachHere(); |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
365 |
} |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
366 |
assert(klass->is_loader_alive(), "must be alive"); |
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
367 |
} |
38133 | 368 |
#endif // ASSERT |
369 |
||
42650 | 370 |
|
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
371 |
void CompiledMethod::clean_ic_if_metadata_is_dead(CompiledIC *ic) { |
38133 | 372 |
if (ic->is_icholder_call()) { |
49969
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
373 |
// The only exception is compiledICHolder metdata which may |
38133 | 374 |
// yet be marked below. (We check this further below). |
49969
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
375 |
CompiledICHolder* cichk_metdata = ic->cached_icholder(); |
38133 | 376 |
|
49969
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
377 |
if (cichk_metdata->is_loader_alive()) { |
38133 | 378 |
return; |
379 |
} |
|
380 |
} else { |
|
49969
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
381 |
Metadata* ic_metdata = ic->cached_metadata(); |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
382 |
if (ic_metdata != NULL) { |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
383 |
if (ic_metdata->is_klass()) { |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
384 |
if (((Klass*)ic_metdata)->is_loader_alive()) { |
38133 | 385 |
return; |
386 |
} |
|
49969
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
387 |
} else if (ic_metdata->is_method()) { |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
388 |
Method* method = (Method*)ic_metdata; |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
389 |
assert(!method->is_old(), "old method should have been cleaned"); |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
390 |
if (method->method_holder()->is_loader_alive()) { |
38133 | 391 |
return; |
392 |
} |
|
393 |
} else { |
|
394 |
ShouldNotReachHere(); |
|
395 |
} |
|
396 |
} |
|
397 |
} |
|
398 |
||
399 |
ic->set_to_clean(); |
|
400 |
} |
|
401 |
||
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
402 |
// static_stub_Relocations may have dangling references to |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
403 |
// nmethods so trim them out here. Otherwise it looks like |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
404 |
// compiled code is maintaining a link to dead metadata. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
405 |
void CompiledMethod::clean_ic_stubs() { |
38133 | 406 |
#ifdef ASSERT |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
407 |
address low_boundary = oops_reloc_begin(); |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
408 |
RelocIterator iter(this, low_boundary); |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
409 |
while (iter.next()) { |
38133 | 410 |
address static_call_addr = NULL; |
411 |
if (iter.type() == relocInfo::opt_virtual_call_type) { |
|
412 |
CompiledIC* cic = CompiledIC_at(&iter); |
|
413 |
if (!cic->is_call_to_interpreted()) { |
|
414 |
static_call_addr = iter.addr(); |
|
415 |
} |
|
416 |
} else if (iter.type() == relocInfo::static_call_type) { |
|
417 |
CompiledStaticCall* csc = compiledStaticCall_at(iter.reloc()); |
|
418 |
if (!csc->is_call_to_interpreted()) { |
|
419 |
static_call_addr = iter.addr(); |
|
420 |
} |
|
421 |
} |
|
422 |
if (static_call_addr != NULL) { |
|
423 |
RelocIterator sciter(this, low_boundary); |
|
424 |
while (sciter.next()) { |
|
425 |
if (sciter.type() == relocInfo::static_stub_type && |
|
426 |
sciter.static_stub_reloc()->static_call() == static_call_addr) { |
|
427 |
sciter.static_stub_reloc()->clear_inline_cache(); |
|
428 |
} |
|
429 |
} |
|
430 |
} |
|
431 |
} |
|
432 |
#endif |
|
433 |
} |
|
434 |
||
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
435 |
// Clean references to unloaded nmethods at addr from this one, which is not unloaded. |
38133 | 436 |
template <class CompiledICorStaticCall> |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
437 |
static void clean_if_nmethod_is_unloaded(CompiledICorStaticCall *ic, address addr, CompiledMethod* from, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
438 |
bool clean_all) { |
38133 | 439 |
// Ok, to lookup references to zombies here |
440 |
CodeBlob *cb = CodeCache::find_blob_unsafe(addr); |
|
441 |
CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; |
|
442 |
if (nm != NULL) { |
|
443 |
// Clean inline caches pointing to both zombie and not_entrant methods |
|
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
444 |
if (clean_all || !nm->is_in_use() || nm->is_unloading() || (nm->method()->code() != nm)) { |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
445 |
ic->set_to_clean(from->is_alive()); |
38133 | 446 |
assert(ic->is_clean(), "nmethod " PTR_FORMAT "not clean %s", p2i(from), from->method()->name_and_sig_as_C_string()); |
447 |
} |
|
448 |
} |
|
449 |
} |
|
450 |
||
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
451 |
static void clean_if_nmethod_is_unloaded(CompiledIC *ic, CompiledMethod* from, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
452 |
bool clean_all) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
453 |
clean_if_nmethod_is_unloaded(ic, ic->ic_destination(), from, clean_all); |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
454 |
} |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
455 |
|
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
456 |
static void clean_if_nmethod_is_unloaded(CompiledStaticCall *csc, CompiledMethod* from, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
457 |
bool clean_all) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
458 |
clean_if_nmethod_is_unloaded(csc, csc->destination(), from, clean_all); |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
459 |
} |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
460 |
|
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
461 |
// Cleans caches in nmethods that point to either classes that are unloaded |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
462 |
// or nmethods that are unloaded. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
463 |
// |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
464 |
// Can be called either in parallel by G1 currently or after all |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
465 |
// nmethods are unloaded. Return postponed=true in the parallel case for |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
466 |
// inline caches found that point to nmethods that are not yet visited during |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
467 |
// the do_unloading walk. |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
468 |
void CompiledMethod::unload_nmethod_caches(bool unloading_occurred) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
469 |
ResourceMark rm; |
38133 | 470 |
|
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
471 |
// Exception cache only needs to be called if unloading occurred |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
472 |
if (unloading_occurred) { |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
473 |
clean_exception_cache(); |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
474 |
} |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
475 |
|
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
476 |
cleanup_inline_caches_impl(unloading_occurred, false); |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
477 |
|
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
478 |
// All static stubs need to be cleaned. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
479 |
clean_ic_stubs(); |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
480 |
|
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
481 |
// Check that the metadata embedded in the nmethod is alive |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
482 |
DEBUG_ONLY(metadata_do(check_class)); |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
483 |
} |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
484 |
|
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
485 |
// The IsUnloadingStruct represents a tuple comprising a result of |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
486 |
// IsUnloadingBehaviour::is_unloading() for a given unloading cycle. |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
487 |
struct IsUnloadingStruct { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
488 |
unsigned int _is_unloading:1; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
489 |
unsigned int _unloading_cycle:2; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
490 |
}; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
491 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
492 |
// The IsUnloadingUnion allows treating the tuple of the IsUnloadingStruct |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
493 |
// like a uint8_t, making it possible to read and write the tuple atomically. |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
494 |
union IsUnloadingUnion { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
495 |
IsUnloadingStruct _inflated; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
496 |
uint8_t _value; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
497 |
}; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
498 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
499 |
bool CompiledMethod::is_unloading() { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
500 |
IsUnloadingUnion state; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
501 |
state._value = RawAccess<MO_RELAXED>::load(&_is_unloading_state); |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
502 |
if (state._inflated._is_unloading == 1) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
503 |
return true; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
504 |
} |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
505 |
if (state._inflated._unloading_cycle == CodeCache::unloading_cycle()) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
506 |
return state._inflated._is_unloading == 1; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
507 |
} |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
508 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
509 |
// The IsUnloadingBehaviour is responsible for checking if there are any dead |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
510 |
// oops in the CompiledMethod, by calling oops_do on it. |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
511 |
bool result = IsUnloadingBehaviour::current()->is_unloading(this); |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
512 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
513 |
state._inflated._unloading_cycle = CodeCache::unloading_cycle(); |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
514 |
state._inflated._is_unloading = result ? 1 : 0; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
515 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
516 |
RawAccess<MO_RELAXED>::store(&_is_unloading_state, state._value); |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
517 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
518 |
return result; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
519 |
} |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
520 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
521 |
void CompiledMethod::clear_unloading_state() { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
522 |
IsUnloadingUnion state; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
523 |
state._inflated._unloading_cycle = CodeCache::unloading_cycle(); |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
524 |
state._inflated._is_unloading = 0; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
525 |
RawAccess<MO_RELAXED>::store(&_is_unloading_state, state._value); |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
526 |
} |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
527 |
|
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
528 |
// Called to clean up after class unloading for live nmethods and from the sweeper |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
529 |
// for all methods. |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
530 |
void CompiledMethod::cleanup_inline_caches_impl(bool unloading_occurred, bool clean_all) { |
52384
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51591
diff
changeset
|
531 |
assert(CompiledICLocker::is_safe(this), "mt unsafe call"); |
50995
3c59afe1afc9
8206394: missing ResourceMark in AOTCompiledMethod::metadata_do, AOTCompiledMethod::clear_inline_caches , CompiledMethod::clear_ic_stubs , CompiledMethod::cleanup_inline_caches_impl
mbaesken
parents:
50416
diff
changeset
|
532 |
ResourceMark rm; |
38133 | 533 |
|
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
534 |
// Find all calls in an nmethod and clear the ones that point to non-entrant, |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
535 |
// zombie and unloaded nmethods. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
536 |
RelocIterator iter(this, oops_reloc_begin()); |
38133 | 537 |
while(iter.next()) { |
538 |
||
539 |
switch (iter.type()) { |
|
540 |
||
541 |
case relocInfo::virtual_call_type: |
|
542 |
if (unloading_occurred) { |
|
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
543 |
// If class unloading occurred we first clear ICs where the cached metadata |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
544 |
// is referring to an unloaded klass or method. |
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
545 |
clean_ic_if_metadata_is_dead(CompiledIC_at(&iter)); |
38133 | 546 |
} |
547 |
||
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
548 |
clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), this, clean_all); |
38133 | 549 |
break; |
550 |
||
551 |
case relocInfo::opt_virtual_call_type: |
|
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
552 |
clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), this, clean_all); |
38133 | 553 |
break; |
554 |
||
555 |
case relocInfo::static_call_type: |
|
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
556 |
clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), this, clean_all); |
38133 | 557 |
break; |
558 |
||
559 |
case relocInfo::oop_type: |
|
560 |
break; |
|
561 |
||
562 |
case relocInfo::metadata_type: |
|
563 |
break; // nothing to do. |
|
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46623
diff
changeset
|
564 |
|
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46623
diff
changeset
|
565 |
default: |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46623
diff
changeset
|
566 |
break; |
38133 | 567 |
} |
568 |
} |
|
569 |
} |
|
51591 | 570 |
|
571 |
// Iterating over all nmethods, e.g. with the help of CodeCache::nmethods_do(fun) was found |
|
572 |
// to not be inherently safe. There is a chance that fields are seen which are not properly |
|
573 |
// initialized. This happens despite the fact that nmethods_do() asserts the CodeCache_lock |
|
574 |
// to be held. |
|
575 |
// To bundle knowledge about necessary checks in one place, this function was introduced. |
|
576 |
// It is not claimed that these checks are sufficient, but they were found to be necessary. |
|
577 |
bool CompiledMethod::nmethod_access_is_safe(nmethod* nm) { |
|
578 |
Method* method = (nm == NULL) ? NULL : nm->method(); // nm->method() may be uninitialized, i.e. != NULL, but invalid |
|
579 |
return (nm != NULL) && (method != NULL) && (method->signature() != NULL) && |
|
580 |
!nm->is_zombie() && !nm->is_not_installed() && |
|
581 |
os::is_readable_pointer(method) && |
|
582 |
os::is_readable_pointer(method->constants()) && |
|
583 |
os::is_readable_pointer(method->signature()); |
|
584 |
} |