compileLog.hpp 3.4 KB
Newer Older
D
duke 已提交
1
/*
2
 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
19 20 21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
D
duke 已提交
22 23 24
 *
 */

25 26 27 28 29
#ifndef SHARE_VM_COMPILER_COMPILELOG_HPP
#define SHARE_VM_COMPILER_COMPILELOG_HPP

#include "utilities/xmlstream.hpp"

30
class ciBaseObject;
D
duke 已提交
31
class ciObject;
32
class ciMetadata;
D
duke 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
class ciSymbol;

// CompileLog
//
// An open stream for logging information about activities in a
// compiler thread.  There is exactly one per CompilerThread,
// if the +LogCompilation switch is enabled.
class CompileLog : public xmlStream {
 private:
  const char*   _file;           // name of file where XML goes
  julong        _file_end;       // last good end of file
  intx          _thread_id;      // which compile thread

  stringStream  _context;        // optional, killable context marker
  char          _context_buffer[100];

  char*         _identities;     // array of boolean
  int           _identities_limit;
  int           _identities_capacity;

  CompileLog*   _next;           // static chain of all logs

  static CompileLog* _first;     // head of static chain

  void va_tag(bool push, const char* format, va_list ap);

 public:
  CompileLog(const char* file, FILE* fp, intx thread_id);
  ~CompileLog();

  intx          thread_id()                      { return _thread_id; }
  const char*   file()                           { return _file; }
V
vlivanov 已提交
65 66 67 68

  // Optional context marker, to help place actions that occur during
  // parsing. If there is no log output until the next context string
  // or reset, context string will be silently ignored
D
duke 已提交
69
  stringStream* context()                        { return &_context; }
V
vlivanov 已提交
70 71
  void    clear_context()                        { context()->reset(); }
  void      set_context(const char* format, ...);
D
duke 已提交
72 73

  void          name(ciSymbol* s);               // name='s'
74
  void          name(Symbol* s)                  { xmlStream::name(s); }
D
duke 已提交
75 76

  // Output an object description, return obj->ident().
77
  int           identify(ciBaseObject* obj);
D
duke 已提交
78 79
  void          clear_identities();

V
vlivanov 已提交
80 81 82
  void inline_fail   (const char* reason);
  void inline_success(const char* reason);

D
duke 已提交
83 84 85 86 87 88 89
  // virtuals
  virtual void see_tag(const char* tag, bool push);
  virtual void pop_tag(const char* tag);

  // make a provisional end of log mark
  void mark_file_end() { _file_end = out()->count(); }

V
vlivanov 已提交
90 91 92
  // Print code cache statistics
  void code_cache_state();

D
duke 已提交
93 94 95 96
  // copy all logs to the given stream
  static void finish_log(outputStream* out);
  static void finish_log_on_error(outputStream* out, char *buf, int buflen);
};
97 98

#endif // SHARE_VM_COMPILER_COMPILELOG_HPP