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@2364 | 2 | * Copyright (c) 1997, 2010, 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 | #include "precompiled.hpp" |
zgu@2364 | 26 | #include "prims/jvm.h" |
zgu@3430 | 27 | #include "runtime/mutexLocker.hpp" |
zgu@3544 | 28 | #include "runtime/os.hpp" |
zgu@2364 | 29 | #include "utilities/decoder.hpp" |
zgu@3544 | 30 | #include "utilities/vmError.hpp" |
zgu@2364 | 31 | |
zgu@3430 | 32 | #if defined(_WINDOWS) |
zgu@3430 | 33 | #include "decoder_windows.hpp" |
zgu@3430 | 34 | #elif defined(__APPLE__) |
zgu@3430 | 35 | #include "decoder_machO.hpp" |
zgu@3430 | 36 | #else |
zgu@3430 | 37 | #include "decoder_elf.hpp" |
zgu@3430 | 38 | #endif |
zgu@2364 | 39 | |
zgu@3544 | 40 | AbstractDecoder* Decoder::_shared_decoder = NULL; |
zgu@3544 | 41 | AbstractDecoder* Decoder::_error_handler_decoder = NULL; |
zgu@3544 | 42 | NullDecoder Decoder::_do_nothing_decoder; |
zgu@3544 | 43 | Mutex* Decoder::_shared_decoder_lock = new Mutex(Mutex::native, |
zgu@3544 | 44 | "SharedDecoderLock"); |
zgu@2364 | 45 | |
zgu@3544 | 46 | AbstractDecoder* Decoder::get_shared_instance() { |
zgu@3544 | 47 | assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(), |
zgu@3430 | 48 | "Require DecoderLock to enter"); |
zgu@2364 | 49 | |
zgu@3544 | 50 | if (_shared_decoder == NULL) { |
zgu@3544 | 51 | _shared_decoder = create_decoder(); |
zgu@3430 | 52 | } |
zgu@3544 | 53 | return _shared_decoder; |
zgu@3544 | 54 | } |
zgu@3430 | 55 | |
zgu@3544 | 56 | AbstractDecoder* Decoder::get_error_handler_instance() { |
zgu@3544 | 57 | if (_error_handler_decoder == NULL) { |
zgu@3544 | 58 | _error_handler_decoder = create_decoder(); |
zgu@3544 | 59 | } |
zgu@3544 | 60 | return _error_handler_decoder; |
zgu@3544 | 61 | } |
zgu@3544 | 62 | |
zgu@3544 | 63 | |
zgu@3544 | 64 | AbstractDecoder* Decoder::create_decoder() { |
zgu@3544 | 65 | AbstractDecoder* decoder; |
zgu@3430 | 66 | #if defined(_WINDOWS) |
zgu@3544 | 67 | decoder = new (std::nothrow) WindowsDecoder(); |
zgu@3430 | 68 | #elif defined (__APPLE__) |
zgu@3544 | 69 | decoder = new (std::nothrow)MachODecoder(); |
zgu@3430 | 70 | #else |
zgu@3544 | 71 | decoder = new (std::nothrow)ElfDecoder(); |
zgu@3430 | 72 | #endif |
zgu@3430 | 73 | |
zgu@3544 | 74 | if (decoder == NULL || decoder->has_error()) { |
zgu@3544 | 75 | if (decoder != NULL) { |
zgu@3544 | 76 | delete decoder; |
zgu@3430 | 77 | } |
zgu@3544 | 78 | decoder = &_do_nothing_decoder; |
zgu@3430 | 79 | } |
zgu@3544 | 80 | return decoder; |
zgu@3430 | 81 | } |
zgu@3430 | 82 | |
zgu@3430 | 83 | bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath) { |
zgu@3544 | 84 | assert(_shared_decoder_lock != NULL, "Just check"); |
zgu@3544 | 85 | bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; |
zgu@3544 | 86 | MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); |
zgu@3544 | 87 | AbstractDecoder* decoder = error_handling_thread ? |
zgu@3544 | 88 | get_error_handler_instance(): get_shared_instance(); |
zgu@3430 | 89 | assert(decoder != NULL, "null decoder"); |
zgu@3430 | 90 | |
zgu@3430 | 91 | return decoder->decode(addr, buf, buflen, offset, modulepath); |
zgu@3430 | 92 | } |
zgu@3430 | 93 | |
zgu@3961 | 94 | bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const void* base) { |
zgu@3961 | 95 | assert(_shared_decoder_lock != NULL, "Just check"); |
zgu@3961 | 96 | bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; |
zgu@3961 | 97 | MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); |
zgu@3961 | 98 | AbstractDecoder* decoder = error_handling_thread ? |
zgu@3961 | 99 | get_error_handler_instance(): get_shared_instance(); |
zgu@3961 | 100 | assert(decoder != NULL, "null decoder"); |
zgu@3961 | 101 | |
zgu@3961 | 102 | return decoder->decode(addr, buf, buflen, offset, base); |
zgu@3961 | 103 | } |
zgu@3961 | 104 | |
zgu@3961 | 105 | |
zgu@3430 | 106 | bool Decoder::demangle(const char* symbol, char* buf, int buflen) { |
zgu@3544 | 107 | assert(_shared_decoder_lock != NULL, "Just check"); |
zgu@3544 | 108 | bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; |
zgu@3544 | 109 | MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); |
zgu@3544 | 110 | AbstractDecoder* decoder = error_handling_thread ? |
zgu@3544 | 111 | get_error_handler_instance(): get_shared_instance(); |
zgu@3430 | 112 | assert(decoder != NULL, "null decoder"); |
zgu@3430 | 113 | return decoder->demangle(symbol, buf, buflen); |
zgu@3430 | 114 | } |
zgu@2364 | 115 | |
zgu@2364 | 116 | bool Decoder::can_decode_C_frame_in_vm() { |
zgu@3544 | 117 | assert(_shared_decoder_lock != NULL, "Just check"); |
zgu@3544 | 118 | bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; |
zgu@3544 | 119 | MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); |
zgu@3544 | 120 | AbstractDecoder* decoder = error_handling_thread ? |
zgu@3544 | 121 | get_error_handler_instance(): get_shared_instance(); |
zgu@3430 | 122 | assert(decoder != NULL, "null decoder"); |
zgu@3430 | 123 | return decoder->can_decode_C_frame_in_vm(); |
zgu@2364 | 124 | } |
zgu@2364 | 125 | |
zgu@3544 | 126 | /* |
zgu@3544 | 127 | * Shutdown shared decoder and replace it with |
zgu@3544 | 128 | * _do_nothing_decoder. Do nothing with error handler |
zgu@3544 | 129 | * instance, since the JVM is going down. |
zgu@3544 | 130 | */ |
zgu@3430 | 131 | void Decoder::shutdown() { |
zgu@3544 | 132 | assert(_shared_decoder_lock != NULL, "Just check"); |
zgu@3544 | 133 | MutexLockerEx locker(_shared_decoder_lock, true); |
zgu@3430 | 134 | |
zgu@3544 | 135 | if (_shared_decoder != NULL && |
zgu@3544 | 136 | _shared_decoder != &_do_nothing_decoder) { |
zgu@3544 | 137 | delete _shared_decoder; |
zgu@3430 | 138 | } |
zgu@3430 | 139 | |
zgu@3544 | 140 | _shared_decoder = &_do_nothing_decoder; |
zgu@2364 | 141 | } |
zgu@2364 | 142 |