Skip to content
Permalink
Browse files
8254029: ObjectMonitor cleanup/minor bug-fix changes extracted from J…
…DK-8253064

Reviewed-by: dholmes, eosterlund
  • Loading branch information
Daniel D. Daugherty committed Oct 20, 2020
1 parent 7a580ca commit c87cdf70e40042371b3474c01fff3457716568be
@@ -168,15 +168,6 @@ void exit_globals() {
static bool destructorsCalled = false;
if (!destructorsCalled) {
destructorsCalled = true;
if (log_is_enabled(Info, monitorinflation)) {
// The ObjectMonitor subsystem uses perf counters so
// do this before perfMemory_exit().
// This other audit_and_print_stats() call is done at the
// Debug level at a safepoint:
// - for async deflation auditing:
// ObjectSynchronizer::do_safepoint_work()
ObjectSynchronizer::audit_and_print_stats(true /* on_exit */);
}
perfMemory_exit();
SafepointTracing::statistics_exit_log();
if (PrintStringTableStatistics) {
@@ -179,7 +179,7 @@ class ObjectMonitor {
jint _contentions; // Number of active contentions in enter(). It is used by is_busy()
// along with other fields to determine if an ObjectMonitor can be
// deflated. It is also used by the async deflation protocol. See
// ObjectSynchronizer::deflate_monitor_using_JT().
// ObjectSynchronizer::deflate_monitor().
protected:
ObjectWaiter* volatile _WaitSet; // LL of threads wait()ing on the monitor
volatile jint _waiters; // number of waiting threads
@@ -234,7 +234,7 @@ void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) {
}

if (deflate_idle_monitors) {
ObjectSynchronizer::deflate_idle_monitors_using_JT();
ObjectSynchronizer::deflate_idle_monitors();
}

if (oop_handles_to_release) {

Large diffs are not rendered by default.

@@ -129,25 +129,27 @@ class ObjectSynchronizer : AllStatic {
// GC: we current use aggressive monitor deflation policy
// Basically we deflate all monitors that are not busy.
// An adaptive profile-based deflation policy could be used if needed
static void deflate_idle_monitors_using_JT();
static void deflate_global_idle_monitors_using_JT();
static void deflate_per_thread_idle_monitors_using_JT(JavaThread* target);
static void deflate_common_idle_monitors_using_JT(bool is_global, JavaThread* target);
static void deflate_idle_monitors();
static void deflate_global_idle_monitors(Thread* self);
static void deflate_per_thread_idle_monitors(Thread* self,
JavaThread* target);
static void deflate_common_idle_monitors(Thread* self, bool is_global,
JavaThread* target);

// For a given in-use monitor list: global or per-thread, deflate idle
// monitors using a JavaThread.
static int deflate_monitor_list_using_JT(ObjectMonitor** list_p,
int* count_p,
ObjectMonitor** free_head_p,
ObjectMonitor** free_tail_p,
ObjectMonitor** saved_mid_in_use_p);
static bool deflate_monitor_using_JT(ObjectMonitor* mid,
ObjectMonitor** free_head_p,
ObjectMonitor** free_tail_p);
// monitors.
static int deflate_monitor_list(Thread* self, ObjectMonitor** list_p,
int* count_p, ObjectMonitor** free_head_p,
ObjectMonitor** free_tail_p,
ObjectMonitor** saved_mid_in_use_p);
static bool deflate_monitor(ObjectMonitor* mid, ObjectMonitor** free_head_p,
ObjectMonitor** free_tail_p);
static bool is_async_deflation_needed();
static bool is_async_deflation_requested() { return _is_async_deflation_requested; }
static bool is_final_audit() { return _is_final_audit; }
static void set_is_final_audit() { _is_final_audit = true; }
static jlong last_async_deflation_time_ns() { return _last_async_deflation_time_ns; }
static bool request_deflate_idle_monitors(); // for whitebox test support and VM exit logging
static bool request_deflate_idle_monitors(); // for whitebox test support
static void set_is_async_deflation_requested(bool new_value) { _is_async_deflation_requested = new_value; }
static jlong time_since_last_async_deflation_ms();

@@ -169,6 +171,7 @@ class ObjectSynchronizer : AllStatic {
static void chk_per_thread_free_list_and_count(JavaThread *jt,
outputStream * out,
int *error_cnt_p);
static void do_final_audit_and_print_stats();
static void log_in_use_monitor_details(outputStream * out);
static int log_monitor_list_counts(outputStream * out);
static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
@@ -182,6 +185,7 @@ class ObjectSynchronizer : AllStatic {
// global list of blocks of monitors
static PaddedObjectMonitor* g_block_list;
static volatile bool _is_async_deflation_requested;
static volatile bool _is_final_audit;
static jlong _last_async_deflation_time_ns;

// Function to prepend new blocks to the appropriate lists:
@@ -431,16 +431,6 @@ int VM_Exit::wait_for_threads_in_native_to_block() {
}
}

bool VM_Exit::doit_prologue() {
if (log_is_enabled(Info, monitorinflation)) {
// Do a deflation in order to reduce the in-use monitor population
// that is reported by ObjectSynchronizer::log_in_use_monitor_details()
// at VM exit.
ObjectSynchronizer::request_deflate_idle_monitors();
}
return true;
}

void VM_Exit::doit() {

if (VerifyBeforeExit) {
@@ -463,6 +453,10 @@ void VM_Exit::doit() {

set_vm_exited();

// The ObjectMonitor subsystem uses perf counters so do this before
// we call exit_globals() so we don't run afoul of perfMemory_exit().
ObjectSynchronizer::do_final_audit_and_print_stats();

// We'd like to call IdealGraphPrinter::clean_up() to finalize the
// XML logging, but we can't safely do that here. The logic to make
// XML termination logging safe is tied to the termination of the
@@ -402,7 +402,6 @@ class VM_Exit: public VM_Operation {
}
}
VMOp_Type type() const { return VMOp_Exit; }
bool doit_prologue();
void doit();
};

@@ -169,13 +169,6 @@ void VMThread::run() {
assert(should_terminate(), "termination flag must be set");
}

if (log_is_enabled(Info, monitorinflation)) {
// Do a deflation in order to reduce the in-use monitor population
// that is reported by ObjectSynchronizer::log_in_use_monitor_details()
// at VM exit.
ObjectSynchronizer::request_deflate_idle_monitors();
}

// 4526887 let VM thread exit at Safepoint
_cur_vm_operation = &halt_op;
SafepointSynchronize::begin();
@@ -195,6 +188,11 @@ void VMThread::run() {
// _thread_in_native state to block.
VM_Exit::wait_for_threads_in_native_to_block();

// The ObjectMonitor subsystem uses perf counters so do this before
// we signal that the VM thread is gone. We don't want to run afoul
// of perfMemory_exit() in exit_globals().
ObjectSynchronizer::do_final_audit_and_print_stats();

// signal other threads that VM process is gone
{
// Note: we must have the _no_safepoint_check_flag. Mutex::lock() allows

1 comment on commit c87cdf7

@bridgekeeper

This comment has been minimized.

Copy link

@bridgekeeper bridgekeeper bot commented on c87cdf7 Oct 20, 2020

Please sign in to comment.