Fri, 05 Oct 2012 18:57:10 -0700
7177003: C1: LogCompilation support
Summary: add LogCompilation support in C1 - both client and tiered mode.
Reviewed-by: twisti, kvn
zgu@2364 | 1 | /* |
zgu@3544 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
zgu@2364 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
zgu@2364 | 4 | * |
zgu@2364 | 5 | * This code is free software; you can redistribute it and/or modify it |
zgu@2364 | 6 | * under the terms of the GNU General Public License version 2 only, as |
zgu@2364 | 7 | * published by the Free Software Foundation. |
zgu@2364 | 8 | * |
zgu@2364 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
zgu@2364 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
zgu@2364 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
zgu@2364 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
zgu@2364 | 13 | * accompanied this code). |
zgu@2364 | 14 | * |
zgu@2364 | 15 | * You should have received a copy of the GNU General Public License version |
zgu@2364 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
zgu@2364 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
zgu@2364 | 18 | * |
zgu@2364 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
zgu@2364 | 20 | * or visit www.oracle.com if you need additional information or have any |
zgu@2364 | 21 | * questions. |
zgu@2364 | 22 | * |
zgu@2364 | 23 | */ |
zgu@2364 | 24 | |
zgu@2364 | 25 | |
zgu@3430 | 26 | #ifndef SHARE_VM_UTILITIES_DECODER_HPP |
zgu@3430 | 27 | #define SHARE_VM_UTILITIES_DECODER_HPP |
zgu@2364 | 28 | |
zgu@2364 | 29 | #include "memory/allocation.hpp" |
zgu@3430 | 30 | #include "runtime/mutex.hpp" |
zgu@2364 | 31 | |
zgu@3900 | 32 | class AbstractDecoder : public CHeapObj<mtInternal> { |
zgu@3430 | 33 | public: |
zgu@2364 | 34 | // status code for decoding native C frame |
zgu@2364 | 35 | enum decoder_status { |
zgu@3430 | 36 | not_available = -10, // real decoder is not available |
zgu@3430 | 37 | no_error = 0, // successfully decoded frames |
zgu@2364 | 38 | out_of_memory, // out of memory |
zgu@2364 | 39 | file_invalid, // invalid elf file |
zgu@2364 | 40 | file_not_found, // could not found symbol file (on windows), such as jvm.pdb or jvm.map |
zgu@2364 | 41 | helper_not_found, // could not load dbghelp.dll (Windows only) |
zgu@2364 | 42 | helper_func_error, // decoding functions not found (Windows only) |
zgu@3430 | 43 | helper_init_error // SymInitialize failed (Windows only) |
zgu@2364 | 44 | }; |
zgu@2364 | 45 | |
zgu@3544 | 46 | // decode an pc address to corresponding function name and an offset from the beginning of |
zgu@3544 | 47 | // the function |
zgu@3544 | 48 | virtual bool decode(address pc, char* buf, int buflen, int* offset, |
zgu@3544 | 49 | const char* modulepath = NULL) = 0; |
zgu@3961 | 50 | virtual bool decode(address pc, char* buf, int buflen, int* offset, const void* base) = 0; |
zgu@3961 | 51 | |
zgu@3544 | 52 | // demangle a C++ symbol |
zgu@3544 | 53 | virtual bool demangle(const char* symbol, char* buf, int buflen) = 0; |
zgu@3544 | 54 | // if the decoder can decode symbols in vm |
zgu@3544 | 55 | virtual bool can_decode_C_frame_in_vm() const = 0; |
zgu@3544 | 56 | |
zgu@3544 | 57 | virtual decoder_status status() const { |
zgu@3544 | 58 | return _decoder_status; |
zgu@3544 | 59 | } |
zgu@3544 | 60 | |
zgu@3544 | 61 | virtual bool has_error() const { |
zgu@3544 | 62 | return is_error(_decoder_status); |
zgu@3544 | 63 | } |
zgu@3544 | 64 | |
zgu@3544 | 65 | static bool is_error(decoder_status status) { |
zgu@3544 | 66 | return (status > 0); |
zgu@3544 | 67 | } |
zgu@3544 | 68 | |
zgu@3544 | 69 | protected: |
zgu@3544 | 70 | decoder_status _decoder_status; |
zgu@3544 | 71 | }; |
zgu@3544 | 72 | |
zgu@3544 | 73 | // Do nothing decoder |
zgu@3544 | 74 | class NullDecoder : public AbstractDecoder { |
zgu@3544 | 75 | public: |
zgu@3430 | 76 | NullDecoder() { |
zgu@3430 | 77 | _decoder_status = not_available; |
zgu@3430 | 78 | } |
zgu@2364 | 79 | |
zgu@3430 | 80 | ~NullDecoder() {}; |
zgu@3430 | 81 | |
zgu@3430 | 82 | virtual bool decode(address pc, char* buf, int buflen, int* offset, |
zgu@3430 | 83 | const char* modulepath = NULL) { |
zgu@3430 | 84 | return false; |
zgu@3430 | 85 | } |
zgu@3430 | 86 | |
zgu@3961 | 87 | virtual bool decode(address pc, char* buf, int buflen, int* offset, const void* base) { |
zgu@3961 | 88 | return false; |
zgu@3961 | 89 | } |
zgu@3961 | 90 | |
zgu@3430 | 91 | virtual bool demangle(const char* symbol, char* buf, int buflen) { |
zgu@3430 | 92 | return false; |
zgu@3430 | 93 | } |
zgu@3430 | 94 | |
zgu@3430 | 95 | virtual bool can_decode_C_frame_in_vm() const { |
zgu@3430 | 96 | return false; |
zgu@3430 | 97 | } |
zgu@3430 | 98 | }; |
zgu@3430 | 99 | |
zgu@3430 | 100 | |
zgu@3544 | 101 | class Decoder : AllStatic { |
zgu@3430 | 102 | public: |
zgu@3430 | 103 | static bool decode(address pc, char* buf, int buflen, int* offset, const char* modulepath = NULL); |
zgu@3961 | 104 | static bool decode(address pc, char* buf, int buflen, int* offset, const void* base); |
zgu@3430 | 105 | static bool demangle(const char* symbol, char* buf, int buflen); |
zgu@2364 | 106 | static bool can_decode_C_frame_in_vm(); |
zgu@2364 | 107 | |
zgu@3544 | 108 | // shutdown shared instance |
zgu@3430 | 109 | static void shutdown(); |
zgu@3430 | 110 | protected: |
zgu@3544 | 111 | // shared decoder instance, _shared_instance_lock is needed |
zgu@3544 | 112 | static AbstractDecoder* get_shared_instance(); |
zgu@3544 | 113 | // a private instance for error handler. Error handler can be |
zgu@3544 | 114 | // triggered almost everywhere, including signal handler, where |
zgu@3544 | 115 | // no lock can be taken. So the shared decoder can not be used |
zgu@3544 | 116 | // in this scenario. |
zgu@3544 | 117 | static AbstractDecoder* get_error_handler_instance(); |
zgu@2364 | 118 | |
zgu@3544 | 119 | static AbstractDecoder* create_decoder(); |
zgu@3430 | 120 | private: |
zgu@3544 | 121 | static AbstractDecoder* _shared_decoder; |
zgu@3544 | 122 | static AbstractDecoder* _error_handler_decoder; |
zgu@3544 | 123 | static NullDecoder _do_nothing_decoder; |
zgu@2364 | 124 | |
zgu@3430 | 125 | protected: |
zgu@3544 | 126 | static Mutex* _shared_decoder_lock; |
zgu@2364 | 127 | }; |
zgu@2364 | 128 | |
zgu@3430 | 129 | #endif // SHARE_VM_UTILITIES_DECODER_HPP |