Mercurial > hg > truffle
annotate src/share/vm/utilities/preserveException.hpp @ 4803:d7e3846464d0
7071311: Decoder enhancement
Summary: Made decoder thread-safe
Reviewed-by: coleenp, kamg
author | zgu |
---|---|
date | Tue, 17 Jan 2012 13:08:52 -0500 |
parents | f08d439fab8c |
children | f34d701e952e |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_UTILITIES_PRESERVEEXCEPTION_HPP |
26 #define SHARE_VM_UTILITIES_PRESERVEEXCEPTION_HPP | |
27 | |
28 #include "runtime/handles.hpp" | |
29 #ifdef TARGET_OS_FAMILY_linux | |
30 # include "thread_linux.inline.hpp" | |
31 #endif | |
32 #ifdef TARGET_OS_FAMILY_solaris | |
33 # include "thread_solaris.inline.hpp" | |
34 #endif | |
35 #ifdef TARGET_OS_FAMILY_windows | |
36 # include "thread_windows.inline.hpp" | |
37 #endif | |
3960 | 38 #ifdef TARGET_OS_FAMILY_bsd |
39 # include "thread_bsd.inline.hpp" | |
40 #endif | |
1972 | 41 |
0 | 42 // This file provides more support for exception handling; see also exceptions.hpp |
43 class PreserveExceptionMark { | |
44 private: | |
45 Thread* _thread; | |
46 Handle _preserved_exception_oop; | |
47 int _preserved_exception_line; | |
48 const char* _preserved_exception_file; | |
49 | |
50 public: | |
51 PreserveExceptionMark(Thread*& thread); | |
52 ~PreserveExceptionMark(); | |
53 }; | |
54 | |
55 | |
56 // This is a clone of PreserveExceptionMark which asserts instead | |
57 // of failing when what it wraps generates a pending exception. | |
58 // It also addresses bug 6431341. | |
59 class CautiouslyPreserveExceptionMark { | |
60 private: | |
61 Thread* _thread; | |
62 Handle _preserved_exception_oop; | |
63 int _preserved_exception_line; | |
64 const char* _preserved_exception_file; | |
65 | |
66 public: | |
67 CautiouslyPreserveExceptionMark(Thread* thread); | |
68 ~CautiouslyPreserveExceptionMark(); | |
69 }; | |
70 | |
71 | |
72 // Like PreserveExceptionMark but allows new exceptions to be generated in | |
73 // the body of the mark. If a new exception is generated then the original one | |
74 // is discarded. | |
75 class WeakPreserveExceptionMark { | |
76 private: | |
77 Thread* _thread; | |
78 Handle _preserved_exception_oop; | |
79 int _preserved_exception_line; | |
80 const char* _preserved_exception_file; | |
81 | |
82 void preserve(); | |
83 void restore(); | |
84 | |
85 public: | |
86 WeakPreserveExceptionMark(Thread* pThread) : _thread(pThread), _preserved_exception_oop() { | |
87 if (pThread->has_pending_exception()) { | |
88 preserve(); | |
89 } | |
90 } | |
91 ~WeakPreserveExceptionMark() { | |
92 if (_preserved_exception_oop.not_null()) { | |
93 restore(); | |
94 } | |
95 } | |
96 }; | |
97 | |
98 | |
99 | |
100 // use global exception mark when allowing pending exception to be set and | |
101 // saving and restoring them | |
102 #define PRESERVE_EXCEPTION_MARK Thread* THREAD; PreserveExceptionMark __em(THREAD); | |
1972 | 103 |
104 #endif // SHARE_VM_UTILITIES_PRESERVEEXCEPTION_HPP |