Mercurial > hg > truffle
annotate src/share/vm/utilities/decoder.cpp @ 13257:4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
author | twisti |
---|---|
date | Thu, 05 Dec 2013 19:28:30 -0800 |
parents | 38f750491293 |
children | de6a9e811145 2b8e28fdf503 |
rev | line source |
---|---|
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
1 /* |
6842
b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
6258
diff
changeset
|
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
4 * |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
8 * |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
13 * accompanied this code). |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
14 * |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
18 * |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
21 * questions. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
22 * |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
23 */ |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
24 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
25 #include "precompiled.hpp" |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
26 #include "prims/jvm.h" |
4917 | 27 #include "runtime/os.hpp" |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
28 #include "utilities/decoder.hpp" |
4917 | 29 #include "utilities/vmError.hpp" |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
30 |
4803 | 31 #if defined(_WINDOWS) |
32 #include "decoder_windows.hpp" | |
33 #elif defined(__APPLE__) | |
34 #include "decoder_machO.hpp" | |
35 #else | |
36 #include "decoder_elf.hpp" | |
37 #endif | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
38 |
4917 | 39 AbstractDecoder* Decoder::_shared_decoder = NULL; |
40 AbstractDecoder* Decoder::_error_handler_decoder = NULL; | |
41 NullDecoder Decoder::_do_nothing_decoder; | |
42 Mutex* Decoder::_shared_decoder_lock = new Mutex(Mutex::native, | |
43 "SharedDecoderLock"); | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
44 |
4917 | 45 AbstractDecoder* Decoder::get_shared_instance() { |
46 assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(), | |
4803 | 47 "Require DecoderLock to enter"); |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
48 |
4917 | 49 if (_shared_decoder == NULL) { |
50 _shared_decoder = create_decoder(); | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
51 } |
4917 | 52 return _shared_decoder; |
53 } | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
54 |
4917 | 55 AbstractDecoder* Decoder::get_error_handler_instance() { |
56 if (_error_handler_decoder == NULL) { | |
57 _error_handler_decoder = create_decoder(); | |
58 } | |
59 return _error_handler_decoder; | |
60 } | |
61 | |
62 | |
63 AbstractDecoder* Decoder::create_decoder() { | |
64 AbstractDecoder* decoder; | |
4803 | 65 #if defined(_WINDOWS) |
4917 | 66 decoder = new (std::nothrow) WindowsDecoder(); |
4803 | 67 #elif defined (__APPLE__) |
4917 | 68 decoder = new (std::nothrow)MachODecoder(); |
4803 | 69 #else |
4917 | 70 decoder = new (std::nothrow)ElfDecoder(); |
4803 | 71 #endif |
72 | |
4917 | 73 if (decoder == NULL || decoder->has_error()) { |
74 if (decoder != NULL) { | |
75 delete decoder; | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
76 } |
4917 | 77 decoder = &_do_nothing_decoder; |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
78 } |
4917 | 79 return decoder; |
4803 | 80 } |
81 | |
12199
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
82 inline bool DecoderLocker::is_first_error_thread() { |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
83 return (os::current_thread_id() == VMError::get_first_error_tid()); |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
84 } |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
85 |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
86 DecoderLocker::DecoderLocker() : |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
87 MutexLockerEx(DecoderLocker::is_first_error_thread() ? |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
88 NULL : Decoder::shared_decoder_lock(), true) { |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
89 _decoder = is_first_error_thread() ? |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
90 Decoder::get_error_handler_instance() : Decoder::get_shared_instance(); |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
91 assert(_decoder != NULL, "null decoder"); |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
92 } |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
93 |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
94 Mutex* Decoder::shared_decoder_lock() { |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
95 assert(_shared_decoder_lock != NULL, "Just check"); |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
96 return _shared_decoder_lock; |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
97 } |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
98 |
4803 | 99 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath) { |
4917 | 100 assert(_shared_decoder_lock != NULL, "Just check"); |
101 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
102 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
103 AbstractDecoder* decoder = error_handling_thread ? | |
104 get_error_handler_instance(): get_shared_instance(); | |
4803 | 105 assert(decoder != NULL, "null decoder"); |
106 | |
107 return decoder->decode(addr, buf, buflen, offset, modulepath); | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
108 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
109 |
6258 | 110 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const void* base) { |
111 assert(_shared_decoder_lock != NULL, "Just check"); | |
112 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
113 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
114 AbstractDecoder* decoder = error_handling_thread ? | |
115 get_error_handler_instance(): get_shared_instance(); | |
116 assert(decoder != NULL, "null decoder"); | |
117 | |
118 return decoder->decode(addr, buf, buflen, offset, base); | |
119 } | |
120 | |
121 | |
4803 | 122 bool Decoder::demangle(const char* symbol, char* buf, int buflen) { |
4917 | 123 assert(_shared_decoder_lock != NULL, "Just check"); |
124 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
125 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
126 AbstractDecoder* decoder = error_handling_thread ? | |
127 get_error_handler_instance(): get_shared_instance(); | |
4803 | 128 assert(decoder != NULL, "null decoder"); |
129 return decoder->demangle(symbol, buf, buflen); | |
130 } | |
131 | |
132 bool Decoder::can_decode_C_frame_in_vm() { | |
4917 | 133 assert(_shared_decoder_lock != NULL, "Just check"); |
134 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
135 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
136 AbstractDecoder* decoder = error_handling_thread ? | |
137 get_error_handler_instance(): get_shared_instance(); | |
4803 | 138 assert(decoder != NULL, "null decoder"); |
139 return decoder->can_decode_C_frame_in_vm(); | |
140 } | |
141 | |
4917 | 142 /* |
143 * Shutdown shared decoder and replace it with | |
144 * _do_nothing_decoder. Do nothing with error handler | |
145 * instance, since the JVM is going down. | |
146 */ | |
4803 | 147 void Decoder::shutdown() { |
4917 | 148 assert(_shared_decoder_lock != NULL, "Just check"); |
149 MutexLockerEx locker(_shared_decoder_lock, true); | |
4803 | 150 |
4917 | 151 if (_shared_decoder != NULL && |
152 _shared_decoder != &_do_nothing_decoder) { | |
153 delete _shared_decoder; | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
154 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
155 |
4917 | 156 _shared_decoder = &_do_nothing_decoder; |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
157 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
158 |