Commit 6e93f476 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Change from "bool is_unwinding" to "int num_uncaught"

Since the unwinder now supports throwing exceptions inside destructors (as long
as they don't propagate out).

This is the same change that C++17 makes, from "bool uncaught_exception()" to
"int uncaught_exceptions()".
parent ef322709
...@@ -26,8 +26,6 @@ class AutoFileTests(unittest.TestCase): ...@@ -26,8 +26,6 @@ class AutoFileTests(unittest.TestCase):
self.f.close() self.f.close()
os.remove(TESTFN) os.remove(TESTFN)
# pyston change:
@unittest.skip("does not work with GC")
def testWeakRefs(self): def testWeakRefs(self):
# verify weak references # verify weak references
p = proxy(self.f) p = proxy(self.f)
......
...@@ -89,15 +89,10 @@ static thread_local Timer per_thread_cleanup_timer(-1); ...@@ -89,15 +89,10 @@ static thread_local Timer per_thread_cleanup_timer(-1);
#ifndef NDEBUG #ifndef NDEBUG
static __thread bool in_cleanup_code = false; static __thread bool in_cleanup_code = false;
#endif #endif
static __thread bool is_unwinding = false; static __thread int num_uncaught_exceptions = 0;
bool isUnwinding() { bool isUnwinding() {
return is_unwinding; return num_uncaught_exceptions > 0;
}
void setUnwinding(bool b) {
assert(!in_cleanup_code);
is_unwinding = b;
} }
extern "C" { extern "C" {
...@@ -574,7 +569,7 @@ static inline void unwind_loop(ExcInfo* exc_data) { ...@@ -574,7 +569,7 @@ static inline void unwind_loop(ExcInfo* exc_data) {
#if STAT_TIMERS #if STAT_TIMERS
pyston::StatTimer::finishOverride(); pyston::StatTimer::finishOverride();
#endif #endif
pyston::is_unwinding = false; pyston::num_uncaught_exceptions--;
} }
static_assert(THREADING_USE_GIL, "have to make the unwind session usage in this file thread safe!"); static_assert(THREADING_USE_GIL, "have to make the unwind session usage in this file thread safe!");
// there is a python unwinding implementation detail leaked // there is a python unwinding implementation detail leaked
...@@ -692,9 +687,7 @@ extern "C" HIDDEN void __cxa_throw(void* exc_obj, std::type_info* tinfo, void (* ...@@ -692,9 +687,7 @@ extern "C" HIDDEN void __cxa_throw(void* exc_obj, std::type_info* tinfo, void (*
pyston::ExcInfo* exc_data = (pyston::ExcInfo*)exc_obj; pyston::ExcInfo* exc_data = (pyston::ExcInfo*)exc_obj;
checkExcInfo(exc_data); checkExcInfo(exc_data);
ASSERT(!pyston::is_unwinding, "We don't support throwing exceptions in destructors!"); pyston::num_uncaught_exceptions++;
pyston::is_unwinding = true;
#if STAT_TIMERS #if STAT_TIMERS
pyston::StatTimer::overrideCounter(unwinding_stattimer); pyston::StatTimer::overrideCounter(unwinding_stattimer);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment