aoqi@0: /* aoqi@0: * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_COMPILER_COMPILELOG_HPP aoqi@0: #define SHARE_VM_COMPILER_COMPILELOG_HPP aoqi@0: aoqi@0: #include "utilities/xmlstream.hpp" aoqi@0: aoqi@0: class ciBaseObject; aoqi@0: class ciObject; aoqi@0: class ciMetadata; aoqi@0: class ciSymbol; aoqi@0: aoqi@0: // CompileLog aoqi@0: // aoqi@0: // An open stream for logging information about activities in a aoqi@0: // compiler thread. There is exactly one per CompilerThread, aoqi@0: // if the +LogCompilation switch is enabled. aoqi@0: class CompileLog : public xmlStream { aoqi@0: private: aoqi@0: const char* _file; // name of file where XML goes aoqi@0: julong _file_end; // last good end of file aoqi@0: intx _thread_id; // which compile thread aoqi@0: aoqi@0: stringStream _context; // optional, killable context marker aoqi@0: char _context_buffer[100]; aoqi@0: aoqi@0: char* _identities; // array of boolean aoqi@0: int _identities_limit; aoqi@0: int _identities_capacity; aoqi@0: aoqi@0: CompileLog* _next; // static chain of all logs aoqi@0: aoqi@0: static CompileLog* _first; // head of static chain aoqi@0: aoqi@0: void va_tag(bool push, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0); aoqi@0: aoqi@0: public: aoqi@0: CompileLog(const char* file_name, FILE* fp, intx thread_id); aoqi@0: ~CompileLog(); aoqi@0: aoqi@0: intx thread_id() { return _thread_id; } aoqi@0: const char* file() { return _file; } aoqi@0: aoqi@0: // Optional context marker, to help place actions that occur during aoqi@0: // parsing. If there is no log output until the next context string aoqi@0: // or reset, context string will be silently ignored aoqi@0: stringStream* context() { return &_context; } aoqi@0: void clear_context() { context()->reset(); } aoqi@0: void set_context(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); aoqi@0: aoqi@0: void name(ciSymbol* s); // name='s' aoqi@0: void name(Symbol* s) { xmlStream::name(s); } aoqi@0: aoqi@0: // Output an object description, return obj->ident(). aoqi@0: int identify(ciBaseObject* obj); aoqi@0: void clear_identities(); aoqi@0: aoqi@0: void inline_fail (const char* reason); aoqi@0: void inline_success(const char* reason); aoqi@0: aoqi@0: // virtuals aoqi@0: virtual void see_tag(const char* tag, bool push); aoqi@0: virtual void pop_tag(const char* tag); aoqi@0: aoqi@0: // make a provisional end of log mark aoqi@0: void mark_file_end() { _file_end = out()->count(); } aoqi@0: aoqi@0: // Print code cache statistics aoqi@0: void code_cache_state(); aoqi@0: aoqi@0: // copy all logs to the given stream aoqi@0: static void finish_log(outputStream* out); aoqi@0: static void finish_log_on_error(outputStream* out, char *buf, int buflen); aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_COMPILER_COMPILELOG_HPP