mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
6965184: possible races in make_not_entrant_or_zombie
Reviewed-by: kvn
This commit is contained in:
parent
ae3ddc1514
commit
7533d0caf7
22 changed files with 226 additions and 740 deletions
|
@ -210,6 +210,7 @@ AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {
|
|||
{
|
||||
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
||||
blob = new (size) AdapterBlob(size, cb);
|
||||
CodeCache::commit(blob);
|
||||
}
|
||||
// Track memory usage statistic after releasing CodeCache_lock
|
||||
MemoryService::track_code_cache_memory_usage();
|
||||
|
@ -281,7 +282,6 @@ RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
|
|||
tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, stub);
|
||||
Disassembler::decode(stub->instructions_begin(), stub->instructions_end());
|
||||
}
|
||||
VTune::register_stub(stub_id, stub->instructions_begin(), stub->instructions_end());
|
||||
Forte::register_stub(stub_id, stub->instructions_begin(), stub->instructions_end());
|
||||
|
||||
if (JvmtiExport::should_post_dynamic_code_generated()) {
|
||||
|
@ -356,7 +356,6 @@ DeoptimizationBlob* DeoptimizationBlob::create(
|
|||
tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
|
||||
Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
|
||||
}
|
||||
VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
||||
Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
||||
|
||||
if (JvmtiExport::should_post_dynamic_code_generated()) {
|
||||
|
@ -414,7 +413,6 @@ UncommonTrapBlob* UncommonTrapBlob::create(
|
|||
tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
|
||||
Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
|
||||
}
|
||||
VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
||||
Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
||||
|
||||
if (JvmtiExport::should_post_dynamic_code_generated()) {
|
||||
|
@ -474,7 +472,6 @@ ExceptionBlob* ExceptionBlob::create(
|
|||
tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
|
||||
Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
|
||||
}
|
||||
VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
||||
Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
||||
|
||||
if (JvmtiExport::should_post_dynamic_code_generated()) {
|
||||
|
@ -533,7 +530,6 @@ SafepointBlob* SafepointBlob::create(
|
|||
tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
|
||||
Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
|
||||
}
|
||||
VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
||||
Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
||||
|
||||
if (JvmtiExport::should_post_dynamic_code_generated()) {
|
||||
|
|
|
@ -93,6 +93,8 @@ class CodeBlob_sizes {
|
|||
|
||||
CodeHeap * CodeCache::_heap = new CodeHeap();
|
||||
int CodeCache::_number_of_blobs = 0;
|
||||
int CodeCache::_number_of_adapters = 0;
|
||||
int CodeCache::_number_of_nmethods = 0;
|
||||
int CodeCache::_number_of_nmethods_with_dependencies = 0;
|
||||
bool CodeCache::_needs_cache_clean = false;
|
||||
nmethod* CodeCache::_scavenge_root_nmethods = NULL;
|
||||
|
@ -176,8 +178,14 @@ void CodeCache::free(CodeBlob* cb) {
|
|||
verify_if_often();
|
||||
|
||||
print_trace("free", cb);
|
||||
if (cb->is_nmethod() && ((nmethod *)cb)->has_dependencies()) {
|
||||
_number_of_nmethods_with_dependencies--;
|
||||
if (cb->is_nmethod()) {
|
||||
_number_of_nmethods--;
|
||||
if (((nmethod *)cb)->has_dependencies()) {
|
||||
_number_of_nmethods_with_dependencies--;
|
||||
}
|
||||
}
|
||||
if (cb->is_adapter_blob()) {
|
||||
_number_of_adapters--;
|
||||
}
|
||||
_number_of_blobs--;
|
||||
|
||||
|
@ -191,9 +199,16 @@ void CodeCache::free(CodeBlob* cb) {
|
|||
void CodeCache::commit(CodeBlob* cb) {
|
||||
// this is called by nmethod::nmethod, which must already own CodeCache_lock
|
||||
assert_locked_or_safepoint(CodeCache_lock);
|
||||
if (cb->is_nmethod() && ((nmethod *)cb)->has_dependencies()) {
|
||||
_number_of_nmethods_with_dependencies++;
|
||||
if (cb->is_nmethod()) {
|
||||
_number_of_nmethods++;
|
||||
if (((nmethod *)cb)->has_dependencies()) {
|
||||
_number_of_nmethods_with_dependencies++;
|
||||
}
|
||||
}
|
||||
if (cb->is_adapter_blob()) {
|
||||
_number_of_adapters++;
|
||||
}
|
||||
|
||||
// flush the hardware I-cache
|
||||
ICache::invalidate_range(cb->instructions_begin(), cb->instructions_size());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -43,6 +43,8 @@ class CodeCache : AllStatic {
|
|||
// 4422213 or 4436291 for details.
|
||||
static CodeHeap * _heap;
|
||||
static int _number_of_blobs;
|
||||
static int _number_of_adapters;
|
||||
static int _number_of_nmethods;
|
||||
static int _number_of_nmethods_with_dependencies;
|
||||
static bool _needs_cache_clean;
|
||||
static nmethod* _scavenge_root_nmethods; // linked via nm->scavenge_root_link()
|
||||
|
@ -105,6 +107,8 @@ class CodeCache : AllStatic {
|
|||
static nmethod* first_nmethod();
|
||||
static nmethod* next_nmethod (CodeBlob* cb);
|
||||
static int nof_blobs() { return _number_of_blobs; }
|
||||
static int nof_adapters() { return _number_of_adapters; }
|
||||
static int nof_nmethods() { return _number_of_nmethods; }
|
||||
|
||||
// GC support
|
||||
static void gc_epilogue();
|
||||
|
|
|
@ -397,11 +397,6 @@ void nmethod::add_handler_for_exception_and_pc(Handle exception, address pc, add
|
|||
//-------------end of code for ExceptionCache--------------
|
||||
|
||||
|
||||
void nmFlags::clear() {
|
||||
assert(sizeof(nmFlags) == sizeof(int), "using more than one word for nmFlags");
|
||||
*(jint*)this = 0;
|
||||
}
|
||||
|
||||
int nmethod::total_size() const {
|
||||
return
|
||||
code_size() +
|
||||
|
@ -419,8 +414,32 @@ const char* nmethod::compile_kind() const {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// %%% This variable is no longer used?
|
||||
int nmethod::_zombie_instruction_size = NativeJump::instruction_size;
|
||||
// Fill in default values for various flag fields
|
||||
void nmethod::init_defaults() {
|
||||
_state = alive;
|
||||
_marked_for_reclamation = 0;
|
||||
_has_flushed_dependencies = 0;
|
||||
_speculatively_disconnected = 0;
|
||||
_has_unsafe_access = 0;
|
||||
_has_method_handle_invokes = 0;
|
||||
_marked_for_deoptimization = 0;
|
||||
_lock_count = 0;
|
||||
_stack_traversal_mark = 0;
|
||||
_unload_reported = false; // jvmti state
|
||||
|
||||
NOT_PRODUCT(_has_debug_info = false);
|
||||
_oops_do_mark_link = NULL;
|
||||
_jmethod_id = NULL;
|
||||
_osr_link = NULL;
|
||||
_scavenge_root_link = NULL;
|
||||
_scavenge_root_state = 0;
|
||||
_saved_nmethod_link = NULL;
|
||||
_compiler = NULL;
|
||||
|
||||
#ifdef HAVE_DTRACE_H
|
||||
_trap_offset = 0;
|
||||
#endif // def HAVE_DTRACE_H
|
||||
}
|
||||
|
||||
|
||||
nmethod* nmethod::new_native_nmethod(methodHandle method,
|
||||
|
@ -580,25 +599,16 @@ nmethod::nmethod(
|
|||
debug_only(No_Safepoint_Verifier nsv;)
|
||||
assert_locked_or_safepoint(CodeCache_lock);
|
||||
|
||||
NOT_PRODUCT(_has_debug_info = false);
|
||||
_oops_do_mark_link = NULL;
|
||||
init_defaults();
|
||||
_method = method;
|
||||
_entry_bci = InvocationEntryBci;
|
||||
_jmethod_id = NULL;
|
||||
_osr_link = NULL;
|
||||
_scavenge_root_link = NULL;
|
||||
_scavenge_root_state = 0;
|
||||
_saved_nmethod_link = NULL;
|
||||
_compiler = NULL;
|
||||
// We have no exception handler or deopt handler make the
|
||||
// values something that will never match a pc like the nmethod vtable entry
|
||||
_exception_offset = 0;
|
||||
_deoptimize_offset = 0;
|
||||
_deoptimize_mh_offset = 0;
|
||||
_orig_pc_offset = 0;
|
||||
#ifdef HAVE_DTRACE_H
|
||||
_trap_offset = 0;
|
||||
#endif // def HAVE_DTRACE_H
|
||||
|
||||
_stub_offset = data_offset();
|
||||
_consts_offset = data_offset();
|
||||
_oops_offset = data_offset();
|
||||
|
@ -616,17 +626,9 @@ nmethod::nmethod(
|
|||
_exception_cache = NULL;
|
||||
_pc_desc_cache.reset_to(NULL);
|
||||
|
||||
flags.clear();
|
||||
flags.state = alive;
|
||||
_markedForDeoptimization = 0;
|
||||
|
||||
_lock_count = 0;
|
||||
_stack_traversal_mark = 0;
|
||||
|
||||
code_buffer->copy_oops_to(this);
|
||||
debug_only(verify_scavenge_root_oops());
|
||||
CodeCache::commit(this);
|
||||
VTune::create_nmethod(this);
|
||||
}
|
||||
|
||||
if (PrintNativeNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) {
|
||||
|
@ -674,15 +676,9 @@ nmethod::nmethod(
|
|||
debug_only(No_Safepoint_Verifier nsv;)
|
||||
assert_locked_or_safepoint(CodeCache_lock);
|
||||
|
||||
NOT_PRODUCT(_has_debug_info = false);
|
||||
_oops_do_mark_link = NULL;
|
||||
init_defaults();
|
||||
_method = method;
|
||||
_entry_bci = InvocationEntryBci;
|
||||
_jmethod_id = NULL;
|
||||
_osr_link = NULL;
|
||||
_scavenge_root_link = NULL;
|
||||
_scavenge_root_state = 0;
|
||||
_compiler = NULL;
|
||||
// We have no exception handler or deopt handler make the
|
||||
// values something that will never match a pc like the nmethod vtable entry
|
||||
_exception_offset = 0;
|
||||
|
@ -708,17 +704,9 @@ nmethod::nmethod(
|
|||
_exception_cache = NULL;
|
||||
_pc_desc_cache.reset_to(NULL);
|
||||
|
||||
flags.clear();
|
||||
flags.state = alive;
|
||||
_markedForDeoptimization = 0;
|
||||
|
||||
_lock_count = 0;
|
||||
_stack_traversal_mark = 0;
|
||||
|
||||
code_buffer->copy_oops_to(this);
|
||||
debug_only(verify_scavenge_root_oops());
|
||||
CodeCache::commit(this);
|
||||
VTune::create_nmethod(this);
|
||||
}
|
||||
|
||||
if (PrintNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) {
|
||||
|
@ -783,21 +771,13 @@ nmethod::nmethod(
|
|||
debug_only(No_Safepoint_Verifier nsv;)
|
||||
assert_locked_or_safepoint(CodeCache_lock);
|
||||
|
||||
NOT_PRODUCT(_has_debug_info = false);
|
||||
_oops_do_mark_link = NULL;
|
||||
init_defaults();
|
||||
_method = method;
|
||||
_jmethod_id = NULL;
|
||||
_entry_bci = entry_bci;
|
||||
_compile_id = compile_id;
|
||||
_comp_level = comp_level;
|
||||
_entry_bci = entry_bci;
|
||||
_osr_link = NULL;
|
||||
_scavenge_root_link = NULL;
|
||||
_scavenge_root_state = 0;
|
||||
_compiler = compiler;
|
||||
_orig_pc_offset = orig_pc_offset;
|
||||
#ifdef HAVE_DTRACE_H
|
||||
_trap_offset = 0;
|
||||
#endif // def HAVE_DTRACE_H
|
||||
_stub_offset = instructions_offset() + code_buffer->total_offset_of(code_buffer->stubs()->start());
|
||||
|
||||
// Exception handler and deopt handler are in the stub section
|
||||
|
@ -824,15 +804,6 @@ nmethod::nmethod(
|
|||
_exception_cache = NULL;
|
||||
_pc_desc_cache.reset_to(scopes_pcs_begin());
|
||||
|
||||
flags.clear();
|
||||
flags.state = alive;
|
||||
_markedForDeoptimization = 0;
|
||||
|
||||
_unload_reported = false; // jvmti state
|
||||
|
||||
_lock_count = 0;
|
||||
_stack_traversal_mark = 0;
|
||||
|
||||
// Copy contents of ScopeDescRecorder to nmethod
|
||||
code_buffer->copy_oops_to(this);
|
||||
debug_info->copy_to(this);
|
||||
|
@ -844,8 +815,6 @@ nmethod::nmethod(
|
|||
|
||||
CodeCache::commit(this);
|
||||
|
||||
VTune::create_nmethod(this);
|
||||
|
||||
// Copy contents of ExceptionHandlerTable to nmethod
|
||||
handler_table->copy_to(this);
|
||||
nul_chk_table->copy_to(this);
|
||||
|
@ -991,11 +960,6 @@ void nmethod::print_nmethod(bool printmethod) {
|
|||
}
|
||||
|
||||
|
||||
void nmethod::set_version(int v) {
|
||||
flags.version = v;
|
||||
}
|
||||
|
||||
|
||||
// Promote one word from an assembly-time handle to a live embedded oop.
|
||||
inline void nmethod::initialize_immediate_oop(oop* dest, jobject handle) {
|
||||
if (handle == NULL ||
|
||||
|
@ -1142,6 +1106,8 @@ void nmethod::cleanup_inline_caches() {
|
|||
// This is a private interface with the sweeper.
|
||||
void nmethod::mark_as_seen_on_stack() {
|
||||
assert(is_not_entrant(), "must be a non-entrant method");
|
||||
// Set the traversal mark to ensure that the sweeper does 2
|
||||
// cleaning passes before moving to zombie.
|
||||
set_stack_traversal_mark(NMethodSweeper::traversal_count());
|
||||
}
|
||||
|
||||
|
@ -1210,7 +1176,7 @@ void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
|
|||
// for later on.
|
||||
CodeCache::set_needs_cache_clean(true);
|
||||
}
|
||||
flags.state = unloaded;
|
||||
_state = unloaded;
|
||||
|
||||
// Log the unloading.
|
||||
log_state_change();
|
||||
|
@ -1236,21 +1202,21 @@ void nmethod::log_state_change() const {
|
|||
if (LogCompilation) {
|
||||
if (xtty != NULL) {
|
||||
ttyLocker ttyl; // keep the following output all in one block
|
||||
if (flags.state == unloaded) {
|
||||
if (_state == unloaded) {
|
||||
xtty->begin_elem("make_unloaded thread='" UINTX_FORMAT "'",
|
||||
os::current_thread_id());
|
||||
} else {
|
||||
xtty->begin_elem("make_not_entrant thread='" UINTX_FORMAT "'%s",
|
||||
os::current_thread_id(),
|
||||
(flags.state == zombie ? " zombie='1'" : ""));
|
||||
(_state == zombie ? " zombie='1'" : ""));
|
||||
}
|
||||
log_identity(xtty);
|
||||
xtty->stamp();
|
||||
xtty->end_elem();
|
||||
}
|
||||
}
|
||||
if (PrintCompilation && flags.state != unloaded) {
|
||||
print_on(tty, flags.state == zombie ? "made zombie " : "made not entrant ");
|
||||
if (PrintCompilation && _state != unloaded) {
|
||||
print_on(tty, _state == zombie ? "made zombie " : "made not entrant ");
|
||||
tty->cr();
|
||||
}
|
||||
}
|
||||
|
@ -1261,8 +1227,9 @@ bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
|
|||
|
||||
bool was_alive = false;
|
||||
|
||||
// Make sure the nmethod is not flushed in case of a safepoint in code below.
|
||||
// Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below.
|
||||
nmethodLocker nml(this);
|
||||
methodHandle the_method(method());
|
||||
|
||||
{
|
||||
// If the method is already zombie there is nothing to do
|
||||
|
@ -1282,7 +1249,7 @@ bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
|
|||
// Enter critical section. Does not block for safepoint.
|
||||
MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
|
||||
|
||||
if (flags.state == state) {
|
||||
if (_state == state) {
|
||||
// another thread already performed this transition so nothing
|
||||
// to do, but return false to indicate this.
|
||||
return false;
|
||||
|
@ -1293,17 +1260,37 @@ bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
|
|||
if (!is_osr_method() && !is_not_entrant()) {
|
||||
NativeJump::patch_verified_entry(entry_point(), verified_entry_point(),
|
||||
SharedRuntime::get_handle_wrong_method_stub());
|
||||
assert (NativeJump::instruction_size == nmethod::_zombie_instruction_size, "");
|
||||
}
|
||||
|
||||
was_alive = is_in_use(); // Read state under lock
|
||||
if (is_in_use()) {
|
||||
// It's a true state change, so mark the method as decompiled.
|
||||
// Do it only for transition from alive.
|
||||
inc_decompile_count();
|
||||
}
|
||||
|
||||
// Change state
|
||||
flags.state = state;
|
||||
_state = state;
|
||||
|
||||
// Log the transition once
|
||||
log_state_change();
|
||||
|
||||
// Remove nmethod from method.
|
||||
// We need to check if both the _code and _from_compiled_code_entry_point
|
||||
// refer to this nmethod because there is a race in setting these two fields
|
||||
// in methodOop as seen in bugid 4947125.
|
||||
// If the vep() points to the zombie nmethod, the memory for the nmethod
|
||||
// could be flushed and the compiler and vtable stubs could still call
|
||||
// through it.
|
||||
if (method() != NULL && (method()->code() == this ||
|
||||
method()->from_compiled_entry() == verified_entry_point())) {
|
||||
HandleMark hm;
|
||||
method()->clear_code();
|
||||
}
|
||||
|
||||
if (state == not_entrant) {
|
||||
mark_as_seen_on_stack();
|
||||
}
|
||||
|
||||
} // leave critical region under Patching_lock
|
||||
|
||||
// When the nmethod becomes zombie it is no longer alive so the
|
||||
|
@ -1311,18 +1298,17 @@ bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
|
|||
// state will be flushed later when the transition to zombie
|
||||
// happens or they get unloaded.
|
||||
if (state == zombie) {
|
||||
// zombie only - if a JVMTI agent has enabled the CompiledMethodUnload event
|
||||
// and it hasn't already been reported for this nmethod then report it now.
|
||||
// (the event may have been reported earilier if the GC marked it for unloading).
|
||||
post_compiled_method_unload();
|
||||
|
||||
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
||||
flush_dependencies(NULL);
|
||||
} else {
|
||||
assert(state == not_entrant, "other cases may need to be handled differently");
|
||||
}
|
||||
|
||||
if (state == not_entrant) {
|
||||
Events::log("Make nmethod not entrant " INTPTR_FORMAT, this);
|
||||
} else {
|
||||
Events::log("Make nmethod zombie " INTPTR_FORMAT, this);
|
||||
}
|
||||
|
||||
if (TraceCreateZombies) {
|
||||
tty->print_cr("nmethod <" INTPTR_FORMAT "> code made %s", this, (state == not_entrant) ? "not entrant" : "zombie");
|
||||
}
|
||||
|
@ -1330,47 +1316,6 @@ bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
|
|||
// Make sweeper aware that there is a zombie method that needs to be removed
|
||||
NMethodSweeper::notify(this);
|
||||
|
||||
// not_entrant only stuff
|
||||
if (state == not_entrant) {
|
||||
mark_as_seen_on_stack();
|
||||
}
|
||||
|
||||
if (was_alive) {
|
||||
// It's a true state change, so mark the method as decompiled.
|
||||
// Do it only for transition from alive.
|
||||
inc_decompile_count();
|
||||
}
|
||||
|
||||
// zombie only - if a JVMTI agent has enabled the CompiledMethodUnload event
|
||||
// and it hasn't already been reported for this nmethod then report it now.
|
||||
// (the event may have been reported earilier if the GC marked it for unloading).
|
||||
if (state == zombie) {
|
||||
post_compiled_method_unload();
|
||||
}
|
||||
|
||||
|
||||
// Zombie only stuff
|
||||
if (state == zombie) {
|
||||
VTune::delete_nmethod(this);
|
||||
}
|
||||
|
||||
// Check whether method got unloaded at a safepoint before this,
|
||||
// if so we can skip the flushing steps below
|
||||
if (method() == NULL) return true;
|
||||
|
||||
// Remove nmethod from method.
|
||||
// We need to check if both the _code and _from_compiled_code_entry_point
|
||||
// refer to this nmethod because there is a race in setting these two fields
|
||||
// in methodOop as seen in bugid 4947125.
|
||||
// If the vep() points to the zombie nmethod, the memory for the nmethod
|
||||
// could be flushed and the compiler and vtable stubs could still call
|
||||
// through it.
|
||||
if (method()->code() == this ||
|
||||
method()->from_compiled_entry() == verified_entry_point()) {
|
||||
HandleMark hm;
|
||||
method()->clear_code();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2109,7 +2054,6 @@ address nmethod::continuation_for_implicit_exception(address pc) {
|
|||
|
||||
void nmethod_init() {
|
||||
// make sure you didn't forget to adjust the filler fields
|
||||
assert(sizeof(nmFlags) <= 4, "nmFlags occupies more than a word");
|
||||
assert(sizeof(nmethod) % oopSize == 0, "nmethod size must be multiple of a word");
|
||||
}
|
||||
|
||||
|
@ -2345,7 +2289,6 @@ void nmethod::print() const {
|
|||
tty->print("((nmethod*) "INTPTR_FORMAT ") ", this);
|
||||
tty->print(" for method " INTPTR_FORMAT , (address)method());
|
||||
tty->print(" { ");
|
||||
if (version()) tty->print("v%d ", version());
|
||||
if (is_in_use()) tty->print("in_use ");
|
||||
if (is_not_entrant()) tty->print("not_entrant ");
|
||||
if (is_zombie()) tty->print("zombie ");
|
||||
|
|
|
@ -78,29 +78,8 @@ class PcDescCache VALUE_OBJ_CLASS_SPEC {
|
|||
|
||||
|
||||
// nmethods (native methods) are the compiled code versions of Java methods.
|
||||
|
||||
struct nmFlags {
|
||||
friend class VMStructs;
|
||||
unsigned int version:8; // version number (0 = first version)
|
||||
unsigned int age:4; // age (in # of sweep steps)
|
||||
|
||||
unsigned int state:2; // {alive, zombie, unloaded)
|
||||
|
||||
unsigned int isUncommonRecompiled:1; // recompiled because of uncommon trap?
|
||||
unsigned int isToBeRecompiled:1; // to be recompiled as soon as it matures
|
||||
unsigned int hasFlushedDependencies:1; // Used for maintenance of dependencies
|
||||
unsigned int markedForReclamation:1; // Used by NMethodSweeper
|
||||
|
||||
unsigned int has_unsafe_access:1; // May fault due to unsafe access.
|
||||
unsigned int has_method_handle_invokes:1; // Has this method MethodHandle invokes?
|
||||
|
||||
unsigned int speculatively_disconnected:1; // Marked for potential unload
|
||||
|
||||
void clear();
|
||||
};
|
||||
|
||||
|
||||
// A nmethod contains:
|
||||
//
|
||||
// An nmethod contains:
|
||||
// - header (the nmethod structure)
|
||||
// [Relocation]
|
||||
// - relocation information
|
||||
|
@ -131,8 +110,6 @@ class nmethod : public CodeBlob {
|
|||
friend class CodeCache; // non-perm oops
|
||||
private:
|
||||
// Shared fields for all nmethod's
|
||||
static int _zombie_instruction_size;
|
||||
|
||||
methodOop _method;
|
||||
int _entry_bci; // != InvocationEntryBci if this nmethod is an on-stack replacement method
|
||||
jmethodID _jmethod_id; // Cache of method()->jmethod_id()
|
||||
|
@ -147,6 +124,11 @@ class nmethod : public CodeBlob {
|
|||
|
||||
AbstractCompiler* _compiler; // The compiler which compiled this nmethod
|
||||
|
||||
// offsets for entry points
|
||||
address _entry_point; // entry point with class check
|
||||
address _verified_entry_point; // entry point without class check
|
||||
address _osr_entry_point; // entry point for on stack replacement
|
||||
|
||||
// Offsets for different nmethod parts
|
||||
int _exception_offset;
|
||||
// All deoptee's will resume execution at this location described by
|
||||
|
@ -175,23 +157,31 @@ class nmethod : public CodeBlob {
|
|||
// pc during a deopt.
|
||||
int _orig_pc_offset;
|
||||
|
||||
int _compile_id; // which compilation made this nmethod
|
||||
int _comp_level; // compilation level
|
||||
int _compile_id; // which compilation made this nmethod
|
||||
int _comp_level; // compilation level
|
||||
|
||||
// offsets for entry points
|
||||
address _entry_point; // entry point with class check
|
||||
address _verified_entry_point; // entry point without class check
|
||||
address _osr_entry_point; // entry point for on stack replacement
|
||||
// protected by CodeCache_lock
|
||||
bool _has_flushed_dependencies; // Used for maintenance of dependencies (CodeCache_lock)
|
||||
bool _speculatively_disconnected; // Marked for potential unload
|
||||
|
||||
bool _marked_for_reclamation; // Used by NMethodSweeper (set only by sweeper)
|
||||
bool _marked_for_deoptimization; // Used for stack deoptimization
|
||||
|
||||
// used by jvmti to track if an unload event has been posted for this nmethod.
|
||||
bool _unload_reported;
|
||||
|
||||
// set during construction
|
||||
unsigned int _has_unsafe_access:1; // May fault due to unsafe access.
|
||||
unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
|
||||
|
||||
// Protected by Patching_lock
|
||||
unsigned char _state; // {alive, not_entrant, zombie, unloaded)
|
||||
|
||||
nmFlags flags; // various flags to keep track of nmethod state
|
||||
bool _markedForDeoptimization; // Used for stack deoptimization
|
||||
enum { alive = 0,
|
||||
not_entrant = 1, // uncommon trap has happened but activations may still exist
|
||||
zombie = 2,
|
||||
unloaded = 3 };
|
||||
|
||||
// used by jvmti to track if an unload event has been posted for this nmethod.
|
||||
bool _unload_reported;
|
||||
|
||||
jbyte _scavenge_root_state;
|
||||
|
||||
|
@ -270,15 +260,15 @@ class nmethod : public CodeBlob {
|
|||
bool make_not_entrant_or_zombie(unsigned int state);
|
||||
void inc_decompile_count();
|
||||
|
||||
// used to check that writes to nmFlags are done consistently.
|
||||
static void check_safepoint() PRODUCT_RETURN;
|
||||
|
||||
// Used to manipulate the exception cache
|
||||
void add_exception_cache_entry(ExceptionCache* new_entry);
|
||||
ExceptionCache* exception_cache_entry_for_exception(Handle exception);
|
||||
|
||||
// Inform external interfaces that a compiled method has been unloaded
|
||||
inline void post_compiled_method_unload();
|
||||
void post_compiled_method_unload();
|
||||
|
||||
// Initailize fields to their default values
|
||||
void init_defaults();
|
||||
|
||||
public:
|
||||
// create nmethod with entry_bci
|
||||
|
@ -393,11 +383,11 @@ class nmethod : public CodeBlob {
|
|||
address verified_entry_point() const { return _verified_entry_point; } // if klass is correct
|
||||
|
||||
// flag accessing and manipulation
|
||||
bool is_in_use() const { return flags.state == alive; }
|
||||
bool is_alive() const { return flags.state == alive || flags.state == not_entrant; }
|
||||
bool is_not_entrant() const { return flags.state == not_entrant; }
|
||||
bool is_zombie() const { return flags.state == zombie; }
|
||||
bool is_unloaded() const { return flags.state == unloaded; }
|
||||
bool is_in_use() const { return _state == alive; }
|
||||
bool is_alive() const { return _state == alive || _state == not_entrant; }
|
||||
bool is_not_entrant() const { return _state == not_entrant; }
|
||||
bool is_zombie() const { return _state == zombie; }
|
||||
bool is_unloaded() const { return _state == unloaded; }
|
||||
|
||||
// Make the nmethod non entrant. The nmethod will continue to be
|
||||
// alive. It is used when an uncommon trap happens. Returns true
|
||||
|
@ -410,37 +400,33 @@ class nmethod : public CodeBlob {
|
|||
bool unload_reported() { return _unload_reported; }
|
||||
void set_unload_reported() { _unload_reported = true; }
|
||||
|
||||
bool is_marked_for_deoptimization() const { return _markedForDeoptimization; }
|
||||
void mark_for_deoptimization() { _markedForDeoptimization = true; }
|
||||
bool is_marked_for_deoptimization() const { return _marked_for_deoptimization; }
|
||||
void mark_for_deoptimization() { _marked_for_deoptimization = true; }
|
||||
|
||||
void make_unloaded(BoolObjectClosure* is_alive, oop cause);
|
||||
|
||||
bool has_dependencies() { return dependencies_size() != 0; }
|
||||
void flush_dependencies(BoolObjectClosure* is_alive);
|
||||
bool has_flushed_dependencies() { return flags.hasFlushedDependencies; }
|
||||
void set_has_flushed_dependencies() {
|
||||
bool has_flushed_dependencies() { return _has_flushed_dependencies; }
|
||||
void set_has_flushed_dependencies() {
|
||||
assert(!has_flushed_dependencies(), "should only happen once");
|
||||
flags.hasFlushedDependencies = 1;
|
||||
_has_flushed_dependencies = 1;
|
||||
}
|
||||
|
||||
bool is_marked_for_reclamation() const { return flags.markedForReclamation; }
|
||||
void mark_for_reclamation() { flags.markedForReclamation = 1; }
|
||||
void unmark_for_reclamation() { flags.markedForReclamation = 0; }
|
||||
bool is_marked_for_reclamation() const { return _marked_for_reclamation; }
|
||||
void mark_for_reclamation() { _marked_for_reclamation = 1; }
|
||||
|
||||
bool has_unsafe_access() const { return flags.has_unsafe_access; }
|
||||
void set_has_unsafe_access(bool z) { flags.has_unsafe_access = z; }
|
||||
bool has_unsafe_access() const { return _has_unsafe_access; }
|
||||
void set_has_unsafe_access(bool z) { _has_unsafe_access = z; }
|
||||
|
||||
bool has_method_handle_invokes() const { return flags.has_method_handle_invokes; }
|
||||
void set_has_method_handle_invokes(bool z) { flags.has_method_handle_invokes = z; }
|
||||
bool has_method_handle_invokes() const { return _has_method_handle_invokes; }
|
||||
void set_has_method_handle_invokes(bool z) { _has_method_handle_invokes = z; }
|
||||
|
||||
bool is_speculatively_disconnected() const { return flags.speculatively_disconnected; }
|
||||
void set_speculatively_disconnected(bool z) { flags.speculatively_disconnected = z; }
|
||||
bool is_speculatively_disconnected() const { return _speculatively_disconnected; }
|
||||
void set_speculatively_disconnected(bool z) { _speculatively_disconnected = z; }
|
||||
|
||||
int comp_level() const { return _comp_level; }
|
||||
|
||||
int version() const { return flags.version; }
|
||||
void set_version(int v);
|
||||
|
||||
// Support for oops in scopes and relocs:
|
||||
// Note: index 0 is reserved for null.
|
||||
oop oop_at(int index) const { return index == 0 ? (oop) NULL: *oop_addr_at(index); }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -50,7 +50,6 @@ void* VtableStub::operator new(size_t size, int code_size) {
|
|||
}
|
||||
_chunk = blob->instructions_begin();
|
||||
_chunk_end = _chunk + bytes;
|
||||
VTune::register_stub("vtable stub", _chunk, _chunk_end);
|
||||
Forte::register_stub("vtable stub", _chunk, _chunk_end);
|
||||
// Notify JVMTI about this stub. The event will be recorded by the enclosing
|
||||
// JvmtiDynamicCodeEventCollector and posted when this thread has released
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue