src/share/vm/utilities/events.cpp

Thu, 29 May 2014 09:56:06 -0700

author
asaha
date
Thu, 29 May 2014 09:56:06 -0700
changeset 6782
f73af4455d7d
parent 6763
0297e36d24a1
parent 6680
78bbf4d43a14
child 6876
710a3c8b516e
child 8720
6bed084fd02f
permissions
-rw-r--r--

Merge

duke@435 1 /*
drchase@6680 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "memory/allocation.inline.hpp"
stefank@2314 27 #include "runtime/mutexLocker.hpp"
stefank@2314 28 #include "runtime/osThread.hpp"
stefank@4299 29 #include "runtime/thread.inline.hpp"
never@3499 30 #include "runtime/threadCritical.hpp"
stefank@2314 31 #include "runtime/threadLocalStorage.hpp"
stefank@2314 32 #include "runtime/timer.hpp"
stefank@2314 33 #include "utilities/events.hpp"
duke@435 34
duke@435 35
never@3499 36 EventLog* Events::_logs = NULL;
never@3499 37 StringEventLog* Events::_messages = NULL;
never@3499 38 StringEventLog* Events::_exceptions = NULL;
never@3499 39 StringEventLog* Events::_deopt_messages = NULL;
duke@435 40
never@3499 41 EventLog::EventLog() {
never@3499 42 // This normally done during bootstrap when we're only single
never@3499 43 // threaded but use a ThreadCritical to ensure inclusion in case
never@3499 44 // some are created slightly late.
never@3499 45 ThreadCritical tc;
never@3499 46 _next = Events::_logs;
never@3499 47 Events::_logs = this;
never@3499 48 }
duke@435 49
never@3499 50 // For each registered event logger, print out the current contents of
never@3499 51 // the buffer. This is normally called when the JVM is crashing.
never@3499 52 void Events::print_all(outputStream* out) {
never@3499 53 EventLog* log = _logs;
never@3499 54 while (log != NULL) {
never@3499 55 log->print_log_on(out);
never@3499 56 log = log->next();
duke@435 57 }
duke@435 58 }
duke@435 59
never@3571 60 void Events::print() {
never@3571 61 print_all(tty);
never@3571 62 }
never@3571 63
never@3499 64 void Events::init() {
never@3499 65 if (LogEvents) {
never@3499 66 _messages = new StringEventLog("Events");
never@3499 67 _exceptions = new StringEventLog("Internal exceptions");
never@3499 68 _deopt_messages = new StringEventLog("Deoptimization events");
never@3499 69 }
duke@435 70 }
duke@435 71
never@3499 72 void eventlog_init() {
never@3499 73 Events::init();
duke@435 74 }
duke@435 75
duke@435 76 ///////////////////////////////////////////////////////////////////////////
duke@435 77 // EventMark
duke@435 78
duke@435 79 EventMark::EventMark(const char* format, ...) {
duke@435 80 if (LogEvents) {
duke@435 81 va_list ap;
duke@435 82 va_start(ap, format);
never@3499 83 // Save a copy of begin message and log it.
never@3499 84 _buffer.printv(format, ap);
drchase@6680 85 Events::log(NULL, "%s", _buffer.buffer());
duke@435 86 va_end(ap);
duke@435 87 }
duke@435 88 }
duke@435 89
duke@435 90 EventMark::~EventMark() {
duke@435 91 if (LogEvents) {
never@3499 92 // Append " done" to the begin message and log it
never@3499 93 _buffer.append(" done");
drchase@6680 94 Events::log(NULL, "%s", _buffer.buffer());
duke@435 95 }
duke@435 96 }

mercurial