165
166 // The CHECK... macros should be used to pass along a THREAD reference and to check for pending
167 // exceptions. In special situations it is necessary to handle pending exceptions explicitly,
168 // in these cases the PENDING_EXCEPTION helper macros should be used.
169 //
170 // Macro naming conventions: Macros that end with _ require a result value to be returned. They
171 // are for functions with non-void result type. The result value is usually ignored because of
172 // the exception and is only needed for syntactic correctness. The _0 ending is a shortcut for
173 // _(0) since this is a frequent case. Example:
174 //
175 // int result = this_function_may_trap(x_arg, y_arg, CHECK_0);
176 //
177 // CAUTION: make sure that the function call using a CHECK macro is not the only statement of a
178 // conditional branch w/o enclosing {} braces, since the CHECK macros expand into several state-
179 // ments!
180
181 #define PENDING_EXCEPTION (((ThreadShadow*)THREAD)->pending_exception())
182 #define HAS_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->has_pending_exception())
183 #define CLEAR_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->clear_pending_exception())
184
185 #define CHECK THREAD); if (HAS_PENDING_EXCEPTION) return ; (0
186 #define CHECK_(result) THREAD); if (HAS_PENDING_EXCEPTION) return result; (0
187 #define CHECK_0 CHECK_(0)
188 #define CHECK_NH CHECK_(Handle())
189 #define CHECK_NULL CHECK_(NULL)
190 #define CHECK_false CHECK_(false)
191
192 #define CHECK_AND_CLEAR THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return; } (0
193 #define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (0
194 #define CHECK_AND_CLEAR_0 CHECK_AND_CLEAR_(0)
195 #define CHECK_AND_CLEAR_NH CHECK_AND_CLEAR_(Handle())
196 #define CHECK_AND_CLEAR_NULL CHECK_AND_CLEAR_(NULL)
197 #define CHECK_AND_CLEAR_false CHECK_AND_CLEAR_(false)
198
199 // The THROW... macros should be used to throw an exception. They require a THREAD variable to be
200 // visible within the scope containing the THROW. Usually this is achieved by declaring the function
201 // with a TRAPS argument.
202
203 #define THREAD_AND_LOCATION THREAD, __FILE__, __LINE__
204
205 #define THROW_OOP(e) \
206 { Exceptions::_throw_oop(THREAD_AND_LOCATION, e); return; }
207
208 #define THROW_HANDLE(e) \
209 { Exceptions::_throw(THREAD_AND_LOCATION, e); return; }
210
211 #define THROW(name) \
212 { Exceptions::_throw_msg(THREAD_AND_LOCATION, name, NULL); return; }
213
246 #define THROW_HANDLE_0(e) THROW_HANDLE_(e, 0)
247 #define THROW_0(name) THROW_(name, 0)
248 #define THROW_MSG_0(name, message) THROW_MSG_(name, message, 0)
249 #define THROW_WRAPPED_0(name, oop_to_wrap) THROW_WRAPPED_(name, oop_to_wrap, 0)
250 #define THROW_ARG_0(name, signature, arg) THROW_ARG_(name, signature, arg, 0)
251 #define THROW_MSG_CAUSE_0(name, message, cause) THROW_MSG_CAUSE_(name, message, cause, 0)
252
253 #define THROW_NULL(name) THROW_(name, NULL)
254 #define THROW_MSG_NULL(name, message) THROW_MSG_(name, message, NULL)
255
256 // The CATCH macro checks that no exception has been thrown by a function; it is used at
257 // call sites about which is statically known that the callee cannot throw an exception
258 // even though it is declared with TRAPS.
259
260 #define CATCH \
261 THREAD); if (HAS_PENDING_EXCEPTION) { \
262 oop ex = PENDING_EXCEPTION; \
263 CLEAR_PENDING_EXCEPTION; \
264 ex->print(); \
265 ShouldNotReachHere(); \
266 } (0
267
268 // ExceptionMark is a stack-allocated helper class for local exception handling.
269 // It is used with the EXCEPTION_MARK macro.
270
271 class ExceptionMark {
272 private:
273 Thread* _thread;
274
275 public:
276 ExceptionMark(Thread*& thread);
277 ~ExceptionMark();
278 };
279
280
281
282 // Use an EXCEPTION_MARK for 'local' exceptions. EXCEPTION_MARK makes sure that no
283 // pending exception exists upon entering its scope and tests that no pending exception
284 // exists when leaving the scope.
285
286 // See also preserveException.hpp for PRESERVE_EXCEPTION_MARK macro,
|
165
166 // The CHECK... macros should be used to pass along a THREAD reference and to check for pending
167 // exceptions. In special situations it is necessary to handle pending exceptions explicitly,
168 // in these cases the PENDING_EXCEPTION helper macros should be used.
169 //
170 // Macro naming conventions: Macros that end with _ require a result value to be returned. They
171 // are for functions with non-void result type. The result value is usually ignored because of
172 // the exception and is only needed for syntactic correctness. The _0 ending is a shortcut for
173 // _(0) since this is a frequent case. Example:
174 //
175 // int result = this_function_may_trap(x_arg, y_arg, CHECK_0);
176 //
177 // CAUTION: make sure that the function call using a CHECK macro is not the only statement of a
178 // conditional branch w/o enclosing {} braces, since the CHECK macros expand into several state-
179 // ments!
180
181 #define PENDING_EXCEPTION (((ThreadShadow*)THREAD)->pending_exception())
182 #define HAS_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->has_pending_exception())
183 #define CLEAR_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->clear_pending_exception())
184
185 #define CHECK THREAD); if (HAS_PENDING_EXCEPTION) return ; (void)(0
186 #define CHECK_(result) THREAD); if (HAS_PENDING_EXCEPTION) return result; (void)(0
187 #define CHECK_0 CHECK_(0)
188 #define CHECK_NH CHECK_(Handle())
189 #define CHECK_NULL CHECK_(NULL)
190 #define CHECK_false CHECK_(false)
191
192 #define CHECK_AND_CLEAR THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return; } (void)(0
193 #define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (void)(0
194 #define CHECK_AND_CLEAR_0 CHECK_AND_CLEAR_(0)
195 #define CHECK_AND_CLEAR_NH CHECK_AND_CLEAR_(Handle())
196 #define CHECK_AND_CLEAR_NULL CHECK_AND_CLEAR_(NULL)
197 #define CHECK_AND_CLEAR_false CHECK_AND_CLEAR_(false)
198
199 // The THROW... macros should be used to throw an exception. They require a THREAD variable to be
200 // visible within the scope containing the THROW. Usually this is achieved by declaring the function
201 // with a TRAPS argument.
202
203 #define THREAD_AND_LOCATION THREAD, __FILE__, __LINE__
204
205 #define THROW_OOP(e) \
206 { Exceptions::_throw_oop(THREAD_AND_LOCATION, e); return; }
207
208 #define THROW_HANDLE(e) \
209 { Exceptions::_throw(THREAD_AND_LOCATION, e); return; }
210
211 #define THROW(name) \
212 { Exceptions::_throw_msg(THREAD_AND_LOCATION, name, NULL); return; }
213
246 #define THROW_HANDLE_0(e) THROW_HANDLE_(e, 0)
247 #define THROW_0(name) THROW_(name, 0)
248 #define THROW_MSG_0(name, message) THROW_MSG_(name, message, 0)
249 #define THROW_WRAPPED_0(name, oop_to_wrap) THROW_WRAPPED_(name, oop_to_wrap, 0)
250 #define THROW_ARG_0(name, signature, arg) THROW_ARG_(name, signature, arg, 0)
251 #define THROW_MSG_CAUSE_0(name, message, cause) THROW_MSG_CAUSE_(name, message, cause, 0)
252
253 #define THROW_NULL(name) THROW_(name, NULL)
254 #define THROW_MSG_NULL(name, message) THROW_MSG_(name, message, NULL)
255
256 // The CATCH macro checks that no exception has been thrown by a function; it is used at
257 // call sites about which is statically known that the callee cannot throw an exception
258 // even though it is declared with TRAPS.
259
260 #define CATCH \
261 THREAD); if (HAS_PENDING_EXCEPTION) { \
262 oop ex = PENDING_EXCEPTION; \
263 CLEAR_PENDING_EXCEPTION; \
264 ex->print(); \
265 ShouldNotReachHere(); \
266 } (void)(0
267
268 // ExceptionMark is a stack-allocated helper class for local exception handling.
269 // It is used with the EXCEPTION_MARK macro.
270
271 class ExceptionMark {
272 private:
273 Thread* _thread;
274
275 public:
276 ExceptionMark(Thread*& thread);
277 ~ExceptionMark();
278 };
279
280
281
282 // Use an EXCEPTION_MARK for 'local' exceptions. EXCEPTION_MARK makes sure that no
283 // pending exception exists upon entering its scope and tests that no pending exception
284 // exists when leaving the scope.
285
286 // See also preserveException.hpp for PRESERVE_EXCEPTION_MARK macro,
|