mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8145153: Convert TraceMonitorInflation to Unified Logging
Updated -XX:+TraceMonitorInflation flag to -Xlog:monitorinflation=debug, with an alias (and related alias table) to support the old option. Reviewed-by: dholmes, mockner, coleenp
This commit is contained in:
parent
ddab9e4387
commit
a74243c302
6 changed files with 115 additions and 15 deletions
|
@ -55,6 +55,7 @@
|
||||||
LOG_TAG(logging) \
|
LOG_TAG(logging) \
|
||||||
LOG_TAG(marking) \
|
LOG_TAG(marking) \
|
||||||
LOG_TAG(metaspace) \
|
LOG_TAG(metaspace) \
|
||||||
|
LOG_TAG(monitorinflation) \
|
||||||
LOG_TAG(phases) \
|
LOG_TAG(phases) \
|
||||||
LOG_TAG(plab) \
|
LOG_TAG(plab) \
|
||||||
LOG_TAG(promotion) \
|
LOG_TAG(promotion) \
|
||||||
|
|
|
@ -399,6 +399,12 @@ static AliasedFlag const aliased_jvm_flags[] = {
|
||||||
{ NULL, NULL}
|
{ NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static AliasedFlag const aliased_jvm_logging_flags[] = {
|
||||||
|
{ "-XX:+TraceMonitorInflation", "-Xlog:monitorinflation=debug" },
|
||||||
|
{ "-XX:-TraceMonitorInflation", "-Xlog:monitorinflation=off" },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
// Return true if "v" is less than "other", where "other" may be "undefined".
|
// Return true if "v" is less than "other", where "other" may be "undefined".
|
||||||
static bool version_less_than(JDK_Version v, JDK_Version other) {
|
static bool version_less_than(JDK_Version v, JDK_Version other) {
|
||||||
assert(!v.is_undefined(), "must be defined");
|
assert(!v.is_undefined(), "must be defined");
|
||||||
|
@ -929,6 +935,20 @@ const char* Arguments::handle_aliases_and_deprecation(const char* arg, bool warn
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lookup_logging_aliases
|
||||||
|
// Called from parse_each_vm_init_arg(). Should be called on -XX options before specific cases are checked.
|
||||||
|
// If arg matches any aliased_jvm_logging_flags entry, look up the real name and copy it into buffer.
|
||||||
|
bool Arguments::lookup_logging_aliases(const char* arg, char* buffer) {
|
||||||
|
for (size_t i = 0; aliased_jvm_logging_flags[i].alias_name != NULL; i++) {
|
||||||
|
const AliasedFlag& flag_status = aliased_jvm_logging_flags[i];
|
||||||
|
if (strcmp(flag_status.alias_name, arg) == 0) {
|
||||||
|
strcpy(buffer, flag_status.real_name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
|
bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
|
||||||
|
|
||||||
// range of acceptable characters spelled out for portability reasons
|
// range of acceptable characters spelled out for portability reasons
|
||||||
|
@ -2605,7 +2625,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
|
||||||
for (int index = 0; index < args->nOptions; index++) {
|
for (int index = 0; index < args->nOptions; index++) {
|
||||||
bool is_absolute_path = false; // for -agentpath vs -agentlib
|
bool is_absolute_path = false; // for -agentpath vs -agentlib
|
||||||
|
|
||||||
const JavaVMOption* option = args->options + index;
|
JavaVMOption* option = args->options + index;
|
||||||
|
|
||||||
if (!match_option(option, "-Djava.class.path", &tail) &&
|
if (!match_option(option, "-Djava.class.path", &tail) &&
|
||||||
!match_option(option, "-Dsun.java.command", &tail) &&
|
!match_option(option, "-Dsun.java.command", &tail) &&
|
||||||
|
@ -2619,6 +2639,16 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
|
||||||
build_jvm_args(option->optionString);
|
build_jvm_args(option->optionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// char buffer to store looked up logging option.
|
||||||
|
char aliased_logging_option[256];
|
||||||
|
|
||||||
|
// Catch -XX options which are aliased to Unified logging commands.
|
||||||
|
if (match_option(option, "-XX:", &tail)) {
|
||||||
|
if (lookup_logging_aliases(option->optionString, aliased_logging_option)) {
|
||||||
|
option->optionString = aliased_logging_option;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -verbose:[class/gc/jni]
|
// -verbose:[class/gc/jni]
|
||||||
if (match_option(option, "-verbose", &tail)) {
|
if (match_option(option, "-verbose", &tail)) {
|
||||||
if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
|
if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
|
||||||
|
|
|
@ -445,6 +445,7 @@ class Arguments : AllStatic {
|
||||||
// Return the "real" name for option arg if arg is an alias, and print a warning if arg is deprecated.
|
// Return the "real" name for option arg if arg is an alias, and print a warning if arg is deprecated.
|
||||||
// Return NULL if the arg has expired.
|
// Return NULL if the arg has expired.
|
||||||
static const char* handle_aliases_and_deprecation(const char* arg, bool warn);
|
static const char* handle_aliases_and_deprecation(const char* arg, bool warn);
|
||||||
|
static bool lookup_logging_aliases(const char* arg, char* buffer);
|
||||||
|
|
||||||
static short CompileOnlyClassesNum;
|
static short CompileOnlyClassesNum;
|
||||||
static short CompileOnlyClassesMax;
|
static short CompileOnlyClassesMax;
|
||||||
|
|
|
@ -1506,9 +1506,6 @@ public:
|
||||||
product(bool, TraceBiasedLocking, false, \
|
product(bool, TraceBiasedLocking, false, \
|
||||||
"Trace biased locking in JVM") \
|
"Trace biased locking in JVM") \
|
||||||
\
|
\
|
||||||
product(bool, TraceMonitorInflation, false, \
|
|
||||||
"Trace monitor inflation in JVM") \
|
|
||||||
\
|
|
||||||
/* gc */ \
|
/* gc */ \
|
||||||
\
|
\
|
||||||
product(bool, UseSerialGC, false, \
|
product(bool, UseSerialGC, false, \
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "precompiled.hpp"
|
#include "precompiled.hpp"
|
||||||
#include "classfile/vmSymbols.hpp"
|
#include "classfile/vmSymbols.hpp"
|
||||||
|
#include "logging/log.hpp"
|
||||||
#include "memory/metaspaceShared.hpp"
|
#include "memory/metaspaceShared.hpp"
|
||||||
#include "memory/padded.hpp"
|
#include "memory/padded.hpp"
|
||||||
#include "memory/resourceArea.hpp"
|
#include "memory/resourceArea.hpp"
|
||||||
|
@ -1414,10 +1415,10 @@ ObjectMonitor * NOINLINE ObjectSynchronizer::inflate(Thread * Self,
|
||||||
// to avoid false sharing on MP systems ...
|
// to avoid false sharing on MP systems ...
|
||||||
OM_PERFDATA_OP(Inflations, inc());
|
OM_PERFDATA_OP(Inflations, inc());
|
||||||
TEVENT(Inflate: overwrite stacklock);
|
TEVENT(Inflate: overwrite stacklock);
|
||||||
if (TraceMonitorInflation) {
|
if (log_is_enabled(Debug, monitorinflation)) {
|
||||||
if (object->is_instance()) {
|
if (object->is_instance()) {
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
tty->print_cr("Inflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s",
|
log_debug(monitorinflation)("Inflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s",
|
||||||
p2i(object), p2i(object->mark()),
|
p2i(object), p2i(object->mark()),
|
||||||
object->klass()->external_name());
|
object->klass()->external_name());
|
||||||
}
|
}
|
||||||
|
@ -1462,10 +1463,10 @@ ObjectMonitor * NOINLINE ObjectSynchronizer::inflate(Thread * Self,
|
||||||
// cache lines to avoid false sharing on MP systems ...
|
// cache lines to avoid false sharing on MP systems ...
|
||||||
OM_PERFDATA_OP(Inflations, inc());
|
OM_PERFDATA_OP(Inflations, inc());
|
||||||
TEVENT(Inflate: overwrite neutral);
|
TEVENT(Inflate: overwrite neutral);
|
||||||
if (TraceMonitorInflation) {
|
if (log_is_enabled(Debug, monitorinflation)) {
|
||||||
if (object->is_instance()) {
|
if (object->is_instance()) {
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
tty->print_cr("Inflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s",
|
log_debug(monitorinflation)("Inflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s",
|
||||||
p2i(object), p2i(object->mark()),
|
p2i(object), p2i(object->mark()),
|
||||||
object->klass()->external_name());
|
object->klass()->external_name());
|
||||||
}
|
}
|
||||||
|
@ -1526,11 +1527,13 @@ bool ObjectSynchronizer::deflate_monitor(ObjectMonitor* mid, oop obj,
|
||||||
// It's idle - scavenge and return to the global free list
|
// It's idle - scavenge and return to the global free list
|
||||||
// plain old deflation ...
|
// plain old deflation ...
|
||||||
TEVENT(deflate_idle_monitors - scavenge1);
|
TEVENT(deflate_idle_monitors - scavenge1);
|
||||||
if (TraceMonitorInflation) {
|
if (log_is_enabled(Debug, monitorinflation)) {
|
||||||
if (obj->is_instance()) {
|
if (obj->is_instance()) {
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
tty->print_cr("Deflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s",
|
log_debug(monitorinflation)("Deflating object " INTPTR_FORMAT " , "
|
||||||
p2i(obj), p2i(obj->mark()), obj->klass()->external_name());
|
"mark " INTPTR_FORMAT " , type %s",
|
||||||
|
p2i(obj), p2i(obj->mark()),
|
||||||
|
obj->klass()->external_name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
68
hotspot/test/runtime/logging/MonitorInflationTest.java
Normal file
68
hotspot/test/runtime/logging/MonitorInflationTest.java
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015, 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8133885
|
||||||
|
* @summary monitorinflation=debug should have logging from each of the statements in the code
|
||||||
|
* @library /testlibrary
|
||||||
|
* @modules java.base/sun.misc
|
||||||
|
* java.management
|
||||||
|
* @build MonitorInflationTest
|
||||||
|
* @run driver MonitorInflationTest
|
||||||
|
*/
|
||||||
|
|
||||||
|
import jdk.test.lib.*;
|
||||||
|
|
||||||
|
public class MonitorInflationTest {
|
||||||
|
static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
|
||||||
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
|
output.shouldContain("Inflating object");
|
||||||
|
output.shouldContain("Deflating object ");
|
||||||
|
output.shouldHaveExitValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void analyzeOutputOff(ProcessBuilder pb) throws Exception {
|
||||||
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
|
output.shouldNotContain("[monitorinflation]");
|
||||||
|
output.shouldHaveExitValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||||
|
"-Xlog:monitorinflation=debug", "-version");
|
||||||
|
analyzeOutputOn(pb);
|
||||||
|
|
||||||
|
pb = ProcessTools.createJavaProcessBuilder(
|
||||||
|
"-XX:+TraceMonitorInflation", "-version");
|
||||||
|
analyzeOutputOn(pb);
|
||||||
|
|
||||||
|
pb = ProcessTools.createJavaProcessBuilder(
|
||||||
|
"-Xlog:monitorinflation=off", "-version");
|
||||||
|
analyzeOutputOff(pb);
|
||||||
|
|
||||||
|
pb = ProcessTools.createJavaProcessBuilder(
|
||||||
|
"-XX:-TraceMonitorInflation", "-version");
|
||||||
|
analyzeOutputOff(pb);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue