Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/utilities/events.cpp
32285 views
/*1* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "memory/allocation.inline.hpp"26#include "runtime/mutexLocker.hpp"27#include "runtime/osThread.hpp"28#include "runtime/thread.inline.hpp"29#include "runtime/threadCritical.hpp"30#include "runtime/threadLocalStorage.hpp"31#include "runtime/timer.hpp"32#include "utilities/events.hpp"333435EventLog* Events::_logs = NULL;36StringEventLog* Events::_messages = NULL;37StringEventLog* Events::_exceptions = NULL;38StringEventLog* Events::_redefinitions = NULL;39StringEventLog* Events::_deopt_messages = NULL;4041EventLog::EventLog() {42// This normally done during bootstrap when we're only single43// threaded but use a ThreadCritical to ensure inclusion in case44// some are created slightly late.45ThreadCritical tc;46_next = Events::_logs;47Events::_logs = this;48}4950// For each registered event logger, print out the current contents of51// the buffer. This is normally called when the JVM is crashing.52void Events::print_all(outputStream* out) {53EventLog* log = _logs;54while (log != NULL) {55log->print_log_on(out);56log = log->next();57}58}5960void Events::print() {61print_all(tty);62}6364void Events::init() {65if (LogEvents) {66_messages = new StringEventLog("Events");67_exceptions = new StringEventLog("Internal exceptions");68_redefinitions = new StringEventLog("Classes redefined");69_deopt_messages = new StringEventLog("Deoptimization events");70}71}7273void eventlog_init() {74Events::init();75}7677///////////////////////////////////////////////////////////////////////////78// EventMark7980EventMark::EventMark(const char* format, ...) {81if (LogEvents) {82va_list ap;83va_start(ap, format);84// Save a copy of begin message and log it.85_buffer.printv(format, ap);86Events::log(NULL, "%s", _buffer.buffer());87va_end(ap);88}89}9091EventMark::~EventMark() {92if (LogEvents) {93// Append " done" to the begin message and log it94_buffer.append(" done");95Events::log(NULL, "%s", _buffer.buffer());96}97}9899100