# HG changeset patch # User coleenp # Date 1433419547 14400 # Node ID 48000028382ce2033492d2fbcf1672a80d06669a # Parent 6df6a1332f236488a053b7849ec7e41c5565cc6c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file Summary: Use the Events::log function to save redefined classes for output to the hs_err file. Reviewed-by: sspitsyn, jiangli, lfoltan diff -r 6df6a1332f23 -r 48000028382c hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp Tue Jun 02 10:41:18 2015 +0200 +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp Thu Jun 04 08:05:47 2015 -0400 @@ -43,6 +43,7 @@ #include "runtime/deoptimization.hpp" #include "runtime/relocator.hpp" #include "utilities/bitMap.inline.hpp" +#include "utilities/events.hpp" PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC @@ -174,6 +175,9 @@ // Free os::malloc allocated memory. os::free(_scratch_classes); + // Reset the_class_oop to null for error printing. + _the_class_oop = NULL; + if (RC_TRACE_ENABLED(0x00000004)) { // Used to have separate timers for "doit" and "all", but the timer // overhead skewed the measurements. @@ -4105,6 +4109,13 @@ java_lang_Class::classRedefinedCount(the_class_mirror), 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); } // end redefine_single_class() @@ -4249,3 +4260,11 @@ 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()); + } +} diff -r 6df6a1332f23 -r 48000028382c hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp Tue Jun 02 10:41:18 2015 +0200 +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp Thu Jun 04 08:05:47 2015 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -539,5 +539,8 @@ static unsigned char * get_cached_class_file_bytes(JvmtiCachedClassFileData *cache) { return cache == NULL ? NULL : cache->data; } + + // Error printing + void print_on_error(outputStream* st) const; }; #endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSES_HPP diff -r 6df6a1332f23 -r 48000028382c hotspot/src/share/vm/runtime/vm_operations.hpp --- a/hotspot/src/share/vm/runtime/vm_operations.hpp Tue Jun 02 10:41:18 2015 +0200 +++ b/hotspot/src/share/vm/runtime/vm_operations.hpp Thu Jun 04 08:05:47 2015 -0400 @@ -192,7 +192,7 @@ static const char* mode_to_string(Mode mode); // Debugging - void print_on_error(outputStream* st) const; + virtual void print_on_error(outputStream* st) const; const char* name() const { return _names[type()]; } static const char* name(int type) { assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type"); diff -r 6df6a1332f23 -r 48000028382c hotspot/src/share/vm/utilities/events.cpp --- a/hotspot/src/share/vm/utilities/events.cpp Tue Jun 02 10:41:18 2015 +0200 +++ b/hotspot/src/share/vm/utilities/events.cpp Thu Jun 04 08:05:47 2015 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ EventLog* Events::_logs = NULL; StringEventLog* Events::_messages = NULL; StringEventLog* Events::_exceptions = NULL; +StringEventLog* Events::_redefinitions = NULL; StringEventLog* Events::_deopt_messages = NULL; EventLog::EventLog() { @@ -66,6 +67,7 @@ if (LogEvents) { _messages = new StringEventLog("Events"); _exceptions = new StringEventLog("Internal exceptions"); + _redefinitions = new StringEventLog("Classes redefined"); _deopt_messages = new StringEventLog("Deoptimization events"); } } diff -r 6df6a1332f23 -r 48000028382c hotspot/src/share/vm/utilities/events.hpp --- a/hotspot/src/share/vm/utilities/events.hpp Tue Jun 02 10:41:18 2015 +0200 +++ b/hotspot/src/share/vm/utilities/events.hpp Thu Jun 04 08:05:47 2015 -0400 @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -186,6 +186,9 @@ // Deoptization related messages static StringEventLog* _deopt_messages; + // Redefinition related messages + static StringEventLog* _redefinitions; + public: static void print_all(outputStream* out); @@ -198,6 +201,8 @@ // Log exception related message 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); // Register default loggers @@ -222,6 +227,15 @@ } } +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, ...) { if (LogEvents) { va_list ap;