39 #endif |
39 #endif |
40 |
40 |
41 AbstractDecoder* Decoder::_shared_decoder = NULL; |
41 AbstractDecoder* Decoder::_shared_decoder = NULL; |
42 AbstractDecoder* Decoder::_error_handler_decoder = NULL; |
42 AbstractDecoder* Decoder::_error_handler_decoder = NULL; |
43 NullDecoder Decoder::_do_nothing_decoder; |
43 NullDecoder Decoder::_do_nothing_decoder; |
44 Mutex* Decoder::_shared_decoder_lock = new Mutex(Mutex::native, |
|
45 "SharedDecoderLock", |
|
46 false, |
|
47 Monitor::_safepoint_check_never); |
|
48 |
44 |
49 AbstractDecoder* Decoder::get_shared_instance() { |
45 AbstractDecoder* Decoder::get_shared_instance() { |
50 assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(), |
46 assert(shared_decoder_lock()->owned_by_self(), "Require DecoderLock to enter"); |
51 "Require DecoderLock to enter"); |
|
52 |
47 |
53 if (_shared_decoder == NULL) { |
48 if (_shared_decoder == NULL) { |
54 _shared_decoder = create_decoder(); |
49 _shared_decoder = create_decoder(); |
55 } |
50 } |
56 return _shared_decoder; |
51 return _shared_decoder; |
87 return (os::current_thread_id() == VMError::get_first_error_tid()); |
82 return (os::current_thread_id() == VMError::get_first_error_tid()); |
88 } |
83 } |
89 |
84 |
90 DecoderLocker::DecoderLocker() : |
85 DecoderLocker::DecoderLocker() : |
91 MutexLockerEx(DecoderLocker::is_first_error_thread() ? |
86 MutexLockerEx(DecoderLocker::is_first_error_thread() ? |
92 NULL : Decoder::shared_decoder_lock(), true) { |
87 NULL : Decoder::shared_decoder_lock(), |
|
88 Mutex::_no_safepoint_check_flag) { |
93 _decoder = is_first_error_thread() ? |
89 _decoder = is_first_error_thread() ? |
94 Decoder::get_error_handler_instance() : Decoder::get_shared_instance(); |
90 Decoder::get_error_handler_instance() : Decoder::get_shared_instance(); |
95 assert(_decoder != NULL, "null decoder"); |
91 assert(_decoder != NULL, "null decoder"); |
96 } |
92 } |
97 |
93 |
98 Mutex* Decoder::shared_decoder_lock() { |
94 Mutex* Decoder::shared_decoder_lock() { |
99 assert(_shared_decoder_lock != NULL, "Just check"); |
95 assert(SharedDecoder_lock != NULL, "Just check"); |
100 return _shared_decoder_lock; |
96 return SharedDecoder_lock; |
101 } |
97 } |
102 |
98 |
103 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath, bool demangle) { |
99 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath, bool demangle) { |
104 assert(_shared_decoder_lock != NULL, "Just check"); |
|
105 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; |
100 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; |
106 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); |
101 MutexLockerEx locker(error_handling_thread ? NULL : shared_decoder_lock(), |
|
102 Mutex::_no_safepoint_check_flag); |
107 AbstractDecoder* decoder = error_handling_thread ? |
103 AbstractDecoder* decoder = error_handling_thread ? |
108 get_error_handler_instance(): get_shared_instance(); |
104 get_error_handler_instance(): get_shared_instance(); |
109 assert(decoder != NULL, "null decoder"); |
105 assert(decoder != NULL, "null decoder"); |
110 |
106 |
111 return decoder->decode(addr, buf, buflen, offset, modulepath, demangle); |
107 return decoder->decode(addr, buf, buflen, offset, modulepath, demangle); |
112 } |
108 } |
113 |
109 |
114 bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const void* base) { |
110 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; |
111 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; |
117 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); |
112 MutexLockerEx locker(error_handling_thread ? NULL : shared_decoder_lock(), |
|
113 Mutex::_no_safepoint_check_flag); |
118 AbstractDecoder* decoder = error_handling_thread ? |
114 AbstractDecoder* decoder = error_handling_thread ? |
119 get_error_handler_instance(): get_shared_instance(); |
115 get_error_handler_instance(): get_shared_instance(); |
120 assert(decoder != NULL, "null decoder"); |
116 assert(decoder != NULL, "null decoder"); |
121 |
117 |
122 return decoder->decode(addr, buf, buflen, offset, base); |
118 return decoder->decode(addr, buf, buflen, offset, base); |
123 } |
119 } |
124 |
120 |
125 |
121 |
126 bool Decoder::demangle(const char* symbol, char* buf, int buflen) { |
122 bool Decoder::demangle(const char* symbol, char* buf, int buflen) { |
127 assert(_shared_decoder_lock != NULL, "Just check"); |
|
128 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; |
123 bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; |
129 MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); |
124 MutexLockerEx locker(error_handling_thread ? NULL : shared_decoder_lock(), |
|
125 Mutex::_no_safepoint_check_flag); |
130 AbstractDecoder* decoder = error_handling_thread ? |
126 AbstractDecoder* decoder = error_handling_thread ? |
131 get_error_handler_instance(): get_shared_instance(); |
127 get_error_handler_instance(): get_shared_instance(); |
132 assert(decoder != NULL, "null decoder"); |
128 assert(decoder != NULL, "null decoder"); |
133 return decoder->demangle(symbol, buf, buflen); |
129 return decoder->demangle(symbol, buf, buflen); |
134 } |
130 } |