Mercurial > hg > graal-compiler
annotate src/share/vm/utilities/decoder.cpp @ 9773:8a1b0a3d4fc3
replaced VerifyOopStubCall with usage of ForeignCallNode
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 17 May 2013 22:45:24 +0200 |
parents | b9a9ed0f8eeb |
children | 38f750491293 bdd155477289 |
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" |
4803 | 27 #include "runtime/mutexLocker.hpp" |
4917 | 28 #include "runtime/os.hpp" |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
29 #include "utilities/decoder.hpp" |
4917 | 30 #include "utilities/vmError.hpp" |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
31 |
4803 | 32 #if defined(_WINDOWS) |
33 #include "decoder_windows.hpp" | |
34 #elif defined(__APPLE__) | |
35 #include "decoder_machO.hpp" | |
36 #else | |
37 #include "decoder_elf.hpp" | |
38 #endif | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
39 |
4917 | 40 AbstractDecoder* Decoder::_shared_decoder = NULL; |
41 AbstractDecoder* Decoder::_error_handler_decoder = NULL; | |
42 NullDecoder Decoder::_do_nothing_decoder; | |
43 Mutex* Decoder::_shared_decoder_lock = new Mutex(Mutex::native, | |
44 "SharedDecoderLock"); | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
45 |
4917 | 46 AbstractDecoder* Decoder::get_shared_instance() { |
47 assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(), | |
4803 | 48 "Require DecoderLock to enter"); |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
49 |
4917 | 50 if (_shared_decoder == NULL) { |
51 _shared_decoder = create_decoder(); | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
52 } |
4917 | 53 return _shared_decoder; |
54 } | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
55 |
4917 | 56 AbstractDecoder* Decoder::get_error_handler_instance() { |
57 if (_error_handler_decoder == NULL) { | |
58 _error_handler_decoder = create_decoder(); | |
59 } | |
60 return _error_handler_decoder; | |
61 } | |
62 | |
63 | |
64 AbstractDecoder* Decoder::create_decoder() { | |
65 AbstractDecoder* decoder; | |
4803 | 66 #if defined(_WINDOWS) |
4917 | 67 decoder = new (std::nothrow) WindowsDecoder(); |
4803 | 68 #elif defined (__APPLE__) |
4917 | 69 decoder = new (std::nothrow)MachODecoder(); |
4803 | 70 #else |
4917 | 71 decoder = new (std::nothrow)ElfDecoder(); |
4803 | 72 #endif |
73 | |
4917 | 74 if (decoder == NULL || decoder->has_error()) { |
75 if (decoder != NULL) { | |
76 delete decoder; | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
77 } |
4917 | 78 decoder = &_do_nothing_decoder; |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
79 } |
4917 | 80 return decoder; |
4803 | 81 } |
82 | |
83 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath) { | |
4917 | 84 assert(_shared_decoder_lock != NULL, "Just check"); |
85 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
86 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
87 AbstractDecoder* decoder = error_handling_thread ? | |
88 get_error_handler_instance(): get_shared_instance(); | |
4803 | 89 assert(decoder != NULL, "null decoder"); |
90 | |
91 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
|
92 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
93 |
6258 | 94 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const void* base) { |
95 assert(_shared_decoder_lock != NULL, "Just check"); | |
96 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
97 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
98 AbstractDecoder* decoder = error_handling_thread ? | |
99 get_error_handler_instance(): get_shared_instance(); | |
100 assert(decoder != NULL, "null decoder"); | |
101 | |
102 return decoder->decode(addr, buf, buflen, offset, base); | |
103 } | |
104 | |
105 | |
4803 | 106 bool Decoder::demangle(const char* symbol, char* buf, int buflen) { |
4917 | 107 assert(_shared_decoder_lock != NULL, "Just check"); |
108 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
109 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
110 AbstractDecoder* decoder = error_handling_thread ? | |
111 get_error_handler_instance(): get_shared_instance(); | |
4803 | 112 assert(decoder != NULL, "null decoder"); |
113 return decoder->demangle(symbol, buf, buflen); | |
114 } | |
115 | |
116 bool Decoder::can_decode_C_frame_in_vm() { | |
4917 | 117 assert(_shared_decoder_lock != NULL, "Just check"); |
118 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
119 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
120 AbstractDecoder* decoder = error_handling_thread ? | |
121 get_error_handler_instance(): get_shared_instance(); | |
4803 | 122 assert(decoder != NULL, "null decoder"); |
123 return decoder->can_decode_C_frame_in_vm(); | |
124 } | |
125 | |
4917 | 126 /* |
127 * Shutdown shared decoder and replace it with | |
128 * _do_nothing_decoder. Do nothing with error handler | |
129 * instance, since the JVM is going down. | |
130 */ | |
4803 | 131 void Decoder::shutdown() { |
4917 | 132 assert(_shared_decoder_lock != NULL, "Just check"); |
133 MutexLockerEx locker(_shared_decoder_lock, true); | |
4803 | 134 |
4917 | 135 if (_shared_decoder != NULL && |
136 _shared_decoder != &_do_nothing_decoder) { | |
137 delete _shared_decoder; | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
138 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
139 |
4917 | 140 _shared_decoder = &_do_nothing_decoder; |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
141 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
142 |