25
#include "precompiled.hpp"
26
#include "memory/resourceArea.hpp"
27
#include "oops/oop.hpp"
28
#include "runtime/handles.inline.hpp"
29
#include "utilities/preserveException.hpp"
31
PreserveExceptionMark::PreserveExceptionMark(Thread* thread) {
33
_preserved_exception_oop = Handle(thread, _thread->pending_exception());
34
_preserved_exception_line = _thread->exception_line();
35
_preserved_exception_file = _thread->exception_file();
36
_thread->clear_pending_exception();
40
PreserveExceptionMark::~PreserveExceptionMark() {
41
if (_thread->has_pending_exception()) {
42
oop exception = _thread->pending_exception();
43
_thread->clear_pending_exception();
44
ResourceMark rm(_thread);
45
assert(false, "PreserveExceptionMark destructor expects no pending exceptions %s",
46
exception->print_string());
49
if (_preserved_exception_oop() != nullptr) {
50
_thread->set_pending_exception(_preserved_exception_oop(), _preserved_exception_file, _preserved_exception_line);
54
void WeakPreserveExceptionMark::preserve() {
55
_preserved_exception_oop = Handle(_thread, _thread->pending_exception());
56
_preserved_exception_line = _thread->exception_line();
57
_preserved_exception_file = _thread->exception_file();
58
_thread->clear_pending_exception();
61
void WeakPreserveExceptionMark::restore() {
62
if (!_thread->has_pending_exception()) {
63
_thread->set_pending_exception(_preserved_exception_oop(), _preserved_exception_file, _preserved_exception_line);