author | pliden |
Wed, 09 Oct 2019 20:12:46 +0200 | |
changeset 58522 | 17a34e111667 |
parent 58226 | 408c445d04e8 |
child 58679 | 9c3209ff7550 |
child 59056 | 15936b142f86 |
permissions | -rw-r--r-- |
38133 | 1 |
/* |
54150
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, 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" |
55293
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
28 |
#include "code/exceptionHandlerTable.hpp" |
38133 | 29 |
#include "code/scopeDesc.hpp" |
30 |
#include "code/codeCache.hpp" |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
31 |
#include "code/icBuffer.hpp" |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
32 |
#include "gc/shared/barrierSet.hpp" |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
33 |
#include "gc/shared/gcBehaviours.hpp" |
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
48955
diff
changeset
|
34 |
#include "interpreter/bytecode.inline.hpp" |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
35 |
#include "logging/log.hpp" |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
36 |
#include "logging/logTag.hpp" |
38133 | 37 |
#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
|
38 |
#include "oops/methodData.hpp" |
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
48955
diff
changeset
|
39 |
#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
|
40 |
#include "prims/methodHandles.hpp" |
55293
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
41 |
#include "runtime/deoptimization.hpp" |
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49340
diff
changeset
|
42 |
#include "runtime/handles.inline.hpp" |
38133 | 43 |
#include "runtime/mutexLocker.hpp" |
55293
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
44 |
#include "runtime/sharedRuntime.hpp" |
38133 | 45 |
|
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
46 |
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
|
47 |
int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
48 |
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
|
49 |
: 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
|
50 |
_mark_for_deoptimization_status(not_marked), |
52660
9cb53c505acd
8214056: Allow the GC to attach context information to CompiledMethod
eosterlund
parents:
52659
diff
changeset
|
51 |
_method(method), |
9cb53c505acd
8214056: Allow the GC to attach context information to CompiledMethod
eosterlund
parents:
52659
diff
changeset
|
52 |
_gc_data(NULL) |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
53 |
{ |
38133 | 54 |
init_defaults(); |
55 |
} |
|
56 |
||
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
57 |
CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, int size, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
58 |
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
|
59 |
OopMapSet* oop_maps, bool caller_must_gc_arguments) |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
60 |
: CodeBlob(name, type, CodeBlobLayout((address) this, size, header_size, cb), cb, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
61 |
frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments), |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
62 |
_mark_for_deoptimization_status(not_marked), |
52660
9cb53c505acd
8214056: Allow the GC to attach context information to CompiledMethod
eosterlund
parents:
52659
diff
changeset
|
63 |
_method(method), |
9cb53c505acd
8214056: Allow the GC to attach context information to CompiledMethod
eosterlund
parents:
52659
diff
changeset
|
64 |
_gc_data(NULL) |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
65 |
{ |
38133 | 66 |
init_defaults(); |
67 |
} |
|
68 |
||
69 |
void CompiledMethod::init_defaults() { |
|
70 |
_has_unsafe_access = 0; |
|
71 |
_has_method_handle_invokes = 0; |
|
72 |
_lazy_critical_native = 0; |
|
73 |
_has_wide_vectors = 0; |
|
74 |
} |
|
75 |
||
76 |
bool CompiledMethod::is_method_handle_return(address return_pc) { |
|
77 |
if (!has_method_handle_invokes()) return false; |
|
78 |
PcDesc* pd = pc_desc_at(return_pc); |
|
79 |
if (pd == NULL) |
|
80 |
return false; |
|
81 |
return pd->is_method_handle_invoke(); |
|
82 |
} |
|
83 |
||
84 |
// Returns a string version of the method state. |
|
85 |
const char* CompiledMethod::state() const { |
|
86 |
int state = get_state(); |
|
87 |
switch (state) { |
|
48007
ab3959df2115
8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents:
47687
diff
changeset
|
88 |
case not_installed: |
ab3959df2115
8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents:
47687
diff
changeset
|
89 |
return "not installed"; |
38133 | 90 |
case in_use: |
91 |
return "in use"; |
|
92 |
case not_used: |
|
93 |
return "not_used"; |
|
94 |
case not_entrant: |
|
95 |
return "not_entrant"; |
|
96 |
case zombie: |
|
97 |
return "zombie"; |
|
98 |
case unloaded: |
|
99 |
return "unloaded"; |
|
100 |
default: |
|
101 |
fatal("unexpected method state: %d", state); |
|
102 |
return NULL; |
|
103 |
} |
|
104 |
} |
|
105 |
||
106 |
//----------------------------------------------------------------------------- |
|
58226 | 107 |
void CompiledMethod::mark_for_deoptimization(bool inc_recompile_counts) { |
108 |
MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, |
|
109 |
Mutex::_no_safepoint_check_flag); |
|
110 |
_mark_for_deoptimization_status = (inc_recompile_counts ? deoptimize : deoptimize_noupdate); |
|
111 |
} |
|
112 |
||
113 |
//----------------------------------------------------------------------------- |
|
38133 | 114 |
|
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
115 |
ExceptionCache* CompiledMethod::exception_cache_acquire() const { |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
116 |
return OrderAccess::load_acquire(&_exception_cache); |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
117 |
} |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
118 |
|
38133 | 119 |
void CompiledMethod::add_exception_cache_entry(ExceptionCache* new_entry) { |
120 |
assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock"); |
|
121 |
assert(new_entry != NULL,"Must be non null"); |
|
122 |
assert(new_entry->next() == NULL, "Must be null"); |
|
123 |
||
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
124 |
for (;;) { |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
125 |
ExceptionCache *ec = exception_cache(); |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
126 |
if (ec != NULL) { |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
127 |
Klass* ex_klass = ec->exception_type(); |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
128 |
if (!ex_klass->is_loader_alive()) { |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
129 |
// We must guarantee that entries are not inserted with new next pointer |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
130 |
// edges to ExceptionCache entries with dead klasses, due to bad interactions |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
131 |
// with concurrent ExceptionCache cleanup. Therefore, the inserts roll |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
132 |
// the head pointer forward to the first live ExceptionCache, so that the new |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
133 |
// next pointers always point at live ExceptionCaches, that are not removed due |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
134 |
// to concurrent ExceptionCache cleanup. |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
135 |
ExceptionCache* next = ec->next(); |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
136 |
if (Atomic::cmpxchg(next, &_exception_cache, ec) == ec) { |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
137 |
CodeCache::release_exception_cache(ec); |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
138 |
} |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
139 |
continue; |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
140 |
} |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
141 |
ec = exception_cache(); |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
142 |
if (ec != NULL) { |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
143 |
new_entry->set_next(ec); |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
144 |
} |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
145 |
} |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
146 |
if (Atomic::cmpxchg(new_entry, &_exception_cache, ec) == ec) { |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
147 |
return; |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
148 |
} |
38133 | 149 |
} |
150 |
} |
|
151 |
||
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
152 |
void CompiledMethod::clean_exception_cache() { |
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
153 |
// For each nmethod, only a single thread may call this cleanup function |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
154 |
// at the same time, whether called in STW cleanup or concurrent cleanup. |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
155 |
// Note that if the GC is processing exception cache cleaning in a concurrent phase, |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
156 |
// then a single writer may contend with cleaning up the head pointer to the |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
157 |
// first ExceptionCache node that has a Klass* that is alive. That is fine, |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
158 |
// as long as there is no concurrent cleanup of next pointers from concurrent writers. |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
159 |
// And the concurrent writers do not clean up next pointers, only the head. |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
160 |
// Also note that concurent readers will walk through Klass* pointers that are not |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
161 |
// alive. That does not cause ABA problems, because Klass* is deleted after |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
162 |
// a handshake with all threads, after all stale ExceptionCaches have been |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
163 |
// unlinked. That is also when the CodeCache::exception_cache_purge_list() |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
164 |
// is deleted, with all ExceptionCache entries that were cleaned concurrently. |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
165 |
// That similarly implies that CAS operations on ExceptionCache entries do not |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
166 |
// suffer from ABA problems as unlinking and deletion is separated by a global |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
167 |
// handshake operation. |
38133 | 168 |
ExceptionCache* prev = NULL; |
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
169 |
ExceptionCache* curr = exception_cache_acquire(); |
38133 | 170 |
|
171 |
while (curr != NULL) { |
|
172 |
ExceptionCache* next = curr->next(); |
|
173 |
||
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
174 |
if (!curr->exception_type()->is_loader_alive()) { |
38133 | 175 |
if (prev == NULL) { |
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
176 |
// Try to clean head; this is contended by concurrent inserts, that |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
177 |
// both lazily clean the head, and insert entries at the head. If |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
178 |
// the CAS fails, the operation is restarted. |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
179 |
if (Atomic::cmpxchg(next, &_exception_cache, curr) != curr) { |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
180 |
prev = NULL; |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
181 |
curr = exception_cache_acquire(); |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
182 |
continue; |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
183 |
} |
38133 | 184 |
} else { |
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
185 |
// It is impossible to during cleanup connect the next pointer to |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
186 |
// an ExceptionCache that has not been published before a safepoint |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
187 |
// prior to the cleanup. Therefore, release is not required. |
38133 | 188 |
prev->set_next(next); |
189 |
} |
|
190 |
// prev stays the same. |
|
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
191 |
|
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
192 |
CodeCache::release_exception_cache(curr); |
38133 | 193 |
} else { |
194 |
prev = curr; |
|
195 |
} |
|
196 |
||
197 |
curr = next; |
|
198 |
} |
|
199 |
} |
|
200 |
||
201 |
// public method for accessing the exception cache |
|
202 |
// These are the public access methods. |
|
203 |
address CompiledMethod::handler_for_exception_and_pc(Handle exception, address pc) { |
|
204 |
// We never grab a lock to read the exception cache, so we may |
|
205 |
// have false negatives. This is okay, as it can only happen during |
|
206 |
// the first few exception lookups for a given nmethod. |
|
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
207 |
ExceptionCache* ec = exception_cache_acquire(); |
38133 | 208 |
while (ec != NULL) { |
209 |
address ret_val; |
|
210 |
if ((ret_val = ec->match(exception,pc)) != NULL) { |
|
211 |
return ret_val; |
|
212 |
} |
|
213 |
ec = ec->next(); |
|
214 |
} |
|
215 |
return NULL; |
|
216 |
} |
|
217 |
||
218 |
void CompiledMethod::add_handler_for_exception_and_pc(Handle exception, address pc, address handler) { |
|
219 |
// There are potential race conditions during exception cache updates, so we |
|
220 |
// must own the ExceptionCache_lock before doing ANY modifications. Because |
|
221 |
// we don't lock during reads, it is possible to have several threads attempt |
|
222 |
// to update the cache with the same data. We need to check for already inserted |
|
223 |
// copies of the current data before adding it. |
|
224 |
||
225 |
MutexLocker ml(ExceptionCache_lock); |
|
226 |
ExceptionCache* target_entry = exception_cache_entry_for_exception(exception); |
|
227 |
||
228 |
if (target_entry == NULL || !target_entry->add_address_and_handler(pc,handler)) { |
|
229 |
target_entry = new ExceptionCache(exception,pc,handler); |
|
230 |
add_exception_cache_entry(target_entry); |
|
231 |
} |
|
232 |
} |
|
233 |
||
234 |
// private method for handling exception cache |
|
235 |
// These methods are private, and used to manipulate the exception cache |
|
236 |
// directly. |
|
237 |
ExceptionCache* CompiledMethod::exception_cache_entry_for_exception(Handle exception) { |
|
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
238 |
ExceptionCache* ec = exception_cache_acquire(); |
38133 | 239 |
while (ec != NULL) { |
240 |
if (ec->match_exception_with_space(exception)) { |
|
241 |
return ec; |
|
242 |
} |
|
243 |
ec = ec->next(); |
|
244 |
} |
|
245 |
return NULL; |
|
246 |
} |
|
247 |
||
52405
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
248 |
//-------------end of code for ExceptionCache-------------- |
c0c6cdea32f1
8212989: Allow CompiledMethod ExceptionCache have unloaded klasses
eosterlund
parents:
52385
diff
changeset
|
249 |
|
38133 | 250 |
bool CompiledMethod::is_at_poll_return(address pc) { |
251 |
RelocIterator iter(this, pc, pc+1); |
|
252 |
while (iter.next()) { |
|
253 |
if (iter.type() == relocInfo::poll_return_type) |
|
254 |
return true; |
|
255 |
} |
|
256 |
return false; |
|
257 |
} |
|
258 |
||
259 |
||
260 |
bool CompiledMethod::is_at_poll_or_poll_return(address pc) { |
|
261 |
RelocIterator iter(this, pc, pc+1); |
|
262 |
while (iter.next()) { |
|
263 |
relocInfo::relocType t = iter.type(); |
|
264 |
if (t == relocInfo::poll_return_type || t == relocInfo::poll_type) |
|
265 |
return true; |
|
266 |
} |
|
267 |
return false; |
|
268 |
} |
|
269 |
||
270 |
void CompiledMethod::verify_oop_relocations() { |
|
271 |
// Ensure sure that the code matches the current oop values |
|
272 |
RelocIterator iter(this, NULL, NULL); |
|
273 |
while (iter.next()) { |
|
274 |
if (iter.type() == relocInfo::oop_type) { |
|
275 |
oop_Relocation* reloc = iter.oop_reloc(); |
|
276 |
if (!reloc->oop_is_immediate()) { |
|
277 |
reloc->verify_oop_relocation(); |
|
278 |
} |
|
279 |
} |
|
280 |
} |
|
281 |
} |
|
282 |
||
283 |
||
284 |
ScopeDesc* CompiledMethod::scope_desc_at(address pc) { |
|
285 |
PcDesc* pd = pc_desc_at(pc); |
|
286 |
guarantee(pd != NULL, "scope must be present"); |
|
287 |
return new ScopeDesc(this, pd->scope_decode_offset(), |
|
288 |
pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(), |
|
289 |
pd->return_oop()); |
|
290 |
} |
|
291 |
||
46796 | 292 |
ScopeDesc* CompiledMethod::scope_desc_near(address pc) { |
293 |
PcDesc* pd = pc_desc_near(pc); |
|
294 |
guarantee(pd != NULL, "scope must be present"); |
|
295 |
return new ScopeDesc(this, pd->scope_decode_offset(), |
|
296 |
pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(), |
|
297 |
pd->return_oop()); |
|
298 |
} |
|
299 |
||
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
300 |
address CompiledMethod::oops_reloc_begin() const { |
38133 | 301 |
// If the method is not entrant or zombie then a JMP is plastered over the |
302 |
// first few bytes. If an oop in the old code was there, that oop |
|
303 |
// should not get GC'd. Skip the first few bytes of oops on |
|
304 |
// not-entrant methods. |
|
52410
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
305 |
if (frame_complete_offset() != CodeOffsets::frame_never_safe && |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
306 |
code_begin() + frame_complete_offset() > |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
307 |
verified_entry_point() + NativeJump::instruction_size) |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
308 |
{ |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
309 |
// If we have a frame_complete_offset after the native jump, then there |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
310 |
// is no point trying to look for oops before that. This is a requirement |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
311 |
// for being allowed to scan oops concurrently. |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
312 |
return code_begin() + frame_complete_offset(); |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
313 |
} |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
314 |
|
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
315 |
// It is not safe to read oops concurrently using entry barriers, if their |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
316 |
// location depend on whether the nmethod is entrant or not. |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
317 |
assert(BarrierSet::barrier_set()->barrier_set_nmethod() == NULL, "Not safe oop scan"); |
9d3abb1b7b1f
8212585: Clean up CompiledMethod::oops_reloc_begin()
eosterlund
parents:
52405
diff
changeset
|
318 |
|
38133 | 319 |
address low_boundary = verified_entry_point(); |
320 |
if (!is_in_use() && is_nmethod()) { |
|
321 |
low_boundary += NativeJump::instruction_size; |
|
322 |
// %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. |
|
323 |
// This means that the low_boundary is going to be a little too high. |
|
324 |
// This shouldn't matter, since oops of non-entrant methods are never used. |
|
325 |
// In fact, why are we bothering to look at oops in a non-entrant method?? |
|
326 |
} |
|
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
327 |
return low_boundary; |
38133 | 328 |
} |
329 |
||
330 |
int CompiledMethod::verify_icholder_relocations() { |
|
331 |
ResourceMark rm; |
|
332 |
int count = 0; |
|
333 |
||
334 |
RelocIterator iter(this); |
|
335 |
while(iter.next()) { |
|
336 |
if (iter.type() == relocInfo::virtual_call_type) { |
|
42650 | 337 |
if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc(), this)) { |
38133 | 338 |
CompiledIC *ic = CompiledIC_at(&iter); |
339 |
if (TraceCompiledIC) { |
|
340 |
tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder())); |
|
341 |
ic->print(); |
|
342 |
} |
|
343 |
assert(ic->cached_icholder() != NULL, "must be non-NULL"); |
|
344 |
count++; |
|
345 |
} |
|
346 |
} |
|
347 |
} |
|
348 |
||
349 |
return count; |
|
350 |
} |
|
351 |
||
352 |
// Method that knows how to preserve outgoing arguments at call. This method must be |
|
353 |
// called with a frame corresponding to a Java invoke |
|
354 |
void CompiledMethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { |
|
355 |
if (method() != NULL && !method()->is_native()) { |
|
356 |
address pc = fr.pc(); |
|
357 |
SimpleScopeDesc ssd(this, pc); |
|
358 |
Bytecode_invoke call(ssd.method(), ssd.bci()); |
|
359 |
bool has_receiver = call.has_receiver(); |
|
360 |
bool has_appendix = call.has_appendix(); |
|
361 |
Symbol* signature = call.signature(); |
|
362 |
||
363 |
// The method attached by JIT-compilers should be used, if present. |
|
364 |
// Bytecode can be inaccurate in such case. |
|
365 |
Method* callee = attached_method_before_pc(pc); |
|
366 |
if (callee != NULL) { |
|
367 |
has_receiver = !(callee->access_flags().is_static()); |
|
368 |
has_appendix = false; |
|
369 |
signature = callee->signature(); |
|
370 |
} |
|
371 |
||
372 |
fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f); |
|
373 |
} |
|
374 |
} |
|
375 |
||
376 |
Method* CompiledMethod::attached_method(address call_instr) { |
|
377 |
assert(code_contains(call_instr), "not part of the nmethod"); |
|
378 |
RelocIterator iter(this, call_instr, call_instr + 1); |
|
379 |
while (iter.next()) { |
|
380 |
if (iter.addr() == call_instr) { |
|
381 |
switch(iter.type()) { |
|
382 |
case relocInfo::static_call_type: return iter.static_call_reloc()->method_value(); |
|
383 |
case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value(); |
|
384 |
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
|
385 |
default: break; |
38133 | 386 |
} |
387 |
} |
|
388 |
} |
|
389 |
return NULL; // not found |
|
390 |
} |
|
391 |
||
392 |
Method* CompiledMethod::attached_method_before_pc(address pc) { |
|
393 |
if (NativeCall::is_call_before(pc)) { |
|
394 |
NativeCall* ncall = nativeCall_before(pc); |
|
395 |
return attached_method(ncall->instruction_address()); |
|
396 |
} |
|
397 |
return NULL; // not a call |
|
398 |
} |
|
399 |
||
400 |
void CompiledMethod::clear_inline_caches() { |
|
401 |
assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint"); |
|
402 |
if (is_zombie()) { |
|
403 |
return; |
|
404 |
} |
|
405 |
||
406 |
RelocIterator iter(this); |
|
407 |
while (iter.next()) { |
|
408 |
iter.reloc()->clear_inline_cache(); |
|
409 |
} |
|
410 |
} |
|
411 |
||
53651
0331b08811ad
8216541: CompiledICHolders of VM locked unloaded nmethods are released too late
eosterlund
parents:
52896
diff
changeset
|
412 |
// Clear IC callsites, releasing ICStubs of all compiled ICs |
0331b08811ad
8216541: CompiledICHolders of VM locked unloaded nmethods are released too late
eosterlund
parents:
52896
diff
changeset
|
413 |
// as well as any associated CompiledICHolders. |
0331b08811ad
8216541: CompiledICHolders of VM locked unloaded nmethods are released too late
eosterlund
parents:
52896
diff
changeset
|
414 |
void CompiledMethod::clear_ic_callsites() { |
52384
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51591
diff
changeset
|
415 |
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
|
416 |
ResourceMark rm; |
38133 | 417 |
RelocIterator iter(this); |
418 |
while(iter.next()) { |
|
419 |
if (iter.type() == relocInfo::virtual_call_type) { |
|
420 |
CompiledIC* ic = CompiledIC_at(&iter); |
|
53651
0331b08811ad
8216541: CompiledICHolders of VM locked unloaded nmethods are released too late
eosterlund
parents:
52896
diff
changeset
|
421 |
ic->set_to_clean(false); |
38133 | 422 |
} |
423 |
} |
|
424 |
} |
|
425 |
||
426 |
#ifdef ASSERT |
|
49821
02c08e20d66c
8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents:
49480
diff
changeset
|
427 |
// Check class_loader is alive for this bit of metadata. |
54150
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
428 |
class CheckClass : public MetadataClosure { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
429 |
void do_metadata(Metadata* md) { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
430 |
Klass* klass = NULL; |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
431 |
if (md->is_klass()) { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
432 |
klass = ((Klass*)md); |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
433 |
} else if (md->is_method()) { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
434 |
klass = ((Method*)md)->method_holder(); |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
435 |
} else if (md->is_methodData()) { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
436 |
klass = ((MethodData*)md)->method()->method_holder(); |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
437 |
} else { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
438 |
md->print(); |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
439 |
ShouldNotReachHere(); |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
440 |
} |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
441 |
assert(klass->is_loader_alive(), "must be alive"); |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
442 |
} |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
443 |
}; |
38133 | 444 |
#endif // ASSERT |
445 |
||
42650 | 446 |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
447 |
bool CompiledMethod::clean_ic_if_metadata_is_dead(CompiledIC *ic) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
448 |
if (ic->is_clean()) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
449 |
return true; |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
450 |
} |
38133 | 451 |
if (ic->is_icholder_call()) { |
49969
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
452 |
// The only exception is compiledICHolder metdata which may |
38133 | 453 |
// yet be marked below. (We check this further below). |
49969
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
454 |
CompiledICHolder* cichk_metdata = ic->cached_icholder(); |
38133 | 455 |
|
49969
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
456 |
if (cichk_metdata->is_loader_alive()) { |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
457 |
return true; |
38133 | 458 |
} |
459 |
} else { |
|
49969
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
460 |
Metadata* ic_metdata = ic->cached_metadata(); |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
461 |
if (ic_metdata != NULL) { |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
462 |
if (ic_metdata->is_klass()) { |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
463 |
if (((Klass*)ic_metdata)->is_loader_alive()) { |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
464 |
return true; |
38133 | 465 |
} |
49969
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
466 |
} else if (ic_metdata->is_method()) { |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
467 |
Method* method = (Method*)ic_metdata; |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
468 |
assert(!method->is_old(), "old method should have been cleaned"); |
8624981f1ffa
8202447: Fix unloading_occurred to mean unloading_occurred
coleenp
parents:
49890
diff
changeset
|
469 |
if (method->method_holder()->is_loader_alive()) { |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
470 |
return true; |
38133 | 471 |
} |
472 |
} else { |
|
473 |
ShouldNotReachHere(); |
|
474 |
} |
|
475 |
} |
|
476 |
} |
|
477 |
||
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
478 |
return ic->set_to_clean(); |
38133 | 479 |
} |
480 |
||
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
481 |
// Clean references to unloaded nmethods at addr from this one, which is not unloaded. |
38133 | 482 |
template <class CompiledICorStaticCall> |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
483 |
static bool clean_if_nmethod_is_unloaded(CompiledICorStaticCall *ic, address addr, CompiledMethod* from, |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
484 |
bool clean_all) { |
38133 | 485 |
// Ok, to lookup references to zombies here |
486 |
CodeBlob *cb = CodeCache::find_blob_unsafe(addr); |
|
487 |
CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; |
|
488 |
if (nm != NULL) { |
|
489 |
// 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
|
490 |
if (clean_all || !nm->is_in_use() || nm->is_unloading() || (nm->method()->code() != nm)) { |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
491 |
if (!ic->set_to_clean(from->is_alive())) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
492 |
return false; |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
493 |
} |
38133 | 494 |
assert(ic->is_clean(), "nmethod " PTR_FORMAT "not clean %s", p2i(from), from->method()->name_and_sig_as_C_string()); |
495 |
} |
|
496 |
} |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
497 |
return true; |
38133 | 498 |
} |
499 |
||
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
500 |
static bool clean_if_nmethod_is_unloaded(CompiledIC *ic, CompiledMethod* from, |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
501 |
bool clean_all) { |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
502 |
return clean_if_nmethod_is_unloaded(ic, ic->ic_destination(), from, clean_all); |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
503 |
} |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
504 |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
505 |
static bool clean_if_nmethod_is_unloaded(CompiledStaticCall *csc, CompiledMethod* from, |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
506 |
bool clean_all) { |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
507 |
return 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
|
508 |
} |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
509 |
|
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
510 |
// 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
|
511 |
// or nmethods that are unloaded. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
512 |
// |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
513 |
// 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
|
514 |
// 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
|
515 |
// 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
|
516 |
// the do_unloading walk. |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
517 |
bool CompiledMethod::unload_nmethod_caches(bool unloading_occurred) { |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
518 |
ResourceMark rm; |
38133 | 519 |
|
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
520 |
// Exception cache only needs to be called if unloading occurred |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
521 |
if (unloading_occurred) { |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
522 |
clean_exception_cache(); |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
523 |
} |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
524 |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
525 |
if (!cleanup_inline_caches_impl(unloading_occurred, false)) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
526 |
return false; |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
527 |
} |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
528 |
|
54150
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
529 |
#ifdef ASSERT |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
530 |
// Check that the metadata embedded in the nmethod is alive |
54150
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
531 |
CheckClass check_class; |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
532 |
metadata_do(&check_class); |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
533 |
#endif |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
534 |
return true; |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
535 |
} |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
536 |
|
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
537 |
void CompiledMethod::cleanup_inline_caches(bool clean_all) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
538 |
for (;;) { |
52896
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
539 |
ICRefillVerifier ic_refill_verifier; |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
540 |
{ CompiledICLocker ic_locker(this); |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
541 |
if (cleanup_inline_caches_impl(false, clean_all)) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
542 |
return; |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
543 |
} |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
544 |
} |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
545 |
InlineCacheBuffer::refill_ic_stubs(); |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
546 |
} |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
52384
diff
changeset
|
547 |
} |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
548 |
|
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
549 |
// 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
|
550 |
// for all methods. |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
551 |
bool 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
|
552 |
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
|
553 |
ResourceMark rm; |
38133 | 554 |
|
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
555 |
// 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
|
556 |
// zombie and unloaded nmethods. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
557 |
RelocIterator iter(this, oops_reloc_begin()); |
54839
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
558 |
bool is_in_static_stub = false; |
38133 | 559 |
while(iter.next()) { |
560 |
||
561 |
switch (iter.type()) { |
|
562 |
||
563 |
case relocInfo::virtual_call_type: |
|
564 |
if (unloading_occurred) { |
|
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
49969
diff
changeset
|
565 |
// 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
|
566 |
// is referring to an unloaded klass or method. |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
567 |
if (!clean_ic_if_metadata_is_dead(CompiledIC_at(&iter))) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
568 |
return false; |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
569 |
} |
38133 | 570 |
} |
571 |
||
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
572 |
if (!clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), this, clean_all)) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
573 |
return false; |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
574 |
} |
38133 | 575 |
break; |
576 |
||
577 |
case relocInfo::opt_virtual_call_type: |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
578 |
if (!clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), this, clean_all)) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
579 |
return false; |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
580 |
} |
38133 | 581 |
break; |
582 |
||
583 |
case relocInfo::static_call_type: |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
584 |
if (!clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), this, clean_all)) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
585 |
return false; |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
586 |
} |
38133 | 587 |
break; |
588 |
||
54839
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
589 |
case relocInfo::static_stub_type: { |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
590 |
is_in_static_stub = true; |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
591 |
break; |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
592 |
} |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
593 |
|
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
594 |
case relocInfo::metadata_type: { |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
595 |
// Only the metadata relocations contained in static/opt virtual call stubs |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
596 |
// contains the Method* passed to c2i adapters. It is the only metadata |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
597 |
// relocation that needs to be walked, as it is the one metadata relocation |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
598 |
// that violates the invariant that all metadata relocations have an oop |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
599 |
// in the compiled method (due to deferred resolution and code patching). |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
600 |
|
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
601 |
// This causes dead metadata to remain in compiled methods that are not |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
602 |
// unloading. Unless these slippery metadata relocations of the static |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
603 |
// stubs are at least cleared, subsequent class redefinition operations |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
604 |
// will access potentially free memory, and JavaThread execution |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
605 |
// concurrent to class unloading may call c2i adapters with dead methods. |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
606 |
if (!is_in_static_stub) { |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
607 |
// The first metadata relocation after a static stub relocation is the |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
608 |
// metadata relocation of the static stub used to pass the Method* to |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
609 |
// c2i adapters. |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
610 |
continue; |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
611 |
} |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
612 |
is_in_static_stub = false; |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
613 |
metadata_Relocation* r = iter.metadata_reloc(); |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
614 |
Metadata* md = r->metadata_value(); |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
615 |
if (md != NULL && md->is_method()) { |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
616 |
Method* method = static_cast<Method*>(md); |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
617 |
if (!method->method_holder()->is_loader_alive()) { |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
618 |
Atomic::store((Method*)NULL, r->metadata_addr()); |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
619 |
|
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
620 |
if (!r->metadata_is_immediate()) { |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
621 |
r->fix_metadata_relocation(); |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
622 |
} |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
623 |
} |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
624 |
} |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
625 |
break; |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
626 |
} |
e9db10a375d9
8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents:
54150
diff
changeset
|
627 |
|
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46623
diff
changeset
|
628 |
default: |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46623
diff
changeset
|
629 |
break; |
38133 | 630 |
} |
631 |
} |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
632 |
|
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52660
diff
changeset
|
633 |
return true; |
38133 | 634 |
} |
51591 | 635 |
|
636 |
// Iterating over all nmethods, e.g. with the help of CodeCache::nmethods_do(fun) was found |
|
637 |
// to not be inherently safe. There is a chance that fields are seen which are not properly |
|
638 |
// initialized. This happens despite the fact that nmethods_do() asserts the CodeCache_lock |
|
639 |
// to be held. |
|
640 |
// To bundle knowledge about necessary checks in one place, this function was introduced. |
|
641 |
// It is not claimed that these checks are sufficient, but they were found to be necessary. |
|
642 |
bool CompiledMethod::nmethod_access_is_safe(nmethod* nm) { |
|
643 |
Method* method = (nm == NULL) ? NULL : nm->method(); // nm->method() may be uninitialized, i.e. != NULL, but invalid |
|
644 |
return (nm != NULL) && (method != NULL) && (method->signature() != NULL) && |
|
645 |
!nm->is_zombie() && !nm->is_not_installed() && |
|
646 |
os::is_readable_pointer(method) && |
|
647 |
os::is_readable_pointer(method->constants()) && |
|
648 |
os::is_readable_pointer(method->signature()); |
|
649 |
} |
|
54150
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
650 |
|
55293
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
651 |
address CompiledMethod::continuation_for_implicit_exception(address pc, bool for_div0_check) { |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
652 |
// Exception happened outside inline-cache check code => we are inside |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
653 |
// an active nmethod => use cpc to determine a return address |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
654 |
int exception_offset = pc - code_begin(); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
655 |
int cont_offset = ImplicitExceptionTable(this).continuation_offset( exception_offset ); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
656 |
#ifdef ASSERT |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
657 |
if (cont_offset == 0) { |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
658 |
Thread* thread = Thread::current(); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
659 |
ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
660 |
HandleMark hm(thread); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
661 |
ResourceMark rm(thread); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
662 |
CodeBlob* cb = CodeCache::find_blob(pc); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
663 |
assert(cb != NULL && cb == this, ""); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
664 |
ttyLocker ttyl; |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
665 |
tty->print_cr("implicit exception happened at " INTPTR_FORMAT, p2i(pc)); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
666 |
print(); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
667 |
method()->print_codes(); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
668 |
print_code(); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
669 |
print_pcs(); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
670 |
} |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
671 |
#endif |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
672 |
if (cont_offset == 0) { |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
673 |
// Let the normal error handling report the exception |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
674 |
return NULL; |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
675 |
} |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
676 |
if (cont_offset == exception_offset) { |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
677 |
#if INCLUDE_JVMCI |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
678 |
Deoptimization::DeoptReason deopt_reason = for_div0_check ? Deoptimization::Reason_div0_check : Deoptimization::Reason_null_check; |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
679 |
JavaThread *thread = JavaThread::current(); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
680 |
thread->set_jvmci_implicit_exception_pc(pc); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
681 |
thread->set_pending_deoptimization(Deoptimization::make_trap_request(deopt_reason, |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
682 |
Deoptimization::Action_reinterpret)); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
683 |
return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap()); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
684 |
#else |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
685 |
ShouldNotReachHere(); |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
686 |
#endif |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
687 |
} |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
688 |
return code_begin() + cont_offset; |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
689 |
} |
d19dc5b10fbb
8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents:
54839
diff
changeset
|
690 |
|
54150
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
691 |
class HasEvolDependency : public MetadataClosure { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
692 |
bool _has_evol_dependency; |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
693 |
public: |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
694 |
HasEvolDependency() : _has_evol_dependency(false) {} |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
695 |
void do_metadata(Metadata* md) { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
696 |
if (md->is_method()) { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
697 |
Method* method = (Method*)md; |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
698 |
if (method->is_old()) { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
699 |
_has_evol_dependency = true; |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
700 |
} |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
701 |
} |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
702 |
} |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
703 |
bool has_evol_dependency() const { return _has_evol_dependency; } |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
704 |
}; |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
705 |
|
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
706 |
bool CompiledMethod::has_evol_metadata() { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
707 |
// Check the metadata in relocIter and CompiledIC and also deoptimize |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
708 |
// any nmethod that has reference to old methods. |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
709 |
HasEvolDependency check_evol; |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
710 |
metadata_do(&check_evol); |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
711 |
if (check_evol.has_evol_dependency() && log_is_enabled(Debug, redefine, class, nmethod)) { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
712 |
ResourceMark rm; |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
713 |
log_debug(redefine, class, nmethod) |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
714 |
("Found evol dependency of nmethod %s.%s(%s) compile_id=%d on in nmethod metadata", |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
715 |
_method->method_holder()->external_name(), |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
716 |
_method->name()->as_C_string(), |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
717 |
_method->signature()->as_C_string(), |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
718 |
compile_id()); |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
719 |
} |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
720 |
return check_evol.has_evol_dependency(); |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53651
diff
changeset
|
721 |
} |