Mercurial > hg > graal-compiler
annotate src/share/vm/utilities/decoder.cpp @ 17936:968a17f18337
8042786: Proper fix for 8032566
Summary: Check for overflow cases in range checks and collapse it if we can.
Reviewed-by: jrose, iveresov
author | kvn |
---|---|
date | Fri, 16 May 2014 12:05:14 -0700 |
parents | a9becfeecd1b |
children | 4ca6dc0799b6 |
rev | line source |
---|---|
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
1 /* |
17467
55fb97c4c58d
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
12199
diff
changeset
|
2 * Copyright (c) 1997, 2013, 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" | |
14411 | 35 #elif defined(AIX) |
36 #include "decoder_aix.hpp" | |
4803 | 37 #else |
38 #include "decoder_elf.hpp" | |
39 #endif | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
40 |
4917 | 41 AbstractDecoder* Decoder::_shared_decoder = NULL; |
42 AbstractDecoder* Decoder::_error_handler_decoder = NULL; | |
43 NullDecoder Decoder::_do_nothing_decoder; | |
44 Mutex* Decoder::_shared_decoder_lock = new Mutex(Mutex::native, | |
45 "SharedDecoderLock"); | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
46 |
4917 | 47 AbstractDecoder* Decoder::get_shared_instance() { |
48 assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(), | |
4803 | 49 "Require DecoderLock to enter"); |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
50 |
4917 | 51 if (_shared_decoder == NULL) { |
52 _shared_decoder = create_decoder(); | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
53 } |
4917 | 54 return _shared_decoder; |
55 } | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
56 |
4917 | 57 AbstractDecoder* Decoder::get_error_handler_instance() { |
58 if (_error_handler_decoder == NULL) { | |
59 _error_handler_decoder = create_decoder(); | |
60 } | |
61 return _error_handler_decoder; | |
62 } | |
63 | |
64 | |
65 AbstractDecoder* Decoder::create_decoder() { | |
66 AbstractDecoder* decoder; | |
4803 | 67 #if defined(_WINDOWS) |
4917 | 68 decoder = new (std::nothrow) WindowsDecoder(); |
4803 | 69 #elif defined (__APPLE__) |
4917 | 70 decoder = new (std::nothrow)MachODecoder(); |
14411 | 71 #elif defined(AIX) |
72 decoder = new (std::nothrow)AIXDecoder(); | |
4803 | 73 #else |
4917 | 74 decoder = new (std::nothrow)ElfDecoder(); |
4803 | 75 #endif |
76 | |
4917 | 77 if (decoder == NULL || decoder->has_error()) { |
78 if (decoder != NULL) { | |
79 delete decoder; | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
80 } |
4917 | 81 decoder = &_do_nothing_decoder; |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
82 } |
4917 | 83 return decoder; |
4803 | 84 } |
85 | |
12199
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
86 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
|
87 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
|
88 } |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
89 |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
90 DecoderLocker::DecoderLocker() : |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
91 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
|
92 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
|
93 _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
|
94 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
|
95 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
|
96 } |
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 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
|
99 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
|
100 return _shared_decoder_lock; |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
101 } |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6842
diff
changeset
|
102 |
4803 | 103 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath) { |
4917 | 104 assert(_shared_decoder_lock != NULL, "Just check"); |
105 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
106 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
107 AbstractDecoder* decoder = error_handling_thread ? | |
108 get_error_handler_instance(): get_shared_instance(); | |
4803 | 109 assert(decoder != NULL, "null decoder"); |
110 | |
111 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
|
112 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
113 |
6258 | 114 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const void* base) { |
115 assert(_shared_decoder_lock != NULL, "Just check"); | |
116 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
117 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
118 AbstractDecoder* decoder = error_handling_thread ? | |
119 get_error_handler_instance(): get_shared_instance(); | |
120 assert(decoder != NULL, "null decoder"); | |
121 | |
122 return decoder->decode(addr, buf, buflen, offset, base); | |
123 } | |
124 | |
125 | |
4803 | 126 bool Decoder::demangle(const char* symbol, char* buf, int buflen) { |
4917 | 127 assert(_shared_decoder_lock != NULL, "Just check"); |
128 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
129 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
130 AbstractDecoder* decoder = error_handling_thread ? | |
131 get_error_handler_instance(): get_shared_instance(); | |
4803 | 132 assert(decoder != NULL, "null decoder"); |
133 return decoder->demangle(symbol, buf, buflen); | |
134 } | |
135 | |
136 bool Decoder::can_decode_C_frame_in_vm() { | |
4917 | 137 assert(_shared_decoder_lock != NULL, "Just check"); |
138 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; | |
139 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); | |
140 AbstractDecoder* decoder = error_handling_thread ? | |
141 get_error_handler_instance(): get_shared_instance(); | |
4803 | 142 assert(decoder != NULL, "null decoder"); |
143 return decoder->can_decode_C_frame_in_vm(); | |
144 } | |
145 | |
4917 | 146 /* |
147 * Shutdown shared decoder and replace it with | |
148 * _do_nothing_decoder. Do nothing with error handler | |
149 * instance, since the JVM is going down. | |
150 */ | |
4803 | 151 void Decoder::shutdown() { |
4917 | 152 assert(_shared_decoder_lock != NULL, "Just check"); |
153 MutexLockerEx locker(_shared_decoder_lock, true); | |
4803 | 154 |
4917 | 155 if (_shared_decoder != NULL && |
156 _shared_decoder != &_do_nothing_decoder) { | |
157 delete _shared_decoder; | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
158 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
159 |
4917 | 160 _shared_decoder = &_do_nothing_decoder; |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
161 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
162 |