提交 c5d6f330 编写于 作者: T thartmann

8058737: CodeCache::find_blob fails with 'unsafe access to zombie method'

Summary: Remove active ICStubs from zombie nmethods
Reviewed-by: kvn, iveresov
上级 97c5a994
...@@ -155,6 +155,14 @@ address CompiledIC::stub_address() const { ...@@ -155,6 +155,14 @@ address CompiledIC::stub_address() const {
return _ic_call->destination(); return _ic_call->destination();
} }
// Clears the IC stub if the compiled IC is in transition state
void CompiledIC::clear_ic_stub() {
if (is_in_transition_state()) {
ICStub* stub = ICStub_from_destination_address(stub_address());
stub->clear();
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// High-level access to an inline cache. Guaranteed to be MT-safe. // High-level access to an inline cache. Guaranteed to be MT-safe.
...@@ -333,10 +341,7 @@ void CompiledIC::set_to_clean() { ...@@ -333,10 +341,7 @@ void CompiledIC::set_to_clean() {
if (safe_transition) { if (safe_transition) {
// Kill any leftover stub we might have too // Kill any leftover stub we might have too
if (is_in_transition_state()) { clear_ic_stub();
ICStub* old_stub = ICStub_from_destination_address(stub_address());
old_stub->clear();
}
if (is_optimized()) { if (is_optimized()) {
set_ic_destination(entry); set_ic_destination(entry);
} else { } else {
......
...@@ -230,6 +230,7 @@ class CompiledIC: public ResourceObj { ...@@ -230,6 +230,7 @@ class CompiledIC: public ResourceObj {
// //
void set_to_clean(); // Can only be called during a safepoint operation void set_to_clean(); // Can only be called during a safepoint operation
void set_to_monomorphic(CompiledICInfo& info); void set_to_monomorphic(CompiledICInfo& info);
void clear_ic_stub();
// Returns true if successful and false otherwise. The call can fail if memory // Returns true if successful and false otherwise. The call can fail if memory
// allocation in the code cache fails. // allocation in the code cache fails.
......
...@@ -1148,6 +1148,18 @@ void nmethod::clear_inline_caches() { ...@@ -1148,6 +1148,18 @@ void nmethod::clear_inline_caches() {
} }
} }
// Clear ICStubs of all compiled ICs
void nmethod::clear_ic_stubs() {
assert_locked_or_safepoint(CompiledIC_lock);
RelocIterator iter(this);
while(iter.next()) {
if (iter.type() == relocInfo::virtual_call_type) {
CompiledIC* ic = CompiledIC_at(&iter);
ic->clear_ic_stub();
}
}
}
void nmethod::cleanup_inline_caches() { void nmethod::cleanup_inline_caches() {
......
...@@ -577,6 +577,7 @@ public: ...@@ -577,6 +577,7 @@ public:
// Inline cache support // Inline cache support
void clear_inline_caches(); void clear_inline_caches();
void clear_ic_stubs();
void cleanup_inline_caches(); void cleanup_inline_caches();
bool inlinecache_check_contains(address addr) const { bool inlinecache_check_contains(address addr) const {
return (addr >= code_begin() && addr < verified_entry_point()); return (addr >= code_begin() && addr < verified_entry_point());
......
...@@ -542,6 +542,10 @@ int NMethodSweeper::process_nmethod(nmethod *nm) { ...@@ -542,6 +542,10 @@ int NMethodSweeper::process_nmethod(nmethod *nm) {
if (PrintMethodFlushing && Verbose) { if (PrintMethodFlushing && Verbose) {
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), nm); tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), nm);
} }
// Clear ICStubs to prevent back patching stubs of zombie or unloaded
// nmethods during the next safepoint (see ICStub::finalize).
MutexLocker cl(CompiledIC_lock);
nm->clear_ic_stubs();
// Code cache state change is tracked in make_zombie() // Code cache state change is tracked in make_zombie()
nm->make_zombie(); nm->make_zombie();
_zombified_count++; _zombified_count++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册