8153413: Exceptions::_throw always logs exceptions, penalizing performance
Construct exception string into Event message directly add if (log_is_enabled) for logging. Reviewed-by: ysuenaga, dholmes
This commit is contained in:
parent
ace0b7a803
commit
e84f0388f5
@ -36,7 +36,7 @@
|
||||
|
||||
EventLog* Events::_logs = NULL;
|
||||
StringEventLog* Events::_messages = NULL;
|
||||
ExtendedStringEventLog* Events::_exceptions = NULL;
|
||||
ExceptionsEventLog* Events::_exceptions = NULL;
|
||||
StringEventLog* Events::_redefinitions = NULL;
|
||||
UnloadingEventLog* Events::_class_unloading = NULL;
|
||||
StringEventLog* Events::_deopt_messages = NULL;
|
||||
@ -67,7 +67,7 @@ void Events::print() {
|
||||
void Events::init() {
|
||||
if (LogEvents) {
|
||||
_messages = new StringEventLog("Events");
|
||||
_exceptions = new ExtendedStringEventLog("Internal exceptions");
|
||||
_exceptions = new ExceptionsEventLog("Internal exceptions");
|
||||
_redefinitions = new StringEventLog("Classes redefined");
|
||||
_class_unloading = new UnloadingEventLog("Classes unloaded");
|
||||
_deopt_messages = new StringEventLog("Deoptimization events");
|
||||
@ -112,3 +112,20 @@ void UnloadingEventLog::log(Thread* thread, InstanceKlass* ik) {
|
||||
st.print("Unloading class " INTPTR_FORMAT " ", p2i(ik));
|
||||
ik->name()->print_value_on(&st);
|
||||
}
|
||||
|
||||
void ExceptionsEventLog::log(Thread* thread, Handle h_exception, const char* message, const char* file, int line) {
|
||||
if (!should_log()) return;
|
||||
|
||||
double timestamp = fetch_timestamp();
|
||||
MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag);
|
||||
int index = compute_log_index();
|
||||
_records[index].thread = thread;
|
||||
_records[index].timestamp = timestamp;
|
||||
stringStream st = _records[index].data.stream();
|
||||
st.print("Exception <");
|
||||
h_exception->print_value_on(&st);
|
||||
st.print("%s%s> (" INTPTR_FORMAT ") \n"
|
||||
"thrown [%s, line %d]\nfor thread " INTPTR_FORMAT,
|
||||
message ? ": " : "", message ? message : "",
|
||||
p2i(h_exception()), file, line, p2i(thread));
|
||||
}
|
||||
|
@ -183,6 +183,14 @@ class UnloadingEventLog : public EventLogBase<StringLogMessage> {
|
||||
void log(Thread* thread, InstanceKlass* ik);
|
||||
};
|
||||
|
||||
// Event log for exceptions
|
||||
class ExceptionsEventLog : public ExtendedStringEventLog {
|
||||
public:
|
||||
ExceptionsEventLog(const char* name, int count = LogEventsBufferEntries) : ExtendedStringEventLog(name, count) {}
|
||||
|
||||
void log(Thread* thread, Handle h_exception, const char* message, const char* file, int line);
|
||||
};
|
||||
|
||||
|
||||
class Events : AllStatic {
|
||||
friend class EventLog;
|
||||
@ -195,7 +203,7 @@ class Events : AllStatic {
|
||||
|
||||
// A log for internal exception related messages, like internal
|
||||
// throws and implicit exceptions.
|
||||
static ExtendedStringEventLog* _exceptions;
|
||||
static ExceptionsEventLog* _exceptions;
|
||||
|
||||
// Deoptization related messages
|
||||
static StringEventLog* _deopt_messages;
|
||||
@ -216,6 +224,7 @@ class Events : AllStatic {
|
||||
|
||||
// Log exception related message
|
||||
static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
|
||||
static void log_exception(Thread* thread, Handle h_exception, const char* message, const char* file, int line);
|
||||
|
||||
static void log_redefinition(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
|
||||
|
||||
@ -245,6 +254,12 @@ inline void Events::log_exception(Thread* thread, const char* format, ...) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void Events::log_exception(Thread* thread, Handle h_exception, const char* message, const char* file, int line) {
|
||||
if (LogEvents) {
|
||||
_exceptions->log(thread, h_exception, message, file, line);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Events::log_redefinition(Thread* thread, const char* format, ...) {
|
||||
if (LogEvents) {
|
||||
va_list ap;
|
||||
|
@ -131,15 +131,17 @@ void Exceptions::_throw_oop(Thread* thread, const char* file, int line, oop exce
|
||||
}
|
||||
|
||||
void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exception, const char* message) {
|
||||
ResourceMark rm;
|
||||
ResourceMark rm(thread);
|
||||
assert(h_exception() != NULL, "exception should not be NULL");
|
||||
|
||||
// tracing (do this up front - so it works during boot strapping)
|
||||
// Note, the print_value_string() argument is not called unless logging is enabled!
|
||||
log_info(exceptions)("Exception <%s%s%s> (" INTPTR_FORMAT ") \n"
|
||||
"thrown [%s, line %d]\nfor thread " INTPTR_FORMAT,
|
||||
h_exception->print_value_string(),
|
||||
message ? ": " : "", message ? message : "",
|
||||
p2i(h_exception()), file, line, p2i(thread));
|
||||
|
||||
// for AbortVMOnException flag
|
||||
Exceptions::debug_check_abort(h_exception, message);
|
||||
|
||||
@ -162,11 +164,7 @@ void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exc
|
||||
thread->set_pending_exception(h_exception(), file, line);
|
||||
|
||||
// vm log
|
||||
if (LogEvents){
|
||||
Events::log_exception(thread, "Exception <%s%s%s> (" INTPTR_FORMAT ") thrown at [%s, line %d]",
|
||||
h_exception->print_value_string(), message ? ": " : "", message ? message : "",
|
||||
p2i(h_exception()), file, line);
|
||||
}
|
||||
Events::log_exception(thread, h_exception, message, file, line);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user