@@ -220,6 +220,9 @@ class Events : AllStatic {
220220 // A log for generic messages that aren't well categorized.
221221 static StringEventLog* _messages;
222222
223+ // A log for VM Operations
224+ static StringEventLog* _vm_operations;
225+
223226 // A log for internal exception related messages, like internal
224227 // throws and implicit exceptions.
225228 static ExceptionsEventLog* _exceptions;
@@ -247,6 +250,8 @@ class Events : AllStatic {
247250 // Logs a generic message with timestamp and format as printf.
248251 static void log (Thread* thread, const char * format, ...) ATTRIBUTE_PRINTF(2 , 3 );
249252
253+ static void log_vm_operation (Thread* thread, const char * format, ...) ATTRIBUTE_PRINTF(2 , 3 );
254+
250255 // Log exception related message
251256 static void log_exception (Thread* thread, const char * format, ...) ATTRIBUTE_PRINTF(2 , 3 );
252257 static void log_exception (Thread* thread, Handle h_exception, const char * message, const char * file, int line);
@@ -270,6 +275,15 @@ inline void Events::log(Thread* thread, const char* format, ...) {
270275 }
271276}
272277
278+ inline void Events::log_vm_operation (Thread* thread, const char * format, ...) {
279+ if (LogEvents && _vm_operations != NULL ) {
280+ va_list ap;
281+ va_start (ap, format);
282+ _vm_operations->logv (thread, format, ap);
283+ va_end (ap);
284+ }
285+ }
286+
273287inline void Events::log_exception (Thread* thread, const char * format, ...) {
274288 if (LogEvents && _exceptions != NULL ) {
275289 va_list ap;
@@ -414,16 +428,49 @@ inline void EventLogBase<ExtendedStringLogMessage>::print(outputStream* out, Ext
414428 out->cr ();
415429}
416430
431+ typedef void (*EventLogFunction)(Thread* thread, const char * format, ...);
432+
433+ class EventMarkBase : public StackObj {
434+ EventLogFunction _log_function;
435+ StringLogMessage _buffer;
436+
437+ NONCOPYABLE (EventMarkBase);
438+
439+ protected:
440+ void log_start (const char * format, va_list argp) ATTRIBUTE_PRINTF(2 , 0 );
441+ void log_end ();
442+
443+ EventMarkBase (EventLogFunction log_function);
444+ };
445+
417446// Place markers for the beginning and end up of a set of events.
418- // These end up in the default log.
419- class EventMark : public StackObj {
447+ template <EventLogFunction log_function>
448+ class EventMarkWithLogFunction : public EventMarkBase {
420449 StringLogMessage _buffer;
421450
422451 public:
423452 // log a begin event, format as printf
424- EventMark (const char * format, ...) ATTRIBUTE_PRINTF(2 , 3 );
453+ EventMarkWithLogFunction (const char * format, ...) ATTRIBUTE_PRINTF(2 , 3 ) :
454+ EventMarkBase (log_function) {
455+ if (LogEvents) {
456+ va_list ap;
457+ va_start (ap, format);
458+ log_start (format, ap);
459+ va_end (ap);
460+ }
461+ }
425462 // log an end event
426- ~EventMark ();
463+ ~EventMarkWithLogFunction () {
464+ if (LogEvents) {
465+ log_end ();
466+ }
467+ }
427468};
428469
470+ // These end up in the default log.
471+ typedef EventMarkWithLogFunction<Events::log> EventMark;
472+
473+ // These end up in the vm_operation log.
474+ typedef EventMarkWithLogFunction<Events::log_vm_operation> EventMarkVMOperation;
475+
429476#endif // SHARE_UTILITIES_EVENTS_HPP
0 commit comments