src/share/vm/utilities/events.cpp

Mon, 02 Jul 2012 13:11:28 -0400

author
coleenp
date
Mon, 02 Jul 2012 13:11:28 -0400
changeset 3901
24b9c7f4cae6
parent 3571
09d00c18e323
child 4299
f34d701e952e
permissions
-rw-r--r--

Merge

duke@435 1 /*
never@3499 2 * Copyright (c) 1997, 2012, 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"
never@3499 29 #include "runtime/threadCritical.hpp"
stefank@2314 30 #include "runtime/threadLocalStorage.hpp"
stefank@2314 31 #include "runtime/timer.hpp"
stefank@2314 32 #include "utilities/events.hpp"
stefank@2314 33 #ifdef TARGET_OS_FAMILY_linux
stefank@2314 34 # include "thread_linux.inline.hpp"
stefank@2314 35 #endif
stefank@2314 36 #ifdef TARGET_OS_FAMILY_solaris
stefank@2314 37 # include "thread_solaris.inline.hpp"
stefank@2314 38 #endif
stefank@2314 39 #ifdef TARGET_OS_FAMILY_windows
stefank@2314 40 # include "thread_windows.inline.hpp"
stefank@2314 41 #endif
never@3156 42 #ifdef TARGET_OS_FAMILY_bsd
never@3156 43 # include "thread_bsd.inline.hpp"
never@3156 44 #endif
duke@435 45
duke@435 46
never@3499 47 EventLog* Events::_logs = NULL;
never@3499 48 StringEventLog* Events::_messages = NULL;
never@3499 49 StringEventLog* Events::_exceptions = NULL;
never@3499 50 StringEventLog* Events::_deopt_messages = NULL;
duke@435 51
never@3499 52 EventLog::EventLog() {
never@3499 53 // This normally done during bootstrap when we're only single
never@3499 54 // threaded but use a ThreadCritical to ensure inclusion in case
never@3499 55 // some are created slightly late.
never@3499 56 ThreadCritical tc;
never@3499 57 _next = Events::_logs;
never@3499 58 Events::_logs = this;
never@3499 59 }
duke@435 60
never@3499 61 // For each registered event logger, print out the current contents of
never@3499 62 // the buffer. This is normally called when the JVM is crashing.
never@3499 63 void Events::print_all(outputStream* out) {
never@3499 64 EventLog* log = _logs;
never@3499 65 while (log != NULL) {
never@3499 66 log->print_log_on(out);
never@3499 67 log = log->next();
duke@435 68 }
duke@435 69 }
duke@435 70
never@3571 71 void Events::print() {
never@3571 72 print_all(tty);
never@3571 73 }
never@3571 74
never@3499 75 void Events::init() {
never@3499 76 if (LogEvents) {
never@3499 77 _messages = new StringEventLog("Events");
never@3499 78 _exceptions = new StringEventLog("Internal exceptions");
never@3499 79 _deopt_messages = new StringEventLog("Deoptimization events");
never@3499 80 }
duke@435 81 }
duke@435 82
never@3499 83 void eventlog_init() {
never@3499 84 Events::init();
duke@435 85 }
duke@435 86
duke@435 87 ///////////////////////////////////////////////////////////////////////////
duke@435 88 // EventMark
duke@435 89
duke@435 90 EventMark::EventMark(const char* format, ...) {
duke@435 91 if (LogEvents) {
duke@435 92 va_list ap;
duke@435 93 va_start(ap, format);
never@3499 94 // Save a copy of begin message and log it.
never@3499 95 _buffer.printv(format, ap);
never@3499 96 Events::log(NULL, _buffer);
duke@435 97 va_end(ap);
duke@435 98 }
duke@435 99 }
duke@435 100
duke@435 101 EventMark::~EventMark() {
duke@435 102 if (LogEvents) {
never@3499 103 // Append " done" to the begin message and log it
never@3499 104 _buffer.append(" done");
never@3499 105 Events::log(NULL, _buffer);
duke@435 106 }
duke@435 107 }

mercurial