8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file

Use the Events::log function to save redefined classes for output to the hs_err file.

Reviewed-by: sspitsyn, jiangli, lfoltan
This commit is contained in:
Coleen Phillimore 2015-06-04 08:05:47 -04:00
parent f3f4608e09
commit d97fc17132
5 changed files with 42 additions and 4 deletions

View file

@ -43,6 +43,7 @@
#include "runtime/deoptimization.hpp" #include "runtime/deoptimization.hpp"
#include "runtime/relocator.hpp" #include "runtime/relocator.hpp"
#include "utilities/bitMap.inline.hpp" #include "utilities/bitMap.inline.hpp"
#include "utilities/events.hpp"
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
@ -174,6 +175,9 @@ void VM_RedefineClasses::doit_epilogue() {
// Free os::malloc allocated memory. // Free os::malloc allocated memory.
os::free(_scratch_classes); os::free(_scratch_classes);
// Reset the_class_oop to null for error printing.
_the_class_oop = NULL;
if (RC_TRACE_ENABLED(0x00000004)) { if (RC_TRACE_ENABLED(0x00000004)) {
// Used to have separate timers for "doit" and "all", but the timer // Used to have separate timers for "doit" and "all", but the timer
// overhead skewed the measurements. // overhead skewed the measurements.
@ -4105,6 +4109,13 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass,
java_lang_Class::classRedefinedCount(the_class_mirror), java_lang_Class::classRedefinedCount(the_class_mirror),
os::available_memory() >> 10)); os::available_memory() >> 10));
{
ResourceMark rm(THREAD);
Events::log_redefinition(THREAD, "redefined class name=%s, count=%d",
the_class->external_name(),
java_lang_Class::classRedefinedCount(the_class_mirror));
}
RC_TIMER_STOP(_timer_rsc_phase2); RC_TIMER_STOP(_timer_rsc_phase2);
} // end redefine_single_class() } // end redefine_single_class()
@ -4249,3 +4260,11 @@ void VM_RedefineClasses::dump_methods() {
tty->cr(); tty->cr();
} }
} }
void VM_RedefineClasses::print_on_error(outputStream* st) const {
VM_Operation::print_on_error(st);
if (_the_class_oop != NULL) {
ResourceMark rm;
st->print_cr(", redefining class %s", _the_class_oop->external_name());
}
}

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -539,5 +539,8 @@ class VM_RedefineClasses: public VM_Operation {
static unsigned char * get_cached_class_file_bytes(JvmtiCachedClassFileData *cache) { static unsigned char * get_cached_class_file_bytes(JvmtiCachedClassFileData *cache) {
return cache == NULL ? NULL : cache->data; return cache == NULL ? NULL : cache->data;
} }
// Error printing
void print_on_error(outputStream* st) const;
}; };
#endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSES_HPP #endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSES_HPP

View file

@ -192,7 +192,7 @@ class VM_Operation: public CHeapObj<mtInternal> {
static const char* mode_to_string(Mode mode); static const char* mode_to_string(Mode mode);
// Debugging // Debugging
void print_on_error(outputStream* st) const; virtual void print_on_error(outputStream* st) const;
const char* name() const { return _names[type()]; } const char* name() const { return _names[type()]; }
static const char* name(int type) { static const char* name(int type) {
assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type"); assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,6 +37,7 @@
EventLog* Events::_logs = NULL; EventLog* Events::_logs = NULL;
StringEventLog* Events::_messages = NULL; StringEventLog* Events::_messages = NULL;
StringEventLog* Events::_exceptions = NULL; StringEventLog* Events::_exceptions = NULL;
StringEventLog* Events::_redefinitions = NULL;
StringEventLog* Events::_deopt_messages = NULL; StringEventLog* Events::_deopt_messages = NULL;
EventLog::EventLog() { EventLog::EventLog() {
@ -66,6 +67,7 @@ void Events::init() {
if (LogEvents) { if (LogEvents) {
_messages = new StringEventLog("Events"); _messages = new StringEventLog("Events");
_exceptions = new StringEventLog("Internal exceptions"); _exceptions = new StringEventLog("Internal exceptions");
_redefinitions = new StringEventLog("Classes redefined");
_deopt_messages = new StringEventLog("Deoptimization events"); _deopt_messages = new StringEventLog("Deoptimization events");
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -186,6 +186,9 @@ class Events : AllStatic {
// Deoptization related messages // Deoptization related messages
static StringEventLog* _deopt_messages; static StringEventLog* _deopt_messages;
// Redefinition related messages
static StringEventLog* _redefinitions;
public: public:
static void print_all(outputStream* out); static void print_all(outputStream* out);
@ -198,6 +201,8 @@ class Events : AllStatic {
// Log exception related message // Log exception related message
static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
static void log_redefinition(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
// Register default loggers // Register default loggers
@ -222,6 +227,15 @@ inline void Events::log_exception(Thread* thread, const char* format, ...) {
} }
} }
inline void Events::log_redefinition(Thread* thread, const char* format, ...) {
if (LogEvents) {
va_list ap;
va_start(ap, format);
_redefinitions->logv(thread, format, ap);
va_end(ap);
}
}
inline void Events::log_deopt_message(Thread* thread, const char* format, ...) { inline void Events::log_deopt_message(Thread* thread, const char* format, ...) {
if (LogEvents) { if (LogEvents) {
va_list ap; va_list ap;