This is the current definition of EXCEPTION_MARK
=============================
// Use an EXCEPTION_MARK for 'local' exceptions. EXCEPTION_MARK makes sure that no
// pending exception exists upon entering its scope and tests that no pending exception
// exists when leaving the scope.
// See also preserveException.hpp for PreserveExceptionMark
// which preserves pre-existing exceptions and does not allow new
// exceptions.
#define EXCEPTION_MARK Thread* THREAD = NULL; ExceptionMark __em(THREAD);
=============================
But the constructor of ExceptionMark calls Thread:current(), which may be costly. If we already have a thread, we should use that instead. E.g.,
{
ExceptionMark em(curentThread);
// call some xxx(CHECK) functions;
// check and clean up PENDING_EXCEPTION
}
=============================
// Use an EXCEPTION_MARK for 'local' exceptions. EXCEPTION_MARK makes sure that no
// pending exception exists upon entering its scope and tests that no pending exception
// exists when leaving the scope.
// See also preserveException.hpp for PreserveExceptionMark
// which preserves pre-existing exceptions and does not allow new
// exceptions.
#define EXCEPTION_MARK Thread* THREAD = NULL; ExceptionMark __em(THREAD);
=============================
But the constructor of ExceptionMark calls Thread:current(), which may be costly. If we already have a thread, we should use that instead. E.g.,
{
ExceptionMark em(curentThread);
// call some xxx(CHECK) functions;
// check and clean up PENDING_EXCEPTION
}